[vorbis-dev] Vorbis & ReplayGain
Gian-Carlo Pascutto
gcp at sjeng.org
Fri Jan 11 12:52:19 PST 2002
Hi all,
I have implemented ReplayGain support for Vorbis.
If you are not familiar with it, it is basically
a method of making sure all your files have equal loudness,
remove the need for normalization and prevent clipping
during playback. The process is totally lossless,
and supporting it requires minimal work.
More info about the exact workings can
be found on www.replaygain.org (recommended reading)
The support consists of three levels:
a) An agreed tag format for storing the ReplayGain
data. I hereby propose:
RG_RADIO=+0.0 dB
RG_AUDIOPHILE=+0.0 dB
RG_PEAK=1.000
The exact meaning of these values is described
on www.replaygain.org. This format should be
self-explanatory otherwhise. Note that the Vorbis
version has a human-readable form, in accordance
with the fact the they are in the 'comment' field
of a Vorbis file.
If possible, and if this format is agreeable
for everyone, I would ask that they be included
in the Vorbis comment/tag format documentation.
<p>b) An analysis program, that reads .ogg files,
calculates the correct gain values, and stores
them back into the oggs as tags.
This program is already written and available at
http://sjeng.org/ftp/vorbis/ReplayGain-0.3.tar.gz.
It should work on both Unix and Windows, although I
have not tried it on the latter yet.
Usage is as simple as:
replaygain <file1> <file2> <...>
to perform the analysis on <file1> and <file2>.
It also supports
replaygain -a <track1> <track2> <...>
to perform 'Audiophile Gain' analysis. This stores
additional ReplayGain values for entire albums.
<p>c) The decoder software
ReplayGain must be supported by the decoder/player to
have any effect. If the decoder/player does not support
ReplayGain, the files will still play as usual.
In fact, nothing will change.
Basic support can be done in a minimal amount of
code:
1) Read out the RG_RADIO tag
2) Calculate scale = 10^(RG_RADIO/20)
3) Multiply all PCM samples with 'scale'
That's it!
If the decoder author wishes to do so, he can also
add support for more advanced features (in order
of complexity):
4) Offer a selection between 'Radio' and 'Audiophile'
ReplayGain and use RG_RADIO or RG_AUDIOPHILE depending
on the selection. (trivial)
5) Use the RG_PEAK value to prevent clipping and thus
improve audio quality. (also very easy, see example code)
6) Implement a preamp and a hard limiter to allow the
user to increase the loudness without causing the audio
to clip. (more tricky to do fast)
Example code, including all of the 'advanced' features is provided
in the form of an enhanced XMMS decoder with ReplayGain support
at:
http://sjeng.org/ftp/vorbis/ReplayGain-XMMS-0.2.tar.gz
--
GCP
<p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis-dev
mailing list