Microchip logo
  • All
  • Products
  • Documents
  • Applications Notes

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

Hardware Peripheral Options

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.

rec CPU run compression alg
recording encoder MIPS

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:

AlgorithmG.711G.726ASpeex
MIPS11320
Flash (KB)3.5630
RAM (KB)3.547
Memory needed to store 1
second of encoded speech
8 KB2,3,4 or 5 KB1 KB
CPU MIPS usage for Compression Algorithm as a percentage of MAx throughput
PIC24F Family6.25%- 
dsPIC33F Family2.5%32.5%50%

The table below provides approximate throughput of various Microchip families:

Device FamilyArchitectureMIPS (MHz)
PIC18 MCU 8-bit PIC®MCU16
PIC24F MCU 16-bit PIC®MCU16-70
dsPIC DSC16-bit dsPIC®DSC40-70
PIC32MM MCU32-bit PIC® MM Family MCU25 MHz
PIC32 MCU32-bit PIC®MCU200

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:

  • Use on-chip A/D Converter
  • Use off-chip Codecs or A/D Converters

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

Option2 Use OFF Chip AD Converter
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

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

Option1 Use On Chip AD Converter
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 (DM330011). Schematics and source code for a demo are available in the zip file provided with the board. Alternatively, one can use the Explorer 16/32 Development Board (DM240001-2) with the Audio PICtail Plus Daughter Board (DM330016).