4

音频单元主机是否有办法逐步检查插件的参数并获得以下信息:

  • 字符串形式的参数名称,例如“延迟时间”
  • 参数范围(最小值、最大值)
  • 参数单位(例如秒)
  • 参数控制(例如滑块)

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

4

1 回答 1

8

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

编辑:这些文件现在可以在“Xcode 音频工具”包中找到。您可以通过转到 Xcode > 打开开发者工具 > 更多开发者工具...

假设您有一个名为的 AudioUnittheUnit以下代码将设置您遍历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
    }
}

例如,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;

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

于 2011-07-08T18:44:49.410 回答