MP3Gain

From Hydrogenaudio Knowledgebase
Revision as of 23:43, 24 March 2006 by Pepoluan (Talk | contribs)

Jump to: navigation, search

MP3Gain is a program that analyzes MP3 files to determine how loud they sound to the human ear. It can then adjust the MP3 files so that they all have the same loudness without any quality loss. This way, you don't have to keep reaching for the volume dial on your MP3 player every time it switches to a new song.

The principle behind MP3Gain is similar to Replaygain. And like Replaygain, MP3Gain also support Track mode and Album mode.

The difference lies in how it is implemented. With 'standard' Replaygain, the necessary loudness adjustment is stored as a metadata, thus leaving the encoding result alone. With MP3Gain, the loudness adjustment is done on the data itself, albeit in a lossless/reversible way.

Another difference is the limitation of MP3Gain that can adjust only in 1.5 dB steps.


Technical Explanation

Here's the technical reason on why it's lossless (despite operating on the data itself), and also why the smallest change possible is 1.5 dB:

The MP3 format stores the sound information in small chunks called "frames". Each frame represents a fraction of a second of sound. In each frame there is a "global gain" field. This field is an 8-bit integer (so its value can be a whole number from 0 to 255).

When an MP3 player decodes the sound in the frame, it uses the global gain field to multiply the decoded sound samples by 2^(gain/4).

  • If you add 1 to this field in all the MP3 frames, you effectively multiply the amplitude of the whole file by 2^(1/4) = 119% = +1.5 dB.
  • Likewise, if you subtract 1 from this field, you multiply the amplitude by 2^(-1/4) = 84% = -1.5 dB.


The way MP3Gain works actually has a very strong benefit: Since it is the data itself that is modified, MP3Gain does not require special support from players, quite unlike Replaygain.


Links