Audio Units secrets: how to handle plugin state save/restore?

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi,

I'm trying to save/restore my plugin state across DAW project sessions. On my AU class that extends AUInstrumentBase I have extended the two following methods:

Code: Select all

OSStatus SaveState(CFPropertyListRef *outData);

OSStatus IAu::SaveState(CFPropertyListRef *outData)
{
    AUInstrumentBase::SaveState(outData);
}

OSStatus RestoreState(CFPropertyListRef *inData);

OSStatus IAu::RestoreState(CFPropertyListRef *inData)
{
    AUInstrumentBase::RestoreState(inData);
}

When I hit save, I have a call on SaveState. My internals save the plugin state in JSON. What is a CFPropertyListRef and how can I convert the JSON to this? Can I simply save binary data?

What about restore? Is it only called when SaveState actually sets anything to outData? Is there any example on how to do it? So far I have only looked onto Will Pirkle books examples.

Any tips?

Thanks!

Regards,

Nuno

Post

You may want to look at what IPlug is doing in IPlugAU.cpp
AU will require some defined format to be validated, but you can put arbitrary binary data in it.
Checkout our VST3/VST2/AU/AAX/LV2:
Inner Pitch | Lens | Couture | Panagement | Graillon

Post

Thanks for the tip! I will give a look then.

Regards

Post

I have gave a look to IPlugAU.cpp and couldn't find state save/restore stuff. What am I missing?

Post

In short, this is save and load states from IPlugAU:
https://github.com/olilarkin/wdl-ol/blo ... .cpp#L1463
https://github.com/olilarkin/wdl-ol/blo ... .cpp#L1492

CFPropertyListRef is a special virtual type describing Core Foundation containers. In AU context I haven't seen use of any other container except CFDictionaryRef.

When saving you must create dictionary and set the following keys in it:

Code: Select all

kAUPresetVersionKey
kAUPresetTypeKey
kAUPresetSubtypeKey
kAUPresetManufacturerKey
And save your data in kAUPresetDataKey key.

When restoring state you should check values of those keys to make sure that the data is generated by your plugin and read data from kAUPresetDataKey.

Post

It took me a while to digest this but it's done! Thanks for your help. Regards

Post Reply

Return to “DSP and Plugin Development”