AU plugins not loading state after removing parameters


#1

During R&D/experimenting stages of developing a plugin, one may add and remove parameters while trying out different ideas.
But whenever a parameter is removed, all the sessions using the plugin stop loading the plugin state. Instead, they could have loaded the parameters that are still there.

This happens due to AUBase::RestoreState loading a redundant copy of the parameters that are also loaded by juce (via setCurrentProgramStateInformation) and in its loading process it throws an exception in AUElement::GetParamEvent due to trying to set a parameter that doesn’t exist.

To work around this problem - so that parameters could be removed and presets will still load etc, I used this workaround in JuceAU::RestoreState:

        ComponentResult err = JuceAUBaseClass::RestoreState (inData);

turned to

        ComponentResult err;
        {
            CFMutableDictionaryRef dataDup =
                CFDictionaryCreateMutableCopy(NULL, 0, (CFDictionaryRef)inData);
            CFDictionaryRemoveValue (dataDup, CFSTR("data"));
            err = JuceAUBaseClass::RestoreState (dataDup);
            CFRelease(dataDup);
        }

removing the “data” entry from the property list disables AUBase’s problematic loading of the redundant copy of the parameters.

I wonder if anyone has a better solution, and maybe if this should be integrated to juce.
cheers


#2

Thanks, that’s interesting… Looks like a good solution, I’ll take a look and see what I can do…