Solutions for Applications requiring Audio & Speech Playback 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 (PWM, 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 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 & 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. Microchip provides software libraries to support algorithms that require no payment of royalties, such as IMA ADPCM for 8 &16-bit PIC® MCUs, G.711, Speex & G.726A for PIC24 MCU & dsPIC DSCs & Speex & ADPCM for PIC32 MCUs. 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 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 Memory needed to store 1 second of encoded speech G.711 8 KB G.726A 2, 3, 4, or 5 KB Speex 1 KB How does this affect your choice of MCU, DSC or Memory component? Use the device below: To store N seconds of speech in on-chip Flash memory using the following encoding algorithms: Device G.711 G.726A Speex 25xx1024 Serial EEPROM PIC24FJ256GA106 or PIC24HJ256GP610 dsPIC33FJ256GP710 PIC32MX360F512L 16 sec 25 to 64 sec. 128 sec 32 sec. 52 to 128 sec. n/a 32 sec. 64 sec. 51 to 128 sec. 102 to 256 sec. 256 sec. 512 sec. Listed below are several application notes and software libraries useful in audio playback applications: Audio Functions MP3 Playback Playback Resource Type App. Note & Source Code App. Note & Source Code App. Note & Source Code Title & Link AN1367 – Porting the Helix MP3 Decoder onto Microchip’s PIC32MX 32-bit MCUs AN 538 – Using PWM to generate Analog Output Supported Families PIC32 MCU ALL Record & Playback Library SW300026 -dsPIC/PIC24 G.711 Speech Encoding & Decoding library PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32 PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, Record & Playback Library SW300090 : dsPIC G.726A Speech Encoding/Decoding Library dsPIC30F, dsPIC33 Record & Playback Library SW300070: Speex Speech encoding/decoding Library dsPIC30F, dsPIC33 Record & Playback Library dsPIC DSC Equalizer Library Record & Playback Library Audio Library for PIC32MX - supports ADPCM and WAV formats ALL Library dsPIC DSC Automatic Gain Control Library dsPIC30F,dsPIC33F ALL GUI dsPIC® DSC Speech and Audio Fast Forward (SAFF) tool dsPIC30F, dsPIC33F ALL GUI Analog Filter & Amplifier Design Record & Playback AN643-Adaptive Differential Pulse Code Modulation dsPIC30F, dsPIC33F PIC32 MCU Analog Design ALL GUI Digital Filter Design dsPIC30F, dsPIC33F Hardware Peripheral Options A few variations are available for implementation in hardware based on trade-offs on quality of audio versus system cost, simplicity versus systemintegration etc. Popular methods supported by Microchip’s MCUs and DSCs are shown below: 1. Use on-chip D/A Converter 2. Use on-chip PWM followed by external low-pass filtering 3. Use off-chip Codecs or D/A Converters Hardware Option 1: Use on-chip D/A Converter 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 D/A converter peripheral is available in some dsPIC Digital Signal Controllers. Learn more about the 16-bit Audio DAC peripheral in our web seminar. Hardware Option 2: Use on-chip PWM followed by external low-pass filtering The option shown above can be used with many of Microchip’s 8, 16 & 32-bit MCUs and DSCs. PWM peripherals are used to drive speakers. The PWM output is filtered prior to amplification. AN5xx describes this technique in greater detail. This option can be prototyped using the Explorer 16 development board and the Speech Playback PICtail Plus accessory. Hardware Option 3: Use off-chip Codecs or D/A Converters A representative design exercising this option can be found in the dsPICDEM 1.1 Plus Development Board. Schematics and source code for a demo are available in the zip file provided with the board.