4

我正在 iOS 上开发一个 VOIP 项目。根据 Apple 文档的建议,我使用 VoiceProcessingIO 音频单元来获得回声消除支持。

由于我的应用程序需要在渲染和捕获端进行单独的操作(例如,关闭扬声器但让麦克风继续),所以我创建了两个音频单元,一个具有捕获端口关闭,而另一个具有渲染端口关闭。

当前代码运行良好,直到我了解回声消除的工作原理:它需要比较来自麦克风和扬声器的信号。所以我担心的是:像我的方法一样使用两个语音处理音频单元是否安全?此外,由于音频消除主要来自捕获端,是否可以使用 RemoteIO 音频单元进行渲染(连接到扬声器)?

我不是 100% 有信心,因为我只是进入这个区域很短的时间。我也从 developer.apple.com 尝试过,但我从 developer.apple.com 找到的所有示例通常只使用一个音频单元。

任何人都可以提供一些提示吗?我的方法对 VoiceProcessingIO 单元的功能有任何潜在影响吗?

谢谢,福州

4

1 回答 1

1

Firstly, VoiceProcessingIO is (as of me writing this) only echo suppression, not echo cancellation. It essentially just turns off the input if the output is too loud. This means that e.g. in a VOIP call, the far end won't be able to hear you while they are talking. Full echo cancellation would keep the input turned on, but attempt to subtract the echoes of the output.

I would suggest only using one unit, and handle the "shutdown speaker" case yourself programmatically. Your output callback might look like this:

OSStatus output_callback(
    void *inRefCon,
    AudioUnitRenderActionFlags  *ioActionFlags,
    const AudioTimeStamp        *inTimeStamp,
    UInt32                      inInputBusNumber,
    UInt32                      inNumberFrames,
    AudioBufferList             *ioData)
{
  my_context_t *context = inRefCon;
  audio_sample_t *dst = (audio_sample_t *)ioData->mBuffers[0].mData;

  if (context->muted) {
    memset(dst, 0, inNumberFrames * sizeof(audio_sample_t));
  } else {
    get_output_samples(context, dst, inNumberFrames);
  }
  return noErr;
}

Giving silence to echo suppression should not affect it adversely.

于 2012-10-10T14:26:39.937 回答