WAV and MP3

WAV and MP3


Converting *.mp3 files into *.wav files (or vice-versa) can be done quite easily under Linux. However, searching Google for mp32wav or wav2mp3 gives sometimes results, which do not actually work...

Here are guidelines, which work:

Convert MP3 into WAV

Use the program mpg123, which is part of the SuSE distribution (current version 0.59r) and enter the following:

   mpg123 -w song.wav song.mp3

   (Notice: outputfile comes first, then the inputfile; for whatever reason...)
    And: the command
       mpg123 -b 10000 -s song.mp3 | sox -t raw -r 44100 -s -w -c2 - song.wav
    as described on some web-pages, does "work", but the output file in *.wav
    format does have an undefined end!

Convert WAV into MP3

Conversion from *.wav into *.mp3 format can easily done with the program bladeenc; just follow the steps described below:

 - http://bladeenc.mp3.no/
 - Click on "Sourcecode" (left frame)
 - Click on "Click here to go to the source archive"
 - Click on the link next to "Latest Stable Source:"
   (in this case bladeenc-0.94.2-src-stable.tar.gz )
 - Download file in a directory of your choice
 - gunzip bladeenc-0.94.2-src-stable.tar.gz
 - cd bladeenc-0.94.2
 - configure
 - make
 - cd bladeenc
 - cp bladeenc /usr/local/bin/.    (maybe this has to be done as root)
 - Convert *wav file into *mp3 file:
      bladeenc song.wav song.mp3
   (the size of the mp3 file will be approx. 10% of the wav file) 

I have listened to songs sampled with various bit-rates and the songs with 128 kbps sounded really like CD-quality. For a comparison of various bit-rates see the web-page of the Fraunhofer Institute.
If you get mp3-Files with other bit-rates (e.g. using qtella you may convert them first to *.wav files and then to *.mp3 files again (now with 128 kbps bitrate).

Below, I include two scripts (mp32wav and wav2mp3, which I have stored on /usr/local/bin and which I use to convert mp3 files into wav files and vice-versa.

# mp32wav     2.6.2001 / uk
for file in `ls -1rt $mp3file` ; do
   echo "$file"
   wavfile=`echo $file | sed s/\\.mp3/.wav/`
   echo $wavfile
   mpg123 -w $wavfile $file

# wav2mp3 2.6.2001 / uk # wavefile="$*" for file in `ls -1rt $wavefile` ; do echo "$file" mp3file=`echo $file | sed s/\\.wav/.mp3/` echo $mp3file bladeenc $file $mp3file done

Last Update: 30Dec2001 uk Created: 09Apr2001 uk