Microchip logo
  • All
  • Products
  • Documents
  • Applications Notes

dsPIC DSC Automatic Gain Control Library

The dsPIC® DSC Automatic Gain Control Library automatically adjusts the amplitude of a speech signal to match a set level. This is useful in speech applications where the distance between the speech source and the microphone is not fixed. The Automatic Gain Control Library can be used readily with Microchip's Speech and Audio Solutions for speech signal pre-processing. Typical applications include:

    • Hands-free cell phone kits

    • Speaker phones

    • Intercoms

    • Teleconferencing systems

    • Headsets

    • Front-end to a speech recognition system or speech encoding algorithm


The Automatic Gain Control (AGC) library is useful in speech and audio applications where distance between the system user and the microphone varies. The main function of the AGC is to estimate the short-term peak amplitude of input speech and apply a gain factor so that is brought up to a desired level which has been set by the user. If no speech is detected the gain will gradually 'leak' back down to a pre-set default level. It is assumed that the system of which the AGC is a part has been correctly set up for normal use by a talker who is close to the microphone. Hence the AGC library maintains the input signal level to the subsequent processing blocks in the signal processing chain. The rate at which the gain changes are applied to the input signal can be controlled.

While the AGC library is implemented entirely in software, it can also be used to control the gain of an external codec and a software hook is provided for this. The library will also flag amplitude clipping on the input. The AGC library also provides hooks for to provide the desired gain to an external codec which can then scale the input signal.


    • The dsPIC DSC Automatic Gain Control library features:

    • Simple user interface – only one library file and one header file

    • All functions called from a C application program

    • Full compliance with the Microchip C30 Compiler, Assembler and Linker

    • Highly optimized assembly code that uses the DSP instructions and advanced addressing modes

    • Comprehensive API provides parametric control of the AGC engine

    • Customized for speech applications.

    • Input signal clip detection

    • Hooks to control gain of external codec

    • Gain attack, release and leakage rate controls

    • Audio bandwidth: 8 – 48 kHz sampling rate

    • Library downloadable from the web, which also includes

    - Sample wave files

    - Sample demo application

    - Windows Help File for Library API


KB Size
Updated as of
dsPIC® DSC Automatic Gain Control (AGC) Library User’s Guide
AGC Setup