We detect you are using an unsupported browser. For the best experience, please visit the site using Chrome, Firefox, Safari, or Edge. X

Audio applications that require playback of voice often fall in one of two classes:

  • Playback of pre-recorded and stored audio
  • Playback of streaming audio

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 (Pulse-Width Modulator (PWM), Digital-to-Analog Converter (DAC), etc.) for reproducing the sound. Some applications that require playback of streaming audio may also require encoding of recorded speech data for duplex transmission. In such cases, the processor throughput (MIPS) required by the microcontroller (MCU) or Digital Signal Controller (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 the raw speech data prior to storage. The graph below compares a variety of compression schemes in use today. We provide software libraries to support algorithms that require no payment of royalties, such as IMA ADPCM for 8- and 16-bit PIC® MCUs, G.711, Speex and G.726A for PIC24 MCUs and dsPIC® DSCs, and G.711, Speex and ADPCM for PIC32 MCUs.

Note: The MIPS usage statistics shown for algorithms within gray ellipses in the graph above represent the requirements of our 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 system cost incurred in saving large amounts of audio data. The table below shows how the various algorithms perform in terms of actual seconds of speech they can store into memory.

Algorithm G.711 G.726A Speed
Memory needed to store 1 second of encoded speech 8 KB 2, 3, 4 or 5 KB 1 KB

How Does This Affect Your Choice of MCU, DSC or Memory Component?


This table shows how many seconds of speech can be stored in the on-chip Flash memory on some example devices by using the same encoding algorithms:

Example devices and their code/audio storage capability G.711 G.726A Speed
25XX1024 Serial EEPROM (128 KB of storage) 16 sec 25 to 64 sec 128 sec
PIC24FJ256GA or PIC24HJ256GP610 (256 KB of storage) 32 sec (1) 52 to 128 sec n/a
dsPIC33EP512MU810 (512 KB of storage) 64 sec (1) 102 to 256 sec 512 sec
PIC32MX360F512L (512 KB of storage) 64 sec (1) 102 to 256 sec 512 sec

Note 1: This is a theoretical maximum value. Since the application program will occupy some of this memory, the actual audio storage capability will be lower than the limits stated here.

Hardware Design Options


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

  • Use off-chip codecs or DACs
  • Use on-chip PWM followed by low-pass filtering
  • Use on-chip Analog-to-Digital Converter (ADC)

Hardware Option 1: Use Off-Chip Codecs or DACs

This option can be prototyped using the Explorer 16/32 Development Board. The schematics and source code for a demo are available in the zip file provided with the board.

Hardware Option 2: Use On-Chip PWM Followed by External Low-Pass Filtering

This option can be used with many of our 8-, 16- and 32-bit PIC MCUs and dsPIC DSCs. PWM peripherals are used to drive the speakers. The PWM output is filtered prior to amplification. This option can be prototyped using the Explorer 16/32 Development Board.

Hardware Option 3: Use On-Chip ADC

In the option shown here, all hardware except for the speaker and analog amplification circuitry resides within the MCU or DSC. A 16-bit audio DAC peripheral is available in some dsPIC DSCs.

Documentation

Title
AN1367 - Porting the Helix MP3 Decoder onto Microchip’s PIC32MX 32-bit MCUs Download
AN1152 - Achieving Higher ADC Resolution Using Oversampling Download
AN1422 - High-Quality Audio Applications Using the PIC32 Download
Adaptive Differential Pulse Code Modulation Using PIC Microcontrollers Download
Title
dsPIC33EPXXX(GP/MC/MU)806/810/814 and PIC24EPXXX(GP/GU)810/814 Data Sheet Download
dsPIC33FJXXXGPX06A/X08A/X10A Data Sheet Download
PIC32MZ Embedded Connectivity with Floating Point Unit (EF) Family Download
PIC32MX1XX/2XX Family Data Sheet Download
PIC32MX330/350/370/430/450/470 Data Sheet Download
PIC24FJ1024GA610/GB610 Family Data Sheet Download
PIC32MX1XX/2XX 28/44-pin XLP Family Data Sheet Download

Development Tools

Description Part Number
PIC32MX Curiosity Development Board DM320103
PIC32MM USB Curiosity Development Board DM320107
PIC32MZ Embedded Connectivity with FPU (EF) Starter Kit DM320007
PIC32MZ Embedded Graphics with Stacked DRAM (DA) Starter Kit DM320010
PIC32MZEF Curiosity Development Board DM320209
Description Part Number
BM64 Bluetooth Radio Daughter Board AC320032-3
Audio Codec Daughter Card – AK4642 AC320100
Audio Coder Daughter Card – AK7755 AC327755
PIC32 Audio DAC Daughter Card AC320032-2
Description Part Number
Explorer 16/32 Development Board
DM240001-2
MPLAB Starter Kit for dsPIC DSC
DM330011

Software Libraries

Recording and Playback Software Libraries


Audio Functions Resource Type Title and Link Supported Families
Audio and Speech Library MP3 Decoder Library for PIC32MX PIC32 MCU
Audio and Speech Library PIC32 Audio Equalizer Filter library PIC32 MCU
Bluetooth Audio Library PIC32 Bluetooth®Audio Software Suites PIC32 MCU
AAC Playback Library AAC Decoder Library for PIC32 PIC32 MCU
Streaming Audio Demo USB Audio Headset Demo PIC32MM MCU
Record and Playback, Streaming Audio Library dsPIC33E Sample Rate Conversion dsPIC33E
Record Application Note and Source Code AN1152-Achieving Higher ADC Resolution Using Oversampling dsPIC33E, dsPIC33F
Record and Playback, Voice Communications Library SW300026 dsPIC/PIC24 G.711 Speech Encoding & Decoding Library dsPIC33E, dsPIC33F
Record and Playback, Voice Communications Library SW300090-dsPIC G.726A Speech Encoding/Decoding Library dsPIC33E, dsPIC33F
Record and Playback, Voice Communications Library SW300070-Speex Speech encoding/decoding Library dsPIC33E, dsPIC33F
Record and Playback, Voice Communications Library dsPIC®DSC Equalizer Library dsPIC33E, dsPIC33F
Voice Communcations Library SW300060-Aucostic Echo Cancellation Library dsPIC33E, dsPIC33F
Voice Communcations Library SW300080-Line Echo Cancellation Library dsPIC33E, dsPIC33F
Voice Communcations Library SW300040-Noise suppression library dsPIC33E, dsPIC33F
Voice Communcations Library dsPIC DSC Automatic Gain Control Library dsPIC33E, dsPIC33F
Record and Playback, Voice Communications GUI dsPIC DSC Speech and Audio Fast Forward (SAFF) tool dsPIC33E, dsPIC33F
Record and Playback, Voice Communications GUI Digital Filter Design dsPIC33E, dsPIC33F
Record and Playback, Voice Communications GUI dsPICworks Data Analysis & DSP software (use to convert PCM to WAV and back) PIC24F, dsPIC33E, dsPIC33F