Hidden AudioUnit generic UI options

Anyone who has worked with AudioUnit plugins knows that a generic Cocoa UI is automatically generated if you don’t supply a custom UI, which is very nice for quick prototyping and/or simple plug-ins. The range of elements that are available is somewhat limited though. However, there are a few more options hidden within the code which expand the palate a bit.

I was recently prototyping a compressor and ended up writing a thousand lines of ‘extra’ code to make myself a UI merely to provide myself with a simple GR meter, clipping indicator and reset button. Since I was only concerned with the DSP at the time, I was so annoyed by the extra work that I decided to so some sleuthing through the headers and frameworks to find a simpler option and found a few useful bits:

Firstly, a parameter with a outParameterInfo.unit set to ‘boolean’ has 3 behaviors depending on the outParameterInfo.flags: a check-box, an indicator light, and a momentary pushbutton. Below is the familiar code from an audiounit’s GetParameterInfo override:

FillInParameterName(outParameterInfo, CFSTR("Parameter Name"), true);
                    outParameterInfo.unit = kAudioUnitParameterUnit_Boolean;
                    outParameterInfo.minValue = 0;
                    outParameterInfo.maxValue = 1;
                    outParameterInfo.defaultValue = 0;

We can access the different behavior by adding:

// For momentary pushbutton

outParameterInfo.flags = kAudioUnitParameterFlag_IsWritable;

// For a signal light

outParameterInfo.flags = kAudioUnitParameterFlag_IsReadable;

// For a check box

outParameterInfo.flags = kAudioUnitParameterFlag_IsWritable | kAudioUnitParameterFlag_IsReadable;

Here is an example of a dummy plugin displaying parameters with each of those behaviors:


To make use of the momentary pushbutton (to call a reset function in this example), define the behavior in a function, and trigger it in your SetParameter override:

    switch (inParameterID)
        case MyParameter:
    return AUBase::SetParameter(inParameterID, inScope, inElement, inValue, inBufferOffsetInFrames);

Secondly, there is a particularly useful combination of flags to show a meter. This can be used with almost every outParameterInfo.unit label (for example: kAudioUnitParameterUnit_Decibels to label an output level meter):

outParameterInfo.flags = kAudioUnitParameterFlag_IsReadable | kAudioUnitParameterFlag_MeterReadOnly;

Here is an example of a dummy plugin displaying a parameter with the meter behavior:


The default behavior of the meter is on a percentage scale normalized to 0-1, so you’ll still have to provide dB conversion, scaling, and ballistics yourself, but it still saves a huge chunk of time (as well as avoiding any Obj-C coding, which always gets a thumbs-up from me).

So there it is. Happy coding!


About alexkenis

Guitarist, philosopher, tinkerer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: