Logic Pro X doesn't save Plug-in State


#1

Hi all,

I'm having issues with saving the state of my plug-in in Logic Pro X.

I created a plug-in with JUCE (version3.0.4) an it works fine on 32-bit and 64-bit systems, VST and AU. But when I use the AU plug-in in a Logic Pro X 10.0.6 session running under OS X 10.9.2 (64-bit) the state of the plug-in is not correctly stored/restored. Within a session, settings are retained when closing then re-opening the plug-in. But when re-opening a saved session the settings revert back to the default state.

I successfully tested the plug-in with the following audio hosts:

- Ableton Live 9 (Win7 and OS X 10.7.5, 32-bit and 64-bit, VST and AU)
- Reaper (OS X 10.7.5, 32-bit, VST and AU)
- Samplitude Pro X (Win 7, 32-Bit, VST)

But the problem occurs with the AU in Logic Pro X 10.0.6 under OS X 10.9.2. I use XCode 4.6.1 under OS X 10.7.5.

I implemented the getStateInformation(...) and setStateInformation(...) methods in my processor:

void MyPluginAudioProcessor::getStateInformation (MemoryBlock& destData)
{
  XmlElement XmlState("MySettings");
  XmlState.setAttribute(String("Gain"), mGain);
  // and so on ...
 
  copyXmlToBinary(XmlState, destData);
}


void MyPluginAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
  ScopedPointer<XmlElement> XmlState(getXmlFromBinary(data, sizeInBytes));

  if (XmlState != 0)
  {
    if (XmlState->hasTagName("MySettings"))
    {
      mGain = XmlState->getFloatAttribute(String("Gain"), mGain);
      // and so on ...
    }
  }
}

When does Logic call these methods? Do I have to implement something in the constructor/destructor?

Please can someone help? Thank you in advance.

Best,
Dirk

 


#2

Does the problem also happen with the JUCE demo plugin? (if it does it will be a sign that the problem isn't in your code, even though it doesn't sound like your code is at fault it's always helpful to double-check)


#3

Got it! Thanks for your tip. Usually I double-check my code. But looking at the demo plugin code was far too simple for me this time. In addition the problem occured also in other DAWs (not only in Logic Pro X).

The problem was in the setStateInformation(...) method. Instead of 'String' you have to use 'StringRef':

void MyPluginAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
  ScopedPointer<XmlElement> XmlState(getXmlFromBinary(data, sizeInBytes));

  if (XmlState != 0)
  {
    if (XmlState->hasTagName("MySettings"))
    {
      mGain = XmlState->getFloatAttribute(StringRef("Gain"), mGain);
      // and so on ...
    }
  }
}

It's hard to see the forest for the trees ...

 


#4

Instead of 'String' you have to use 'StringRef':

..nope..

The two things are interchangable. If a method parameter is a StringRef you can pass either a String or a StringRef or a literal. They all work the same.

And why are you wrapping a string literal in the class name anyway? You can just say getFloatAttribute ("Gain")


#5

Sorry for the misinformation. Unfortunately there was a bug in the management of my presets. Oddly this bug only had an impact on Logic. I assume that it has something to do with the initialisation procedure of the hosts.

Jules, thank you for the hint. I dropped wrapping the string literal in the class name. Now I just use getDoubleAttribute ("Gain") as shown in the demo plug-in. But the method 'getFloatAttribute' as you suggested doesn't exist (yet).

Now the plug-in really works correctly. Thanks.