LINUX CD Writing

This is an updated version for recent versions of mkisofs and cdrecord, as used under 2.6 kernel, which does not require using SCSI emulation.
cdrecord is preferred over older cdwrite.
cdrecord -scanbus dev=ATA
will tell you what devices are present.

cdrdao creates audio CD's.

ISO9660 filesystems standard supports only 8 levels of directories, and 32 char filenames. Rockridge extensions allow deeper directories, longer filenames, and UNIX file permissions. MS still does not support any kind of work-around to rockridge.

El Torito is the standard for bootable CD-Roms.

After searching around, I found that I prefer to do most of my work using the cdparanoia ripper, mkisofs to create CD file systems, and sox to convert audio formats and play.

To write a directory to CD-ROM, I use

mkisofs -r -T . | /usr/bin/nice --17 cdrecord speed=8 dev=ATA:0,1,0 -
For RockRidge extensions (UNIX, handles symlinks). Replace the -r with -J for MS-style Joliet extensions.
You may want to make an ISO image first, then confirm that its as you want it with a loopback mount.
mkisofs -r -T -o /tmp/img.iso /scr/backups/dirToBackup 
mount -t iso9660 -r -o loop /tmp/img.iso /mnt/tmp
# now Check that /mnt/tmp looks as desired
umount /mnt/tmp

At first I was converting WAV to MP3 with bladenc, which supported rates of 32,40,48,56,64,80,96,112,128,160,192,224,256,320 kbps.

The new(er) ripperx seems to do pretty much exactly what I want. Rip with cdparanoia, compress with lame. User's can control most necessary command line options.

At this time I have switched lame, which I believe to be of better quality (because of the VBR extensions), and it may works better with UNIX design philosophies. (bladenc was ported from MS, and does not seem to support pipes properly)

I have written a script to rip CD's directly to MP3 files in my standard artist/album directory structure. It has some goofy 70's style menus in it to set sone titles. I did not make a GUI to avoid having it require anything more than perl, and because I do not know perl/tk ;-) It would be nice if it would try to get song titles from a CD database, and perhaps in the future, I should allow names longer than the MP3 comment limits, and just truncate this data for the MP3 file.

I have sometime had some problems with ripping. In fact, the latest cdparanoia seems to be broken at this time. cdda2wav still seems to work. For these cases, I have a script which assumes that the CD in the drive has already been ripped to .wav files. It uses CDDB and a user-edited text input file to compress to conveniently formatted MP3 files.


mkisofs -J -T -print-size .
will show how many extents will be used to burn the current directory to CD-ROM. It appears that an extent is a sector, which is 2048 bytes. If a CD holds 650Mb, which I believe is true, that translates to 68157440 bytes, which is equivalent to 332800 extents. Hence, you can run mkisofs with the -print-size option to check if the desired data will fit on the disk. It appears to me that if mkisofs reports less than 332800 extents, your data will fit on one CD-ROM.

Audacity is my current sound-editor of choice. I can use this to find track seperations on an LP, but its usually easier to use a wav splitter to chop the tracks up.
(I don't recall the name of the little program I used. something like wavsplit or splitwav)

I had trouble finding an editor which works well with large sound files. All I needed to do was seperate tracks from a recording of an LP. Here are some aliases I set up to help to do this from the command line. This is still a work in progress. In fact, I'm still working on finding appropriate voice compression. GSM at 8kbps is in sox, but I would think a CELP based vocoder would be better. I downloaded a mess o CELP software, but it all looks researchy. I don't know if I'm ambitious enough to coomplete some of these codecs and create a file format. I want to use whats available, if anything. I hear that a good CELP codec will do solid telephone quality voice audio at about 2.4kbps.

################ Stuff for dealing with raw 44.1KHz sterio files
alias soxRaw 'sox -t raw -r 44100 -s -w -c 2'

#### extracts 0.1 sec blocks from raw sterio audio files
# Give file name, start block, nblocks to extract
alias extPlay "ext \!* | soxRaw - -t ossdsp /dev/dsp"
# to convert back to wav, ext myfile.raw start nblocks | soxRaw - myfile.wav

alias soxRec 'sox -r 44100 -s -w -c 2 -t ossdsp /dev/dsp'
#alias recLvl "soxRec -t raw - | ~aaron/bin/stats 22050"
alias recLvl "nice +19 sox -r 44100 -s -w -c 2 -t ossdsp /dev/dsp -t raw - | nice +19 ~aaron/bin/stats 22050"
alias recLvla "recLvl -a"
alias soxRecLvl "soxRec -t raw - | tee \!* | nice +19 ~aaron/bin/stats 22050 -a"
########### Stuff for dealing with voice
alias soxVoice "sox -V -r 8000 -w -t ossdsp /dev/dsp \!*.gsm"
alias voicePlay "sox \!* -t ossdsp /dev/dsp"

Here's the source for the ext script

#!/bin/sh
exec dd if=$1 bs=17640 skip=$2 count=$3
I couldn't figgure how to do the numbered command line args from a csh alias.

I couldn't find anything decent to monitor recording levels, so I wrote this little C program stats which takes a stream from sox in the above aliases to print out windows of data StDev, and max. I use the max to adjust recording levels so that saturated samples stay under the 32767 limit.

Typical use of the above aliases is:

recLvl
Run this and play with a mixer to get recording levels correct.
soxRec myFile.raw
Record data from analog input to raw samples, but at CD-style rate and resolution.
soxRecLvl myFile.raw
Records and shows recording level simultaneously.
extPlay myFile.raw start len
Play an excerpt from raw sound file, myFile.raw which is 2 channel sterio at 44.1KHz in signed 16-bit integers. Start playing at start tenths of a second into file. e.g. use 100 to start playing 10 seconds into recording, 350 to start playing 35 seconds into recording. The len length of the selection to be played is also defined in units of tenths of a second. Use 100 to play a 10 second snippet. I would have use 1 second as the "block" size, but that seemed a bit coarse for me. 1/10 of a second is close enough of a grain size for me.
ext myFile.raw start len > myTrack.raw
Extract a section of file myFile.raw at given starting time (in tenths of a second) and for given length (also tenths of a second) and write this data to myTrack.raw