Re: Saving the state of a music device
Re: Saving the state of a music device
- Subject: Re: Saving the state of a music device
- From: William Stewart <email@hidden>
- Date: Mon, 10 Sep 2007 11:23:06 -0700
On 09/09/2007, at 10:32 PM, Todd Blanchard wrote:
I've got saving working well mostly - but there are few snags.
Prior to saving state, I call AUGraphGetNodeInfo(graph, node, 0, 0,
&properties,0) to get the properties memento from the audio unit.
On restarts, I provide this memento in AUGraphNewNode to restore
the state of the unit. Works great - sometimes.
We've actually deprecated AUGraphNewNode in Leopard because we've
found that in general it is better to handle the class info (what you
call properties) yourself.
So, when getting it:
AudioUnit unit;
AUGraphGetNodInfo (graph, node, ..&unit..);
CFPropertyList properties;
AudioUnitGetProperty (kAudioUnitProperty_ClassInfo, ...&properties...);
That is the state of the AU
To restore it...
AUNode node;
AUGraphNewNode (... the basic info for the kind of AU you want, &node);
AudioUnit unit;
AUGraphGetNodInfo (graph, node, ..&unit..);
CFPropertyList properties = ReconstructProperties(...);
AudioUnitSetProperty (kAudioUnitProperty_ClassInfo, ...&properties...);
One thing to be aware of is that when setting the class info, some
audio units are particular about their initialised state. So in AULab
we have this additional check (this is using the CAAudioUnit wrapper
around and AudioUnit);
if (inDict.HasKey (kAUPresetStr)) {
CFPropertyListRef preset = NULL;
if (inDict.GetCFType (kAUPresetStr, preset)) {
result = inUnit.SetAUPresetFromDocument (preset);
if (result == kAudioUnitErr_Uninitialized) {
require_noerr (result = inUnit.Initialize(), home);
inUnit.SetAUPresetFromDocument (preset);
}
else if (result) {
result = inUnit.SetAUPreset (preset);
if (result == kAudioUnitErr_Uninitialized) {
require_noerr (result = inUnit.Initialize(), home);
inUnit.SetAUPreset (preset);
}
result = noErr;
}
}
}
Firstly SetAUPresetFromDocument - uses a new class info property we
added for Leopard:
kAudioUnitProperty_ClassInfoFromDocument = 50
Some AUs want to know the difference between a preset "in action" and
a preset from a document. If that returns an error could be because
of the init state, so respond accordingly. otherwise, just assume
that AU doesn't implement that and set the normal property
If that last preset call fails we still make the AU at that node, it
just won't have a preset restored (for whatever reason).
It doesn't seem to work with the Korg Digital Legacy Collection (M1
and Wavestation emulators).
This could be because the AUGraphGetNodeInfo call may not be actually
getting the preset from the AU. So try this with the suggestion I've
made and see if that is still a problem.
I'm not sure what I need to do to save the state of these puppies.
The M1 in particular seems odd as it operates in a couple different
modes - a multi timbral mode, and a straightI'm open to suggestions?
The other thing that AULab does is to save off the state of the AU -
what are the formats of all of its inputs and outputs.. (We use the
code in the CAAudioUnit, CAComponentDescription, to save and restore
all of this info)... Then when it is restoring an AU, it first sets
it all up and initialises it to make sure that it all takes. Most of
the basic code that AULab uses to save/restore AU structures is in
the PublicUtility code in /Developer/Examples/CoreAudio to help
others with this
HTH
Bill
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
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
________________________________________________________________________
__
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden