JUCE_VST3_CAN_REPLACE_VST2 issue in Studio One


In Studio One, parameters values are lost when switching between VST2 and VST3 versions of the same JUCE plugin.

The problem is in JUCE’s VST3 wrapper: it expects a ‘VstW’ header that Studio One doesn’t provide, whereas Cubase and Sonar do.

According to VST3 docs, ‘VstW’ is not part of the VST3 specification and therefore up to the host to add it to the chunk.

Here’s a quick and dirty patch to fix that:

void loadVST2Block (const char* data, int size)
    auto bank = (const vst2FxBank*) data;
    auto version = static_cast<int> (htonl (bank->version1)); ignoreUnused (version);
    jassert ('CcnK' == htonl (bank->magic1));
    jassert ('FBCh' == htonl (bank->magic2));
    jassert (version == 1 || version == 2);
    jassert (JucePlugin_VSTUniqueID == htonl (bank->fxID));
    setStateInformation (bank->chunk,
                         jmin ((int) (size - (bank->chunk - data)),
                               (int) htonl (bank->chunkSize)));

bool loadVST2CompatibleState (const char* data, int size)
    if (size < 4)
        return false;

    auto header = htonl (*(juce::int32*) data);
    if (header == 'VstW')
        loadVST2VstWBlock (data, size);
        return true;
    else if (header == 'CcnK')
        loadVST2Block (data, size);
        return true;

    if (memcmp (data, "VST3", 4) == 0)
        // In Cubase 5, when loading VST3 .vstpreset files,
        // we get the whole content of the files to load.
        // In Cubase 7 we get just the contents within and
        // we go directly to the loadVST2VstW codepath instead.
        return loadVST3PresetFile (data, size);

    return false;


bump :slight_smile:


Thanks! I’ll take a look at this now…