[<--] [Cover] [Table of Contents] [Concept Index] [Program Index] [-->]
Google
 
Web dsl.org


Audio Compact Discs

Audio compact discs can be played on systems that have a CD-ROM drive and sound card installed. You can control playback of an audio CD in all the ways you can with a traditional CD player, except on a Linux system you control playback with software tools on the command line. There are tools for reading the audio data from a CD and writing it to a file (which you can later write to a CD-R disc, or convert to MP3 format).

Tools and techniques for manipulating CD-ROMs (data CDs) are in CD-ROMs.

Controlling CD Audio

Debian: `cdtool'
WWW: ftp://jaka.cerl.uiuc.edu/pub/tinsel/


These recipes describe various ways to play audio CDs using the command-line tools found in the `CDTOOL' suite. Other CD audio tools, including X clients, are listed in Other Audio CD Applications.

Playing an Audio CD

Use cdplay to play an audio CD in the CD-ROM drive; the sound is output through the speakers connected to the LINE OUT jack on your sound card. (You may need to use the audio mixer to adjust the volume level and other settings; see Adjusting the Audio Controls.)

To begin with a particular track, give the number of the track as an argument.

To end with a particular track, give the number of the track as a second argument.

Pausing an Audio CD

Use cdpause to pause audio CD playback.

Use cdplay to start playback at the point where it was paused; to restart the playback from the beginning, use cdplay with `x' as an argument.

Stopping an Audio CD

To stop playback of an audio CD, use cdstop.

Shuffling Audio CD Tracks

Use cdplay with the `shuffle' argument to play the CD tracks in random order.

Displaying Information about an Audio CD

Use cdinfo to display information about an audio CD, including its play status and track times. With no options, it outputs the play status: `play' if the CD is currently playing, `paused' if the CD is currently on pause, `no-status' if the CD is not playing, and `nodisc' if no disc is in the drive.

In addition, cdinfo recognizes the following options:
OPTION DESCRIPTION
-a Output the absolute disc time.
-r Output the relative track time.
-s Output the play status (the default action).
-t Output the current track.
-v Output all available information: play status, current track, absolute disc time, and relative track time.
To show the lengths of all tracks on an audio CD in a directory-like format, use cdir. This tool will also show titles and artist names, if known, but for this to work, you must set up an audio CD database (see the cdtool man page for details---Reading a Page from the System Manual).

In this example, the CD contains eight tracks, with a total of 43 minutes and 14 seconds play time.

Ejecting an Audio CD

Use cdeject to eject the disc in the CD-ROM drive. If the disc is currently playing, play will stop and the disc will eject.

NOTE: This command will also eject a CD-ROM (data CD), if the CD-ROM is not currently mounted (see CD-ROMs).

Sampling Sound from a CD

Debian: `cdda2wav'
Debian: `cdparanoia'
WWW: ftp://ftp.gwdg.de/pub/linux/misc/cdda2wav/
WWW: http://www.mit.edu/afs/sipb/user/xiphmont/cdparanoia/index.html


Two tools used for sampling (sometimes called "ripping") data from an audio CD are cdda2wav and cdparanoia. Both can retrieve single tracks or entire disks; the former is the archetypal CD audio-sampling tool for Linux, and should be used when speed is more important than sound quality. The latter does various extra checks for the paranoid, and should be used when an absolutely perfect copy is necessary -- at the expense of speed. cdda2wav is perfectly capable of creating a digitally perfect audio sample; cdparanoia is useful for when your original CD may have scratches (its scratch detection capability can attempt to "hold sync" across the scratch), or for when you are using a less-than-optimal-quality CD-ROM drive.

With cdda2wav, you specify the track number to be retrieved as an argument to the `-t' option; use `x' to specify a CD-quality retrieval, and give the name of the CD-ROM device with the `-D' option -- unless you have multiple CD-ROM drives installed, this is almost certainly going to be `/dev/cdrom'.

By default, files are written as WAV format files; use the `-O' option followed by `cdr' to write the files in CD audio format. `.cdr' files are useful for burning an audio CD containing the files as tracks (discussed in the following section), and `.wav' files are useful for converting to MP3 format (see Making an MP3 File). You can convert either format to the other at a later time with sox---see Converting Sound Files.

For more reliable sampling, use cdparanoia. Give the range of audio tracks to sample as an argument (with no arguments, it samples the entire disc). Use the `-w' option to specify WAV format output.

NOTE: Sampling an entire audio CD can use a lot of disk space; most people delete the `.cdr' or `.wav' files as soon as they make MP3s or burn an audio CD-R from the data.

Writing an Audio CD-R

Debian: `cdrecord'
WWW: http://freshmeat.net/projects/cdrecord/


Use `cdrecord' to write (or "burn") audio files to a blank CD-R disc. You will need a CD-R drive(31) and the audio files must be in CD-DA CD audio format (they usually have a `.cdda' or `.cdr' file name extension).

Specify the CD-R drive with the special `dev' argument, which is given in this form:

`dev=scsibus,target,lun'

where scsibus is the number of the SCSI bus (0 for the primary bus), target is the SCSI target ID (usually a number from 1 to 6), and lun is its LUN number (most always 0).

Use the `speed' argument to set the speed factor for writing data: give `speed=2' to specify double speed or `speed=4' to specify quad speed.

Use the `-dummy' option to run with the drive laser turned off, so no actual burning takes place; this is useful when you are first using a CD-R drive and need to test your configuration to make sure you've got it right. Another useful option is `-v', which gives a more verbose message output.

Give the names of the audio files to burn, in the order that they should appear on the disc, as arguments to the `-audio' option. The files are written in CD-DA CD audio format, and they should contain 16-bit stereo at 44,100 samples/second (the `.cdr' or `.cdda' files meet this criterion).

When you use wildcards for files, as in the second-to-the-last example, the shell expands the files in alphabetical order. To write a group of tracks in a particular order without specifying all of their names as arguments, rename them so that their names begin with numbers that correspond to the order you want to write them in (see Moving Files and Directories).

For example, if you have the three files `morning-song.cdr', `midday-song.cdr', and `evening-song.cdr', and you want to write them in that order, rename the files to `01-morning-song.cdr', `02-midday-song.cdr', and `03-evening-song.cdr'; otherwise, if you specify them as `*.cdr', the shell will sort their names so that they will be written to CD-R in the order of `evening-song.cdr', `midday-song.cdr', and `morning-song.cdr'---exactly the opposite of what was intended!

To write a disc containing both data and audio tracks, first specify the file for the data track (it should contain a filesystem image in either ISO 9660 or Rock Ridge format), and then follow it with the `-audio' option and the names of the audio tracks to use. The resulting CD-R will be both mountable as a data CD and playable on audio CD players (the first track on the disc, the data track, will be skipped when playing the audio).

NOTE: When writing an audio CD, you should have as few processes running as possible. If cdrecord has to pause even momentarily to let the system shuffle other processes, the CD-R could be ruined! For this reason, it is advisable to avoid switching between consoles -- or between windows, if running X -- during the CD-R burning process.

Other Audio CD Applications

The following table lists some of the other available tools and applications that work on audio compact discs.
TOOL DESCRIPTION
dynamic Project Dynamic is a tool for playing samples of audio CDs; it is distinctive in that it can play audio CDs backwards.
WWW: http://www.cse.unsw.edu.au/~flatmax/dynamic/
workbone An interactive CD player that can be used on the console or in X; it allows you to skip forward and backward through tracks as they are playing.
workman A tool for playing audio CDs, with a graphical interface that looks like the front panel of a physical CD player.
xcdroast XCDRoast is a graphical front-end to the cdrecord tool for use in X.
WWW: http://www.xcdroast.org/


[<--] [Cover] [Table of Contents] [Concept Index] [Program Index] [-->]