Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am looking for a way to normalize the sound in MANY MP3 files I have. Some have low sound, while others are louder so I have to turn the volume up or down depending on the song. What ways are there to do this for all files. I specially would like to do it via the terminal but GUI ways are also accepted.

share|improve this question
    
For normalizing while playing see: askubuntu.com/questions/95716/…. This will however not change your mp3 file content - may be of advantage ;) –  Takkat Jan 22 '13 at 18:09
    
Not while playing, don't want to have to set it everytime or have a player set the normalize every time I want to listen to the songs. For example, let us say I want to copy the songs to an ipod shuffle or to a pen drive to listen in a mp3 capable player. –  Luis Jan 22 '13 at 18:13
    
@Takkat BTW nicely done in that other question. Good information. –  Luis Jan 22 '13 at 18:24
1  
My wife just tested the Audacity method, and it worked perfectly! Recommended. Please, when people ask for advice it is because they are NOT experts. So don´t tell them to use command line tools when they can do the job with easy-to-understand graphical tools like Audacity. Telling new Linux users to open terminal and run command line tools will just scare them away from Ubuntu, with a feeling that Windows is simple, Linux is difficult. It is not a surprise that DOS is dead, but Windows is alive. –  Orvar L Jun 23 at 20:42

4 Answers 4

up vote 5 down vote accepted

Audacity Install audacity

With Audacity we can easily batch process files to apply conversions or effects to many files in a list. To do so we first have to define a "Chain" containing the effects we want to apply.

This is done with "File --> Edit Chains...". In the now opening window press the Add button on the bottom left to insert a new chain (give it a sensible name):

enter image description here

Then choose the effect and it's parameters to insert to the chain (here shown for default values and the Normalize effect).

Important: we always need to also add the effect "Export MP3" (or any other export format) for saving the resulting conversion to disk.

When done leave this window with OK to open "File --> Apply Chain...". Select the Chain we have just created and load all files you need with "Apply to files...". Several files can be selected from the file chooser that opens.

enter image description here

Processed files will be saved in a new subdirectory "cleaned" in the original's path.

share|improve this answer

I would use this project Normalize, it's a command-line tool for normalizing audio files. Looks to be exactly what you need. Can do batch processing and doesn't require resampling to intermediate formats.

It's in the package repos as normalize-audio, sudo apt-get install normalize-audio. This is a build maintained upstream by Debian so it should be in anything LTS or newer and is built with mp3 compatibility (tested). There is a good manpage man normalize-audio to explore the options but the commands defaults appear to work well. For batch processing (normalize volume across multiple files), normalize-audio -b *.mp3 or specify individual filenames instead of using wildcards.

share|improve this answer
    
The OP wants instructions for doing this. Can you provide those? –  Seth Jan 22 '13 at 18:13
    
@iSeth I was initially incorrect about the source only comment because I couldn't find it with apt-cache search. I've updated with details about the deb package. –  sean_m Jan 23 '13 at 8:23

Take a look @ mp3gain which for me is even better than normalize-audio

mp3gain -r *.mp3

another useful version could be the -c which prevent to ask if you want to do the changes for many files:

mp3gain -c -r *.mp3

as said in the man page:

mp3gain does not just do peak normalization, as many normalizers do. Instead, it does some statistical analysis to determine how loud the file actually sounds to the human ear. Also, the changes mp3gain makes are completely lossless. There is no quality lost in the change because the program adjusts the mp3 file directly, without decoding and re-encoding.

share|improve this answer

For the sake of it, I'll throw my 2 cents in. I was looking for exactly the same thing (only for ogg files) and started a thread at Crunchbang Forum. You can view it here: Normalize-audio can't find mp3 decoder

Basically my solution was the script in post #8. It works for mp3, flac, and ogg input files, possibly others but definitely not wav.

Just create a file (name it whatever you want, I called mine db_adjust_mp3), chmod +x , and stick it in your ~/bin folder. It fills in any missing codec data as well. Example:

Original file: 16._This_Protector.mp3: Audio file with ID3 version 2.3.0, contains:

vs.

Normalized file: 16._This_Protector.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, JntStereo

I've modified the script to use normalize-mp3 here so you can use it if you want:

#!/bin/bash

find "$1" -iname "*.""$2" > $HOME/file_list

cat $HOME/file_list | while read line; do
#  echo "$line"
  orig_gain="$(normalize-mp3 -n "$line" | cut -d 'd' -f1)"
  larger=$(echo "$orig_gain"'>'-12 | bc)
  if [[ larger ]]
    then
      gain_difference=$(echo "$orig_gain"*-1-12 | bc)
    else
      gain_difference=$(echo "$orig_gain"-12 | bc)
  fi
  echo "Gain Difference will be: $gain_difference""db"
  normalize-ogg --mp3 --bitrate "$3" -g "$gain_difference""db" -v "$line"
done

This script calculates the difference between the current db level and -12db, then applies a gain adjustment to put the gain at exactly -12db, which is what I've found works the best for me. It is recursive as well, which makes it great for doing entire music collections or files in many subfolders. If you wish to set a different db level, just change the both instances of the number "12" to whatever db level you would like to use. As I posted in my Crunchbang thread, usage is as follows:

normalize-mp3 <directory> <file extenstion(with no leading dot)> <bitrate>

However, when I used to keep my music library in mp3 format, I used to use mp3gain as well, just as Philippe suggested. The dead simplicity of it is great and I really liked it. The problem with normalize-audio though is that it does decode an re-endcode the files, so there is some sound degradation. But unless you're an audiophile and your mp3's are encoded at a high bitrate you shouldn't notice much difference.

The thing I noticed with mp3gain though was that no matter what options I tried I couldn't get everything in my collection to be exactly the same db level, which is what I want so that I never have to adjust the volume from one track to the next. This script does exactly that. Sorry for being so long winded. Hope this helps.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.