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

4
有没有一种方法让音频单元主机逐步通过插件的参数并获取以下信息:
  • 参数名称,例如字符串“Delay Time”
  • 参数范围(最小值、最大值)
  • 参数单位(例如秒)
  • 参数控制(例如滑块)
据我所知,此信息在插件中可用,但我无法弄清楚如何从主机端查询它。
1个回答

8
您需要首先#import CAAUParameter和AUParamInfo(可以在/Developer/Extras/CoreAudio/PublicUtility中找到)。 编辑:这些文件现在可以在“Xcode音频工具”包中找到。您可以通过转到Xcode > 打开开发人员工具 > 更多开发人员工具...来获取它。
假设您有一个名为theUnit的AudioUnit,以下代码将设置您遍历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(例如通过在包含该单元的图形上调用AUGraphOpen())才能进行操作。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接