Assertion failure calling AudioPluginInstance::prepareToPlay()

When I call prepareToPlay() from an AudioPluginInstance, I get this error if the plugin supports double processing "JUCE Assertion failure in juce_VSTPluginFormat.cpp:949"

            if (supportsDoublePrecisionProcessing())
                VstInt32 vstPrecision = isUsingDoublePrecision() ? kVstProcessPrecision64
                                                                 : kVstProcessPrecision32;

                // if you get an assertion here then your plug-in claims it supports double precision
                // but returns an error when we try to change the precision
                VstIntPtr err = dispatch (effSetProcessPrecision, 0, (VstIntPtr) vstPrecision, 0, 0);
                jassert (err > 0);
                ignoreUnused (err);

With float processing plugins works fine.

       String errorMsg;

        PluginDescription* plugDescription = knownPluginList.getType (knownPluginList.getIndexChosenByMenu (menuId));

        AudioPluginInstance* loadedPlugin = formatManager.createPluginInstance (*plugDescription, 44100, 256, errorMsg);

        plugin->setPlayConfigDetails (numIns, numOuts, sampleRate, samplesPerBlock);

        loadedPlugin->prepareToPlay(sampleRate, samplesPerBlock);

what am I doing wrong?

I noticed that the same assert happens in the Plugin Host example (from juce 4.1 and 4.0.2) if you try to load double precisions plugins.

Old Plugin Host (from juce 3.2) works fine.

I don't think there's anything wrong with our hosting code - the specification for that effSetProcessPrecision SDK call is that the plugin should return 1 if it supports the requested precision. If a plugin fails to do that then it'd be the plugin that's at fault.

Seems like quite a few commercial plugins get that wrong. Maybe we could change the assertion to jassert(!isUsingDoublePrecision() || err > 0) so hosts aren't bothered by incomplete plugins. If i understand the vst specifications right: it defaults to float rendering and nothing bad happens if a host wants float anyway and the call fails with kVstProcessPrecision32 as argument.

Alternatively that whole branch could be wrapped into if (supportsDoublePrecisionProcessing() &&isUsingDoublePrecision())


Well the assertion is quite an important warning about plugin being inconsistent about what it claims to be able to do.

If we find that a huge number of plugins are badly-implemented and that it's just annoying then I can remove the assertion (or you could just comment it out if you need to).

Alternatively that whole branch could be wrapped into if (supportsDoublePrecisionProcessing() &&isUsingDoublePrecision())

No, that'd mean that once switched into 64-bit mode, a plugin could never be switched back to 32-bit.