[FR] VST3PluginFormat::loadFromVstPresetFile()

JUCE’s AudioProcessor interface just doesn’t really fit very well to the underlying state management of VST3. However, by using JUCE’s AudioProcessor::getPlatformSpecificData you can invoke the VST3’s setState method directly:

#include <pluginterfaces/vst/ivstcomponent.h>
#include <public.sdk/source/common/memorystream.h>

void setVST3PluginStateDirect (AudioPluginInstance* instance, const MemoryBlock& rawData)
{
    auto funknown = static_cast<Steinberg::FUnknown*> (instance->getPlatformSpecificData());
    Steinberg::Vst::IComponent* vstcomponent = nullptr;
    
    if (funknown->queryInterface (Steinberg::Vst::IComponent_iid, (void**) &vstcomponent) == 0
        && vstcomponent != nullptr)
    {
        
        auto* memoryStream = new Steinberg::MemoryStream (rawData.getData(), (int) rawData.getSize());
        vstcomponent->setState (memoryStream);
        memoryStream->release();
        vstcomponent->release();
    }
}

Would that work for you?

1 Like