Atmel AVR32840: AVR UC3 Audio Player MAD MP3 Decoder Features 32-bit Atmel Microcontroller • Software MAD MP3 decoder implementation – Player implementation – Player configuration – Licensing Application Note 1. Introduction This application note is an extension of the Atmel® AVR32839: AVR® UC3 Audio Player application note. The aim is to give the reader all he needs about implementation and configuration of the Underbit Technologies™ MPEG Audio Decoder (MAD) MP3 decoder in the Atmel AVR UC3 Audio Player. 32173A–AVR32–10/11 2. UC3 audio player 2.1 Overview The Atmel AVR UC3 audio player is a generic audio player interface and is designed to support multiple audio formats like MP3, WMA, AAC… This document details the implementation of the MAD decoder in this player. 2.2 Package The UC3 audio player package implementing the MAD decoder is the: audio_player-evk1104-evk1105-MP3-<version>.zip file. 2.3 2.3.1 MAD decoder Overview MAD is a high-quality MPEG audio decoder. It currently supports MPEG-1 and the MPEG-2 extension to lower sampling frequencies, as well as the de facto MPEG 2.5 format. All three audio layers — Layer I, Layer II, and Layer III (that is, MP3) — are fully implemented. MAD has the following special features: • 24-bit PCM output • 100% fixed-point (integer) computation • Implementation based on the ISO/IEC standards More information can be retrieved http://www.underbit.com/products/mad/. 2.3.2 from the MAD home page: Source code The source code for the UC3 specific parts of the libmad decoder is available from [1] and binaries can be built from [2]. Notes: 2.3.3 2.4 2.4.1 1. http://git.buildroot.net/buildroot/tree/package/multimedia/libmad/libmad-0.15.1boptimization.patch.avr32. 2. http://git.buildroot.net/buildroot/tree/package/multimedia/libmad. Supported devices The MAD decoder can be ported to any Atmel AVR UC3 devices, assuming parts has enough flash and RAM resources. Player implementation Source code As highlighted in Figure 2-1, the MAD decoder source code is implemented in /thirdparty/libmad directory. The optimized UC3 library is available in /thirparty/libmad/libs directory. 2.4.2 Player layer The MP3 player layer is located in /avr32/services/audio/players/mp3/mp3_libmad_player.[c,h]. 2 AVR32840 32173A–AVR32–10/11 AVR32840 Figure 2-1. Player software architecture. Audio Player Application main.c Audio Interface Task (AI) Communication Task (HMI) GUI Task (specific) _gui.c Controller ai_task.c Audio Decoding Audio Interface audio_interface.c SD Card Audio interface host_mass_storage_task.c codec_mp3_task.c _controller.c com_task.c Host Mass Storage Codec(s) ai_sd_mmc.c /thirdparty/libmad ai_usb_ms.c usb_task.c USB Host task MP3 MAD Decoder Mass Storage Audio interface USB usb_host_task.c Decoder 2 /thirdparty/decoder2 File System Decoder 3 /services/fs/fat/ /thirdparty/decoder3 Decoder 2 and above are optional Drivers usart.c, spi.c, twi.c, ssc_i2s.c, flashc.c, pm.c, gpio.c 2.5 Player configuration As detailed in the Atmel AVR32839: AVR UC3 Audio Player application note, the task() function is in charge of calling the software “tasks” to perform audio decoding. The task() is macro based and defined in /config/conf_audio_player.h file where the call to the MP3 task is defined: #define task() \ { \ task_usb(); \ task_usb_ms(); \ task_mp3(); \ } The MP3 support is then enabled by defining the MP3_SUPPORT to true: #define SUPPORT_MP3 true The MP3 file extension filtering is enabled in the following section of the conf_audio_player.h file: // ***** MP3 Support ******************************************* #if defined(SUPPORT_MP3) && SUPPORT_MP3 == true #include "ai_usb_ms_mp3_support.h" #define task_mp3() \ { \ extern void codec_mp3_task(void); \ codec_mp3_task(); \ } #define file_format_mp3 MP3_FILE_FORMAT, #else 3 32173A–AVR32–10/11 #define task_mp3() #define file_format_mp3 #endif 2.6 Decoder license The MAD decoder is distributed under the terms of the GNU General Public License (GPL). The license is located in /thirdparty/libmad/license.txt. 2.7 Performance Table 2-1 shows the memory requirement for the MP3 MAD decoder implementation. Table 2-1. MP3 MAD decoder performance. Compiler (1) RAM [KB] (2) GCC 4.4.3 (3) 67.1 / 59.4 31.9 / 31.2 IAR EWAVR32 3.31.1 60.4 / 57.7 31.3 / 31.3 1. 2. 3. 4 Flash [KB] Speed / Size optimization Speed / Size optimization AVR 32-bit GNU Toolchain 3.3.1 build 285 AVR32840 32173A–AVR32–10/11 Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: (+1)(408) 441-0311 Fax: (+1)(408) 487-2600 www.atmel.com Atmel Asia Limited Unit 1-5 & 16, 19/F BEA Tower, Millennium City 5 418 Kwun Tong Road Kwun Tong, Kowloon HONG KONG Tel: (+852) 2245-6100 Fax: (+852) 2722-1369 Atmel Munich GmbH Business Campus Parkring 4 D-85748 Garching b. Munich GERMANY Tel: (+49) 89-31970-0 Fax: (+49) 89-3194621 Atmel Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 JAPAN Tel: (+81)(3) 3523-3551 Fax: (+81)(3) 3523-7581 © 2011 Atmel Corporation. All rights reserved. Atmel ®, Atmel logo and combinations thereof, AVR ® and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others. Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. 32173A–AVR32–10/11