是否可以枚举音频单元参数描述?

j b*_*j b 4 core-audio audiounit

有没有办法让音频单元主机逐步执行插件的参数并获取以下信息:

  • 参数名称为字符串,例如"延迟时间"
  • 参数范围(最小值,最大值)
  • 参数单位(例如秒)
  • 参数控制(例如滑块)

AFAICT这个信息在插件中可用,但我无法弄清楚如何从主机端查询它.

adm*_*syn 8

您首先需要#importCAAUParameter和AUParamInfo(可以在/ Developer/Extras/CoreAudio/PublicUtility中找到).

编辑:现在可以在"Audio Tools For Xcode"包中找到这些文件.您可以通过访问Xcode> Open Developer Tool>更多开发人员工具来获取它...

假设您有一个名为AudioUnit theUnit的代码以下代码将设置您迭代theUnit的参数:

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
    }
}
Run Code Online (Sandbox Code Playgroud)

例如,info.GetParamInfo(i))->ParamInfo()将为您提供一个AudioUnitParameterInfo结构,其定义如下:

typedef struct AudioUnitParameterInfo
{
    char                        name[52];
    CFStringRef                 unitName;
    UInt32                      clumpID;
    CFStringRef                 cfNameString;
    AudioUnitParameterUnit      unit;                       
    AudioUnitParameterValue     minValue;           
    AudioUnitParameterValue     maxValue;           
    AudioUnitParameterValue     defaultValue;       
    UInt32                      flags;              
} AudioUnitParameterInfo;
Run Code Online (Sandbox Code Playgroud)

请注意,您需要首先打开AudioUnit(例如,通过在包含该单元的Graph上调用AUGraphOpen()).