Re: AU2 - questions about presets and ClassInfo
Re: AU2 - questions about presets and ClassInfo
- Subject: Re: AU2 - questions about presets and ClassInfo
- From: Bill Stewart <email@hidden>
- Date: Wed, 02 Oct 2002 18:43:25 -0700
on 2/10/02 1:29 PM, Marc Poirier wrote:
>
Thanks for all of the helpful info, Bill, I have a much better
>
understanding of the AU approach to presets now. It's a lot different
>
from what I'm used to (VST), although I think much better. Just a couple
>
more questions lingering now:
>
>
>
Am I correct that the preset number for user presets is not really of any
>
concern to the AU? It is more just a piece of info for the host and its
>
own settings storage management?
Yes - for user presets the AU does nothing with it (and doesn't save it) -
its really only there for the factory presets
>
Since factory presets are read-only, then does that mean that the name
>
can't be modified by the user? Because in AUBase::DispatchSetProperty, it
>
is possible to change the name of a factory preset (not in the AU
>
executable of course, but at least for that instance). Is this a bug or
>
correct behaviour?
It's only "meant" to select a factory preset (using the number). AUBase's
default implementation is to reject a factory preset.
With our units, the reverb unit has presets for room sizes... You pass in a
room size preset, it selects it, then the name gets set.
If you saved it, and you took that name, the next time you open the unit is
won't be consistent - so I guess this is either a bug or "undefined"
behaviour...
>
I would also think that, in the case of choosing a factory preset as the
>
CurrentPreset, it also shouldn't matter if a name is supplied. But in
>
DispatchSetProperty, a name is required:
>
>
case kAudioUnitProperty_CurrentPreset:
>
<snip>
>
if (newPreset.presetName) {
>
if (newPreset.presetNumber < 0 || NewFactoryPresetSet(newPreset) == noErr) {
>
<snip>
>
} else
>
result = kAudioUnitErr_InvalidPropertyValue;
>
} else
>
result = kAudioUnitErr_InvalidPropertyValue;
>
>
Shouldn't that be something more like:
>
>
if ( newPreset.presetName && (newPreset.presetNumber < 0) )
>
// ...store the new name and set the preset number...
>
else if ( (newPreset.presetNumber >= 0) && (NewFactoryPresetSet(newPreset)
>
== noErr) )
>
// ...only set the preset number...
>
else
>
result = kAudioUnitErr_InvalidPropertyValue;
>
>
Maybe I'm wrong about this, though...
No - you're right - with a slight tweak:
if (newPreset.presetName && newPreset.presetNumber < 0)
{
CFRelease (mCurrentPreset.presetName);
mCurrentPreset = newPreset;
CFRetain (mCurrentPreset.presetName);
}
else if (newPreset.presetNumber >= 0 && NewFactoryPresetSet(newPreset) ==
noErr)
{
// NewFactoryPreset SHOULD call SetAFactoryPreset if the preset is valid
// from its own list of preset number->name
}
else
result = kAudioUnitErr_InvalidPropertyValue;
This way the AU that has factory presets ensures that the preset name is
correct given a valid preset number:...
The code that sets a factory preset may look like this:
SInt32 roomType = inNewFactoryPreset.presetNumber;
for (int i = 0; i < kNumRoomPresets; ++i) {
if (roomType == sRoomPresets[i].presetNumber) {
// do what you need to do to set this room type preset
SetAFactoryPresetAsCurrent (sRoomPresets[i]);
return noErr;
}
}
//ie. The preset number is NOT a valid factory preset
return kAudioUnitErr_InvalidPropertyValue;
(In our case the Reverb already calls SetAFactoryPresetAsCurrent with its
default preset in the constructor, so its already doing this somewhere)
This way, also the factory preset won't get the "wrong" name
I'll make sure I update the docs
Thanks
Bill
>
Thanks again,
>
Marc
>
--
mailto:email@hidden
tel: +1 408 974 4056
__________________________________________________________________________
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
__________________________________________________________________________
_______________________________________________
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.