Audio in Embedded Linux Systems
Total Page:16
File Type:pdf, Size:1020Kb
Audio in embedded Linux systems Audio in embedded Linux systems Michael Opdenacker Free Electrons http://free-electrons.com Created with OpenOffice.org 2.0 Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 1 Rights to copy Attribution ± ShareAlike 2.0 © Copyright 2004-2005 You are free Michael Opdenacker to copy, distribute, display, and perform the work [email protected] to make derivative works to make commercial use of the work Document sources, updates and translations: Under the following conditions http://free-electrons.com/training/audio Attribution. You must give the original author credit. Corrections, suggestions, contributions and Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license translations are welcome! identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. License text: http://creativecommons.org/licenses/by-sa/2.0/legalcode Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 2 Best viewed with... This document is best viewed with a recent PDF reader or with OpenOffice.org itself! Take advantage of internal or external hyperlinks. So, don't hesitate to click on them! Find pages quickly thanks to automatic search Use thumbnails to navigate in the document in a quick way If you're reading a paper or HTML copy, you should get your copy in PDF or OpenOffice.org format on http://free-electrons.com/training/audio! Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 3 Scope of this training Audio in embedded Linux systems This training targets the development of audio-capable embedded Linux systems. Though it can be useful to playing or creating sound on GNU/Linux desktops, it is not meant to cover everything about audio on GNU/Linux. Linux 2.6 This training only targets new systems based on the Linux 2.6 kernel. This way, you leverage the most advanced technology and don©t learn about something getting obsolete. Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 4 Contents (1) Introduction System perspective Glossary System overview Audio codecs and file formats Advanced Linux Sound Architecture (ALSA) ALSA kernel drivers Kernel low latency requirements for sound ALSA userspace interface Sound servers - JACK Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 5 Contents (2) Free Software audio Audio players For the GNU / Linux workstation For the embedded Linux target Audio encoders Misc Speech synthesis References Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 6 Quick Glossary PCM: Pulse Code Modulation Digital audio encoding, representing the amplitude of a signal at uniform intervals. Codec: coder / decoder Program or device coding and / or decoding a data stream or a signal. MIDI: Musical Instrument Digital Interface. Standard to control electronic musical instruments. See http://wikipedia.org for details! Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 7 Audio in embedded Linux systems Free Software Audio Audio codecs and file formats Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 8 MP3 MPEG-1 Audio Layer III The most popular. Users have lots of from the Fraunhofer Society files in this format. Free Software encoders and decoders Lossy audio format exist Bitrates from 32 to 320 kbit/s But relies on patented algorithms. Quality depends on the bitrate: Depending on which country you sell 128-192: good, 192-224: very good, to, you may have to pay for a license. 224-320: excellent Licenses can apply to encoding, Depends also pretty much on the decoding or even songs! encoder and on the source. Ask for legal advice! Depends on the listener too! See http://en.wikipedia.org/wiki/Mp3 for details Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 9 AAC Advanced Audio Coding Used on some on-line music stores (Apple MPEG-4 Audio iTunes) and portable players (Apple iPod). Standard format from the MPEG Also burdened by patents, like MP3. group: Dolby, Fraunhofer, AT&T, License needed to encode and read this Sony, and Nokia format. Lossy audio format Free Software decoders available Designed to replace MP3. Just one Free Software encoder available Consistently better audio quality (faac) than MP3 at lower bitrates. Can be DRM encrypted (FairPlay) More details on http://en.wikipedia.org/wiki/Advanced_Audio_Coding Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 10 RealAudio From RealNetworks Free Software decoders available http://realnetworks.com/ (Helix, mplayer) Mainly used for streaming, used by a Lossy audio format significant number of on-line media. Proprietary format Useful for mobile devices connecting to these media. Designed for very low bandwidth connections Only proprietary encoders. RealNetworks encoder free of charge Bitrates: 12 to 800 kbit/s only for personal use. Now uses AAC at 128 kbit/s and more Lossless format also supported More details on http://en.wikipedia.org/wiki/Real_Audio Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 11 WMA Windows Media Audio Now supported by more and more digital players and on-line music stores. Microsoft proprietary, as a alternative Users may ask for WMA playing to MP3 (patented by somebody else) capability. and now AAC. Lack of Free Software players (except Almost always encapsulated in an libavcodec) and encoders Advanced Systems Format (ASF) file Relies on patented algorithms. File extensions: asf or wma Licenses may apply to encoding, Supports constant and variable decoding or even songs, though MS is bitrates, and lossless compression. still very tolerant so far (to achieve Can be DRM encrypted dominance). See http://en.wikipedia.org/wiki/WMA for details Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 12 Ogg Vorbis From the Xiph foundation Growing in popularity. More and more http://xiph.org/ hardware players available. Xiph.org releases libraries under a Ogg: container for multimedia streams BSD-style license and GPL for tools. Vorbis: lossy audio format Various Free Software decoders and Open, patent and royalty free! encoders available. Supported by many proprietary players too. Bitrates from 45 to 500 kbit/s Variable bitrate Achieves better quality than MP3 at low bitrates See for http://en.wikipedia.org/wiki/Ogg_vorbis details Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 13 Ogg Speex From the Xiph foundation Constant or variable bitrate, http://www.speex.org/ from 2 to 44 kbit/s Ogg: container Listen to samples on Usual file extension: .spx http://www.speex.org/samples.html Speex: lossy audio dedicated to Free Software encoder, decoders speech encoding. and applications available. Targets Voice over IP applications, Even supported by proprietary voice mail archival, audio books... tools (e.g. MS NetMeeting) Open, patent and royalty free! See http://en.wikipedia.org/wiki/Speex for details Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 14 Flac http://flac.sourceforge.net/ Libraries available under a BSD-like Supported by Xiph.org license, and tools under the GPL. Free Software players available Lossless audio compression format Compress audio files at no risk! Even starts to be supported by hardware players Preferred format for trading live music on-line Supports streaming Ogg: also used as a container Integer-only coder and decoder available. See http://en.wikipedia.org/wiki/FLAC for details Audio in embedded Linux systems Copyright 2005, Michael Opdenacker Creative Commons Attribution-ShareAlike 2.0 license http://free-electrons.com/ Sep 21, 2005 15 Compression rate example comparison (1) Format / bitrate 64 kbit/s 128 kbit/s 192 kbit/s 256 kbit/s Wav 100.00% MP3 4.6% (22:1) 9.1% (11:1) 13.6% (7:1) 18.2% (5:1) (lame 3.96.1) Ogg Vorbis 4.3% (23:1) 8.5% (12:1) 12.7% (8:1) 17.7 % (6:1) (oggenc 1.0.1) Flac (flac 1.1.0) 56.30% bzip2 (1.0.2) 89.50% Source: Omara Portuondo, Flor de Amor (Cuban Salsa) Audio in embedded Linux systems Copyright 2005, Michael Opdenacker