【问题标题】:Record audio from non-default audio device in objective C在目标 C 中录制来自非默认音频设备的音频
【发布时间】:2014-08-05 07:54:20
【问题描述】:

我们知道没有用于录制 OS X 的实时流式音频(输出声音)的 API。我们应该安装一个像SoundFlower这样的内核扩展,然后通过该内核扩展录制输出通道的音频。

我知道像 audacity 这样的一些开源应用程序使用端口音频库来捕获系统默认音频设备以外的其他音频设备的音频。但是在 Xcode 上构建时,由于错误太多,我无法编译 Port Audio。

我想知道有一个直接的 Core Audio API 可以选择录音设备吗? AudioQueue API 无法确定记录设备的类型。 如何使用某些特定的 Mac 提供的 API 记录通过目标 C 中的 SoundFLower 播放的输出声音?

提前感谢您的回复。

【问题讨论】:

  • 那个问题没有正确回答。我的问题不仅涉及音频队列,还涉及所有可用于选择录制 API 的可选输入的音频框架。
  • 在 OS X 上,AudioDeviceID 可以与 AUHAL、音频队列和大多数音频 API 一起使用。那个问题或者stackoverflow.com/questions/4575408/… 没有回答你的问题呢?
  • 你的意思是我可以使用 Audio Queue API 来捕获任何带有 AudioDeviceID 的可选音频设备?
  • 你的意思是我可以使用 Audio Queue API 来捕获任何带有 AudioDeviceID 的可选音频设备声音吗?

标签: objective-c macos core-audio audio-recording


【解决方案1】:

这是 SoundFlowerBed 中用于查找和选择特定音频设备的相关代码:

/* From Interface */
AudioDeviceID mSoundflower2Device;
AudioDeviceID mSoundflower16Device;

/* Implementation */
// find soundflower devices, store and remove them from our output list
AudioDeviceList::DeviceList &thelist = mOutputDeviceList->GetList();
int index = 0;
for (AudioDeviceList::DeviceList::iterator i = thelist.begin(); i != thelist.end(); ++i, ++index) {
    if (0 == strcmp("Soundflower (2ch)", (*i).mName)) {
        mSoundflower2Device = (*i).mID;
        AudioDeviceList::DeviceList::iterator toerase = i;
        i--;
        thelist.erase(toerase);
    }
    else if (0 == strcmp("Soundflower (16ch)", (*i).mName)) {
        mSoundflower16Device = (*i).mID;
        AudioDeviceList::DeviceList::iterator toerase = i;
        i--;
        thelist.erase(toerase);
    }
    else if (0 == strcmp("Soundflower (64ch)", (*i).mName)) {
        mSoundflower16Device = (*i).mID;
        AudioDeviceList::DeviceList::iterator toerase = i;
        i--;
        thelist.erase(toerase);
    }
}

您需要在此处下载源表单:https://github.com/mattingalls/Soundflower,并在您的项目中包含 AudioDevice 和 AudioDeviceList 文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-26
    • 1970-01-01
    • 2019-12-29
    • 1970-01-01
    • 1970-01-01
    • 2012-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多