The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Поиск:  Каталог документации

2. Audio CDs

2.1. Preparing the Tracks


All commands assume bash shell

  1. Collect all MP3 files in one directory.

  2. If your MP3 files came from DOS/Windows, they may have uppercase extensions. You can convert whole names to lowercase or just extensions. For everything lowercase do:

         for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done 

    to convert just extensions:

         for i in *.MP3; do mv "$i" "`basename "$i" .MP3`.mp3"; done
  3. If any filenames contain spaces, first convert them to underscores:

         for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done 
  4. Convert them to WAV with the command:

         for i in *.mp3; do mpg123 -w `basename $i .mp3`.wav $i; done 

    When decoding 22khz MP3 files the output of mpg123 may be distorted. To fix this, use:

         for i in *.mp3; do mpg123 --rate 44100 --stereo --buffer 3072 --resync -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

    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 With madplayer, the command line is:

         for i in *.mp3; do madplay -o `basename $i .mp3`.wav $i; done 

    There is yet another way to do the conversion. Some MP3 files apparently give both mpg123 and madplay trouble with decoding. The lame encoder, which has a decoding mode, seems to handle difficult cases very well (lame can be found at :

         for i in *.mp3; do lame --decode $i `basename $i .mp3`.wav; 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/'`

  5. Run "file *.wav" and check the output for any files different from 16 bit, stereo 44100 Hz.

  6. 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

    or, if the above introduces static when converting mono files:

         sox track01.wav -r 44100 -c 2 track01-new.wav

    Sox is so popular, that it's probably installed by default with any Linux distribution, and can be obtained from However, the command-line options are somewhat cryptic for the casual user (me). Look at for some tips on usage.

  7. 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

    I use the following syntax (-m is for mix mode, where all files should be as loud as possible):

         normalize -m *.wav

2.2. 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:

     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


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.

2.3. Burning a DAO CD

DAO, Disc-At-Once, is as of now the only method for burning a CD without a 2-second pause between the tracks. It's useful for burning party mixes. The program for burning CDs in DAO mode is cdrdao, available from SourceForge,

The cdrdao program uses description files called TOC (Table Of Contents, of course). There are two ways to create such file. First is to use a shell script, distributed with cdrdao source (in contrib directory, called It takes a list of .wav files as an argument and produces a cd.toc file. Second way is to simply create such file yourself in a text editor of your choice. Here is a self-explanatory example:


AUDIOFILE "mix-01.wav" 0

AUDIOFILE "mix-02.wav" 0

AUDIOFILE "mix-03.wav" 0

AUDIOFILE "mix-04.wav" 0

AUDIOFILE "mix-05.wav" 0

The 0 (zero) after the wave filename means start from the beginning of the file. There can be a second number providing the length (time) of file to record. The xcdroast creates similar TOC files, there are also examples in testtocs directory of cdrdao source.

The cdrdao by default uses the device /dev/cdrecorder, which should be a link to the cdwriter device. Assuming your cd recorder device file is /dev/scd0, create the link (as root) as follows:

ln -s /dev/scd0 /dev/cdrecorder

Then, assuming that the TOC file is named cd.toc the command to burn the cd is simply:

cdrdao write cd.toc

2.4. Software

There are some programs available, that can automate the process of creating CDs from MP3 files. Here is arbitrarily selected list:

Inferno Solutions
Hosting by

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру