AVAudioEngine in a VoIP app

Hello,


Our used case is real-time audio (voip) application. I wanted to use AVAudioEngine for to capture and render audio.


This is how I am setting up the AVAudioEngine nodes in my app -

AVAudioUnit -> MainMixer -> Speaker

Microphone -> InputNode -> MicMixer -> Tap (write audio to a file)


When I am writing the tapped buffers into a file, I noticed, the audio played on speaker gets captured by the microphone and gets written to file. I do not want the audio played on the speaker to be captured.


Is Acoustic Echo Cancellation (AEC) is supported by AVAudioEngine? Do I need to make any specific configuration or design changes to achieve the AEC? Is there a recommendation on how to achieve the mentioned used case?


Any help for this is greatly appreciated.

Thank you,

Piyush

Replies

Hello,


I was able to achieve bi-directional audio with echo cancellation using VoiceProcessingIO Audio Unit and AVAudioEngine's manual rendering mode.


Example code: https://github.com/twilio/video-quickstart-swift/blob/master/AudioDeviceExample/AudioDevices/ExampleAVAudioEngineDevice.m


The example uses CoreAudio's VoiceProcessingIO audio unit to playback and records audio at up to 48KHz with built-in echo cancellation. The example uses AVAudioEngine in manual rendering mode for mixing the Remote Participant's audio and audio from a file. CoreAudio receives the mixed audio samples from the AVAudioUnit's output node.


Thank you,

Piyush

Amazing !


I searched for using Acoustic Echo Cancellation (AEC) with AudioEngine for a very long time but I didn't find anything.

I tried using https://developer.apple.com/documentation/avfoundation/avaudiounit but without success.


Thank you for your sample !