AUWrapper audioProcessorChanged/Preset Name

​I guess like most plugin programmers I cooked up my own preset system to have truly crossplatform and cross-standard presets that can be moved around as files based on Juce ValueTrees. While implementing my system I came across a "problem" with the AU wrapper.

My plugins allow to rename the current preset in the plugin GUI and this should be an issue for any plugin allowing renaming of presets.

When using the vst wrapper, calling audioProcessorChanged() calls vsts UpdateDisplay() method which makes the host re-read the current preset name. For AU that did not work and I thought it was maybe just not possible.

Then I found 3rd party plugins doing exactly what I need (not Juce-based). It is especially important for Logic X where the preset name is displayed in large letters above the plugin GUI. I ended up patching the AU Wrapper the following way and I'm hoping this could become part of JUCE because I find it so useful. It might look weird, but I found out the only way to change the current preset name (which is stored in a private variable inside AUBase) is to call SetAFactoryPresetAsCurrent(). Just calling PropertyChanged() is not enough due to the way AUBase and the wrapper work. That's how I ended up with these lines:

    void audioProcessorChanged (AudioProcessor*)
        PropertyChanged (kAudioUnitProperty_Latency,       kAudioUnitScope_Global, 0);
        PropertyChanged (kAudioUnitProperty_ParameterList, kAudioUnitScope_Global, 0);
        PropertyChanged (kAudioUnitProperty_ParameterInfo, kAudioUnitScope_Global, 0);

   +    AUPreset preset;
   +    const int prg = juceFilter->getCurrentProgram();
   +    preset.presetNumber = prg;
   +    preset.presetName = juceFilter->getProgramName(prg).toCFString();
   +    SetAFactoryPresetAsCurrent(preset);
   +    PropertyChanged (kAudioUnitProperty_PresentPreset, kAudioUnitScope_Global, 0);


Thanks for bringing this issue up!

It should work now using the newest tip.

Thank you for the fix!