Recipe 11.12. Recording an Audio CD for Standard CD Players

 < Day Day Up > 

11.12.1 Problem

You want to know how to record audio CDs for playback on a standard audio disk player, like in your car. You need to know how to convert different audio file formats, such as ogg-vorbis, mp3, .wav, and .cdr, because these do not play on standard audio CD players, only on computers.

11.12.2 Solution

Use sox, normalize, and cdrecord. And use CD blanks that are made for audio recording.

The first step is to use sox to convert your sound files to .cdr format, to convert them to the correct file structure; then convert the .cdr to .wav format.

Then, the -audio option for cdrecord converts .wav files to CD-DA (Compact Disk Digital Audio) format, which is what standard audio CD players need.

$ sox soundfile filename.cdr $ sox filename.cdr filename.wav $ cdrecord -v -nofix -eject dev=0,1,0 -audio -pad filename.wav

The -pad options ensures that disk sectors will be filled correctly, and -nofix leaves the disk open for adding additional music tracks. To fix and close the disk:

$ cdrecord -v -fix  -eject dev=0,1,0

Converting files one at a time is tedious. This Bash command converts a batch of .ogg files to .cdr format:

$ for i in *.ogg ; do echo $i ; sox $i ${i%%.ogg}.cdr ; echo ${i%%.ogg}.cdr;done

Simply substitute whatever file extensions you need to convert.

If you're compiling a collection of tracks from diverse sources, use the normalize utility to equalize sound volumes,with the -m (mixed-mode) option:

$ normalize -m /soundfiles/*.wav

There are many ways to select tracks to record. This command records all the *.wav-formatted songs in the /home/songs directory, in sorted order: numbers first, then alphabetic capitals, then alphabetic lowercase.

$ cdrecord -v -nofix -eject dev=0,1,0 -audio -pad /home/songs/*.wav

Or, you can change to the /songs directory, then list individual songs:

$ cdrecord -v -nofix -eject dev=0,1,0 -audio -pad song1.wav song3.wav song7.wav

Be sure to use an audio CD-R made for playback in standard audio players.

11.12.3 Discussion

Newer versions of sox are supposed to support .mp3, but this isn't always the case. Run sox -h to see what formats it supports. If your particular version of sox will not convert .mp3s, use mpg123 and sox:

$ mpg123 -b 10000 -s  filename.mp3  | sox -t raw -r 44100 -s -w -c 2 -filename.wav


-b 10000

This sets the buffer size, in bytes.


-s

The -s flag redirects to stdout, instead of trying to play the file.


sox -t raw -r 44100 -s -w -c 2

This is the same as .cdr format, only all the specs are spelled out.

There is a limit of 99 songs per disk. They would have to be very short songs to actually stuff that many on to a CD. You could record about 30 Ramones songs, or a single Beethoven symphony, so it just depends.

If your music files are already in the .wav format, like the files you get from online music services, you probably don't need to convert them. However, not all .wav files have the correct structure for making CDRs; cdrecord will halt and give an error message if this is the case. Use sox to convert the errant .wav to .cdr, then .cdr to .wav.

.wav and .flac formats are the highest-quality digital audio formats. Always start with these, if you can. Then convert them to other formats as needed. The primary reason to convert is to save disk space, as .wav and .flac files are very large. An .ogg file is typically one-tenth the size of a .wav file.

Ogg Vorbis is an open, patent-free, audio encoding and streaming technology. It has no licensing fees or other restrictions that accompany patented, proprietary formats like MP3. It delivers decent sound quality in a compressed, lossy format. "Lossy" means bits are stripped away to reduce file sizes.

MP3 is also a compressed, lossy format of good quality. It's a patented, proprietary format, so there are restrictions on its use, the code is closed, and there are licensing fees for artists and distributors. Thomson and Fraunhofer, who control the MP3 format, are adding DRM (Digital Rights Management, or copy restriction) technology to the MP3 format.

11.12.4 See Also

  • cdrecord(1), sox(1), normalize(1)

     < Day Day Up > 


    Linux Cookbook
    Linux Cookbook
    ISBN: 0596006403
    EAN: 2147483647
    Year: 2004
    Pages: 434

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net