Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to enumerate Audio Unit parameter descriptions?

Is there a way for an Audio Unit host to step through a plugin's parameters and gain such information as:

  • parameter name as a string e.g. "Delay Time"
  • parameter range (minimum, maximum)
  • parameter units (e.g. seconds)
  • parameter control (e.g. slider)

AFAICT this information is available in the plugin, but I can't figure out how to query it from the host side.

like image 600
j b Avatar asked Feb 24 '23 16:02

j b


1 Answers

You'll first need to #import CAAUParameter and AUParamInfo (which can be found in /Developer/Extras/CoreAudio/PublicUtility).

EDIT: These files are now found in the "Audio Tools For Xcode" package. You can get it by going to Xcode > Open Developer Tool > More Developer Tools...

Assuming you have an AudioUnit called theUnit The following code will set you up to iterate through theUnit's parameters:

bool includeExpert   = false;
bool includeReadOnly = false;

AUParamInfo info (theUnit, includeExpert, includeReadOnly); 

for(int i = 0; i < info.NumParams(); i++)
{
    if(NULL != info.GetParamInfo(i))
    {
        // Do things with info here
    }
}

For example, info.GetParamInfo(i))->ParamInfo() will give you an AudioUnitParameterInfo struct which is defined as follows:

typedef struct AudioUnitParameterInfo
{
    char                        name[52];
    CFStringRef                 unitName;
    UInt32                      clumpID;
    CFStringRef                 cfNameString;
    AudioUnitParameterUnit      unit;                       
    AudioUnitParameterValue     minValue;           
    AudioUnitParameterValue     maxValue;           
    AudioUnitParameterValue     defaultValue;       
    UInt32                      flags;              
} AudioUnitParameterInfo;

Note that you'll need to open the AudioUnit first (eg. by calling AUGraphOpen() on the Graph which contains the unit).

like image 97
admsyn Avatar answered May 03 '23 21:05

admsyn