Replay Gain - A Proposed Standard

Replay Gain Data Format

What to store

Three values must be stored.

  1. Peak signal amplitude
  2. "Radio" = Replay Gain adjustment required to make all tracks equal loudness
  3. "Audiophile" = Replay Gain adjustment required to give ideal listening loudness

If calculated on a track-by-track basis, ReplayGain yields (2). If calculated on a disc-by-disc basis, ReplayGain will usually yield (3), though this value may be more accurately determined by a human listener if required.

To allow for future expansion: If more than three values are stored, players should ignore those they do not recognise, but process those that they do. If additional Replay Gain adjustments other than "Radio" and "Audiophile" are stored, they should come after "Radio" and "Audiophile". The Peak Amplitude must always occupy the first 4 bytes of the Replay Gain header frame. The three values listed above (or at least fields to hold the three values, should the values themselves be unknown) are required in all Replay Gain headers.

Range

The replay gain adjustment must be between -51.0dB and +51.0dB. Values outside this range must be limited to be within the range, though they are certainly in error, and should probably be re-calculated, or stored as "not set". For example, trying to cause a silent 24-bit file to play at 83dB will yield a replay gain adjustment of +57dB.

In practice, adjustment values from -23dB to +17dB are the likely extremes, and values from -18dB to +2dB are more usual.

Bit format

Each Replay Gain value should be stored in a Replay Gain Adjustment field consisting of two bytes (16 bits). Here are two example Replay Gain Adjustment fields:


               Radio Gain Adjustment              Audiophile Gain Adjustment

          0 0 1 0 1 1 1 0 0 1 1 1 1 1 0 1       0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0
          \___/ \___/ | \_______________/       \___/ \___/ | \_______________/
            |     |   |         |                 |     |   |         |
          name    |  sign       |               name    |  sign       |
          code    |  bit        |               code    |  bit        |
                  |             |                       |             |
             originator         |                  originator         |
                code            |                     code            |
                           Replay Gain                           Replay Gain
                            Adjustment                            Adjustment

In the above example, the Radio Gain Adjustment is -12.5dB, and was calculated automatically. The Audiophile Gain Adjustment is +2.0dB, and was set by the user.

- Name code

000 = not set
001 = Radio Gain Adjustment
010 = Audiophile Gain Adjustment
other = reserved for future use

If space has been reserved for the Replay Gain in the file header, but no replay gain calculation has been carried out, then all bits (including the Name code) may be zero.

For each Replay Gain Adjustment field, if the name code = 000 (not set), then players should ignore the rest of that individual field.

For each Replay Gain Adjustment field, if the name code is an unrecognised value (i.e. not 001-Radio or 010-Audiophile), then players should ignore the rest of that individual field.

If no valid Replay Gain Adjustment fields are found (i.e. all name codes are either 000 or unknown), then the player should proceed as if the file contained no Replay Gain Adjustment information (see player requirements).

- Originator code

000 = Replay Gain unspecified
001 = Replay Gain pre-set by artist/producer/mastering engineer
010 = Replay Gain set by user
011 = Replay Gain determined automatically, as described on this site
other = reserved for future use

For each Replay Gain Adjustment field, if the name code is valid, but the Originator code is 000 (Replay Gain unspecified), then the player should ignore that Replay Gain adjustment field.

For each Replay Gain Adjustment field, if the name code is valid, but the Originator code is unknown, then the player should still use the information within that Replay Gain Adjustment field. This is because, even if we are unsure as to how the adjustment was determined, any valid Replay Gain adjustment is more useful than none at all.

If no valid Replay Gain Adjustment fields are found (i.e. all originator codes are 000), then the player should proceed as if the file contained no Replay Gain Adjustment information (see player requirements).

- Sign bit

0 = +
1 = -

- Replay Gain Adjustment

The value, multiplied by ten, stripped of its sign (since the + or - is stored in the "sign" bit), is represented in 9 bits. e.g. -3.1dB becomes 31 = 000011111.

Default Value

$00 $00 (0000000000000000) should be used where no Replay Gain has been calculated or set. This value will be interpreted by players in the same manner as a file without a Replay Gain field in the header (see player requirements).

The values of xxxyyy0000000000 (where xxx is any name code, and yyy is any originator code) are all valid, but indicate that the Replay Gain is to be left at 83dB (0dB Replay Gain Adjustment). These are not default values, and should only be used where appropriate (e.g. where the user, producer, or Replay Gain calculation has indicated that the correct Replay Gain is 83dB).

Illegal Values

The values xxxyyy1000000000 are all illegal. You cannot have negative zero! These values may be used to convey other information in the future. They must not be used at present. If enountered, players should treat them in the same manner as $00 $00 (the default value).

The value $xx $ff is not illegal, but it would give a false synch value within an mp3 file. The problems this may cause should be investigated, and a solution (e.g. unsychronisation) sought. Maybe this is a use for negative zero?

Implementation

Please contact me if you have implemented any software which makes use of this format.

Suggestions and further work

Please contact me if you anticipate any problems with this data format.