How to implement Acoustic Echo Cancellation?


This article is a brief introduction about Acoustic Echo Cancellation (AEC) in relation with Ozeki VoIP SIP SDK. After reading through this page you will be fully familiar with all the essential terms concerning AES technology and what you will need for creating your own solution using Ozeki VoIP SIP SDK.

What is Acoustic Echo Cancellation? How does it work?

AEC is the process of removing echo from a voice communication in order to improve voice quality on a telephone call. In addition to improving subjective quality, this process increases the capacity achieved through silence suppression by preventing echo from traveling across a network.

Acoustic echo arises when sound from a loudspeaker for example, the earpiece of a telephone handset is picked up by the microphone in the same room for example, the mic in the very same handset. The problem exists in any communications scenario where there is a speaker and a microphone.

How to implement Acoustic Echo Cancellation using C#?

Ozeki VoIP SIP SDK has a great set of methods provided for AEC technology. You can use them for making your voice call quality better.

The Acoustic Echo Cancellation can be used through the Ozeki.Media.MediaHandlers.AudioQualityEnhancer class. This class contains an AcousticeEchoCancellation property that can be set for the echo cancellation (true or false).
The SetEchoSrouce() method of the class should also be set in order to work acoustic echo cancellation properly. In the following example, the speaker is being set as the source of the echo.
To learn more about media handlers, please visit the Managing Media Handler article.

As the AudioQualityEnhancer is a MediaHandler, it needs to be connected to the proper MediaHandlers in order to work. If you want to use it for echo cancellation, you need to put the AudioQualityEnhancer between the microphone and the PhoneCallAudioSender (this example does not make a call, so it will send the voice data to the speaker object instead of a PhoneCallAudioSender one).
An AudioMixerMediaHandler object also needs to be set between the AudioQualityEnhancer and the sender in order to create an outgoing audio stream from the voice coming from the microphone and the echo cancelled sound.
The outgoingDataMixer is an instance of the AudioMixerMediaHandler class.

Acoustic Echo Cancellation example in C#

using System;
using Ozeki.Media;

namespace Acoustic_Echo_Cancellation
    class Program
        static Microphone microphone;
        static Speaker speaker;
        static MediaConnector connector;
        static AudioQualityEnhancer audioProcessor;

        static void Main(string[] args)
            microphone = Microphone.GetDefaultDevice();
            speaker = Speaker.GetDefaultDevice();
            connector = new MediaConnector();
            audioProcessor = new AudioQualityEnhancer();

            audioProcessor.AcousticEchoCancellation = true; // acoustic echo cancellation is enabled
            audioProcessor.SetEchoSource(speaker);  // sets the speaker to be the source of the echo

            connector.Connect(microphone, audioProcessor);  // voice data is being sent through the enhancer
            connector.Connect(audioProcessor, speaker);



Training guides, simple examples

If you would like to visit the detailed developer documentations, you can learn much more from the Ozeki VoIP SIP SDK Training chapter.

If you have any questions or need assistance, please contact us at

Related Pages

Copyright © 2000- - Ozeki Ltd |
Legal | Privacy | Terms of use | 7373 | | Login