steinbergmedia / vst3_public_sdk

VST 3 Implementation Helper Classes And Examples
Other
139 stars 46 forks source link

Can't make mda vsts reload their state under linux #35

Closed jcelerier closed 2 years ago

jcelerier commented 3 years ago

Hello,

My loading code does the following:

  if (fx.component)
  {
    // First reload the processor state into the processor.
    {
      QDataStream str{m_savedProcessorState};
      Vst3DataStream stream{str};
      fx.component->setState(&stream);

      // Then into the controller
      if (fx.controller)
      {
        QDataStream str{m_savedProcessorState};
        Vst3DataStream stream{str};
        fx.controller->setComponentState(&stream);
      }
      m_savedProcessorState = {};
    }

    // Then reload the controller-specific data
    if (fx.controller)
    {
      if(!m_savedControllerState.isEmpty())
      {
        QDataStream str{m_savedControllerState};

        Vst3DataStream stream{str};

        fx.controller->setState(&stream);

        m_savedControllerState = {};
      }
    }
  }

and seems to work for most plug-ins, but not for the mda plug-ins that come with the SDK. I put a breakpoint in fx.controller->setComponentState(&stream); and observe the following trace which leads to stuff not being reloaded:

1   VST3::(anonymous namespace)::loadProgram(const VST3::(anonymous namespace)::IO::BigEndianStream &, const VST3::Optional<int> &)       vst2persistence.cpp 
2   VST3::(anonymous namespace)::loadPrograms(Steinberg::IBStream &, VST3::Vst2xState::Programs &, const VST3::Optional<int> &)       vst2persistence.cpp
3   VST3::tryVst2StateLoad(Steinberg::IBStream&, VST3::Optional<int>)       vst2persistence.cpp 
4   Steinberg::Vst::mda::BaseController::setComponentState(Steinberg::IBStream *)       mdaBaseController.cpp 

e.g. in loadProgram it returns there:

Optional<VST3::Vst2xProgram> loadProgram (const IO::BigEndianStream& state,
                                          const Optional<int32_t>& vst2xUniqueID)
{
    Vst2xProgram program;
    int32_t id;
    if (!(state >> id))
        return {};
    if (id != cMagic)   // < here this condition fails, id == 0;
        return {};
    ...

I have no idea where to look ; I tried to disable the suspicious-looking SMTG_MDA_VST2_COMPATIBILITY macro but in that case the plug-ins stop loading altogether.

jcelerier commented 3 years ago

I also checked that

in public.sdk/samples/vst/mda-vst3/source/mdaBaseProcessor.cpp:405

VST3::writeVst2State (fxb, *state);

indeed returns true so the state seems to be saved correctly.

scheffle commented 3 years ago

Can you store vstpreset files? (see vstpresetfile.h) Maybe you can try with PresetFile::savePreset and PresetFile::loadPreset if that works.