Linux MP3 CD Burning mini-HOWTO Greg Wierzchowski greg.wierzchowski@usa.net 2001-05-29 Revision History Revision 1.2 2001-07-12 Revised by: GW Minor layout changes; Added Translations subsection into Credits. Revision 1.1 2001-06-12 Revised by: GW Minor cleanup; Regexp fix for MP3 to WAV name conversion example. Revision 1.0 2001-05-29 Revised by: GW Initial Release. A complete recipe for creating audio CDs from MP3 files. ----------------------------------------------------------------------------- Table of Contents 1. Introduction 1.1. Copyright and License 2. Preparing the Tracks 3. Burning Your CD 4. Credits 4.1. Translations 4.2. Other Credits 1. Introduction This mini-HOWTO was created because of my experience with burning music CDs and lack of some specific information about sound normalization on the Internet. I usually burn music CDs as a mix - different songs from different sources.Very often volume level between songs varies greatly. This is the first obstacle. Second, many of the files on the Internet are not CD-compatible (16 bit, stereo, 44.1 kHz) and have to be converted. There are many programs to burn music CDs from MP3 files, and many of them do the conversion transparently. But I haven't seen a single tool that also normalizes the volume, so that's why I worked out my own CD-burning recipe. I'm assuming you wish to burn a CD with the collection of songs you obtained from different sources, all varying quality, but you want to get the best-sounding CD possible. This mini-HOWTO outlines the steps that may help you. ----------------------------------------------------------------------------- 1.1. Copyright and License This document is copyright 2001 by Greg Wierzchowski and is released under the terms of the GNU Free Documentation License, which is hereby incorporated by reference. Send feedback to greg.wierzchowski@usa.net. ----------------------------------------------------------------------------- 2. Preparing the Tracks Note: All commands assume bash shell 1. Collect all MP3 files in one directory. 2. If any filenames contain spaces, first convert them to underscores: for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done 3. Convert them to WAV with the command: for i in *.mp3; do mpg123 -w `basename $i .mp3`.wav $i; done Mpg123 should be present in any Linux distribution, but if you don't have it, get it at [http://www.mpg123.de/] http://www.mpg123.de/. NOTE I noticed that with some MP3 files mpg123 output was distorted. At first I thought that MP3's were bad, but then I checked with another player and they sounded OK. So I searched for another MP3 player that could write WAV files to disk, and found this one: MAD mp3 decoder at [http://www.mars.org/home/rob/proj/mpeg/] http://www.mars.org/home/rob/ proj/mpeg/. With madplayer, the command line is: for i in *.mp3; do madplay -o `basename $i .mp3`.wav $i; done NOTE: The `basename $i .mp3`.wav command replaces MP3 extensions with WAV. There are 101 ways to do that, here's the alternative: `echo "$1" | sed 's/\.mp3$/.wav/'` 4. Run "file *.wav" and check the output for any files different from 16 bit, stereo 44100 Hz. 5. If there are files with different characteristics, convert them to the above specs. For example, to convert file track01.wav to obtain sample rate 44.1 kHz, you could use: sox track01.wav -r 44100 track01-new.wav resample Sox is so popular, that it's probably installed by default with any Linux distribution, and can be obtained from [http://www.spies.com/Sox/] http:/ /www.spies.com/Sox/. However, the command-line options are somewhat cryptic for the casual user (me). Look at [http://www.spies.com/Sox/ sox.tips.html] http://www.spies.com/Sox/sox.tips.html for some tips on usage. 6. Normalize your WAV files, to avoid drastic differences in volume levels. I use a program by Chris Vaill (), called normalize - it can be obtained from [http://www.cs.columbia.edu/~cvaill/ normalize/] http://www.cs.columbia.edu/~cvaill/normalize/ I use the following syntax (-m is for mix mode, where all files should be as loud as possible): normalize -m *.wav ----------------------------------------------------------------------------- 3. Burning Your CD There are many programs to create CDs from WAV files. I use cdrecord for command-line burning and XCDROAST for gui. For cdrecord, you have to know what SCSI device your CD-writer is. If you're using ATAPI writer, use SCSI emulation (kernel module ide-scsi). Let's assume, that your ATAPI cdwriter is on the second IDE bus as a master. Thus, it will have /dev/hdc device file. To instruct the kernel that you want to treat it as a SCSI device, add the following line to /etc/lilo.conf: append=" hdc=ide-scsi" Also, if your kernel doesn't automatically load ide-scsi module, add insmod ide-scsi into your rc.local (or equivalent) file. Once you have our CD-writer recognized as a SCSI device, run cdrecord --scanbus to find out what's the "dev" parameter to cdrecord. On my system, the output looks like the following: scsibus1: 1,0,0 100) 'IOMEGA ' 'ZIP 250 ' '51.G' Removable Disk 1,1,0 101) 'HP ' 'CD-Writer+ 7100 ' '3.01' Removable CD-ROM So, the cdrecord command line will contain dev=1,1,0 to specify the device. Here is the complete command on my system: cdrecord dev=1,1,0 -eject speed=2 -pad -audio *.wav NOTE: The -pad argument is neccessary, because all audio tracks on the CD must be adjusted for the proper data length, which is not always the case with mp3 files. ----------------------------------------------------------------------------- 4. Credits Special thanks to all the people who contribute to the Linux community and who made this HOWTO possible. ----------------------------------------------------------------------------- 4.1. Translations   * Im Eunjea - Translated this document to Korean, URL is [http:// kltp.kldp.org/eunjea/mp3_burning/] http://kltp.kldp.org/eunjea/ mp3_burning/.   * Mendel L Chan - Translated this document to Chinese, URL is [http:// www.linux.org.tw/CLDP/mini/MP3-CD-Burning/] http://www.linux.org.tw/CLDP/ mini/MP3-CD-Burning/. ----------------------------------------------------------------------------- 4.2. Other Credits   * Greg Ferguson - Initially converted this document from HTML to SGML.   * Rob Russell - Corrected my name conversion example.   * Terry Davis - Suggested submitting my HOWTO to linuxdoc.   * Chris Vaill - Created normalize program.