Burning Audio CDs on Linux/Unix (semi out-dated, but may still be useful on Debian)

Category: Software and Systems Engineering
Author: Sean O'Donnell
Wed, May. 2nd, 2007 @ 23:19:50 (MDT)

NOTE: This article was written back in 2007, using the Debian GNU/Linux distro. This article is probably not too useful for other distros, especially redhat-based distros, such as fedora or CentOS.

Burning Audio CDs from a command-line may seem like a trivial (and sometimes daunting) task, but I always seem to forget the commands involved in the process, so this snippet will help me for future reference (or until I write a script that makes life easier).

Detecting/Identifying the CD-R/W Device

Unless your CD-R/W device uses an ATAPI interface, you should be able to use the following command to identify your CD-R/W device (reference id):

cdrecord -scanbus

If you're not sure whether or not your CD-R/W device uses an ATAPI interface, then give it a try.

If you don't see your CD-R/W listed in the results, then chances are it uses an ATAPI interface.

If your CD-R/W is in fact an ATAPI device, you'll need to use the following command:

cdrecord dev=ATAPI -scanbus

The CD-R/W device on my laptop uses an ATAPI interface, so I use the 'cdrecord dev=ATAPI -scanbus' command, which returns the following results:

Cdrecord-Clone 2.01 (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jörg Schilling
cdrecord: Warning: Running on Linux-2.6.13
cdrecord: There are unsettled issues with Linux-2.5 and newer.
cdrecord: If you have unexpected problems, please try Linux-2.4 or Solaris.
scsidev: 'ATAPI'
devname: 'ATAPI'
scsibus: -2 target: -2 lun: -2
Warning: Using ATA Packet interface.
Warning: The related Linux kernel interface code seems to be unmaintained.
Warning: There is absolutely NO DMA, operations thus are slow.
Using libscg version 'schily-0.8'.
        0,0,0     0) 'TOSHIBA ' 'CDW/DVD SD-R2612' 'TU30' Removable CD-ROM
        0,1,0     1) *
        0,2,0     2) *
        0,3,0     3) *
        0,4,0     4) *
        0,5,0     5) *
        0,6,0     6) *
        0,7,0     7) *

From the looks of the results, it seems that '0,0,0' is the reference id to use when creating a new disk with cdrecord.

Alternatively, you can use the 'ATA' interface (for older CD-R/W devices I suppose), but the ATAPI interface is suggested for (newer) devices that support it.

Converting a single MP3 file to WAV format

cd /path/to/music/files
mpg123 -s file.mp3 | sox -t .raw -r 44100 -sw -c 2 - file.wav

Converting Multiple MP3 files to WAV format

cd /path/to/music/files
for i in *.mp3; do mpg123 -s "$i" | sox -t .raw -r 44100 -sw -c 2 - "$i".wav; done;

Normalize the WAV file(s) before burning.

normalize -m *.wav

Burn the Audio CD

cdrecord -v dev=ATAPI:0,0,0 -audio -pad *.wav

The command (above) should begin the Audio CD Burning process.

You should receive something similar to the following results:

cdrecord -v dev=ATAPI:0,0,0 -audio -pad cv_fri13th_special.wav
cdrecord: No write mode specified.
cdrecord: Asuming -tao mode.
cdrecord: Future versions of cdrecord may have different drive dependent defaults.
cdrecord: Continuing in 5 seconds...
Cdrecord-Clone 2.01 (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jörg Schilling
cdrecord: Warning: Running on Linux-2.6.13
cdrecord: There are unsettled issues with Linux-2.5 and newer.
cdrecord: If you have unexpected problems, please try Linux-2.4 or Solaris.
TOC Type: 0 = CD-DA
scsidev: 'ATAPI:0,0,0'
devname: 'ATAPI'
scsibus: 0 target: 0 lun: 0
Warning: Using ATA Packet interface.
Warning: The related Linux kernel interface code seems to be unmaintained.
Warning: There is absolutely NO DMA, operations thus are slow.
Using libscg version 'schily-0.8'.
SCSI buffer size: 64512
atapi: 1
Device type    : Removable CD-ROM
Version        : 0
Response Format: 1
Vendor_info    : 'TOSHIBA '
Identifikation : 'CDW/DVD SD-R2612'
Revision       : 'TU30'
Device seems to be: Generic mmc2 DVD-ROM.
Current: 0x0009
Profile: 0x000A 
Profile: 0x0009 (current)
Profile: 0x0008 
Profile: 0x0010 
Using generic SCSI-3/mmc   CD-R/CD-RW driver (mmc_cdr).
Driver flags   : MMC-3 SWABAUDIO BURNFREE 
Supported modes: TAO PACKET SAO SAO/R96P SAO/R96R RAW/R16 RAW/R96P RAW/R96R
Drive buf size : 1943040 = 1897 KB
FIFO size      : 4194304 = 4096 KB
Track 01: audio  713 MB (70:39.46) no preemp pad     
Total size:      713 MB (70:39.46) = 317960 sectors
Lout start:      713 MB (70:41/35) = 317960 sectors
Current Secsize: 2048
ATIP info from disk:
  Indicated writing power: 6
  Is not unrestricted
  Is not erasable
  Disk sub type: Medium Type C, low Beta category (C-) (6)
  ATIP start of lead in:  -11231 (97:32/19)
  ATIP start of lead out: 359846 (79:59/71)
Disk type:    Short strategy type (Phthalocyanine or similar)
Manuf. index: 27
Manufacturer: Prodisc Technology Inc.
Blocks total: 359846 Blocks current: 359846 Blocks remaining: 41886
Starting to write CD/DVD at speed 20 in real TAO mode for single session.
Last chance to quit, starting real write    0 seconds. Operation starts.
Waiting for reader process to fill input buffer ... input buffer ready.
BURN-Free is OFF.
Performing OPC...
Starting new track at sector: 0
Track 01:  713 of  713 MB written (fifo 100%) [buf 100%]  10.3x.
WARNING: padding up to secsize.
Track 01: Total bytes read/written: 747841536/747841920 (317960 sectors).
Writing  time:  421.375s
Average write speed  10.5x.
Min drive buffer fill was 100%
Fixating time:   38.386s
cdrecord: fifo had 11777 puts and 11777 gets.
cdrecord: fifo was 0 times empty and 11653 times full, min fill was 84%.

The above issued a few warnings, and burned the CD @ 10.5x. You can specify more options to remove some of the errors, as well as adjusting the write-speed to something more suitable for Audio CDs (such as 8x).

For more info on possible cdrecord command options, try reading the cdrecord unix manual.

man cdrecord

Copyleft (<) 1998-2019 www.seanodonnell.com