Re: AU : Parameter handling...
Re: AU : Parameter handling...
- Subject: Re: AU : Parameter handling...
- From: Marc Poirier <email@hidden>
- Date: Tue, 15 Oct 2002 16:07:10 +0200 (CEST)
>
I need to have some private data that would be saved with the
>
preset. There are various need like, lfo phase... As far as I
>
saw, I can do this if and only if those parameters are floats ?
No, there's no need to make them parameters...
>
What about Midi configuration data (internal modulation
>
routing), filename (for a sample), etc ?
>
>
In VST, RTAS, MAS, DX, PTAF, those are handled differently :
>
- VST, RTAS : availability to save a chunck of opaque data as
>
well as float parameters
>
- MAS, each parameter has a type (float, double, Byte, array of
>
Bytes...) which are concatened using a stream (the best way to
>
handle parameters IMHO)
>
- DX : as always been natively a chunk of opaque data (no parameters)
And Audio Unit is better yet: a nicely formatted/keyed CoreFoundation
dictionary with the possibility to include your own opaque data chunks in
there. What you want to do is override SaveState and RestoreState. You
might want to keep the AUBase implementations and add your own stuff from
there, as the base implementations take care of some good stuff for you
(making sure the settings are for the correct AU, handling the preset
name, storing/restoring parameter values, etc.). This is how I do it in
my plugins (stuff in all-caps is what you need to change, except for
NULL and CFSTR, of course):
ComponentResult YOUR_PLUGIN::SaveState(CFPropertyListRef *outData)
{
ComponentResult result = AUBase::SaveState(outData);
if (result != noErr)
return result;
CFMutableDictionaryRef dict = (CFMutableDictionaryRef) *outData;
CFMutableDataRef cfdata = CFDataCreateMutable(NULL, NULL);
UInt8 * plaindata;
unsigned long plaindatasize;
SAVE_YOUR_STUFF(&plaindata, &plaindatasize);
CFDataAppendBytes(cfdata, plaindata, plaindatasize);
CFDictionarySetValue(dict, CFSTR("YOUR-DATA-KEY"), cfdata);
CFRelease(cfdata);
*outData = dict;
return noErr;
}
ComponentResult YOUR_PLUGIN::RestoreState(CFPropertyListRef inData)
{
ComponentResult result = AUBase::RestoreState(inData);
if (result != noErr)
return result;
CFDataRef cfdata =
reinterpret_cast<CFDataRef>(CFDictionaryGetValue((CFDictionaryRef)inData,
CFSTR("YOUR-DATA-KEY"));
if (cfdata == NULL)
return kAudioUnitErr_InvalidPropertyValue;
const UInt8 * plaindata = CFDataGetBytePtr(cfdata);
unsigned long plaindatasize = CFDataGetLength(cfdata);
RESTORE_YOUR_STUFF(plaindata, plaindatasize);
return noErr;
}
_______________________________________________
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.