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

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 microcontroller (MCU) or Digital Signal Contrller (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. We provide 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 MCUs and dsPIC® DSCs 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 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 our 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 Speed
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 maximum throughput  
PIC24F Family 6.25% -  
dsPIC33F Family 2.5% 32.5% 50%

The table below provides approximate throughput of various Microchip products:

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 our MCUs and DSCs are shown below:

  • Use off-chip codecs or ADCs
  • Use on-chip Analog-to-Digital Converter (ADC)

Hardware Option 1: Use Off-Chip Codecs or ADCs

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 ADC

In the option shown here, a 12-bit ADC 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 ADC peripheral is available in many PIC MCUs and dsPIC DSCs. A representative design exercising this option can be found in the MPLAB® Starter Kit for dsPIC DSCs (DM330011). Schematics and source code for a demo are available in the zip file provided with the board.

Documentation

Title Download
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
AN643 - Adaptive Differential Pulse Code Modulation using the PIC16/17 Download
Title Download
dsPIC33EPXXX(GP/MC/MU)806/810/814 and PIC24EPXXX(GP/GU)810/814 Data Sheet Download
dsPIC33FJXXXGPX06A/X08A/X10A Family Data Sheet Download
PIC32MX1xx/2xx 28/36/44-pin Family Data Sheet Download
PIC32MZ Embedded Connectivity with Floating Point Unit (EF) Family Data Sheet Download
PIC32MX330/350/370/430/450/470 Family Data Sheet Download
PIC32MX1xx/2xx/5xx 64/100-pin Family 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