I have been trying to implement handling to control changes on my Audio Unit but i'm having a strange issue, the new value notification is not coherent. This is what I'm doing:
In the Audio Unit code I'm registering parameters as follow:
Code: Select all
OSStatus IAu::GetParameterInfo(AudioUnitScope inScope, AudioUnitParameterID inParameterID, AudioUnitParameterInfo &outParameterInfo)
{
if (inScope != kAudioUnitScope_Global)
return kAudioUnitErr_InvalidScope;
outParameterInfo.flags = kAudioUnitParameterFlag_IsWritable;
outParameterInfo.flags += kAudioUnitParameterFlag_IsReadable;
AUBase::FillInParameterName(outParameterInfo, CFStringCreateWithCStringNoCopy(NULL, "parameter name", kCFStringEncodingMacRoman, NULL), false);
outParameterInfo.unit = kAudioUnitParameterUnit_CustomUnit;
outParameterInfo.minValue = 0;
outParameterInfo.maxValue = 1.0;
outParameterInfo.defaultValue = 1.0;
return noErr;
}
Code: Select all
void addParamListener(AUEventListenerRef listener, void* refCon, AudioUnitEvent *inEvent)
{
inEvent->mEventType = kAudioUnitEvent_ParameterValueChange;
verify_noerr(AUEventListenerAddEventType(listener, refCon, inEvent));
}
Code: Select all
void EventListenerDispatcher(void *inRefCon, void *inObject, const AudioUnitEvent *inEvent, UInt64 inHostTime, Float32 inValue)
{
IAuView *view = (IAuView*) inRefCon;
[view eventListener:inObject event: inEvent value: inValue];
}
Code: Select all
verify_noerr(AUEventListenerCreate(EventListenerDispatcher, self, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode, 0.05, 0.05, &_AUEventListener));
AudioUnitEvent auEvent;
AudioUnitParameter parameter = { _audioUnit, 0, kAudioUnitScope_Global, 0 };
auEvent.mArgument.mParameter = parameter;
addParamListener(_AUEventListener, self, &auEvent);
for (int i=1; i<DRCSynthEngine::NumParameters; i++)
{
auEvent.mArgument.mParameter.mParameterID = i;
addParamListener(_AUEventListener, self, &auEvent);
}
Code: Select all
0
-3.68935e+19
0
3.68935e+19
2
3.68935e+19
0
-1.0842e-19
0
-1.0842e-19
0
0
Any ideas?
Thanks!
Nuno