我目前从事基于 Xamarin.iOS 平台的跨平台 Voip 应用开发。我确实搜索了 iOS 上的 AEC 实现,但大多数主题都与 Objective-C 相关。 我现在已经实现的是:我可以使用Audiotoolbox(音频队列)从麦克风获取输入的原始声音数据并通过套接字将其发送出去。但是在使用其他设备进行测试时,我在电话中听到了非常清晰的回声。这是代码:
private void SetupInputQueue()
{
inputQueue = new InputAudioQueue(audioStreamBasicDescription);
//sendbuffer initialization
heading = Encoding.ASCII.GetBytes("msg ");
sendBuffer = new byte[CountAudioBuffers][];
for (int i = 0; i < CountAudioBuffers; i++)
{
sendBuffer[i] = new byte[516];
for (int j = 0; j < heading.Length; j++)
{
sendBuffer[i][j] = heading[j];
}
}
for (int count = 0; count < CountAudioBuffers; count++)
{
IntPtr bufferpointer;
inputQueue.AllocateBuffer(AudioBufferLength, out bufferpointer);
inputQueue.EnqueueBuffer(bufferpointer, AudioBufferLength, null);
}
inputQueue.InputCompleted += HandleInputCompleted;
}
private void HandleInputCompleted(object sender, InputCompletedEventArgs e)
{
unsafe
{
byte* shortPtr = (byte*)e.UnsafeBuffer->AudioData;
for (int count = heading.Length; count < sendBuffer[sendOutIndex].Length; count++)
{
sendBuffer[sendOutIndex][count] = *shortPtr;
shortPtr++;
}
}
socket.SendTo(sendBuffer[sendOutIndex], master);
this.inputQueue.EnqueueBuffer(e.IntPtrBuffer, AudioBufferLength, null);
sendOutIndex = (sendOutIndex + 1) % CountAudioBuffers;
}
根据 AEC on OSX using AudioQueue ,我了解到我应该将原始声音数据传递给 I/O 单元(音频单元?)的提示。但是由于Xamarin.iOS(c#)中缺少示例,我无法弄清楚如何详细实现这个过程。任何熟悉 Xamarin 平台上的 Voip 应用程序开发的人都可以给我一些例子来学习吗?非常感谢对此的任何帮助或提示。
(Nov, 21, 2018)我找到的一些相关帖子:Record audio with audio unit Audio unit Callbacks An audio unit example
最佳答案
我建议分析您系统中回声的性质(例如 test the echo path )。也许它超出了内置回声消除的能力范围。
关于c# - Xamarin.iOS 上的回声消除 (AEC),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53402009/