Re: Automation record ?
Re: Automation record ?
- Subject: Re: Automation record ?
- From: Nikolaus Gerteis <email@hidden>
- Date: Fri, 29 Nov 2002 09:43:21 -0800
Could someone explain to me what is the internal mechanism for
an AU host application to :
- get the parameter list and props of an AU ?
Here is my Logic code for that:
//--------------------------------------------------------------------
// This is what I do during plugin initialization
[...]
// Properties ar set, now initialize (see SDK)
if (AudioUnitInitialize(m_tAudioUnit)!=noErr) return someError;
// Install a parameter listener for parameter changes
tErr=AUListenerCreate(AUParameterListenerProc(ParameterListener), this,
CFRunLoopRef(NULL), CFStringRef(NULL), 0.0f, &m_tParListener);
// Get the parameter list
UInt32 size = 0;
if (AudioUnitGetPropertyInfo(m_tAudioUnit,
kAudioUnitProperty_ParameterList, kAudioUnitScope_Global, 0, &size,
NULL) ==noErr)
{
UInt32 numParam=size/sizeof(AudioUnitParameterID);
mNumControls=1+numParam;
m_asParameterList=new AudioUnitParameterID[numParam];
AudioUnitGetProperty(m_tAudioUnit,
kAudioUnitProperty_ParameterList, kAudioUnitScope_Global, 0,
m_asParameterList, &size);
// Request parameter change notification for every parameter
for (UInt32 n=0; m_tParListener && n<numParam; ++n)
{
AudioUnitParameter sParam={ m_tAudioUnit, m_asParameterList[n],
kAudioUnitScope_Global, 0 };
tErr=AUListenerAddParameter(m_tParListener, NULL, &sParam);
}
}
[...]
//--------------------------------------------------------------------
// This is done during GUI instantiation
[...]
// Add a listener for mouse down and mouse up events.
// Needed for proper automation recording.
tErr=AudioUnitCarbonViewSetEventListener(m_tView, EventListener, this);
[...]
//--------------------------------------------------------------------
// These are the listeners for parameter changes and GUI events.
pascal void MDAudioUnit::ParameterListener(void* pUser, void* pObj,
const AudioUnitParameter* tParam, Float32 rValue)
{
MDAudioUnit* pcThis=(MDAudioUnit*)(pUser);
if (pcThis && tParam)
{
// Record parameter change
}
}
void MDAudioUnit::EventListener(void* inUserData, AudioUnitCarbonView
inView, const AudioUnitParameter* inParameter,
AudioUnitCarbonViewEventID inEvent, const void* inEventParam)
{
MDAudioUnit* pcThis=(MDAudioUnit*)(inUserData);
if (pcThis && inParameter)
{
if (inEvent==kAudioUnitCarbonViewEvent_MouseDownInControl)
// Record start of automation for this control
else if (inEvent==kAudioUnitCarbonViewEvent_MouseUpInControl)
// Record end of automation for this control
}
}
So there are three scenarios:
1. The plugin has no custom GUI
Then you only have to provide the parameter list and the parameter info
for every parameter.
2. The plugin has a custom GUI with carbon controls (using the
CarbonViewBase etc. sources)
You have to provide the parameter list and the parameter info and use
AUParameterSet for setting
the parameter value with ParameterListener notification. Mouse down and
up events are handled
by the CarbonViewBase base class.
3. The plugin has a custom GUI with own controls
Like 2 but you have to implement the mouse down/up notification, too.
See the CarbonViewControl and
CarbonViewBase base classes on how to do that.
Here is how I implemented it in one of our own Audio Units:
// This is called when a parameter is changed in the custom GUI
void CAUWrapper::AutomationCallback(long lPar, int iHint)
{
AudioUnitParameter sPar={ m_tAudioUnit, AudioUnitParameterID(lPar),
kAudioUnitScope_Global, 0 };
if (m_pcView && iHint==CHost::kHintMouseDw)
m_pcView->TellListener((AUVParameter&)(sPar),
kAudioUnitCarbonViewEvent_MouseDownInControl, NULL);
// Get the value from the plugin and set it for the AUBase
framework with notification call
float rValue=0.0f;
m_pcShell->CtrlGetValue(lPar, rValue);
const OSStatus tErr=AUParameterSet(NULL, NULL, &sPar, rValue, 0);
if (m_pcView && iHint==CHost::kHintMouseUp)
m_pcView->TellListener((AUVParameter&)(sPar),
kAudioUnitCarbonViewEvent_MouseUpInControl, NULL);
}
Hope this helps.
Niko
_______________________________________________
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.