I’m trying to load a VST patch (fxp file) to a plugin instance using VSTPluginFormat::loadFromFXBFile (following another post: Possible to load fxb/fxp files from disk?)
bool ProcessDescription::applyProcessorSettings(AudioProcessor * processor, std::string patch)
{
AudioPluginInstance* plugin = dynamic_cast<AudioPluginInstance*>(processor);
if (plugin == NULL) throw std::invalid_argument("Passed processor argument cannot be cast to a plugin instance.");
File f(patch);
MemoryBlock mb;
f.loadFileAsData(mb);
VSTPluginFormat::loadFromFXBFile(plugin, mb.getData(), mb.getSize());
}
However, this does nothing. Looking at the implementation of loadFromFXBFile() inside the juce_VSTPluginFormat.cpp, it expects an argument of type VSTPluginInstance:
bool VSTPluginFormat::loadFromFXBFile (AudioPluginInstance* plugin, const void* data, size_t dataSize)
{
if (VSTPluginInstance* vst = dynamic_cast<VSTPluginInstance*> (plugin))
return vst->loadFromFXBFile (data, dataSize);
return false;
}
Debugging shows that the argument I pass cannot be cast to VSTPluginInstance, so loadFromFXBFile just returns false. The AudioProcessor I pass was loaded from a vst3. Also, the declaration of VSTPluginInstance is hidden inside juce_VSTPluginFormat.cpp so I can’t cast/create an object/pointer of that type to pass to loadFromFXBFile.
How then should I pass a plugin instance for loadFromFXBFile to work…?
Any ideas would be greatly appreciated!