Re: ClassInfo save and restore in Reverb AU
Re: ClassInfo save and restore in Reverb AU
- Subject: Re: ClassInfo save and restore in Reverb AU
- From: Robert Grant <email@hidden>
- Date: Mon, 5 Jan 2004 07:46:26 -0500
Hi Craig,
I'm not sure to what purpose you're saving the class info. Most people
do it to save custom settings in a user preset. What you're doing below
looks to be either redundant or even incorrect. If users have made
changes to a factory preset then this will be saved in the class info,
but the current preset (this should be "PresentPreset" BTW,
CurrentPreset has been deprecated - though some AUs still want it, so
you have to code for both) still points to the factory preset (or a
user preset if that's what was selected before editing begain). Saving
the current factory preset number and then restoring it will simply set
the AU back to the factory preset and will override the class info you
just restored.
If that makes sense.
I think the bug is still in the AU generic view. It should show the
name of the current custom preset as well as the factory presets, but
then the preset menu won't work properly because the AU doesn't save
the state of the current custom preset so switching back to the custom
preset through the menu won't work. This is not a good area... :-(
Robert.
On Jan 5, 2004, at 5:52 AM, Craig Bakalian wrote:
Hi Robert,
I resolved this one yesterday. You must set the preset and then the
popup button will reflect the current reverberation [setting ?] It
looks like this now ->
-(void)saveReverbUnitInfoToFile
{
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *pathWithFile = [path stringByAppendingPathComponent:
@"/ReverbData"];
if(reverbUnit)
{
CFPropertyListRef list;
UInt32 size = sizeof(CFPropertyListRef);
AudioUnitGetProperty(reverbUnit,
kAudioUnitProperty_ClassInfo,kAudioUnitScope_Global, 0, &list, &size);
AUPreset room;
size = sizeof(AUPreset);
AudioUnitGetProperty(reverbUnit, kAudioUnitProperty_CurrentPreset,
kAudioUnitScope_Global, 0, &room, &size);
NSArray *saveArray = [NSArray arrayWithObjects: (NSDictionary
*)list, [NSNumber numberWithUnsignedInt: room.presetNumber], nil];
[NSArchiver archiveRootObject: saveArray toFile: pathWithFile];
}
}
-(void)restoreReverbUnitFromFile
{
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *pathWithFile = [path stringByAppendingPathComponent:
@"/ReverbData"];
if( [[NSFileManager defaultManager] fileExistsAtPath: pathWithFile])
{
if(reverbUnit)
{
NSArray *saveArray = [NSUnarchiver unarchiveObjectWithFile:
pathWithFile];
NSDictionary *dict = [saveArray objectAtIndex: 0];
CFPropertyListRef list = (CFPropertyListRef)dict;
UInt32 size = sizeof(CFPropertyListRef);
AudioUnitSetProperty(reverbUnit,
kAudioUnitProperty_ClassInfo,kAudioUnitScope_Global, 0, &list, size);
UInt32 pNumber = [(NSNumber *)[saveArray objectAtIndex: 1]
unsignedIntValue];
AUPreset room;
room.presetNumber = pNumber;
size = sizeof(AUPreset);
AudioUnitSetProperty(reverbUnit, kAudioUnitProperty_CurrentPreset,
kAudioUnitScope_Global, 0, &room, size);
}
}
}
On Jan 4, 2004, at 3:43 PM, Robert Grant wrote:
Hi Craig,
I think your problem is that the generic AU UI is unable to display
the names of non-factory presets. When I reproduce your case the
preset name syncs properly when switching between factory presets but
goes to an empty selection when a user preset is loaded from
ClassInfo.
I guess this is a feature? You can always set the window title to
indicate the name of the current preset ;-)
Robert.
Craig Bakalian
www.eThinkingCap.com
_______________________________________________
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.