Question about AudioUnit parameter listeners
Question about AudioUnit parameter listeners
- Subject: Question about AudioUnit parameter listeners
- From: Per Bull Holmen <email@hidden>
- Date: Fri, 13 May 2011 17:05:02 +0200
Hi folks,
When you dispose of a parameter listener, using AUListenerDispose, do
you really have to remove each specific parameter that's being tracked
from the listener first? I'm asking because in the autogenerated code
from the XCode template "AudioUnit effect with Cocoa view", the
following code is used to add and remove parameter change listeners:
-----
- (void)_addListeners {
NSAssert ( AUListenerCreate( ParameterListenerDispatcher, self,
CFRunLoopGetCurrent(),
kCFRunLoopDefaultMode, 0.100, // 100 ms
&mParameterListener ) == noErr,
@"[CocoaView _addListeners] AUListenerCreate()");
int i;
for (i = 0; i < kNumberOfParameters; ++i) {
mParameter[i].mAudioUnit = mAU;
NSAssert ( AUListenerAddParameter (mParameterListener, NULL,
&mParameter[i]) == noErr,
@"[CocoaView _addListeners] AUListenerAddParameter()");
}
[[NSNotificationCenter defaultCenter] addObserver: self selector:
@selector(handleMouseDown:)
name:SpectrumAnalyserAU_GestureSliderMouseDownNotification object:
uiParam1Slider];
[[NSNotificationCenter defaultCenter] addObserver: self selector:
@selector(handleMouseUp:)
name:SpectrumAnalyserAU_GestureSliderMouseUpNotification object:
uiParam1Slider];
}
- (void)_removeListeners {
int i;
for (i = 0; i < kNumberOfParameters; ++i) {
NSAssert ( AUListenerRemoveParameter(mParameterListener, NULL,
&mParameter[i]) == noErr,
@"[CocoaView _removeListeners]
AUListenerRemoveParameter()");
}
NSAssert ( AUListenerDispose(mParameterListener) == noErr,
@"[CocoaView _removeListeners] AUListenerDispose()");
[[NSNotificationCenter defaultCenter] removeObserver: self];
}
-----
Here we see that they are going through the extra pain of keeping a
copy of each AudioUnitParameter they are tracking, and manually
removing each AudioUnitParameter from the listener before they call
AUListenerDispose. The documentation in AudioUnitUtilities does not
mention whether this is necessary. You'd think the AUListener object
could handle that itself? Not?
Per
_______________________________________________
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