converting .wav to .amr for fun and profit!

converting .wav to .amr for fun and profit!

I’m about 2 years behind the trend – now I can record random noises and make them my ring and message alert tones, and this is great fun. Nick (I think) had the great idea of getting some pirate .wavs from the internets and using them instead of using my own voice.

I downloaded a snippet of Disney’s Pirates of the Carribean song, and uploaded the wav to my phone. No dice, phone doesn’t play wavs.

The track I recorded is an .amr, though, so lets see if sox can convert it… nope, it doesn’t know about it. But google mentions there’s some reference code at 3gpp.org which will do the conversion. Well, it didn’t at first, but to cut a long story short because it’s late, xa.bi has links to the code, which you want to download, unpack, and modify the makefile.gcc and decoder.c per the instructions there. Then:

make -f makefile.gcc
sox input.wav -r 8000 -w -c 1 -s output.raw
./encoder -dtx MR475 output.raw ringtone.amr

That differs from the xa.bi amrconvert script only in that there’s a -s option to tell sox to also convert to 16 bit signed PCM, in case the wav started out as GSM or some other format. The script also tries to fiddle with the amr after it’s encoded, but that didn’t work for me; short circuiting it and just loading the amr straight onto the phone worked fine.

So now I’ve got the glorious pirates singing along each time I get an SMS. Can’t wait for the monitoring to go off at work tomorrow…