Audio Units secrets: handling control changes

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi,

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;
}
Then, in Audio Unit view I have the following to listen to property changes:

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);
}
The problem is that when I use the device box on Ableton Live to change the plugin parameter the values that come out on the eventListener are as follow:

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
This was a swipe from left to right. I was expecting to see something between 0 and 1. I have reviewed the code several times and I can't find an explanation for this.

Any ideas?

Thanks!

Nuno

Post Reply

Return to “DSP and Plugin Development”