Audio and Sound

Audio and Speech Recording / Encoding / Compression Application Solutions


Recording of speech or audio signals requires compressing (encoding) it for efficient storage or transmission. Some embedded applications may require recording of speech while the system is deployed in the field. A new voice message could be recorded as part of a field update to change an existing message being played back by the system. In the case of communication applications recording (including compression) may be performed prior to streaming out data.

In both cases, the quality of audio depends on both the compression scheme (G.726A, Speex, etc.) used in firmware as well as the hardware peripherals used (PWM, DAC etc.) for reproducing the sound. Most communication applications that require encoding of streaming audio will also require decoding of received speech data. In all applications requiring recording of speech, the processor throughput (MIPS) required by the MCU or DSC is largely dependent on the encoding algorithm. These applications are discussed in detail in the Communications section. In this section, we present the solutions required for playback-only applications in two parts:

Software Algorithm Libraries


The choice of software algorithm used to playback audio and speech signals depends on the compression algorithm used to encode/record the raw speech data prior to storage. The graph below compares a variety of compression schemes in use today. Microchip provides software libraries to support algorithms that require no payment of royalties, such as IMA ADPCM for 8- and 16-bit MCUs, G.711, Speex and G.726A for PIC24 MCU and dsPIC® DSCs and ADPCM for PIC32 MCUs.

Click image to enlarge

Click image to enlarge

Note: The MIPS usage statistics shown for algorithms within gray ellipses in the graph above represent the requirements of Microchip's implementation of these algorithms on 16-bit PIC® MCUs and dsPIC® DSCs.

A decision on the algorithm to use is often based on a tradeoff between quality and memory costs incurred in saving large amounts of audio data. Another critical benchmark affecting the choice of processor used in recording applications is the MIPS needed to execute the encoding algorithm. The table below shows approximate MIPS needed for various algorithms on Microchip’s 16-bit MCUs and DSCs. Since most applications that require encoding also require decoding, the MIPS throughput for both encoding and decoding is presented below:

Algorithm G.711 G.726A Speex
MIPS 1 13 20
Flash (KB) 3.5 6 30
RAM (KB) 3.5 4 7
Memory needed to store 1
second of encoded speech
8 KB 2,3,4 or 5 KB 1 KB
CPU MIPS usage for Compression Algorithm as a percentage of MAx throughput
PIC24F Family 6.25% -  
PIC24H Family 2.5% -  
dsPIC33F Family 2.5% 32.5% 50%

The table below provides approximate throughput of various Microchip families:

Device Family Architecture MIPS (MHz)
PIC18 MCU 8-bit PIC® MCU 16
PIC24 MCU 16-bit PIC® MCU 16-70
dsPIC DSC 16-bit dsPIC® DSC 40-70
PIC32 MCU 32-bit PIC® MCU 80

Hardware Design Options


A couple of variations are available for implementation in hardware based on trade-offs on quality of audio versus system cost, simplicity versus system-integration etc. Popular methods supported by Microchip’s MCUs and DSCs are shown below:

  1. Use on-chip A/D Converter
  2. Use off-chip Codecs or A/D Converters

In the option shown here, a 12-bit A/D converter may be used to digitize speech data once the analog waveform from the microphone or Line input has been amplified and band-limited. A 12-bit A/D converter peripheral is available in many PIC® MCUs & dsPIC® Digital Signal Controllers. Learn more about the 12-bit ADC peripheral in our web seminar. A representative design exercising this option can be found in the MPLAB® Starter Kit for dsPIC® DSC. Schematics and source code for a demo are available in the zip file provided with the board.

Hardware Option 1: Use on-chip A/D Converter

Click image to enlarge

Hardware Option 2:
Use off-chip Codecs or A/D Converters

Click image to enlarge

A representative design exercising this option using a voice-band codec can be found in the PIC32 Audio Development Board (DM320011). Schematics and source code for a demo are available in the zip file provided with the board. A second design exercising this option with a hi-fidelity audio codec can be found in the dsPIC® DSC Audio Development Board. Schematics and source code for a demo are available in the zip file provided with the board.