via [Ubuntu Blog]
I confess to the grave sin of storing part of my music collection in the mp3 format – mostly music I have had around for ages. There, now that that is out of the way, let’s move on to making that collection friendlier.
I have the habit of going to sleep while listening to a little light music. Some of the songs in my collection would sound louder than the others. So when I have a couple of classical music tracks lined up with Paul McCartney and Guns ‘N Roses, I sometimes get jolted awake by the difference in the playback volume. So off I went looking for solutions.
My main concerns when I started my research were:
- My mp3s should not be irretrievably changed into something I end up hating
- I did not want all songs sounding as loud as the loudest song
- The algorithm or method used should be free of the application used for music playback
Fortunately, besides the websites for the applications, I ran into this thread at jwz’s livejournal. Thank god for geeks-who-start-nightclubs and their friends! I also followed most of the replaygain technical outline, since mp3gain is an implementation of the replaygain idea.
Normalize is simple, perhaps a little too simple.
mp3gain works by figuring out how loud the music actually sounds to the human ear, and then figuring out how much positive or negative gain to apply to the mp3 file to “fix” it. I was happy to note that it does not use the peak volume in a file as a benchmark for normalization. It applies changes by modifying the mp3 file in some fashion, but I read that the change is reversible since mp3gain writes some tags (not ID3 tags) to the mp3s for possible later undoing. This fact also means that one you use mp3gain on a file, if you try doing it again, it takes a lot less time – almost no time. So in the future if I add files to the collection, and I don’t remember what files I added, I can run mp3gain on the entire collection, and it will complete much faster than the first time.
To cut to the chase, I decided to go with mp3gain. I installed the mp3gain package (using $sudo apt-get install mp3gain), and set out to normalize my entire music collection. (For those of you who also have .oggs, check out vorbisgain).
The following command, executed from the directory where I store my music normalized all the files in my collection:
$find . -type f -iname ‘*.mp3’ -print0 | xargs -0 mp3gain -r -k
What it does is, it finds all files (type -f) in the present directory (.) with a name that ends in “.mp3″ and creates a list of the same. The output of this find command is then piped to the mp3gain program. The options that I ended up using for mp3gain, -r and -k dictate that the calculated track gain will be applied automatically to normalize the volume, and that files should be protected against “clipping” by lowering the applied gain if the required gain seems likely to clip the sound. Concoct your own recipe by referring to the man page for mp3gain.
After around 16 hours of processing on my old PIII desktop, my massive 50 GB music collection now agrees on what is an acceptable volume. Needless to say, I sleep in peace.