This is release 0.6.1 of Normalize, a wave file volume normalizer.
Copyright (C) 1999--2001, Chris Vaill <cvaill@cs.columbia.edu>

Normalize is an overly complicated tool for adjusting the volume of
wave files to a standard level.  This is useful for things like
creating mixed CD's and mp3 collections, where different recording
levels on different albums can cause the volume to vary greatly from
song to song.

To build, just run:

./configure
make
make install

See the file INSTALL for more extensive directions.
See the man page, normalize.1, for usage.

Send bug reports, suggestions, comments to cvaill@cs.columbia.edu.

normalize is free software.  See the file COPYING for copying conditions.

-------------------------------------------------------------------------

1 What platforms does this work on?
       I've tested normalize on GNU/Linux and FreeBSD on x86 and
       Solaris on sparc.  I've heard that it works on GNU/Linux
       on alpha and on BeOS R5.  As far as Windows is concerned,
       you may be able to compile it using the cygwin toolkit
       (see http://www.cygwin.com/), but I don't know.

       I've tried to make the code as portable as possible, so
       I'd appreciate hearing whether normalize works on other
       platforms.

2 What is this useful for?
       Let's say you've got a bunch of wav files containing what
       are, in your estimation, Elvis's greatest hits, collected
       from various albums.  You want to encode them as mp3's and
       add them to an established collection, but since they're
       all from different albums, they're all recorded at differ
       ent volumes from each other and from the rest of your mp3
       collection.  If you've been using normalize on all your
       wav files before you encode them, your collection is nor
       malized to the default volume level, and you want these
       new additions to be at the same level.  Just run normalize
       with no options on the files, and each will be adjusted to
       the proper volume level:

            normalize "Hound Dog.wav" "Blue Suede Shoes.wav" \
                      "Here Comes Santa Claus.wav" ...

       Suppose now you've just extracted all the wav files from
       the Gorilla Biscuits album "Start Today," which, you may
       know, is recorded at a particularly low volume.  We want
       to make the whole album louder, but individual tracks
       should stay at the same volume relative to each other.
       For this we use batch mode.  Say the files are named
       01.wav to 14.wav, and are in the current directory.  We
       invoke normalize in batch mode to preserve the relative
       volumes, but otherwise, everything's the default:

            normalize -b *.wav

       You can then fire up your mp3 encoder, and the whole album
       will be uniformly louder.

       Now suppose we want to encode the Converge album "When
       Forever Comes Crashing."  This album has one song, "Ten
       Cents," that is really quiet while the rest of the songs
       have about the same (loud) volume.  We'll turn up the ver
       bosity so we can see what's going on:

            > normalize -bv *.wav
            Computing levels...
            Level for track01.cdda.wav: -9.3980dBFS (0.0000dBFS peak)
            Level for track02.cdda.wav: -9.2464dBFS (-0.1538dBFS peak)
            Level for track03.cdda.wav: -8.6308dBFS (-0.2520dBFS peak)
            Level for track04.cdda.wav: -8.7390dBFS (0.0000dBFS peak)
            Level for track05.cdda.wav: -8.1000dBFS (-0.0003dBFS peak)
            Level for track06.cdda.wav: -8.2215dBFS (-0.1754dBFS peak)
            Level for track07.cdda.wav: -8.9346dBFS (-0.1765dBFS peak)
            Level for track08.cdda.wav: -13.6175dBFS (-0.4552dBFS peak)
            Level for track09.cdda.wav: -9.0107dBFS (-0.1778dBFS peak)
            Level for track10.cdda.wav: -8.1824dBFS (-0.4519dBFS peak)
            Level for track11.cdda.wav: -8.5700dBFS (-0.1778dBFS peak)
            Standard deviation is 1.47 dB
            Throwing out level of -13.6175dBFS (different by 4.58dB)
            Average level: -8.6929dBFS
            Applying adjustment of -3.35dB...

       The volume of "Ten Cents," which is track 8, is 4.58 deci
       bels off the average, which, given a standard deviation of
       1.47 decibels, makes it a statistical aberration (which
       I've defined as anything off by more that twice the stan
       dard deviation, but you can set a constant decibel thresh
       old with the -t option).  Therefore, it isn't counted in
       the average, and the adjustment applied to the album isn't
       thrown off because of one song.  Although the aberrant
       song's volume is not counted in the average, it is
       adjusted along with the rest of the files.

       Finally, say you want to make a mixed CD of 80's songs for
       your mom or something.  You won't allow any 80's songs to
       taint your hallowed mp3 collection, so the absolute vol
       umes of these tracks don't matter, as long as they're all
       about the same, so mom doesn't have to keep adjusting the
       volume.  For this, use the mix mode option,

            normalize -m *.wav

       and each track will be adjusted to the average level of
       all the tracks.

3 How does it work?
       This is just a little background on how normalize computes
       the volume of a wav file, in case you want to know just
       how your files are being munged.

       The volumes calculated are RMS amplitudes, which corre
       spond (roughly) to perceived volume.  Taking the RMS
       amplitude of an entire file would not give us quite the
       measure we want, though, because a quiet song punctuated
       by short loud parts would average out to a quiet song, and
       the adjustment we would compute would make the loud parts
       excessively loud.

       What we want is to consider the maximum volume of the
       file, and normalize according to that.  We break up the
       signal into 100 chunks per second, and get the signal
       power of each chunk, in order to get an estimation of
       "instantaneous power" over time.  This "instantaneous
       power" signal varies too much to get a good measure of the
       original signal's maximum sustained power, so we run a
       smoothing algorithm over the power signal (specifically, a
       mean filter with a window width of 100 elements).  The
       maximum point of the smoothed power signal turns out to be
       a good measure of the maximum sustained power of the file.
       We can then take the square root of the power to get maxi
       mum sustained RMS amplitude.

       As for the default target amplitude of 0.25 (-12dBFS),
       I've found that it's pretty close to the level of most of
       my albums already, but not so high as to cause a lot of
       limiting on quieter albums.  You may want to choose a dif
       ferent target amplitude, depending on your music collec
       tion (just make sure you normalize everything to the same
       amplitude if you want it to all be the same volume!).

       Regarding clipping: since version 0.6, a limiter is
       employed to eliminate clipping.  The limiter is on by
       default; you don't have to do anything to use it.  The 0.5
       series had a -c option to turn on limiting, but that lim
       iter caused problems with inexact volume adjustment.  The
       new limiter doesn't have this problem, and the -c option
       is considered deprecated (it will be removed in version
       1.0).

       Please note that I'm not a recording engineer or an elec
       trical engineer, so my signal processing theory may be
       off.  I'd be glad to hear from any signal processing wiz
       ards if I've made faulty assumptions regarding signal
       power, perceived volume, or any of that fun signal theory
       stuff.

4 Why don't you normalize using peak levels instead of RMS amplitude?
       Well, in early (unreleased) versions, this is how it
       worked. I found that this just didn't work well.  The vol
       ume that your ear hears corresponds more closely with
       average RMS amplitude level than with peak level.  There
       fore, making the RMS amplitude of two files equal makes
       their perceived volume equal.  (Approximately equal, any
       way: certain frequencies sound louder at the same ampli
       tude because the ear is just more sensitive to those fre
       quencies.  I may try to take this into account in a future
       version, but that opens up a whole new can of worms.)

       "Normalizing" by peak level generally makes files with
       small dynamic range very loud and does nothing to files
       with large dynamic ranges.  There's not really any normal
       ization being done, it's more of a histogram expansion.
       That said, since version 0.5, you can use the --peak
       option to do this in normalize.

5 Can you make normalize operate directly on mp3 files?
       The short answer is maybe -- I'm looking into it.

       MPEG layer III audio files store audio data as Huffman-
       coded frequency components.  Theoretically, frequency com
       ponents can be analyzed and adjusted just as easily as
       time-domain samples (such as the PCM samples in a WAV
       file).  However, because the samples are Huffman-coded, it
       is likely that decoding the samples, adjusting them, and
       re-encoding them will cause them to take more or less bits
       than before.  This is a problem, since MPEG audio files
       have a set bitrate.  Layer III files have a bit reservoir
       mechanism that could absorb some of the changes, but
       essentially there's no guarantee that adjusted audio data
       will still fit in the MP3 file.  The process of getting
       the data to fit in the given bitrate is basically the same
       as the encoding process.  That is, it's hard.

       A simpler task, which normalize may be able to do soon, is
       to analyze an MP3 file, and set its volume adjustment ID3
       tag instead of actually adjusting the audio data.  The
       only problem with this method is that I don't know of any
       MP3 players that honor this tag.

       The current situation is that to normalize an mp3 file,
       you can decode it to WAV, normalize the WAV, and re-encode
       it, but you incur the encoding loss a second time. If you
       don't mind the loss, you can do just this with the
       "normalize-mp3" script that is included in the distribution.
