Note: All commands assume bash shell
Collect all MP3 files in one directory.
If any filenames contain spaces, first convert them to underscores:
for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done |
Convert them to WAV with the command:
for i in *.mp3; do mpg123 -w `basename $i .mp3`.wav $i; done |
Mpg123 should be present in any Linux distribution, but if you don't have it, get it at http://www.mpg123.de/.
NOTE I noticed that with some MP3 files mpg123 output was distorted. At first I thought that MP3's were bad, but then I checked with another player and they sounded OK. So I searched for another MP3 player that could write WAV files to disk, and found this one: MAD mp3 decoder at http://www.mars.org/home/rob/proj/mpeg/. With madplayer, the command line is:
for i in *.mp3; do madplay -o `basename $i .mp3`.wav $i; done |
NOTE: The `basename $i .mp3`.wav command replaces MP3 extensions with WAV. There are 101 ways to do that, here's the alternative: `echo "$1" | sed 's/\.mp3$/.wav/'`
Run "file *.wav" and check the output for any files different from 16 bit, stereo 44100 Hz.
If there are files with different characteristics, convert them to the above specs. For example, to convert file track01.wav to obtain sample rate 44.1 kHz, you could use:
sox track01.wav -r 44100 track01-new.wav resample |
Sox is so popular, that it's probably installed by default with any Linux distribution, and can be obtained from http://www.spies.com/Sox/. However, the command-line options are somewhat cryptic for the casual user (me). Look at http://www.spies.com/Sox/sox.tips.html for some tips on usage.
Normalize your WAV files, to avoid drastic differences in volume levels. I use a program by Chris Vaill (<cvaill@cs.columbia.edu>), called normalize - it can be obtained from http://www.cs.columbia.edu/~cvaill/normalize/
I use the following syntax (-m is for mix mode, where all files should be as loud as possible):
normalize -m *.wav |