AUPresets in Logic
AUPresets in Logic
- Subject: AUPresets in Logic
- From: Marc Poirier <email@hidden>
- Date: Thu, 3 Oct 2002 15:20:19 +0200 (CEST)
Hey, has anyone successfully implemented presets in an Audio Unit and
gotten them to work in Logic? I am having severe crashing and bogus data
problems, but I'm not sure whether it's the fault of Logic or my fault for
doing something wrong in GetPresets.
What's happeningis that, when I choose a preset number from the plugin
window menu in Logic, Logic calls AUBase::DispatchSetProperty with
kAudioUnitProperty_CurrentPreset as the selector. Looking at that part of
AUBase's code, we see:
case kAudioUnitProperty_CurrentPreset:
{
require(inScope == kAudioUnitScope_Global, InvalidScope);
AUPreset & newPreset = *(AUPreset *)inData;
if (newPreset.presetNumber >= 0)
CRASH HAPPENS HERE
So as soon as the inData is accessed as an AUPreset, a crash occurs.
Sometimes it can be accessed and I can print out the value of
newPreset.presetNumber and it's something crazy like -1609364160, so
clearly this data being passed in is bogus, either the inData pointer
itself or what it points to. If the data is being squeezed right out of
what I return from GetPresets, then it's probably my fault, but if not,
then it's probably Logic's fault. So anyway, I'm wondering if anyone has
had success, then I'll know that it's probably my fault.
So... if it is my fault and anyone cares to be so kind as to take a look
and tell me what I'm doing wrong... :)
// presets[].name is a C string
// numPresets is how many presets my plugin has
ComponentResult DfxPlugin::GetPresets(CFArrayRef *outData) const
{
AUPreset aupresets[numPresets];
for (long i=0; i < numPresets; i++)
{
aupresets[i].presetNumber = i;
aupresets[i].presetName = CFStringCreateWithCString(NULL,
presets[i].name, kCFStringEncodingMacRoman);
}
*outData = CFArrayCreate(NULL, (const void**)(&aupresets),
numPresets, NULL);
for (long i=0; i < numPresets; i++)
CFRelease(aupresets[i].presetName);
return noErr;
}
I might be messing up some CoreFoundation stuff (I'm still trying to
figure out when I need to release things and when I don't), but I tried
not releasing aupresets[i].presetName at the end and that did not help,
and I tried making aupresets[] a class member so that it would live
through the whole plugin instance, and that didn't help either.
Any help or insights or other experiences would be appreciated!
Thanks,
Marc
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.