【问题标题】:How does one discover [non-Apple] Audio Units with Audio Component Services?如何发现具有音频组件服务的 [非 Apple] 音频单元?
【发布时间】:2014-07-26 22:38:39
【问题描述】:

在 OS X 中,我试图找到一个示例,说明如何发现最终用户系统上安装的所有音频单元并取回该信息以供显示和使用。

我知道音频组件与该任务有关,但我完全不知道如何去做。我遇到的所有示例都是基于使用 AudioComponentFindNext 查找“已知”Apple AU,而我找不到其他示例。

谁能给我举个例子?

谢谢

【问题讨论】:

    标签: macos core-audio audiounit


    【解决方案1】:

    您可以使用0 作为类型、子类型和制造商的通配符来设置AudioComponentDescription 结构。将其传递给AudioComponentFindNext

    AudioComponentDescription acd = { 0 };
    AudioComponent comp = nullptr;
    while((comp = AudioComponentFindNext(comp, &acd)) {
      // Found an AU
    }
    

    以下是标题中的一些相关文档:

    @function       AudioComponentFindNext
    @abstract       Finds an audio component.
    @discussion     This function is used to find an audio component that is the closest match
                    to the provided values.
    @param          inComponent
                        If NULL, then the search starts from the beginning until an audio
                        component is found that matches the description provided by inDesc.
                        If non-NULL, then the search starts (continues) from the previously
                        found audio component specified by inComponent, and will return the next
                        found audio component.
    @param          inDesc
                        The type, subtype and manufacturer fields are used to specify the audio
                        component to search for. A value of 0 (zero) for any of these fields is
                        a wildcard, so the first match found is returned.
    @result         An audio component that matches the search parameters, or NULL if none found.
    

    【讨论】:

      【解决方案2】:

      只需使用提供的 AVAudioUnitComponentManager 组件函数即可获取音频单元。

      它将返回与您传递的AudioComponentDescription 匹配的音频单元数组。 命令单击AudioComponentDescriptionkAudioUnitType_MusicDevice 以查看您可以使用的各种值。

      // Exemple to get instruments audio units
      var match = AudioComponentDescription()
      match.componentType = kAudioUnitType_MusicDevice
              
      let audioUnitComponents = AVAudioUnitComponentManager.shared().components(matching: match)
      

      【讨论】:

      • 请对您的回答提供一些解释
      • 完成 ;) 这需要一些想象力,因为它几乎是一行代码。 2014 年要困难得多
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多