What to do with Stupid .ape files

Yet another redundant and badly-supported audio compression file format, Monkey's Audio (hence the .ape extension) exploits the fact that the information streams in two stereo channels are similar. It then only encodes one channel and the difference of the other channel plus a few other tricks, for loss-less compression. This may well be a vaguely clever idea, but useless for mono or multi-channel encoding. Besides, we have FLAC-encoding, which compresses audio (to the same degree as Monkey) in a loss-less way for CD-quality reproduction. More importantly,  it is very well supported.

So, what do we do with this stupid ape-file?

The approach is to get the file out of the Monkey's Audio format into a common format. With this obstacle overcome,  the file can be converted to any format you want to using freely availble and well-supported conversion tools. In other words, convert the .ape file to a .wav file, which is the basic uncompressed and lossless file format in which audio is encoded on CDs. From this point onwards, the world is your oyster.

First, you need the Monkey's Audio Conversion (MAC) utility.  You can download the source code (which I modified for it compile at all) from here. There does not appear to be an installation package for this on any Linux distro.

Prerequisites:

A C++ compiler needs to be installed. If you get this error: configure error: C++ compiler cannot create executables, then this applies to you - install the C++ compiler like this:
Gentoo, Sabayon et al:

sudo emerge g++

Ubuntu, Mint et al:

sudo apt-get install g++

RedHat:

{geshi lang="bash"}sudo yum install g++{/geshi}

How to compile and install it:

Download the source code from here: mac-3.99-u4-b6.tar.gz

Unpack it:
tar -xzvf mac-3.99-u4-b6.tar.gz

Build it:
cd mac-3.99-u4-b6
./configure
make

Install it:

sudo make install

Converting .ape to .wav

mac myfile.ape myfile.wav

You now have the basic, loss-less and uncompressed audio file.  From here, convert it to any audio format you want to:

Convert .wav to .flac

flac -o myfile.flac myfile.wav

Convert .wav to .mp3

lame myfile.wav myfile.mp3

Some clever tricks

If you know BASH shell, you will understand the one-liner below, which converts an entire directory of .ape file into .flac files:

for i in *.ape; do mac "$i" - -d | flac -o "${i/ape/flac}" -; done