Hack36.Normalize the Volume of Your Audio Files


Hack 36. Normalize the Volume of Your Audio Files

Use the normalize tool to adjust the volume of audio files so they all have the same volume.

Many, if not most, people find TV commercials (or at least some of them) annoying. One particularly annoying trait of some TV commercials is their volume setting. The volume of the TV is set perfectly for the show you are watching, but the moment the commercial break starts, the advertising blares through the speakers, forcing you to adjust the volume again. Of course, this means that once the commercials are finished, you have to adjust the volume back to a level suitable for the program.

Music often suffers from the same volume issues that plague TV commercialssome CDs are recorded with particularly low volume, others with a particularly high volume. If you listen to your music on Random (or using a tool such as IMMS [Hack #19]), you end up fiddling with the volume control to account for these differences. Luckily, under Linux there is an excellent tool called normalize that can analyze a series of audio files and adjust them so they are all the same volume.

normalize has been around for years, and many other multimedia projects use it behind the scenes. As a result, your distribution probably already has it packaged (often called normalize or normalize-audio). If your distribution doesn't have normalize, download it from the official site at http://www1.cs.columbia.edu/~cvaill/normalize and compile and install it according to the provided documentation.

2.25.1. Normal Mode

Once normalize is installed, usage is fairly straightforwardtype normalize followed by a list of WAV files to normalize. The following command normalizes all WAV files in the current directory to the default volume level:

 $ normalize *.wav Computing levels…      file1.wav           100% done, ETA 00:00:00 (batch 100% done, ETA 00:00:00)      Applying adjustment of 20.10dB to file1.wav…      file1.wav           100% done, ETA 00:00:00 (batch 100% done, ETA 00:00:00)      …  

By default, normalize will take any files it is passed and adjust the volume to its default volume setting. In the above example, file1.wav was too quiet so normalize increased the volume by 20.10 decibels. Normalize will output progress information as it processes each file, but you can pass the -q argument to suppress this output.

On newer normalize packages, the actual command-line program is called normalize-audio to differentiate the WAV normalizing program from the MP3 (normalize-mp3) and OGG (normalize-ogg) normalizing programs that the package now includes.


2.25.2. Mix Mode

One obvious application of the normalize tool is to help adjust the volume on mixed CDs you might create. When you create a mixed CD, often you don't necessarily care whether the tracks are the same volume as the rest of your music collection as long as they are about the same volume as each other. Normalize's mix mode computes the volume for each file and then calculates the average volume and sets each file to that volume. Use the -m option to turn on mix mode:

 $ normalize -m *.wav 

Once the WAV files have been normalized you can burn them to a CD. If you've already created a mix CD that wasn't normalized you can rip the CD [Hack #24], normalize it, and then burn it again with no loss of quality, because the WAV files you ripped to are a lossless format.

2.25.3. Batch Mode

Some of you might be thinking that the fact that different tracks on an album have different volumes is a feature, not a bug. Many albums feature songs of many different relative volumes for effect, and you may not want to just randomly assign them all the same volume if you plan to listen to the album sequentially. All the same, if the album was recorded a bit too quiet, you might want to increase the volume of each track relative to each other, without setting the volume of each track to the same value. Batch mode accomplishes this.

In batch mode, normalize will scan through each file, compute its volume level, and compare it to the relative volume levels of each of the other files. Then it will compare the average volume of these files to normalize's default volume level and increase or decrease the volumes accordingly. In addition, normalize will throw out any tracks that are much louder or much softer when it computes the average, so as not to throw it off. Add the -b option to turn on batch mode:

 $ normalize -b *.wav 

2.25.4. Normalize MP3 and Ogg Files

It used to be that normalize only worked on WAV files, so if your files were in MP3 or Ogg Vorbis format, you would have to convert them to WAV, normalize them, and then convert them back. While you still need to do this in a manner of speaking, normalize has automated the process for you and created two tools, normalize-mp3 and normalize-ogg to normalize MP3 and Ogg files, respectively. You can use these tools just like normalize, so to normalize all of the MP3 files in a directory, type:

 $ normalize-mp3 -b *.mp3 




Linux Multimedia Hacks
Linux Multimedia Hacks
ISBN: 596100760
EAN: N/A
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net