I was asked to convert some audio files that we got sent on cd. The
files had the extension .sd2, and a description saying "44100 stereo 24
bit". Obviously the files were just the data fork of sound designer 2
files. I could reproduce them perfectly with aplay -r 44100 -f S24_3BE
-c 2, but when I wanted to convert the files, I found sox could not deal
with 24 bit, and sndfile-convert needs files with a header (as far as I
understand). So I used an approach that you might find useful.
I thought, if aplay can play them, and alsa pcm plugins can do format
conversion.. why not use those?
The asoundrc below creates a device called cdaudiofile, of type plug,
that takes care of the format conversion. It's slave is a device of type
file, called stdoutfile, that writes to the standard out and has a
snd-dummy device as slave. (Is there another way to do that without
loading snd-dummy? I tried plug: null, but that didn't work)
The result is clear: using device cdaudiofile for playback, will do the
format conversion, and write the audio to the stdout:
(create card 1, which is dummy)
$ modprobe snd-dummy
(convert to raw S16LE)
$ aplay -D cdaudiofile -r 44100 -f S24_3BE -c 2 file.raw > cdaudiofile.raw
(convert and pipe through sox to create a wav file)
$ aplay -D cdaudiofile -r 44100 -f S24_3BE -c 2 file.raw
| sox -r 44100 -c 2 -s -w -t raw - cdaudiofile.wav
It made me really appreciate the flexibility and elegance of alsa.