I had the bad luck that a CD image I acquired from the Internet consisted of a .ape file for the audio and a .cue file for the track offsets. cdrdao has no problem with .cue files but .ape is the file extension for Monkey Audio files. Monkey Audio is the awkwardly licensed monkey brother of Flac. (They’re both lossless audio encoding formats.)

This is one of those I-want-to-remember-this-for-later posts which I should really do more often if I wander about investigating various technicalities. Although such posts aren’t the most comprehensive and useful to the reader, they’re invaluable to myself six months from now.

mac is a tool capable of converting .ape files to .wav files. But first, .Ape’s awkward licensing problem meant I had to find an ebuild for mac to put in my Portage overlay in $PORTDIR_OVERLAY at $PORTDIR_OVERLAY/media-sound/mac. Through references in the Gentoo Forum and the Gentoo Wiki, I came across two different bug reports with ebuilds for mac attached. Bug 52882 had the newest ebuilds attached.

$ mkdir -p /usr/local/portage/media-sound/mac
$ cd /usr/local/portage/media-sound/mac
$ wget http://bugs.gentoo.org/attachment.cgi?id=154775
$ ebuild mac-3.99.4.5-r2.ebuild manifest
$ emerge -av mac

Now, I could convert any .ape files to WAV:

$ mac CDImage.ape CDImage.wav -d

Alternatively, I could have done this using shntool, a handy front-end for all sorts of lossless audio programs:

$ emerge -av shntool
$ shntool conv -o wav CDImage.ape

Now, I could have just gone into the CDImage.cue file and change the reference to the .ape file to a reference to the .wav file:

$ sed -i -e 's/.ape/.wav/' CDImage.cue
$ cdrdao write CDImage.cue

But, first I was sidetracked to splitting the tracks (until realizing that wodim wouldn’t burn the correct pregaps).

Just grepping for “INDEX 01” didn’t generate the indexes in a format that shntool split would eat, leading to the emergence of yet another package: cuetools.

$ emerge -av cuetools
$ cuebreakpoints CDImage.cue | shntool split CDImage.wav