Hi, it seems that calling setProgram(int)
to load a plugin’s preset from a host app doesn’t work on iOS.
The current code builds the AUPreset struct populating only the preset number, using an empty string for the name.
void setCurrentProgram (int newIndex) override
{
AUPreset current;
current.presetNumber = newIndex;
current.presetName = CFSTR("");
AudioUnitSetProperty (audioUnit, kAudioUnitProperty_PresentPreset,
kAudioUnitScope_Global, 0, ¤t, sizeof (AUPreset));
sendAllParametersChangedEvents();
}
Populating correctly also the corresponding preset name works fine, for example:
void setCurrentProgram (int newIndex) override
{
AUPreset current;
current.presetNumber = newIndex;
CFArrayRef presets;
UInt32 sz = sizeof (CFArrayRef);
if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_FactoryPresets,
kAudioUnitScope_Global, 0, &presets, &sz) == noErr)
{
if (const AUPreset* p = (const AUPreset*) CFArrayGetValueAtIndex (presets, newIndex))
{
current.presetName = p->presetName;
}
CFRelease(presets);
}
AudioUnitSetProperty (audioUnit, kAudioUnitProperty_PresentPreset,
kAudioUnitScope_Global, 0, ¤t, sizeof (AUPreset));
sendAllParametersChangedEvents();
}