Microchip Technology Inc

dsPIC DSC Acoustic Echo Cancellation Library


The dsPIC DSC Acoustic Echo Cancellation (AEC) Library is fully compatible with G.167 standard for Acoustic Echo Cancellation. The software library provides a
function to eliminate echo generated in the acoustic path between a speaker and a microphone. This function is useful for speech and telephony applications in
which a speaker and a microphone are located in close proximity to each other, and therefore susceptible to signals propagating from the speaker to the
microphone resulting in a perceptible and distracting echo effect at the far end.


  • Automobile Hands-free Cell Phone Kits
  • Speaker phones
  • Intercoms
  • Teleconferencing

The Acoustic Echo Cancellation (AEC) Library is written almost entirely in assembly language and is highly optimized to make extensive use of the dsPIC DSC device instruction set and advanced addressing modes. The algorithm avoids data overflow. The AEC Library provides an EC_init function for initializing the various data structures required by the algorithm and an EC_apply function to remove the echo component from a 10 ms block of sampled 16-bit speech data. You can easily
call both functions through a well-documented Application Programmer’s Interface.

The Acoustic Echo Cancellation algorithm is primarily a Time Domain algorithm. The received far-end speech samples (typically received across a communication channel, such as a telephone line) are filtered using an adaptive Finite Impulse Response (FIR) filter, and then subtracted from the near-end input speech signal. The coefficients of this filter are adapted using the Normalized Least Mean Square (NLMS) algorithm, such that the filter closely models the acoustic path between the near-end speaker and the near-end microphone (i.e., the path traversed by the echo). A Nonlinear Processor (NLP) algorithm is available to eliminate residual echo.

Key features of the AEC Library include the following:
• Simple user interface – only one library file and one header file
• All functions can be called from a C application program
• Compatible with the Microchip C30 Compiler, Assembler and Linker
• Highly optimized assembly code that uses DSP instructions and advanced addressing modes
• Acoustic echo cancellation for 16, 32, 64 or 128 ms echo delays or “tail lengths” (configurable)
• Fully tested for compliance with G.167 specifications for in-car applications
• Audio Bandwidth: 0 to 4 kHz at 8 kHz sampling rate
• Convergence Rate: Up to 47 dB/sec., typically greater than 30 dB/sec
• Acoustic Echo Cancellation: Up to 50 dB, typically > 40 dB
• Can be used together with the Noise Suppression (NS) Library
• Demo application source code is provided with the Library
• Can be instantiated multiple times to support multiple input audio streams.
• NLP attenuation level can be adjusted to suit application requirements
• Acoustic Echo Cancellation adaptation can be force-enabled or disabled by the user application
• Run-time control of key algorithm parameters is provided


KB Size
Updated as of
dsPIC® DSC Acoustic Echo Cancellation Library User’s Guide
AEC setup
Example Audio file with Cancelled Acoustic Echo - 64mSec
Example Audio File with Acoustic Echo -64mSec