Hello,
I’m trying to load a VST inside a JUCE plugin host and am experiencing some strange behavior only in my Windows build (no issues with OSX). The plugin is a sampler with internal plugin effect modules that are instantiated in a singleton registry. With JUCE 4.3 and up, when I load this vst, the effects modules disappear.
Now, I’ve traced the issue to the function in juce_VSTPluginFormat.cpp
:
static VSTPluginInstance* create (const ModuleHandle::Ptr& newModule, double initialSampleRate, int initialBlockSize)
This function seems to be creating the vst twice and, probably due to a bug in the vst, the effects module instance registry gets corrupted on the second loading. I think there’s an issue with releasing the first instance before creating the second one.
Though I’m trying to find the root of the cause in the vst, commenting out the code that loads the vst the second time around seems to fix the problem. So, my actual question is: why does the vst need to be created twice, and are there any consequences to altering the function as follows?
static VSTPluginInstance* create (const ModuleHandle::Ptr& newModule,
double initialSampleRate,
int initialBlockSize)
{
if (VstEffectInterface* newEffect = constructEffect (newModule))
{
/* commented out
newEffect->hostSpace2 = 0;
newEffect->dispatchFunction (newEffect, plugInOpcodeIdentify, 0, 0, 0, 0);
newEffect->dispatchFunction (newEffect, plugInOpcodeSetSampleRate, 0, 0, 0, static_cast<float> (initialSampleRate));
newEffect->dispatchFunction (newEffect, plugInOpcodeSetBlockSize, 0, jmax (32, initialBlockSize), 0, 0);
newEffect->dispatchFunction (newEffect, plugInOpcodeOpen, 0, 0, 0, 0);
*/
BusesProperties ioConfig = queryBusIO (newEffect);
/* commented out
newEffect->dispatchFunction (newEffect, plugInOpcodeClose, 0, 0, 0, 0);
newEffect = constructEffect (newModule);
*/
if (newEffect != nullptr)
return new VSTPluginInstance (newModule, ioConfig, newEffect);
}
return nullptr;
}