<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.hydrogenaudio.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Skamp</id>
	<title>Hydrogenaudio Knowledgebase - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.hydrogenaudio.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Skamp"/>
	<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Special:Contributions/Skamp"/>
	<updated>2026-04-28T18:59:27Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=LossyWAV&amp;diff=38815</id>
		<title>LossyWAV</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=LossyWAV&amp;diff=38815"/>
		<updated>2026-01-24T14:43:39Z</updated>

		<summary type="html">&lt;p&gt;Skamp: removed lossyWV support from caudec&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Software Infobox&lt;br /&gt;
| name = lossyWAV&lt;br /&gt;
| logo =&lt;br /&gt;
| screenshot = &lt;br /&gt;
| caption = &lt;br /&gt;
| maintainer = [http://www.hydrogenaud.io/forums/index.php?showuser=42400 Nick.C]&lt;br /&gt;
| stable_release = [https://hydrogenaud.io/index.php/topic,112649 1.4.2]&lt;br /&gt;
| preview_release = -&lt;br /&gt;
| operating_system = [[Wikipedia:Microsoft Windows|Windows]], [[Wikipedia:Linux|Linux]]&lt;br /&gt;
| use = [[Wikipedia:Digital signal processing|Digital signal processing]]&lt;br /&gt;
| license = [[Wikipedia:GNU General Public License|GNU GPL]]&lt;br /&gt;
| website = [http://www.hydrogenaud.io/forums/index.php?showtopic=107081 1.4.0 release thread]&amp;lt;br /&amp;gt;[http://www.hydrogenaud.io/forums/index.php?showtopic=109239 1.5.0 development thread]&lt;br /&gt;
}}&lt;br /&gt;
lossyWAV is a [[Wikipedia:Free software|free]], [[lossy]] pre-processor for [[PCM]] audio contained in the [[RIFF WAVE|WAV]] file format. Proposed by [http://www.hydrogenaud.io/forums/index.php?showuser=409 David Robinson], it reduces [[Wikipedia:Audio bit depth|bit depth]] of the input signal, which, when used in conjunction with certain lossless codecs, reduces the bitrate of the encoded file significantly compared to unpreprocessed compression.&lt;br /&gt;
lossyWAV&#039;s primary goal is to maintain [[transparency]] with a high degree of confidence when processing any audio data.&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
lossyWAV is based on the lossyFLAC idea proposed by [http://www.hydrogenaud.io/forums/index.php?showuser=409 David Robinson] at Hydrogenaudio, which is a method of carefully reducing the bitdepth of (blocks of) samples which will then allow the FLAC lossless encoder to make use of its wasted bits feature. The aim is to transparently reduce audio bit depth (by making some lower significant bits ([[Wikipedia:Least significant bit|lsb]]&#039;s) zero), consequently taking advantage of FLAC&#039;s detection of consistently-zeroed lower significant bits within each single frame and significantly increasing coding efficiency.[http://www.hydrogenaud.io/forums/index.php?s=&amp;amp;showtopic=55522&amp;amp;view=findpost&amp;amp;p=498179] In this way the user can enjoy audio encoded using the same codec (which may be all important from a hardware compatibility perspective) at a reduced bitrate compared to the lossless version.&lt;br /&gt;
&lt;br /&gt;
[http://www.hydrogenaud.io/forums/index.php?showuser=42400 Nick Currie] ported the original [[Wikipedia:MATLAB|MATLAB]] implementation to [[Wikipedia:Borland Delphi|Delphi]] (Many thanks [[Wikipedia:CodeGear|CodeGear]] for Turbo Explorer!) with a liberal sprinkling of [[Wikipedia:IA-32|IA-32]] and [[Wikipedia:x87|x87]] Assembly Language for speed.&lt;br /&gt;
&lt;br /&gt;
Subsequently, lossyFLAC proved itself to work with other lossless codecs, so the application name was changed to lossyWAV. &lt;br /&gt;
&lt;br /&gt;
Since then, Nick has heavily developed and built upon lossyWAV, with valuable tuning performed by [http://www.hydrogenaud.io/forums/index.php?showuser=25015 Horst Albrecht] at Hydrogenaudio. Although the current lossyWAV implementation has built on David&#039;s original method, the method itself still very much belongs to its author.&lt;br /&gt;
&lt;br /&gt;
==Indicative bitrate reduction==&lt;br /&gt;
It must be stressed that lossyWAV is a pure variable bit-depth pre-processor in that the overall sample size remains the same after processing but the number of significant bits used for the samples in a codec-block can change on a block-by-block basis. Bits-to-remove from the audio data are calculated on a block-by-block basis (codec-block length = 512 samples, 11.6msec @ 44.1kHz) using overlapping [[Wikipedia:fast Fourier transform|fast Fourier Transform]] (FFT) analyses of at least two lengths (default quality preset (-q 5) = 32, 64 &amp;amp; 1024 [[Wikipedia:Sampling (signal processing)|samples]]). After some manipulation, the results of each FFT analysis for a specific codec-block are then grouped and the minimum value used to determine bits-to-remove for the whole codec-block. Bit removal adds noise to the output, however the level of the added noise associated with the removal of a number of bits has been pre-calculated and the number of bits to remove will depend on the level of the noise floor of the codec-block in question. The added noise is adaptively shaped by default, however the user can select parameters to make the added noise fixed shaped or simply [[Wikipedia:white noise|white noise]]. Each sample in the codec-block is then rounded such that the first &amp;lt;bits-to-remove&amp;gt; lsb&#039;s are zero. In this way the wasted bits feature of [[FLAC]] et al. is exploited.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!lossyWAV Test Set (16 bit / 44.1kHz)&lt;br /&gt;
!Codec&lt;br /&gt;
!lossless&lt;br /&gt;
!--insane&lt;br /&gt;
!--extreme&lt;br /&gt;
!--high&lt;br /&gt;
!--standard&lt;br /&gt;
!--economic&lt;br /&gt;
!--portable&lt;br /&gt;
!--extraportable&lt;br /&gt;
|-&lt;br /&gt;
!10 Album Test Set&lt;br /&gt;
| FLAC&lt;br /&gt;
| 854 kbit/s&lt;br /&gt;
| 627 kbit/s&lt;br /&gt;
| 548 kbit/s&lt;br /&gt;
| 477 kbit/s&lt;br /&gt;
| 442 kbit/s&lt;br /&gt;
| 407 kbit/s&lt;br /&gt;
| 353 kbit/s&lt;br /&gt;
| 311 kbit/s&lt;br /&gt;
|-&lt;br /&gt;
!Nick.C&#039;s Full Collection&lt;br /&gt;
| FLAC&lt;br /&gt;
| 882 kbit/s&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 307 kbit/s&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==File identification==&lt;br /&gt;
lossyWAV-processed WAV files are named with a double filename extension, .lossy.wav, to make them instantly identifiable. e.g. &amp;quot;.lossy.flac&amp;quot; would indicate an audio file which was processed using lossyWAV, and subsequently encoded using FLAC.[http://www.hydrogenaud.io/forums/index.php?s=&amp;amp;showtopic=55522&amp;amp;view=findpost&amp;amp;p=498559]&lt;br /&gt;
&lt;br /&gt;
The --correction parameter is used when processing to create a correction file which is named with the .lwcdf.wav double filename extension. When &amp;quot;added&amp;quot; to the corresponding .lossy.wav, using the --merge parameter, the original file will be reconstituted.&lt;br /&gt;
&lt;br /&gt;
Combinations of lossyWAV with each specific encoder are referred to as lossy&#039;&#039;&#039;X&#039;&#039;&#039;, where &#039;&#039;&#039;X&#039;&#039;&#039; is an abbreviation of the lossless codec name. Combination names are listed in the &amp;quot;[[LossyWAV#Known supported codecs|known supported codecs]]&amp;quot; section below.&lt;br /&gt;
&lt;br /&gt;
lossyWAV inserts a variable-length &#039;fact&#039; chunk into the WAV file immediately after the &#039;fmt &#039; chunk. This takes the form:&amp;lt;pre&amp;gt;fact/&amp;lt;size&amp;gt;/lossyWAV x.y.z @ dd/mm/yyyy hh:mm:ss, -q 5&amp;lt;/pre&amp;gt;Where the version, date &amp;amp; time and user settings are copied. Additionally, if a lossyWAV &#039;fact&#039; chunk is found in a file, the processing will be halted (exit code = 16) to prevent re-processing of an already processed file.&lt;br /&gt;
&lt;br /&gt;
The --check parameter can be used to determine whether a file has previously been processed without trying to process it, exit code = 16 if already processed; exit code = 0 if not.&lt;br /&gt;
&lt;br /&gt;
==Quality presets==&lt;br /&gt;
*--quality insane: (-q I or -q 10) Highest quality preset, generally considered to be excessive;&lt;br /&gt;
*--quality extreme: (-q E or -q 7.5) Higher quality preset, disc space-saving alternative to lossless archiving for large audio collections, considered to be suitable for transcoding to other lossy codecs;&lt;br /&gt;
*--quality high: (-q H or -q 5.0) High quality preset, midway between extreme and standard;&lt;br /&gt;
*--quality standard: (-q S or -q 2.5) Default preset, generally accepted to be transparent;&lt;br /&gt;
*--quality economic: (-q C or -q 0.0) Intermediate preset midway between standard and portable;&lt;br /&gt;
*--quality portable: (-q P or -q -2.5) DAP quality preset for use on a compatible [[Wikipedia:Digital audio player|DAP]].[http://www.hydrogenaud.io/forums/index.php?s=&amp;amp;showtopic=56129&amp;amp;view=findpost&amp;amp;p=531316]&lt;br /&gt;
*--quality extraportable: (-q X or -q -5.0) Lowest quality preset for use on a compatible [[Wikipedia:Digital audio player|DAP]].[http://www.hydrogenaud.io/forums/index.php?s=&amp;amp;showtopic=56129&amp;amp;view=findpost&amp;amp;p=531316]&lt;br /&gt;
&lt;br /&gt;
All tuning for version 1.0.0 was performed on quality preset --standard with higher presets being more conservative. For versions 1.1.0, 1.2.0 and 1.3.0, tuning effort has been focused on the lowest quality preset in an effort to achieve an effective compromise between resultant bitrate and perceived quality. Quality preset --standard is generally accepted to be (and from testing so far is) transparent. If you find a track which --standard fails to achieve transparency after processing, please post a sample (no more than 30 seconds) in the development thread.&lt;br /&gt;
&lt;br /&gt;
The upper frequency limit used in the calculation of minimum signal power varies, dependent on quality preset, in the range 15.159kHz to 16.682kHz&lt;br /&gt;
&lt;br /&gt;
==Supported input formats==&lt;br /&gt;
*[[WAV]]: 9-bit to 32-bit integer; 1 to 8 channels; sample rate &amp;amp;ge; 32kHz [[Pulse Code Modulation|PCM]]. Very high sample rates (&amp;amp;gt;48kHz) have not been extensively tested. Tunings have been focussed on 16-bit, 44.1kHz samples (i.e. [[Wikipedia:Red Book (audio CD standard)|CD]] PCM).&lt;br /&gt;
&lt;br /&gt;
==Codec compatibility==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Codec&lt;br /&gt;
!Supported&lt;br /&gt;
!Encoder parameters&lt;br /&gt;
!Combination name&lt;br /&gt;
|-&lt;br /&gt;
! [[Free Lossless Audio Codec|FLAC]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;5&#039;&#039;&#039; -&#039;&#039;&#039;b&#039;&#039;&#039; 512 --&#039;&#039;&#039;keep-foreign-metadata&#039;&#039;&#039;&lt;br /&gt;
| lossy&#039;&#039;&#039;FLAC&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Lossless Predictive Audio Compression|LPAC]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;b&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;LPAC&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Wikipedia:Audio Lossless Coding|MPEG-4 ALS]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;l&#039;&#039;&#039; -&#039;&#039;&#039;n&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;ALS&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[TAK]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;fsl&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;TAK&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[WavPack]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| --&#039;&#039;&#039;blocksize&#039;&#039;&#039;=512 --&#039;&#039;&#039;merge-blocks&#039;&#039;&#039;&lt;br /&gt;
| lossy&#039;&#039;&#039;WV&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Windows Media Audio#Windows Media Audio Lossless|WMA Lossless]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| lossy&#039;&#039;&#039;WMALSL&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Apple Lossless]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Lossless Audio|LA]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Monkey&#039;s Audio]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[OptimFROG]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Wikipedia:TTA (codec)|TTA]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* Combinations of lossyWAV with each specific encoder are referred to as lossy&#039;&#039;&#039;X&#039;&#039;&#039;, where &#039;&#039;&#039;X&#039;&#039;&#039; is an abbreviation of the lossless codec name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is also [http://www.hometheaterhifi.com/volume_8_4/dvd-benchmark-part-6-dvd-audio-11-2001.html#Meridian%20Lossless%20Packing%20(MLP)%20in%20a%20Nutshell evidence] &amp;amp;mdash; so-called &amp;quot;Bit Shifting&amp;quot; &amp;amp;mdash; to suggest that lossyWAV may work with [[Wikipedia:Meridian Lossless Packing|MLP]], but this remains untested due to prohibitive prices of encoders. At least one [http://www.hydrogenaud.io/forums/index.php?showtopic=98609&amp;amp;hl= commercial DVD-A] uses constant bit-depth reduction with lower bit-depth on rear channels.&lt;br /&gt;
&lt;br /&gt;
A comparison of portable media players is [[Wikipedia:Comparison of portable media players#Audio Formats|here]], which shows FLAC and WMA Lossless compatibility among listed players.&lt;br /&gt;
Any player supported by [http://www.rockbox.org Rockbox] can use FLAC or WavPack files after installing Rockbox.&lt;br /&gt;
===Important note===&lt;br /&gt;
&#039;&#039;&#039;NB: when encoding using a lossless codec, please ensure that the block size of the lossless codec matches that of lossyWAV (default = 512 samples). If this is not done then the lossless encoding of the processed WAV file will (almost certainly) be larger than it would otherwise have been. This is achieved by adding the &amp;quot;Encoder Parameters&amp;quot; in the table above to the command line of the lossless codec in question.&#039;&#039;&#039;&lt;br /&gt;
===Bonus feature===&lt;br /&gt;
Another, possibly not obvious, feature of lossyWAV is that the processed output can be &amp;quot;transcoded&amp;quot; from one lossless codec to another lossless codec with absolutely no loss of quality whatsoever. This is solely due to the fact that lossyWAV output is designed to be losslessly encoded - something that lossless codecs do very well indeed.&lt;br /&gt;
&lt;br /&gt;
==Using lossyWAV==&lt;br /&gt;
===Application settings===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lossyWAV 1.4.2, Copyright (C) 2007-2016 Nick Currie. Copyleft.&lt;br /&gt;
&lt;br /&gt;
This program is free software: you can redistribute it and/or modify it under&lt;br /&gt;
the terms of the GNU General Public License as published by the Free Software&lt;br /&gt;
Foundation, either version 3 of the License, or (at your option) any later&lt;br /&gt;
version.&lt;br /&gt;
&lt;br /&gt;
This program is distributed in the hope that it will be useful,but WITHOUT ANY&lt;br /&gt;
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A&lt;br /&gt;
PARTICULAR PURPOSE.  See the GNU General Public License for more details.&lt;br /&gt;
&lt;br /&gt;
You should have received a copy of the GNU General Public License along with&lt;br /&gt;
this program.  If not, see &amp;lt;http://www.gnu.org/licenses/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Process Description:&lt;br /&gt;
&lt;br /&gt;
lossyWAV is a near lossless audio processor which dynamically reduces the&lt;br /&gt;
bitdepth of the signal on a block-by-block basis. Bitdepth reduction adds noise&lt;br /&gt;
to the processed output. The amount of permissible added noise is based on&lt;br /&gt;
analysis of the signal levels in the default frequency range 20Hz to 16kHz.&lt;br /&gt;
&lt;br /&gt;
If signals above the upper limiting frequency are at an even lower level, they&lt;br /&gt;
can be swamped by the added noise. This is usually inaudible, but the behaviour&lt;br /&gt;
can be changed by specifying a different --limit (in the range 10kHz to 20kHz).&lt;br /&gt;
&lt;br /&gt;
For many audio signals there is little content at very high frequencies and&lt;br /&gt;
forcing lossyWAV to keep the added noise level lower than the content at these&lt;br /&gt;
frequencies can increase the bitrate of the losslessly compressed output&lt;br /&gt;
dramatically for no perceptible benefit.&lt;br /&gt;
&lt;br /&gt;
The noise added by the process is shaped using an adaptive method provided by&lt;br /&gt;
Sebastian Gesemann. This method, as implemented in lossyWAV, aims to use the&lt;br /&gt;
signal itself as the basis of the filter used for noise shaping. Adaptive noise&lt;br /&gt;
shaping is enabled by default.&lt;br /&gt;
&lt;br /&gt;
Usage   : lossyWAV &amp;lt;input wav file&amp;gt; &amp;lt;options&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example : lossyWAV musicfile.wav&lt;br /&gt;
&lt;br /&gt;
Quality Options:&lt;br /&gt;
&lt;br /&gt;
-q, --quality &amp;lt;t&amp;gt;    where t is one of the following (default = standard):&lt;br /&gt;
    I, insane        highest quality output, suitable for transcoding;&lt;br /&gt;
    E, extreme       higher quality output, suitable for transcoding;&lt;br /&gt;
    H, high          high quality output, suitable for transcoding;&lt;br /&gt;
    S, standard      default quality output, considered to be transparent;&lt;br /&gt;
    C, economic      intermediate quality output, likely to be transparent;&lt;br /&gt;
    P, portable      good quality output for DAP use, may not be transparent;&lt;br /&gt;
    X, extraportable lowest quality output, probably not transparent.&lt;br /&gt;
&lt;br /&gt;
Standard Options:&lt;br /&gt;
&lt;br /&gt;
-C, --correction     write correction file for processed WAV file; default=off.&lt;br /&gt;
-f, --force          forcibly over-write output file if it exists; default=off.&lt;br /&gt;
-h, --help           display help.&lt;br /&gt;
-L, --longhelp       display extended help.&lt;br /&gt;
-M, --merge          merge existing lossy.wav and lwcdf.wav files.&lt;br /&gt;
-o, --outdir &amp;lt;t&amp;gt;     destination directory for the output file(s).&lt;br /&gt;
-v, --version        display the lossyWAV version number.&lt;br /&gt;
-w, --writetolog     create (or add to) lossyWAV.log in the output directory.&lt;br /&gt;
&lt;br /&gt;
Advanced Options:&lt;br /&gt;
&lt;br /&gt;
-                    take WAV input from STDIN.&lt;br /&gt;
-c, --check          check if WAV file has already been processed; default=off.&lt;br /&gt;
                     errorlevel=16 if already processed, 0 if not.&lt;br /&gt;
-q, --quality &amp;lt;n&amp;gt;    quality preset (-5.0&amp;lt;=n&amp;lt;=10.0); (-5=lowest, 10=highest;&lt;br /&gt;
                     default=2.5; I=10.0; E=7.5; H=5.0; S=2.5; C=0.0; P=-2.5;&lt;br /&gt;
                     X=-5.0.&lt;br /&gt;
--, --stdout         write WAV output to STDOUT.&lt;br /&gt;
    --stdinname &amp;lt;t&amp;gt;  pseudo filename to use when input from STDIN.&lt;br /&gt;
&lt;br /&gt;
Advanced Quality Options:&lt;br /&gt;
&lt;br /&gt;
-A, --altspread [n]  disables &#039;old&#039; sperading mechanism in favour of &#039;new&#039;&lt;br /&gt;
                     mechanism (default spreading uses both &#039;old&#039; and &#039;new&#039;&lt;br /&gt;
                     mechanisms). Takes an optional parameter, n, which relates&lt;br /&gt;
                     to the proportion of adjacent bins taken into account when&lt;br /&gt;
                     calculating spread average for a particular bin (0&amp;lt;=n&amp;lt;=1;&lt;br /&gt;
                     default = 0.768544).&lt;br /&gt;
-a, --analyses &amp;lt;n&amp;gt;   set number of FFT analysis lengths, (2&amp;lt;=n&amp;lt;=7; default=3,&lt;br /&gt;
                     i.e. 32, 64 &amp;amp; 1024 samples. n = 2, remove 32 sample FFT;&lt;br /&gt;
                     n &amp;gt; 3 add 16; n &amp;gt; 4, add 128; n &amp;gt; 5, add 256, n &amp;gt; 6, add&lt;br /&gt;
                     512) n.b. FFT lengths stated are for 44.1/48kHz audio,&lt;br /&gt;
                     higher sample rates will automatically increase all FFT&lt;br /&gt;
                     lengths as required.&lt;br /&gt;
-D, --dynamic &amp;lt;n&amp;gt;    select minimum_bits_to_keep_dynamic to n bits (default&lt;br /&gt;
                     2.71 at -q X and 5.00 at -q I, 1.0 &amp;lt;= n &amp;lt;= 7.0.&lt;br /&gt;
    --feedback [n]   enable experimental bit removal / adaptive noise shaping&lt;br /&gt;
                     noise limiter. Tuning has been carried out at -q X and&lt;br /&gt;
                     should have a negligible effect at -q S. Optional setting&lt;br /&gt;
                     (0.0 &amp;lt;= n &amp;lt;= 10.0, default = 0.0) automatically selects&lt;br /&gt;
                     the following parameters (0 = least effect, 10 = most):&lt;br /&gt;
       r, round &amp;lt;n&amp;gt;  limit deviation from expected added noise due to rounding&lt;br /&gt;
                     (-2.0 &amp;lt;= n &amp;lt;= 2.0, default = 0.0).&lt;br /&gt;
       n, noise &amp;lt;n&amp;gt;  limit added noise due to adaptive noise shaping&lt;br /&gt;
                     (-2.5 &amp;lt;= n &amp;lt;= 7.5, default = 0.0).&lt;br /&gt;
       a, aclips &amp;lt;n&amp;gt; number of permissible exceedences of adaptive noise&lt;br /&gt;
                     shaping level limit (0 &amp;lt;= n &amp;lt;= 64, default = 32).&lt;br /&gt;
       A, alevel &amp;lt;n&amp;gt; adaptive noise shaping level limit (-2.0 &amp;lt;= n &amp;lt;= 2.5,&lt;br /&gt;
                     default = 0.0).&lt;br /&gt;
       V, verbose    enable more detailed feedback information in output.&lt;br /&gt;
-I, --ignore-chunk-sizes.&lt;br /&gt;
                     ignore &#039;RIFF&#039; and &#039;data&#039; chunk sizes in input.&lt;br /&gt;
-l, --limit &amp;lt;n&amp;gt;      set upper frequency limit to be used in analyses to n Hz;&lt;br /&gt;
                     (12500 &amp;lt;= n &amp;lt;= 20000*; default=16000).&lt;br /&gt;
                     *: for 44.1/48 kHz audio. Upper limit for audio of&lt;br /&gt;
                     other sampling rates is limited to sample-rate x 45.35%&lt;br /&gt;
    --linkchannels   revert to original single bits-to-remove value for all&lt;br /&gt;
                     channels rather than channel dependent bits-to-remove.&lt;br /&gt;
    --maxclips &amp;lt;n&amp;gt;   set max. number of acceptable clips per channel per block;&lt;br /&gt;
                     (0 &amp;lt;= n &amp;lt;= 16; default = 3,3,3,3,3,2,2,2,2,2,1,1,1,0,0,0).&lt;br /&gt;
-m, --midside        analyse 2 channel audio for mid/side content.&lt;br /&gt;
    --nodccorrect    disable DC correction of audio data prior to FFT analysis,&lt;br /&gt;
                     default=on; (DC offset calculated per FFT data set).&lt;br /&gt;
-n, --noskew         disable application of low frequency level reduction prior&lt;br /&gt;
                     to determination of bits-to-remove.&lt;br /&gt;
    --scale &amp;lt;n&amp;gt;      factor to scale audio by; (0.03125 &amp;lt; n &amp;lt;= 8.0; default=1).&lt;br /&gt;
-s, --shaping        modify settings for noise shaping used in bit-removal:&lt;br /&gt;
       a, altfilter  enable alternative adaptive shaping filter method.&lt;br /&gt;
       A, average    set factor of shape modification above upper calculation&lt;br /&gt;
                     frequency limit (0.00000 &amp;lt;= n &amp;lt;= 1.00000)&lt;br /&gt;
       c, cubic      enable cubic interpolation when defining filter shape&lt;br /&gt;
       e, extra      additional white noise to add during creation of filter&lt;br /&gt;
       f, fixed      disable adaptive noise shaping (use fixed shaping)&lt;br /&gt;
       h, hybrid     enable hybrid alternative to default adaptive noise shaping&lt;br /&gt;
                     method. Uses all available calculated analyses to create&lt;br /&gt;
                     the desired noise filter shape rather than only those for&lt;br /&gt;
                     1.5ms and 20ms FFT analyses.&lt;br /&gt;
       n, nowarp     disable warped noise shaping (use linear frequency shaping)&lt;br /&gt;
       o, off        disable noise shaping altogether (use simple rounding)&lt;br /&gt;
       s, scale &amp;lt;n&amp;gt;  change effectiveness of noise shaping (0 &amp;lt; n &amp;lt;= 2; default&lt;br /&gt;
                     = 1.0)&lt;br /&gt;
       t, taps &amp;lt;n&amp;gt;   select number of taps to use in FIR filter (8 &amp;lt;= n &amp;lt;= 256;&lt;br /&gt;
                     default = 64)&lt;br /&gt;
       w, warp       enable cubic interpolation when creating warped filter&lt;br /&gt;
    --static &amp;lt;n&amp;gt;     set minimum-bits-to-keep-static to n bits (default=6;&lt;br /&gt;
                     3&amp;lt;=n&amp;lt;=28, limited to bits-per-sample - 3).&lt;br /&gt;
-U, --underlap &amp;lt;n&amp;gt;   enable underlap mode to increase number of FFT analyses&lt;br /&gt;
                     performed at each FFT length, (n = 2, 4 or 8, default=2).&lt;br /&gt;
&lt;br /&gt;
Output Options:&lt;br /&gt;
&lt;br /&gt;
    --bitdist        show distrubution of bits to remove.&lt;br /&gt;
    --blockdist      show distribution of lowest / highest significant bit of&lt;br /&gt;
                     input codec-blocks and bit-removed codec-blocks.&lt;br /&gt;
-d, --detail         enable per block per channel bits-to-remove data display.&lt;br /&gt;
-F, --freqdist [all] enable frequency analysis display of input data. Use of&lt;br /&gt;
                     &#039;all&#039; parameter displays all calculated analyses.&lt;br /&gt;
-H, --histogram      show sample value histogram (input, lossy and correction).&lt;br /&gt;
    --perchannel     show selected distribution data per channel.&lt;br /&gt;
-p, --postanalyse    enable frequency analysis display of output and&lt;br /&gt;
                     correction data in addition to input data.&lt;br /&gt;
    --sampledist     show distribution of lowest / highest significant bit of&lt;br /&gt;
                     input samples and bit-removed samples.&lt;br /&gt;
    --spread [full]  show detailed [more detailed] results from the spreading/&lt;br /&gt;
                     averaging algorithm.&lt;br /&gt;
-W, --width &amp;lt;n&amp;gt;      select width of output options (79&amp;lt;=n&amp;lt;=255).&lt;br /&gt;
&lt;br /&gt;
System Options:&lt;br /&gt;
&lt;br /&gt;
-B, --below          set process priority to below normal.&lt;br /&gt;
    --low            set process priority to low.&lt;br /&gt;
-N, --nowarnings     suppress lossyWAV warnings.&lt;br /&gt;
-Q, --quiet          significantly reduce screen output.&lt;br /&gt;
-S, --silent         no screen output.&lt;br /&gt;
&lt;br /&gt;
Special thanks go to:&lt;br /&gt;
&lt;br /&gt;
David Robinson       for the publication of his lossyFLAC method, guidance, and&lt;br /&gt;
                     the motivation to implement his method as lossyWAV.&lt;br /&gt;
&lt;br /&gt;
Horst Albrecht       for ABX testing, valuable support in tuning the internal&lt;br /&gt;
                     presets, constructive criticism and all the feedback.&lt;br /&gt;
&lt;br /&gt;
Sebastian Gesemann   for the adaptive noise shaping method and the amount of&lt;br /&gt;
                     help received in implementing it and also for the basis of&lt;br /&gt;
                     the fixed noise shaping method.&lt;br /&gt;
&lt;br /&gt;
Tyge Lovset          for the C++ translation initiative.&lt;br /&gt;
&lt;br /&gt;
Matteo Frigo and     for libfftw3-3.dll contained in the FFTW distribution&lt;br /&gt;
Steven G Johnson     (v3.2.1 or v3.2.2).&lt;br /&gt;
&lt;br /&gt;
Mark G Beckett       for the Delphi unit that provides an interface to the&lt;br /&gt;
(Univ. of Edinburgh) relevant fftw routines in libfftw3-3.dll.&lt;br /&gt;
&lt;br /&gt;
Don Cross            for the Complex-FFT algorithm originally used.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example drag &#039;n&#039; drop batch file===&lt;br /&gt;
Simply drag the FLAC files onto this batch file and it will process, recode in FLAC and copy ALL of the tags from the input FLAC file, placing the output lossyFLAC file in the same directory as the input FLAC file. Requires flac.exe and [http://www.synthetic-soul.co.uk/tag/ tag.exe] to be somewhere on the path. &lt;br /&gt;
&amp;lt;pre&amp;gt;@echo off&lt;br /&gt;
:repeat&lt;br /&gt;
if %1.==. goto end&lt;br /&gt;
if exist &amp;quot;%~1&amp;quot; flac -d &amp;quot;%~1&amp;quot; --stdout --silent|lossywav - --stdout --quality standard ^&lt;br /&gt;
  --stdinname &amp;quot;%~1&amp;quot;|flac - -b 512 -o &amp;quot;%~dpn1.lossy.flac&amp;quot; --silent &amp;amp;&amp;amp; tag ^&lt;br /&gt;
  --fromfile &amp;quot;%~1&amp;quot; &amp;quot;%~dpn1.lossy.flac&amp;quot;&lt;br /&gt;
shift&lt;br /&gt;
goto repeat&lt;br /&gt;
:end&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and FFTW===&lt;br /&gt;
Since version 1.2.0, lossyWAV has been compatible with [[Wikipedia:FFTW|FFTW]] although not dependent on it. Should the user wish to take advantage of the increased processing speed available when using FFTW (from superior FFT implementations), libfftw3-3.dll should be placed in a directory on the host computer which features on the path.&lt;br /&gt;
&lt;br /&gt;
===Linux / OS X support: lossyWAV and WINE===&lt;br /&gt;
The cause of lossyWAV&#039;s WINE incompatibility was found and removed during the development of 1.2.0 and retrospectively amended for 1.1.0b in a maintenance release (1.1.0c). The latest stable version (1.3.0 at the time of writing) is fully supported.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/gcocatre/caudec caudec] is a command-line tool that can encode and decode lossyWAV / lossyFLAC files, using the a linux or macOS build (see the POSIX version below).&lt;br /&gt;
&lt;br /&gt;
There is also a [http://github.com/MoSal/lossywav-for-posix lossyWAV for POSIX] port available on GitHub that does not require any Wine emulation.&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and [[foobar2000]]===&lt;br /&gt;
Example [[foobar2000]] converter settings:&lt;br /&gt;
&lt;br /&gt;
lossyFLAC settings:&amp;lt;pre&amp;gt;Encoder: c:\windows\system32\cmd.exe&lt;br /&gt;
Extension: lossy.flac&lt;br /&gt;
Parameters: /d /c c:\&amp;quot;program files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|c:\&amp;quot;program files&amp;quot;\bin\flac - -b 512 -5 -f -o%d --ignore-chunk-sizes&lt;br /&gt;
Format is: lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyTAK settings:&amp;lt;pre&amp;gt;Encoder: c:\windows\system32\cmd.exe&lt;br /&gt;
Extension: lossy.tak&lt;br /&gt;
Parameters: /d /c c:\&amp;quot;program files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|c:\&amp;quot;program files&amp;quot;\bin\takc -e -p2m -fsl512 -ihs - %d&lt;br /&gt;
Format is: lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyWV settings:&amp;lt;pre&amp;gt;Encoder: c:\windows\system32\cmd.exe&lt;br /&gt;
Extension: lossy.wv&lt;br /&gt;
Parameters: /d /c c:\&amp;quot;program files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|c:\&amp;quot;program files&amp;quot;\bin\wavpack -hm --blocksize=512 --merge-blocks -i - %d&lt;br /&gt;
Format is: lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyWMALSL* settings:&amp;lt;pre&amp;gt;Encoder: c:\windows\system32\cmd.exe&lt;br /&gt;
Extension: lossy.wma&lt;br /&gt;
Parameters: /d /c c:\&amp;quot;program files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|c:\&amp;quot;program files&amp;quot;\bin\wmaencode.exe - %d --codec lsl --ignorelength&lt;br /&gt;
Format is: lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enclose the element of the path containing spaces within double quotation marks (&amp;quot;), e.g. C:\&amp;quot;Program Files&amp;quot;\directory_where_executable_is\executable_name. This is a Windows limitation.&lt;br /&gt;
&lt;br /&gt;
lossyWMALSL conversion uses WMAEncode.exe by lvqcl found [http://www.hydrogenaud.io/forums/index.php?s=&amp;amp;showtopic=90519&amp;amp;view=findpost&amp;amp;p=767754 here].&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and EAC===&lt;br /&gt;
:&#039;&#039;For example settings, see [[EAC and LossyWAV]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Frequently asked questions==&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why is the &amp;quot;.wav&amp;quot; file extension used?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039; The &amp;quot;.wav&amp;quot; file extension is used because lossyWAV is a digital signal processor and not a codec. No decoding is required for any program to play a WAV file which has been processed with lossyWAV as it remains compliant with the RIFF WAVE format.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why create a processor which means that I cannot be sure that a lossless file is truly lossless?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039; Unless one creates the lossless file personally, one can &#039;&#039;&#039;never&#039;&#039;&#039; be completely sure that the file is indeed lossless. E.g. a lossless file you receive could be transcoded from [[MP3]] without your knowledge. To distinguish a lossyWAV file from lossless files it is recommended to use the extension .lossy.EXT where EXT is the original extension e.g. .lossy.flac&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[Variable Bitrate|VBR]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; Yes.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Do I need to re-process to change lossless codecs?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[Transparency|transparent]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; At preset --standard, almost certainly.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[lossless]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Will it ever have a [[Constant Bitrate|CBR]] mode?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Will it low-pass filter my audio?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No. The frequency limit is for the analysis only. LossyWAV cannot low-pass filter your audio.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why should I use this?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039;&lt;br /&gt;
:*high quality&lt;br /&gt;
:*extremely low chance of audible [[artifact]]s&lt;br /&gt;
:*reasonable [[bitrate]]s&lt;br /&gt;
:*usable with unmodified, established lossless formats.&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=55522 Original lossyFLAC thread] - Introduction of the concept by David Robinson (Replay Gain developer) and initial development&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=109239 lossyWAV 1.5.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=107081 lossyWAV 1.4.0 release thread] - Release of version 1.4.0 on 02 Oktober 2014&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=96635 lossyWAV 1.3.1 Delphi to C++ translation thread]&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=81002 lossyWAV 1.3.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=90104 lossyWAV 1.3.0 release thread] - Release of version 1.3.0 on 06 August 2011&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=65499 lossyWAV 1.2.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=77042 lossyWAV 1.2.0 release thread] - Release of version 1.2.0 on 16 December 2009&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=63254 lossyWAV 1.1.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=64617 lossyWAV 1.1.0 release thread] - Release of version 1.1.0 on 12 July 2008&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=56129 lossyWAV Development thread] - Conversion of the original MATLAB script to Delphi and evolution of the method&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=63225 lossyWAV 1.0.0 release thread] - Release of version 1.0.0b on 12 May 2008&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Software]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=LossyWAV&amp;diff=38814</id>
		<title>LossyWAV</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=LossyWAV&amp;diff=38814"/>
		<updated>2026-01-24T14:39:15Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Updated lossyWAV support with caudec&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Software Infobox&lt;br /&gt;
| name = lossyWAV&lt;br /&gt;
| logo =&lt;br /&gt;
| screenshot = &lt;br /&gt;
| caption = &lt;br /&gt;
| maintainer = [http://www.hydrogenaud.io/forums/index.php?showuser=42400 Nick.C]&lt;br /&gt;
| stable_release = [https://hydrogenaud.io/index.php/topic,112649 1.4.2]&lt;br /&gt;
| preview_release = -&lt;br /&gt;
| operating_system = [[Wikipedia:Microsoft Windows|Windows]], [[Wikipedia:Linux|Linux]]&lt;br /&gt;
| use = [[Wikipedia:Digital signal processing|Digital signal processing]]&lt;br /&gt;
| license = [[Wikipedia:GNU General Public License|GNU GPL]]&lt;br /&gt;
| website = [http://www.hydrogenaud.io/forums/index.php?showtopic=107081 1.4.0 release thread]&amp;lt;br /&amp;gt;[http://www.hydrogenaud.io/forums/index.php?showtopic=109239 1.5.0 development thread]&lt;br /&gt;
}}&lt;br /&gt;
lossyWAV is a [[Wikipedia:Free software|free]], [[lossy]] pre-processor for [[PCM]] audio contained in the [[RIFF WAVE|WAV]] file format. Proposed by [http://www.hydrogenaud.io/forums/index.php?showuser=409 David Robinson], it reduces [[Wikipedia:Audio bit depth|bit depth]] of the input signal, which, when used in conjunction with certain lossless codecs, reduces the bitrate of the encoded file significantly compared to unpreprocessed compression.&lt;br /&gt;
lossyWAV&#039;s primary goal is to maintain [[transparency]] with a high degree of confidence when processing any audio data.&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
lossyWAV is based on the lossyFLAC idea proposed by [http://www.hydrogenaud.io/forums/index.php?showuser=409 David Robinson] at Hydrogenaudio, which is a method of carefully reducing the bitdepth of (blocks of) samples which will then allow the FLAC lossless encoder to make use of its wasted bits feature. The aim is to transparently reduce audio bit depth (by making some lower significant bits ([[Wikipedia:Least significant bit|lsb]]&#039;s) zero), consequently taking advantage of FLAC&#039;s detection of consistently-zeroed lower significant bits within each single frame and significantly increasing coding efficiency.[http://www.hydrogenaud.io/forums/index.php?s=&amp;amp;showtopic=55522&amp;amp;view=findpost&amp;amp;p=498179] In this way the user can enjoy audio encoded using the same codec (which may be all important from a hardware compatibility perspective) at a reduced bitrate compared to the lossless version.&lt;br /&gt;
&lt;br /&gt;
[http://www.hydrogenaud.io/forums/index.php?showuser=42400 Nick Currie] ported the original [[Wikipedia:MATLAB|MATLAB]] implementation to [[Wikipedia:Borland Delphi|Delphi]] (Many thanks [[Wikipedia:CodeGear|CodeGear]] for Turbo Explorer!) with a liberal sprinkling of [[Wikipedia:IA-32|IA-32]] and [[Wikipedia:x87|x87]] Assembly Language for speed.&lt;br /&gt;
&lt;br /&gt;
Subsequently, lossyFLAC proved itself to work with other lossless codecs, so the application name was changed to lossyWAV. &lt;br /&gt;
&lt;br /&gt;
Since then, Nick has heavily developed and built upon lossyWAV, with valuable tuning performed by [http://www.hydrogenaud.io/forums/index.php?showuser=25015 Horst Albrecht] at Hydrogenaudio. Although the current lossyWAV implementation has built on David&#039;s original method, the method itself still very much belongs to its author.&lt;br /&gt;
&lt;br /&gt;
==Indicative bitrate reduction==&lt;br /&gt;
It must be stressed that lossyWAV is a pure variable bit-depth pre-processor in that the overall sample size remains the same after processing but the number of significant bits used for the samples in a codec-block can change on a block-by-block basis. Bits-to-remove from the audio data are calculated on a block-by-block basis (codec-block length = 512 samples, 11.6msec @ 44.1kHz) using overlapping [[Wikipedia:fast Fourier transform|fast Fourier Transform]] (FFT) analyses of at least two lengths (default quality preset (-q 5) = 32, 64 &amp;amp; 1024 [[Wikipedia:Sampling (signal processing)|samples]]). After some manipulation, the results of each FFT analysis for a specific codec-block are then grouped and the minimum value used to determine bits-to-remove for the whole codec-block. Bit removal adds noise to the output, however the level of the added noise associated with the removal of a number of bits has been pre-calculated and the number of bits to remove will depend on the level of the noise floor of the codec-block in question. The added noise is adaptively shaped by default, however the user can select parameters to make the added noise fixed shaped or simply [[Wikipedia:white noise|white noise]]. Each sample in the codec-block is then rounded such that the first &amp;lt;bits-to-remove&amp;gt; lsb&#039;s are zero. In this way the wasted bits feature of [[FLAC]] et al. is exploited.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!lossyWAV Test Set (16 bit / 44.1kHz)&lt;br /&gt;
!Codec&lt;br /&gt;
!lossless&lt;br /&gt;
!--insane&lt;br /&gt;
!--extreme&lt;br /&gt;
!--high&lt;br /&gt;
!--standard&lt;br /&gt;
!--economic&lt;br /&gt;
!--portable&lt;br /&gt;
!--extraportable&lt;br /&gt;
|-&lt;br /&gt;
!10 Album Test Set&lt;br /&gt;
| FLAC&lt;br /&gt;
| 854 kbit/s&lt;br /&gt;
| 627 kbit/s&lt;br /&gt;
| 548 kbit/s&lt;br /&gt;
| 477 kbit/s&lt;br /&gt;
| 442 kbit/s&lt;br /&gt;
| 407 kbit/s&lt;br /&gt;
| 353 kbit/s&lt;br /&gt;
| 311 kbit/s&lt;br /&gt;
|-&lt;br /&gt;
!Nick.C&#039;s Full Collection&lt;br /&gt;
| FLAC&lt;br /&gt;
| 882 kbit/s&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 307 kbit/s&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==File identification==&lt;br /&gt;
lossyWAV-processed WAV files are named with a double filename extension, .lossy.wav, to make them instantly identifiable. e.g. &amp;quot;.lossy.flac&amp;quot; would indicate an audio file which was processed using lossyWAV, and subsequently encoded using FLAC.[http://www.hydrogenaud.io/forums/index.php?s=&amp;amp;showtopic=55522&amp;amp;view=findpost&amp;amp;p=498559]&lt;br /&gt;
&lt;br /&gt;
The --correction parameter is used when processing to create a correction file which is named with the .lwcdf.wav double filename extension. When &amp;quot;added&amp;quot; to the corresponding .lossy.wav, using the --merge parameter, the original file will be reconstituted.&lt;br /&gt;
&lt;br /&gt;
Combinations of lossyWAV with each specific encoder are referred to as lossy&#039;&#039;&#039;X&#039;&#039;&#039;, where &#039;&#039;&#039;X&#039;&#039;&#039; is an abbreviation of the lossless codec name. Combination names are listed in the &amp;quot;[[LossyWAV#Known supported codecs|known supported codecs]]&amp;quot; section below.&lt;br /&gt;
&lt;br /&gt;
lossyWAV inserts a variable-length &#039;fact&#039; chunk into the WAV file immediately after the &#039;fmt &#039; chunk. This takes the form:&amp;lt;pre&amp;gt;fact/&amp;lt;size&amp;gt;/lossyWAV x.y.z @ dd/mm/yyyy hh:mm:ss, -q 5&amp;lt;/pre&amp;gt;Where the version, date &amp;amp; time and user settings are copied. Additionally, if a lossyWAV &#039;fact&#039; chunk is found in a file, the processing will be halted (exit code = 16) to prevent re-processing of an already processed file.&lt;br /&gt;
&lt;br /&gt;
The --check parameter can be used to determine whether a file has previously been processed without trying to process it, exit code = 16 if already processed; exit code = 0 if not.&lt;br /&gt;
&lt;br /&gt;
==Quality presets==&lt;br /&gt;
*--quality insane: (-q I or -q 10) Highest quality preset, generally considered to be excessive;&lt;br /&gt;
*--quality extreme: (-q E or -q 7.5) Higher quality preset, disc space-saving alternative to lossless archiving for large audio collections, considered to be suitable for transcoding to other lossy codecs;&lt;br /&gt;
*--quality high: (-q H or -q 5.0) High quality preset, midway between extreme and standard;&lt;br /&gt;
*--quality standard: (-q S or -q 2.5) Default preset, generally accepted to be transparent;&lt;br /&gt;
*--quality economic: (-q C or -q 0.0) Intermediate preset midway between standard and portable;&lt;br /&gt;
*--quality portable: (-q P or -q -2.5) DAP quality preset for use on a compatible [[Wikipedia:Digital audio player|DAP]].[http://www.hydrogenaud.io/forums/index.php?s=&amp;amp;showtopic=56129&amp;amp;view=findpost&amp;amp;p=531316]&lt;br /&gt;
*--quality extraportable: (-q X or -q -5.0) Lowest quality preset for use on a compatible [[Wikipedia:Digital audio player|DAP]].[http://www.hydrogenaud.io/forums/index.php?s=&amp;amp;showtopic=56129&amp;amp;view=findpost&amp;amp;p=531316]&lt;br /&gt;
&lt;br /&gt;
All tuning for version 1.0.0 was performed on quality preset --standard with higher presets being more conservative. For versions 1.1.0, 1.2.0 and 1.3.0, tuning effort has been focused on the lowest quality preset in an effort to achieve an effective compromise between resultant bitrate and perceived quality. Quality preset --standard is generally accepted to be (and from testing so far is) transparent. If you find a track which --standard fails to achieve transparency after processing, please post a sample (no more than 30 seconds) in the development thread.&lt;br /&gt;
&lt;br /&gt;
The upper frequency limit used in the calculation of minimum signal power varies, dependent on quality preset, in the range 15.159kHz to 16.682kHz&lt;br /&gt;
&lt;br /&gt;
==Supported input formats==&lt;br /&gt;
*[[WAV]]: 9-bit to 32-bit integer; 1 to 8 channels; sample rate &amp;amp;ge; 32kHz [[Pulse Code Modulation|PCM]]. Very high sample rates (&amp;amp;gt;48kHz) have not been extensively tested. Tunings have been focussed on 16-bit, 44.1kHz samples (i.e. [[Wikipedia:Red Book (audio CD standard)|CD]] PCM).&lt;br /&gt;
&lt;br /&gt;
==Codec compatibility==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Codec&lt;br /&gt;
!Supported&lt;br /&gt;
!Encoder parameters&lt;br /&gt;
!Combination name&lt;br /&gt;
|-&lt;br /&gt;
! [[Free Lossless Audio Codec|FLAC]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;5&#039;&#039;&#039; -&#039;&#039;&#039;b&#039;&#039;&#039; 512 --&#039;&#039;&#039;keep-foreign-metadata&#039;&#039;&#039;&lt;br /&gt;
| lossy&#039;&#039;&#039;FLAC&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Lossless Predictive Audio Compression|LPAC]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;b&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;LPAC&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Wikipedia:Audio Lossless Coding|MPEG-4 ALS]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;l&#039;&#039;&#039; -&#039;&#039;&#039;n&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;ALS&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[TAK]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;fsl&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;TAK&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[WavPack]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| --&#039;&#039;&#039;blocksize&#039;&#039;&#039;=512 --&#039;&#039;&#039;merge-blocks&#039;&#039;&#039;&lt;br /&gt;
| lossy&#039;&#039;&#039;WV&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Windows Media Audio#Windows Media Audio Lossless|WMA Lossless]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| lossy&#039;&#039;&#039;WMALSL&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Apple Lossless]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Lossless Audio|LA]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Monkey&#039;s Audio]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[OptimFROG]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Wikipedia:TTA (codec)|TTA]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* Combinations of lossyWAV with each specific encoder are referred to as lossy&#039;&#039;&#039;X&#039;&#039;&#039;, where &#039;&#039;&#039;X&#039;&#039;&#039; is an abbreviation of the lossless codec name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is also [http://www.hometheaterhifi.com/volume_8_4/dvd-benchmark-part-6-dvd-audio-11-2001.html#Meridian%20Lossless%20Packing%20(MLP)%20in%20a%20Nutshell evidence] &amp;amp;mdash; so-called &amp;quot;Bit Shifting&amp;quot; &amp;amp;mdash; to suggest that lossyWAV may work with [[Wikipedia:Meridian Lossless Packing|MLP]], but this remains untested due to prohibitive prices of encoders. At least one [http://www.hydrogenaud.io/forums/index.php?showtopic=98609&amp;amp;hl= commercial DVD-A] uses constant bit-depth reduction with lower bit-depth on rear channels.&lt;br /&gt;
&lt;br /&gt;
A comparison of portable media players is [[Wikipedia:Comparison of portable media players#Audio Formats|here]], which shows FLAC and WMA Lossless compatibility among listed players.&lt;br /&gt;
Any player supported by [http://www.rockbox.org Rockbox] can use FLAC or WavPack files after installing Rockbox.&lt;br /&gt;
===Important note===&lt;br /&gt;
&#039;&#039;&#039;NB: when encoding using a lossless codec, please ensure that the block size of the lossless codec matches that of lossyWAV (default = 512 samples). If this is not done then the lossless encoding of the processed WAV file will (almost certainly) be larger than it would otherwise have been. This is achieved by adding the &amp;quot;Encoder Parameters&amp;quot; in the table above to the command line of the lossless codec in question.&#039;&#039;&#039;&lt;br /&gt;
===Bonus feature===&lt;br /&gt;
Another, possibly not obvious, feature of lossyWAV is that the processed output can be &amp;quot;transcoded&amp;quot; from one lossless codec to another lossless codec with absolutely no loss of quality whatsoever. This is solely due to the fact that lossyWAV output is designed to be losslessly encoded - something that lossless codecs do very well indeed.&lt;br /&gt;
&lt;br /&gt;
==Using lossyWAV==&lt;br /&gt;
===Application settings===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lossyWAV 1.4.2, Copyright (C) 2007-2016 Nick Currie. Copyleft.&lt;br /&gt;
&lt;br /&gt;
This program is free software: you can redistribute it and/or modify it under&lt;br /&gt;
the terms of the GNU General Public License as published by the Free Software&lt;br /&gt;
Foundation, either version 3 of the License, or (at your option) any later&lt;br /&gt;
version.&lt;br /&gt;
&lt;br /&gt;
This program is distributed in the hope that it will be useful,but WITHOUT ANY&lt;br /&gt;
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A&lt;br /&gt;
PARTICULAR PURPOSE.  See the GNU General Public License for more details.&lt;br /&gt;
&lt;br /&gt;
You should have received a copy of the GNU General Public License along with&lt;br /&gt;
this program.  If not, see &amp;lt;http://www.gnu.org/licenses/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Process Description:&lt;br /&gt;
&lt;br /&gt;
lossyWAV is a near lossless audio processor which dynamically reduces the&lt;br /&gt;
bitdepth of the signal on a block-by-block basis. Bitdepth reduction adds noise&lt;br /&gt;
to the processed output. The amount of permissible added noise is based on&lt;br /&gt;
analysis of the signal levels in the default frequency range 20Hz to 16kHz.&lt;br /&gt;
&lt;br /&gt;
If signals above the upper limiting frequency are at an even lower level, they&lt;br /&gt;
can be swamped by the added noise. This is usually inaudible, but the behaviour&lt;br /&gt;
can be changed by specifying a different --limit (in the range 10kHz to 20kHz).&lt;br /&gt;
&lt;br /&gt;
For many audio signals there is little content at very high frequencies and&lt;br /&gt;
forcing lossyWAV to keep the added noise level lower than the content at these&lt;br /&gt;
frequencies can increase the bitrate of the losslessly compressed output&lt;br /&gt;
dramatically for no perceptible benefit.&lt;br /&gt;
&lt;br /&gt;
The noise added by the process is shaped using an adaptive method provided by&lt;br /&gt;
Sebastian Gesemann. This method, as implemented in lossyWAV, aims to use the&lt;br /&gt;
signal itself as the basis of the filter used for noise shaping. Adaptive noise&lt;br /&gt;
shaping is enabled by default.&lt;br /&gt;
&lt;br /&gt;
Usage   : lossyWAV &amp;lt;input wav file&amp;gt; &amp;lt;options&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example : lossyWAV musicfile.wav&lt;br /&gt;
&lt;br /&gt;
Quality Options:&lt;br /&gt;
&lt;br /&gt;
-q, --quality &amp;lt;t&amp;gt;    where t is one of the following (default = standard):&lt;br /&gt;
    I, insane        highest quality output, suitable for transcoding;&lt;br /&gt;
    E, extreme       higher quality output, suitable for transcoding;&lt;br /&gt;
    H, high          high quality output, suitable for transcoding;&lt;br /&gt;
    S, standard      default quality output, considered to be transparent;&lt;br /&gt;
    C, economic      intermediate quality output, likely to be transparent;&lt;br /&gt;
    P, portable      good quality output for DAP use, may not be transparent;&lt;br /&gt;
    X, extraportable lowest quality output, probably not transparent.&lt;br /&gt;
&lt;br /&gt;
Standard Options:&lt;br /&gt;
&lt;br /&gt;
-C, --correction     write correction file for processed WAV file; default=off.&lt;br /&gt;
-f, --force          forcibly over-write output file if it exists; default=off.&lt;br /&gt;
-h, --help           display help.&lt;br /&gt;
-L, --longhelp       display extended help.&lt;br /&gt;
-M, --merge          merge existing lossy.wav and lwcdf.wav files.&lt;br /&gt;
-o, --outdir &amp;lt;t&amp;gt;     destination directory for the output file(s).&lt;br /&gt;
-v, --version        display the lossyWAV version number.&lt;br /&gt;
-w, --writetolog     create (or add to) lossyWAV.log in the output directory.&lt;br /&gt;
&lt;br /&gt;
Advanced Options:&lt;br /&gt;
&lt;br /&gt;
-                    take WAV input from STDIN.&lt;br /&gt;
-c, --check          check if WAV file has already been processed; default=off.&lt;br /&gt;
                     errorlevel=16 if already processed, 0 if not.&lt;br /&gt;
-q, --quality &amp;lt;n&amp;gt;    quality preset (-5.0&amp;lt;=n&amp;lt;=10.0); (-5=lowest, 10=highest;&lt;br /&gt;
                     default=2.5; I=10.0; E=7.5; H=5.0; S=2.5; C=0.0; P=-2.5;&lt;br /&gt;
                     X=-5.0.&lt;br /&gt;
--, --stdout         write WAV output to STDOUT.&lt;br /&gt;
    --stdinname &amp;lt;t&amp;gt;  pseudo filename to use when input from STDIN.&lt;br /&gt;
&lt;br /&gt;
Advanced Quality Options:&lt;br /&gt;
&lt;br /&gt;
-A, --altspread [n]  disables &#039;old&#039; sperading mechanism in favour of &#039;new&#039;&lt;br /&gt;
                     mechanism (default spreading uses both &#039;old&#039; and &#039;new&#039;&lt;br /&gt;
                     mechanisms). Takes an optional parameter, n, which relates&lt;br /&gt;
                     to the proportion of adjacent bins taken into account when&lt;br /&gt;
                     calculating spread average for a particular bin (0&amp;lt;=n&amp;lt;=1;&lt;br /&gt;
                     default = 0.768544).&lt;br /&gt;
-a, --analyses &amp;lt;n&amp;gt;   set number of FFT analysis lengths, (2&amp;lt;=n&amp;lt;=7; default=3,&lt;br /&gt;
                     i.e. 32, 64 &amp;amp; 1024 samples. n = 2, remove 32 sample FFT;&lt;br /&gt;
                     n &amp;gt; 3 add 16; n &amp;gt; 4, add 128; n &amp;gt; 5, add 256, n &amp;gt; 6, add&lt;br /&gt;
                     512) n.b. FFT lengths stated are for 44.1/48kHz audio,&lt;br /&gt;
                     higher sample rates will automatically increase all FFT&lt;br /&gt;
                     lengths as required.&lt;br /&gt;
-D, --dynamic &amp;lt;n&amp;gt;    select minimum_bits_to_keep_dynamic to n bits (default&lt;br /&gt;
                     2.71 at -q X and 5.00 at -q I, 1.0 &amp;lt;= n &amp;lt;= 7.0.&lt;br /&gt;
    --feedback [n]   enable experimental bit removal / adaptive noise shaping&lt;br /&gt;
                     noise limiter. Tuning has been carried out at -q X and&lt;br /&gt;
                     should have a negligible effect at -q S. Optional setting&lt;br /&gt;
                     (0.0 &amp;lt;= n &amp;lt;= 10.0, default = 0.0) automatically selects&lt;br /&gt;
                     the following parameters (0 = least effect, 10 = most):&lt;br /&gt;
       r, round &amp;lt;n&amp;gt;  limit deviation from expected added noise due to rounding&lt;br /&gt;
                     (-2.0 &amp;lt;= n &amp;lt;= 2.0, default = 0.0).&lt;br /&gt;
       n, noise &amp;lt;n&amp;gt;  limit added noise due to adaptive noise shaping&lt;br /&gt;
                     (-2.5 &amp;lt;= n &amp;lt;= 7.5, default = 0.0).&lt;br /&gt;
       a, aclips &amp;lt;n&amp;gt; number of permissible exceedences of adaptive noise&lt;br /&gt;
                     shaping level limit (0 &amp;lt;= n &amp;lt;= 64, default = 32).&lt;br /&gt;
       A, alevel &amp;lt;n&amp;gt; adaptive noise shaping level limit (-2.0 &amp;lt;= n &amp;lt;= 2.5,&lt;br /&gt;
                     default = 0.0).&lt;br /&gt;
       V, verbose    enable more detailed feedback information in output.&lt;br /&gt;
-I, --ignore-chunk-sizes.&lt;br /&gt;
                     ignore &#039;RIFF&#039; and &#039;data&#039; chunk sizes in input.&lt;br /&gt;
-l, --limit &amp;lt;n&amp;gt;      set upper frequency limit to be used in analyses to n Hz;&lt;br /&gt;
                     (12500 &amp;lt;= n &amp;lt;= 20000*; default=16000).&lt;br /&gt;
                     *: for 44.1/48 kHz audio. Upper limit for audio of&lt;br /&gt;
                     other sampling rates is limited to sample-rate x 45.35%&lt;br /&gt;
    --linkchannels   revert to original single bits-to-remove value for all&lt;br /&gt;
                     channels rather than channel dependent bits-to-remove.&lt;br /&gt;
    --maxclips &amp;lt;n&amp;gt;   set max. number of acceptable clips per channel per block;&lt;br /&gt;
                     (0 &amp;lt;= n &amp;lt;= 16; default = 3,3,3,3,3,2,2,2,2,2,1,1,1,0,0,0).&lt;br /&gt;
-m, --midside        analyse 2 channel audio for mid/side content.&lt;br /&gt;
    --nodccorrect    disable DC correction of audio data prior to FFT analysis,&lt;br /&gt;
                     default=on; (DC offset calculated per FFT data set).&lt;br /&gt;
-n, --noskew         disable application of low frequency level reduction prior&lt;br /&gt;
                     to determination of bits-to-remove.&lt;br /&gt;
    --scale &amp;lt;n&amp;gt;      factor to scale audio by; (0.03125 &amp;lt; n &amp;lt;= 8.0; default=1).&lt;br /&gt;
-s, --shaping        modify settings for noise shaping used in bit-removal:&lt;br /&gt;
       a, altfilter  enable alternative adaptive shaping filter method.&lt;br /&gt;
       A, average    set factor of shape modification above upper calculation&lt;br /&gt;
                     frequency limit (0.00000 &amp;lt;= n &amp;lt;= 1.00000)&lt;br /&gt;
       c, cubic      enable cubic interpolation when defining filter shape&lt;br /&gt;
       e, extra      additional white noise to add during creation of filter&lt;br /&gt;
       f, fixed      disable adaptive noise shaping (use fixed shaping)&lt;br /&gt;
       h, hybrid     enable hybrid alternative to default adaptive noise shaping&lt;br /&gt;
                     method. Uses all available calculated analyses to create&lt;br /&gt;
                     the desired noise filter shape rather than only those for&lt;br /&gt;
                     1.5ms and 20ms FFT analyses.&lt;br /&gt;
       n, nowarp     disable warped noise shaping (use linear frequency shaping)&lt;br /&gt;
       o, off        disable noise shaping altogether (use simple rounding)&lt;br /&gt;
       s, scale &amp;lt;n&amp;gt;  change effectiveness of noise shaping (0 &amp;lt; n &amp;lt;= 2; default&lt;br /&gt;
                     = 1.0)&lt;br /&gt;
       t, taps &amp;lt;n&amp;gt;   select number of taps to use in FIR filter (8 &amp;lt;= n &amp;lt;= 256;&lt;br /&gt;
                     default = 64)&lt;br /&gt;
       w, warp       enable cubic interpolation when creating warped filter&lt;br /&gt;
    --static &amp;lt;n&amp;gt;     set minimum-bits-to-keep-static to n bits (default=6;&lt;br /&gt;
                     3&amp;lt;=n&amp;lt;=28, limited to bits-per-sample - 3).&lt;br /&gt;
-U, --underlap &amp;lt;n&amp;gt;   enable underlap mode to increase number of FFT analyses&lt;br /&gt;
                     performed at each FFT length, (n = 2, 4 or 8, default=2).&lt;br /&gt;
&lt;br /&gt;
Output Options:&lt;br /&gt;
&lt;br /&gt;
    --bitdist        show distrubution of bits to remove.&lt;br /&gt;
    --blockdist      show distribution of lowest / highest significant bit of&lt;br /&gt;
                     input codec-blocks and bit-removed codec-blocks.&lt;br /&gt;
-d, --detail         enable per block per channel bits-to-remove data display.&lt;br /&gt;
-F, --freqdist [all] enable frequency analysis display of input data. Use of&lt;br /&gt;
                     &#039;all&#039; parameter displays all calculated analyses.&lt;br /&gt;
-H, --histogram      show sample value histogram (input, lossy and correction).&lt;br /&gt;
    --perchannel     show selected distribution data per channel.&lt;br /&gt;
-p, --postanalyse    enable frequency analysis display of output and&lt;br /&gt;
                     correction data in addition to input data.&lt;br /&gt;
    --sampledist     show distribution of lowest / highest significant bit of&lt;br /&gt;
                     input samples and bit-removed samples.&lt;br /&gt;
    --spread [full]  show detailed [more detailed] results from the spreading/&lt;br /&gt;
                     averaging algorithm.&lt;br /&gt;
-W, --width &amp;lt;n&amp;gt;      select width of output options (79&amp;lt;=n&amp;lt;=255).&lt;br /&gt;
&lt;br /&gt;
System Options:&lt;br /&gt;
&lt;br /&gt;
-B, --below          set process priority to below normal.&lt;br /&gt;
    --low            set process priority to low.&lt;br /&gt;
-N, --nowarnings     suppress lossyWAV warnings.&lt;br /&gt;
-Q, --quiet          significantly reduce screen output.&lt;br /&gt;
-S, --silent         no screen output.&lt;br /&gt;
&lt;br /&gt;
Special thanks go to:&lt;br /&gt;
&lt;br /&gt;
David Robinson       for the publication of his lossyFLAC method, guidance, and&lt;br /&gt;
                     the motivation to implement his method as lossyWAV.&lt;br /&gt;
&lt;br /&gt;
Horst Albrecht       for ABX testing, valuable support in tuning the internal&lt;br /&gt;
                     presets, constructive criticism and all the feedback.&lt;br /&gt;
&lt;br /&gt;
Sebastian Gesemann   for the adaptive noise shaping method and the amount of&lt;br /&gt;
                     help received in implementing it and also for the basis of&lt;br /&gt;
                     the fixed noise shaping method.&lt;br /&gt;
&lt;br /&gt;
Tyge Lovset          for the C++ translation initiative.&lt;br /&gt;
&lt;br /&gt;
Matteo Frigo and     for libfftw3-3.dll contained in the FFTW distribution&lt;br /&gt;
Steven G Johnson     (v3.2.1 or v3.2.2).&lt;br /&gt;
&lt;br /&gt;
Mark G Beckett       for the Delphi unit that provides an interface to the&lt;br /&gt;
(Univ. of Edinburgh) relevant fftw routines in libfftw3-3.dll.&lt;br /&gt;
&lt;br /&gt;
Don Cross            for the Complex-FFT algorithm originally used.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example drag &#039;n&#039; drop batch file===&lt;br /&gt;
Simply drag the FLAC files onto this batch file and it will process, recode in FLAC and copy ALL of the tags from the input FLAC file, placing the output lossyFLAC file in the same directory as the input FLAC file. Requires flac.exe and [http://www.synthetic-soul.co.uk/tag/ tag.exe] to be somewhere on the path. &lt;br /&gt;
&amp;lt;pre&amp;gt;@echo off&lt;br /&gt;
:repeat&lt;br /&gt;
if %1.==. goto end&lt;br /&gt;
if exist &amp;quot;%~1&amp;quot; flac -d &amp;quot;%~1&amp;quot; --stdout --silent|lossywav - --stdout --quality standard ^&lt;br /&gt;
  --stdinname &amp;quot;%~1&amp;quot;|flac - -b 512 -o &amp;quot;%~dpn1.lossy.flac&amp;quot; --silent &amp;amp;&amp;amp; tag ^&lt;br /&gt;
  --fromfile &amp;quot;%~1&amp;quot; &amp;quot;%~dpn1.lossy.flac&amp;quot;&lt;br /&gt;
shift&lt;br /&gt;
goto repeat&lt;br /&gt;
:end&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and FFTW===&lt;br /&gt;
Since version 1.2.0, lossyWAV has been compatible with [[Wikipedia:FFTW|FFTW]] although not dependent on it. Should the user wish to take advantage of the increased processing speed available when using FFTW (from superior FFT implementations), libfftw3-3.dll should be placed in a directory on the host computer which features on the path.&lt;br /&gt;
&lt;br /&gt;
===Linux / OS X support: lossyWAV and WINE===&lt;br /&gt;
The cause of lossyWAV&#039;s WINE incompatibility was found and removed during the development of 1.2.0 and retrospectively amended for 1.1.0b in a maintenance release (1.1.0c). The latest stable version (1.3.0 at the time of writing) is fully supported.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/gcocatre/caudec caudec] is a command-line tool that can encode and decode lossyWAV files (lossyFLAC, lossyWV), using the a linux or macOS build (see the POSIX version below).&lt;br /&gt;
&lt;br /&gt;
There is also a [http://github.com/MoSal/lossywav-for-posix lossyWAV for POSIX] port available on GitHub that does not require any Wine emulation.&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and [[foobar2000]]===&lt;br /&gt;
Example [[foobar2000]] converter settings:&lt;br /&gt;
&lt;br /&gt;
lossyFLAC settings:&amp;lt;pre&amp;gt;Encoder: c:\windows\system32\cmd.exe&lt;br /&gt;
Extension: lossy.flac&lt;br /&gt;
Parameters: /d /c c:\&amp;quot;program files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|c:\&amp;quot;program files&amp;quot;\bin\flac - -b 512 -5 -f -o%d --ignore-chunk-sizes&lt;br /&gt;
Format is: lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyTAK settings:&amp;lt;pre&amp;gt;Encoder: c:\windows\system32\cmd.exe&lt;br /&gt;
Extension: lossy.tak&lt;br /&gt;
Parameters: /d /c c:\&amp;quot;program files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|c:\&amp;quot;program files&amp;quot;\bin\takc -e -p2m -fsl512 -ihs - %d&lt;br /&gt;
Format is: lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyWV settings:&amp;lt;pre&amp;gt;Encoder: c:\windows\system32\cmd.exe&lt;br /&gt;
Extension: lossy.wv&lt;br /&gt;
Parameters: /d /c c:\&amp;quot;program files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|c:\&amp;quot;program files&amp;quot;\bin\wavpack -hm --blocksize=512 --merge-blocks -i - %d&lt;br /&gt;
Format is: lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyWMALSL* settings:&amp;lt;pre&amp;gt;Encoder: c:\windows\system32\cmd.exe&lt;br /&gt;
Extension: lossy.wma&lt;br /&gt;
Parameters: /d /c c:\&amp;quot;program files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|c:\&amp;quot;program files&amp;quot;\bin\wmaencode.exe - %d --codec lsl --ignorelength&lt;br /&gt;
Format is: lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enclose the element of the path containing spaces within double quotation marks (&amp;quot;), e.g. C:\&amp;quot;Program Files&amp;quot;\directory_where_executable_is\executable_name. This is a Windows limitation.&lt;br /&gt;
&lt;br /&gt;
lossyWMALSL conversion uses WMAEncode.exe by lvqcl found [http://www.hydrogenaud.io/forums/index.php?s=&amp;amp;showtopic=90519&amp;amp;view=findpost&amp;amp;p=767754 here].&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and EAC===&lt;br /&gt;
:&#039;&#039;For example settings, see [[EAC and LossyWAV]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Frequently asked questions==&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why is the &amp;quot;.wav&amp;quot; file extension used?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039; The &amp;quot;.wav&amp;quot; file extension is used because lossyWAV is a digital signal processor and not a codec. No decoding is required for any program to play a WAV file which has been processed with lossyWAV as it remains compliant with the RIFF WAVE format.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why create a processor which means that I cannot be sure that a lossless file is truly lossless?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039; Unless one creates the lossless file personally, one can &#039;&#039;&#039;never&#039;&#039;&#039; be completely sure that the file is indeed lossless. E.g. a lossless file you receive could be transcoded from [[MP3]] without your knowledge. To distinguish a lossyWAV file from lossless files it is recommended to use the extension .lossy.EXT where EXT is the original extension e.g. .lossy.flac&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[Variable Bitrate|VBR]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; Yes.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Do I need to re-process to change lossless codecs?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[Transparency|transparent]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; At preset --standard, almost certainly.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[lossless]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Will it ever have a [[Constant Bitrate|CBR]] mode?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Will it low-pass filter my audio?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No. The frequency limit is for the analysis only. LossyWAV cannot low-pass filter your audio.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why should I use this?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039;&lt;br /&gt;
:*high quality&lt;br /&gt;
:*extremely low chance of audible [[artifact]]s&lt;br /&gt;
:*reasonable [[bitrate]]s&lt;br /&gt;
:*usable with unmodified, established lossless formats.&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=55522 Original lossyFLAC thread] - Introduction of the concept by David Robinson (Replay Gain developer) and initial development&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=109239 lossyWAV 1.5.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=107081 lossyWAV 1.4.0 release thread] - Release of version 1.4.0 on 02 Oktober 2014&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=96635 lossyWAV 1.3.1 Delphi to C++ translation thread]&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=81002 lossyWAV 1.3.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=90104 lossyWAV 1.3.0 release thread] - Release of version 1.3.0 on 06 August 2011&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=65499 lossyWAV 1.2.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=77042 lossyWAV 1.2.0 release thread] - Release of version 1.2.0 on 16 December 2009&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=63254 lossyWAV 1.1.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=64617 lossyWAV 1.1.0 release thread] - Release of version 1.1.0 on 12 July 2008&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=56129 lossyWAV Development thread] - Conversion of the original MATLAB script to Delphi and evolution of the method&lt;br /&gt;
*[http://www.hydrogenaud.io/forums/index.php?showtopic=63225 lossyWAV 1.0.0 release thread] - Release of version 1.0.0b on 12 May 2008&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Software]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38812</id>
		<title>Revised ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38812"/>
		<updated>2026-01-23T19:07:28Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Make it clear that the REPLAYGAIN_REFERENCE_LOUDNESS tag goes against the ReplayGain philosophy of having a single target, not a moveable one.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;4&amp;quot;&amp;gt;&#039;&#039;This is a proposed update to the [[ReplayGain 1.0 specification|original ReplayGain specification]]. This proposal is currently &#039;&#039;&#039;Under Construction&#039;&#039;&#039;. Please discuss this proposal on the [[Talk:ReplayGain 2.0 specification|discussion page]] or the [https://hydrogenaudio.org/index.php/topic,129032.0.html dedicated thread on Hydrogenaudio].&#039;&#039; --[[User:Skamp|Skamp]] 22:10 CET, January 22, 2026&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although music is encoded to a digital format with a clearly defined maximum peak amplitude, and although most recordings are normalized to utilize this peak amplitude, not all recordings sound equally loud. This is because once this peak amplitude is reached, perceived loudness can be further increased through signal-processing techniques such as dynamic range compression and equalization.&amp;lt;ref&amp;gt;Source: Wikipedia - [http://en.wikipedia.org/wiki/Loudness_war Loudness war]&amp;lt;/ref&amp;gt; Therefore, the loudness of a given album has more to do with the year of issue or the whim of the producer than the intended emotional effect. Because of this, a random play through a music collection can have one leaping for the volume control every other track.&lt;br /&gt;
&lt;br /&gt;
There is a solution to this annoyance: within each audio file, information can be stored about what volume change would be required to play each track or album at a standard loudness, and players can use this &amp;quot;replay gain&amp;quot; information to automatically nudge the volume up or down as required.&lt;br /&gt;
&lt;br /&gt;
The ReplayGain specification is a standard which defines an appropriate reference level, explains a way of calculating and representing the ideal replay gain for a given track or album, and provides guidance for players to make the required volume adjustment during playback. The standard also specifies a means to prevent clipping when the calculated replay gain exceeds the limits of digital audio, and it describes how the replay gain information is stored within audio files.&lt;br /&gt;
&lt;br /&gt;
==Loudness measurement==&lt;br /&gt;
Loudness is a subjective measure of the intensity of sound. The correlation of perceived loudness to sound pressure level is determined by the peculiarities of the auditory system.&lt;br /&gt;
&lt;br /&gt;
The [[ReplayGain 1.0 specification|original ReplayGain specification]] described a loudness measurement system which included a weighting filter, root mean square (RMS) measurement and statistical processing that model human perception of loudness in both the frequency and time domains.&lt;br /&gt;
&lt;br /&gt;
Since original ReplayGain proposal in 2001, the science, practice and standards for loudness normalization have been advanced significantly. The current industry standard approach to loudness measurement is described by the International Telecommunications Union&amp;lt;ref&amp;gt;http://www.itu.int/en/Pages/default.aspx&amp;lt;/ref&amp;gt; (ITU) as BS.1770. The most recent version of this standard is known as ITU BS.1770-5&amp;lt;ref&amp;gt;https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en&amp;lt;/ref&amp;gt; and was published in December 2023. The ITU work is freely available and is not believed to be encumbered by any patent issues. The ITU BS.1770-2 standard has been adopted in the United States by the [http://www.atsc.org ATSC] as [http://www.atsc.org/cms/standards/a_85-2011a.pdf A/85] and in Europe by the [http://www.ebu.ch European Broadcast Union] as [http://tech.ebu.ch/docs/tech/tech3343.pdf EBU R-128] for broadcast audio. &lt;br /&gt;
&lt;br /&gt;
BS.1770 uses a &amp;quot;K-weighted&amp;quot; RMS measurement. This weighting function is significantly less complex than the inverted Fletcher-Munson weighting used by the original ReplayGain algorithm. A gating function designed measure the loudness of foreground components in the audio program. The gate in BS.1770 performs a similar function as the statistical processing in the original RG specification. &lt;br /&gt;
&lt;br /&gt;
The computation required for BS.1770 loudness measurement is reduced compared to the original RG technique. Nevertheless, BS.1770 has been shown in several academic studies to be equally or more effective than the RG algorithm in modeling human loudness perception on music program as well as other material such as podcasts, television programs and movies.&amp;lt;ref&amp;gt;Paul Nygren. [http://www.speech.kth.se/prod/publications/files/3319.pdf Achieving equal loudness between audio files]. KTH Royal Institute of Technology&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Martin Wolters; Harald Mundt; Jeffrey Riedmiller (May 2010). [http://www.aes.org/e-lib/browse.cfm?elib=15341 Loudness Normalization In The Age Of Portable Media Players]. Audio Engineering Society.&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Esben Skovenborg; Søren H. Nielsen (October 2004). [http://web.archive.org/web/20120208024743/http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf Evaluation of Different Loudness Models with Music and Speech Material]. Audio Engineering Society. Archived from [http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf the original] on 2012-02-08.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recent RG implementations use BS.1770 for loudness measurement. It is expected the ITU standard will evolve over time to meet the needs of broadcasters and governments. It is the intent of the ReplayGain community that RG follow any future backwards-compatible improvements to loudness measurement using the BS.1770 standard.&lt;br /&gt;
&lt;br /&gt;
==Reference level==&lt;br /&gt;
&lt;br /&gt;
Classic ReplayGain is calibrated to a pink noise reference signal with a RMS level 14&amp;amp;nbsp;dB below a full-scale sinusoid. This reference signal is used to establish a reference level. ReplayGain will apply no gain or attenuation to the reference signal or any program material which has the same loudness measurements as the reference signal.&lt;br /&gt;
&lt;br /&gt;
BS-1770 defines a loudness scale for program material. The units of BS.1770 loudness measurements are in Loudness Units [relative to] Full Scale (LUFS). LUFS can be treated like decibels.&lt;br /&gt;
&lt;br /&gt;
In order to maintain backwards compatibility with classic RG, newer RG uses a -18&amp;amp;nbsp;LUFS reference, which based on lots of music, can give similar loudness compared to classic RG.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
The loudness measurement of the RG1 reference signal is NOT -18 LUFS; &lt;br /&gt;
The original -20 RMS dBFS one is -20.36 LUFS, and the -14 RMS dbFS one would be -15.36 LUFS.&lt;br /&gt;
&lt;br /&gt;
We picked -18 here is the result of analyzing actual music. &lt;br /&gt;
&lt;br /&gt;
Check what 2Bdecided said here: https://hydrogenaud.io/index.php/topic,109076.msg899298.html#msg899298&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Gain calculation==&lt;br /&gt;
RG achieves loudness compensated playback by applying gain (or attenuation) dependent on the measured loudness of the audio file relative to the established reference level. The gain is calculated as follows:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG=L_{r}-L&amp;lt;/math&amp;gt;&lt;br /&gt;
Where:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG&amp;lt;/math&amp;gt; is the replay gain adjustment in decibels,&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{r}&amp;lt;/math&amp;gt; is the -18&amp;amp;nbsp;LUFS reference level&lt;br /&gt;
:&amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; is the measured loudness of the audio file in LUFS.&lt;br /&gt;
&lt;br /&gt;
Gain is positive if the loudness of the audio file is lower than the reference level. The gain is negative (representing an attenuation) if the loudness of the audio file is higher than the reference level. The gain is stored as metadata with the audio file as described below and is used by players to adjust output volume of tracks as they are played as described in [[ReplayGain 2.0 specification#Player requirements|Player requirements]] below.&lt;br /&gt;
&lt;br /&gt;
==Metadata==&lt;br /&gt;
For ReplayGain to do its work during playback, four values must be stored as metadata&amp;lt;ref&amp;gt;Metadata is &amp;quot;data about data.&amp;quot; For example, the ID3 &#039;&#039;de facto&#039;&#039; standard provides a way to store artist, title, album title, track number, and other metadata in data blocks called &amp;quot;tags&amp;quot; immediately before or after the audio data in an MP3 file. Other metadata storage/tagging standards and conventions exist for other audio file formats.&amp;lt;/ref&amp;gt; with or within the audio file:&lt;br /&gt;
# Peak track amplitude&lt;br /&gt;
# Peak album amplitude&lt;br /&gt;
# Track replay gain&lt;br /&gt;
# Album replay gain&lt;br /&gt;
&lt;br /&gt;
If calculated for an individual track, the loudness measurement (as specified above) yields track replay gain. If calculated on an album basis, with all tracks concatenated to make one long audio file, the loudness measurement yields album replay gain.&lt;br /&gt;
&lt;br /&gt;
===Replay gain===&lt;br /&gt;
Under some listening conditions, it&#039;s useful to have every track sound equally loud. The problem with a track-by-track approach is that tracks which should be quiet in the context of the album on which they reside will be brought up to the level of all the rest. For casual listening, or in a noisy background, this can be a good thing. For serious listening, it does not respect the intent of the artist or mastering engineer; a tender ballad track will be blasting at the same loudness as a hard rock track on the same album. It&#039;s generally ideal to leave the intentional loudness differences between tracks in place, yet still correct for unmusical and annoying loudness differences between albums. To accomplish this, ReplayGain suggests that two different gain adjustments should be stored as metadata with each sound file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Album replay gain&#039;&#039; represents the ideal listening gain for an entire album. ReplayGain reads the collection of tracks that comprise an album, and calculates a single replay gain for the whole set. This single gain can be used for playback of all tracks of the album. Intentionally quiet tracks then stay appropriately quieter than the rest. It still solves the basic problem (annoying, unwanted level differences between discs) because quiet or loud discs are still adjusted overall&amp;amp;mdash;so the pop CD that&#039;s 20&amp;amp;nbsp;dB louder than the classical CD will be brought into line.&lt;br /&gt;
&lt;br /&gt;
===Peak amplitude===&lt;br /&gt;
Scanning a track or album for the peak amplitude can be a time-consuming process. Therefore, it&#039;s helpful if this single value is stored as metadata. This is used to predict whether the required replay gain adjustment will cause clipping during playback.&lt;br /&gt;
&lt;br /&gt;
The maximum peak amplitude value is stored as a floating point number, where 1.0 represents digital full scale. As with replay gain values, separate peak amplitude values are stored per track and per album.&lt;br /&gt;
&lt;br /&gt;
For uncompressed files simply, scanners store the maximum absolute sample value held in the file on any channel for positive or negative excursion. The single sample value should be converted to a floating-point representation, such that digital full scale is equivalent to a value of 1.0.&lt;br /&gt;
&lt;br /&gt;
Psychoacoustically coded audio, such as MP3, does not exist as a sequence of samples until it is decoded. Psychoacoustic coding of a heavily limited file can lead to sample values larger than digital full scale upon decoding. The coded files must be decoded using a fully compliant decoder that allows peak overflows (i.e. has headroom) and may result in peak amplitude values greater than 1.0.&lt;br /&gt;
&lt;br /&gt;
==Metadata format==&lt;br /&gt;
From the standpoint of metadata storage, each audio file format presents a unique situation. There are three favored schemes defined for storage of ReplayGain metadata: &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; and &#039;&#039;&#039;APEv2&#039;&#039;&#039;. A survey of file formats is listed below with metadata schemes in order of preference for each:&lt;br /&gt;
* .aac (Advanced Audio Coding raw format) &amp;amp;ndash; No metadata support (use .mp4 instead)&lt;br /&gt;
* .aiff, .aif, .aifc (Apple Interchange File Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID3&amp;quot; IFF chunk)&lt;br /&gt;
* .ape, .apl (Monkey&#039;s Audio) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .bwf (Broadcast Wave Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in RIFF chunk)&lt;br /&gt;
* .flac (Free Lossless Audio Codec) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .mp3 (MPEG audio layer 3) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, LAME VBR proposed tag specification&lt;br /&gt;
* .mp4 also .m4a, .m4b, .m4p, m4r (MPEG-4 Part 14) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID32&amp;quot; box)&lt;br /&gt;
* .mpc (Musepack) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .ogg (Ogg Vorbis) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;, same for other Ogg codecs&lt;br /&gt;
* .opus (Ogg Opus) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; available&lt;br /&gt;
** standard {{code|R128_TRACK_GAIN}} and {{code|R128_ALBUM_GAIN}} (MUST adjust for -23 LUFS) comment keys may be preferable (used by {{code|loudgain}})&lt;br /&gt;
* .tta (True Audio) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .asf, .wma (Windows Media audio) - &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; in Extended Content Description Object&lt;br /&gt;
** {{code|loudgain}} instead uses native ASF/WMA attributes (itself a key-value storage) via TagLib, which is more sensible&lt;br /&gt;
* .wav (Windows PCM) &amp;amp;ndash; No metadata support (use .bwf instead)&lt;br /&gt;
** ID3 RIFF chunk possible (used by {{code|loudgain}})&lt;br /&gt;
* .wv (WavPack) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===ID3v2===&lt;br /&gt;
The ID3v2 standard&amp;lt;ref&amp;gt;The ID3v2 format is explained at [http://www.id3.org/ www.id3.org]. The most useful document is the [http://www.id3.org/id3v2.3.0.html ID3v2 v2.3.0 standard]. Although this document has been superseded by v2.4.0, the earlier document is complete (rather than an update), and in indexed HTML form. As such, it represents a better technical introduction to ID3v2.&amp;lt;/ref&amp;gt; defines a &#039;&#039;tag&#039;&#039; which is situated before the data in an MP3 file.&amp;lt;ref&amp;gt;The original ID3 (v1) tags resided at the end of the file, and contained a few fields of information. The ID3v1 tag is not extensible and therefore cannot support ReplayGain metadata.&amp;lt;/ref&amp;gt; ID3 is used primarily with MP3 audio files but means of adapting the system to other file types have been developed.&lt;br /&gt;
&lt;br /&gt;
The ID3v2 tag is divided into &#039;&#039;frames&#039;&#039;. The preferred means of storing ReplayGain metadata is use of &#039;&#039;TXXX&#039;&#039; key/value pair frames. Two other legacy schemes for storing ReplayGain metadata exist: [[ReplayGain legacy metadata formats#ID3v2 RGAD|RGAD]] and [[ReplayGain legacy metadata formats#ID3v2 RVA2|RVA2]]. These formats are documented in the [[ReplayGain legacy metadata formats|appendix]]. Players may choose to look for these formats if metadata in the &#039;&#039;TXXX&#039;&#039; format is not found in the ID3v2 tag. New scanners may write these older formats in addition to the newer (TXXX) ones if they wish to remain backwards compatible with older players.&lt;br /&gt;
&lt;br /&gt;
ReplayGain uses four TXXX frames. The header of a TXXX frame is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Frame ID       $54 58 58 58 (&amp;quot;TXXX&amp;quot;) &lt;br /&gt;
 Size           $xx xx xx xx (size of frame excluding this header)&lt;br /&gt;
 Flags          $40 $00      (discard frame if audio data is altered)&lt;br /&gt;
&lt;br /&gt;
Frame data is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Text encoding  $00          (ISO-8859-1 encoding)&lt;br /&gt;
 Description    &amp;lt;key string&amp;gt; $00&lt;br /&gt;
 Value          &amp;lt;value string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The four frames associated with ReplayGain metadata use the following key/value pairs&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Table 3: Metadata keys and value formatting&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
|-&lt;br /&gt;
|Track replay gain&lt;br /&gt;
|REPLAYGAIN_TRACK_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak track amplitude&lt;br /&gt;
|REPLAYGAIN_TRACK_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|-&lt;br /&gt;
|Album replay gain&lt;br /&gt;
|REPLAYGAIN_ALBUM_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak album amplitude&lt;br /&gt;
|REPLAYGAIN_ALBUM_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Gains are specified textually in decibels. Negative gains (attenuation) are prefixed with a &#039;-&#039;. Positive gains have no prefix. Integral portion of the gain (a) may be one or two numeric (0-9) digits. If there is no integral portion the field is &#039;0&#039;. The decimal portion of the gain (bb) is two numeric digits. Gains are suffixed with a space followed by &#039;dB&#039;.&lt;br /&gt;
&lt;br /&gt;
Peak levels are specified textually as a positive decimal. Peak level is a dimensionless quantity with 1.000000 representing full scale. No suffix is included on peak values. The integer field (c) is typically 1 or 0. Six numeric digits in the decimal field (dddddd) is adequate to accurately represent peak values for 16-bit audio data.&lt;br /&gt;
&lt;br /&gt;
A robust player should be prepared to parse the following variations in either replay gain or peak level metadata:&lt;br /&gt;
*Positive gains with leading &#039;+&#039;&lt;br /&gt;
*More or fewer significant digits than specified in any field&lt;br /&gt;
*Leading zeros or spaces in integer fields&lt;br /&gt;
*Missing or malformed &#039;dB&#039; suffix (e.g. no space between numeric digits and suffix, alternate capitalization)&lt;br /&gt;
*Alternate capitalization of keys&lt;br /&gt;
&lt;br /&gt;
Other formatting errors indicate more severe problems and should result in player ignoring data as if the frame did not exist.&lt;br /&gt;
&lt;br /&gt;
===Vorbis comments===&lt;br /&gt;
A Vorbis comment&amp;lt;ref&amp;gt;[http://www.xiph.org/vorbis/doc/v-comment.html Vorbis comment metadata format]. ReplayGain metadata is documented on the [http://wiki.xiph.org/VorbisComment#Replay_Gain Xiph Wiki].&amp;lt;/ref&amp;gt; uses an ASCII &amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; format. When Vorbis comments are used, the four ReplayGain metadata items are stored as separate comments. The &#039;&#039;keys&#039;&#039; and formatting for &#039;&#039;values&#039;&#039; is the same as specified for ID3v2. Keys and values are required by the Vorbis comment specification to b separated by &#039;=&#039; (equal character).&lt;br /&gt;
&lt;br /&gt;
===APEv2===&lt;br /&gt;
The APEv2 metadata format&amp;lt;ref&amp;gt;[http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification APEv2 Specification at Hydrogen Audio Wiki]&amp;lt;/ref&amp;gt; also organizes data into key/value pairs. Keys are ASCII format. A flags field allows support for several value formats including UTF-8 and binary. Under APEv2, ReplayGain meta data is stored using the same keys and data as ASCII values in the same format as specified for ID3v2.&lt;br /&gt;
&lt;br /&gt;
===De-Facto extensions===&lt;br /&gt;
MusicBrainz Picard and [http://github.com/Moonbase59/loudgain#tags-written-andor-deleted LoudGain] also support the following additional tags, named using the same conventions:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Extension metadata keys&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
!Purpose&lt;br /&gt;
|-&lt;br /&gt;
|Track range&lt;br /&gt;
|REPLAYGAIN_TRACK_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|rowspan=2 | Indicates dynamics (R-128 Loudness Range / LRA), may guide pre-amplification&lt;br /&gt;
|-&lt;br /&gt;
|Album range&lt;br /&gt;
|REPLAYGAIN_ALBUM_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Reference loudness&lt;br /&gt;
|&amp;lt;s&amp;gt;REPLAYGAIN_REFERENCE_LOUDNESS&amp;lt;/s&amp;gt;&lt;br /&gt;
|[-]a.bb LUFS&lt;br /&gt;
| Use alternative reference levels; change ref levels without re-scanning the file.&lt;br /&gt;
--&lt;br /&gt;
This field is harmful and deviates from the standard, which has only one reference target. The effective playback level is changed within the player and does not require any form of rescanning.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Proposed extension(s) ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Extension metadata keys&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
!Purpose&lt;br /&gt;
|-&lt;br /&gt;
|Algorithm&lt;br /&gt;
|REPLAYGAIN_ALGORITHM&lt;br /&gt;
|ITU-R BS.1770&lt;br /&gt;
|Method to produce values&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Player requirements==&lt;br /&gt;
[[File:RG_Player_control.gif‎|frame|Figure 8: Example ReplayGain control panel]]&lt;br /&gt;
&lt;br /&gt;
Loudness normalization, pre-amplification and clipping prevention are the operations performed by a ReplayGain player.&lt;br /&gt;
&lt;br /&gt;
===Loudness normalization===&lt;br /&gt;
To properly normalize loudness, the player needs to determine if the user desires Track style level normalization (all tracks same loudness), or Album style level normalization (all albums same loudness, tracks of an album played at the same relative level as on the original release). This option should be selectable in the ReplayGain control panel (Figure 8). The player reads the corresponding gain metadata value from the file and scales the audio data as appropriate. Scaling the audio data simply means multiplying each sample value by a constant value. This constant is given by:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;10^\frac{gain}{20}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, in words, replay gain divided by 20 all raised to the power of ten.&amp;lt;ref&amp;gt;After any such operation, it&#039;s a good idea to dither the result. If this calculation and the pre-amp are implemented separately, then dither should only be added to the final result, just before the result is truncated back to 16 bits, or 24, or 8, as limited by the soundcard&amp;amp;mdash;not the file (i.e. after ReplayGain adjustment, an 8-bit file should be sent to a 16-bit soundcard at 16-bits).&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the file only contains one of the replay gain adjustments (e.g. Album) but the user has requested the other (Track), then the player should use the one that is available (in this case, Album). If neither (Track or Album) gain metadata is available, then the player needs to choose a suitable default gain. Potential choices include unity gain (0 dB) or an average of gains from other tracks in the album or playlist.&lt;br /&gt;
&lt;br /&gt;
===Pre-amplification===&lt;br /&gt;
Although the calibration level used by ReplayGain suggests that the average level of an audio track should be 14&amp;amp;nbsp;dB below full scale, some pop music is dynamically compressed to peak at 0&amp;amp;nbsp;dB and average around 3&amp;amp;nbsp;dB below full scale. This means that, when the replay gain is applied, the level of such tracks will be reduced by 11&amp;amp;nbsp;dB! If users are listening to a mixture of highly compressed and more dynamic tracks, ReplayGain will make the listening experience more pleasurable by bringing the level of the compressed tracks down into line with that of the others. However, if users are only listening to highly compressed music, then they may complain that all their files are now too quiet.&amp;lt;ref&amp;gt;This problem can be especially noticeable on portable players with limited output or gain.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To address this problem, a pre-amp feature should be incorporated into the player. A user-supplied pre-amp setting is an adjustment to the calculated replay gain. It should default to perform no adjustment. This means that casual users will experience a moderate reduction in the loudness of their compressed pop music. Less-compressed material can generally be played at the same loudness without clipping. Normalization of more dynamic material may cause clipping or invoke the [[ReplayGain 2.0 specification#Clipping prevention|clipping prevention]] mechanism (see below). Power users and audiophiles can reduce the pre-amp gain to enjoy the full dynamic range of all of their music.&lt;br /&gt;
&lt;br /&gt;
If enabled, the player should read the user selected pre-amp gain, and scale the audio signal by the appropriate amount. For example, a +6&amp;amp;nbsp;dB gain requires a scale of 10&amp;lt;sup&amp;gt;6/20&amp;lt;/sup&amp;gt;, which is approximately 2. The replay gain and pre-amp scale factors can be combined&amp;lt;ref&amp;gt;Scale factors in  Decibel units are added to produce the same effect as multiplying scale factors in linear units.&amp;lt;/ref&amp;gt; for simplicity and ease of processing.&lt;br /&gt;
&lt;br /&gt;
===Clipping prevention===&lt;br /&gt;
ReplayGain&#039;s suggestion of a -14&amp;amp;nbsp;dB average playback level leaves sufficient headroom for the bulk of modern recordings. Nevertheless, there exists the possibility that after application of replay gain and pre-amp adjustment, a track may exceed full scale during its dynamic peaks. Without intervention, this will result in clipping, a severe form of distortion. Factors introducing the possibility of clipping include:&lt;br /&gt;
&lt;br /&gt;
# Recordings from certain genres and certain periods in the history of commercial recordings require additional headroom. Although these recordings can be accommodated through a downwards adjustment of the pre-amp setting, it may be difficult to determine a safe adjustment and it may be undesirable to lower average level to accommodate the rare track which requires it. &lt;br /&gt;
# ReplayGain will make loud dynamically compressed tracks quieter, and quiet dynamically uncompressed tracks louder. The average levels will then be similar, but the quiet tracks will actually have louder peaks. If the user pushes the pre-amp gain upwards the peaks of the (originally) quieter tracks will be pushed well over full scale.&lt;br /&gt;
# In coded audio (e.g. MP3 files) a file that was hard-limited to digital full scale before encoding will often be pushed over the limit by the psychoacoustic compression. A decoder with headroom can recover the over full scale signal by reducing the gain.&lt;br /&gt;
&lt;br /&gt;
ReplayGain suggests two possible solutions which prevent clipping in these situations. A player should support one or both of these.&lt;br /&gt;
&lt;br /&gt;
====Audio limiting====&lt;br /&gt;
In situation 2 above, the user clearly wants all the music to sound very loud. To give them their wish, any signal which would peak above digital full scale should be hard limited at just below digital full scale. This is also useful at lower pre-amp gains, where it allows the average level of classical music to be raised to that of pop music, without distorting. The exact type of nature limiting or compression an implementation choice for the player.&amp;lt;ref&amp;gt;Something like the Hard Limiter found in Cool Edit Pro (Syntrillium) would be appropriate for pop music at least.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reduced gain====&lt;br /&gt;
The audiophile user will not want any compression or limiting on the signal. In this case the only option is to automatically and temporarily reduce the pre-amp gain below the user-selected setting for tracks where clipping would otherwise occur. Clipping can be predicted by examining the peak level of the track or album being played.&lt;br /&gt;
&lt;br /&gt;
The player must read the peak amplitude metadata. If peak level metadata is unavailable, the player should assume a peak level of 1.0. If the peak level for both track and album is stored as metadata in the file, it is possible to calculate if, following the replay gain adjustment and pre-amp gain, the signal will clip at some point. If it won&#039;t, then no further action is necessary. &lt;br /&gt;
&lt;br /&gt;
An overall scale factor for loudness normalization taking into account replay gain, pre-amp setting and clipping prevention through gain reduction is given below.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;min( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{peak amplitude} )&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;!-- use this when tex is fixed: :&amp;lt;math&amp;gt;\operatorname{min}( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{L_{\mathrm{peak}}} )&amp;lt;/math&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hardware implementation===&lt;br /&gt;
The above three steps are appropriate to software players operating on the digital signal in order to scale it. However, it is possible to send the digital signal to the DAC without level correction, and to place an attenuator in the analogue signal path. The attenuator can then be driven by the Replay Gain value. The clipping problem can be addressed by providing adequate headroom in the analog circuitry. Bit transparency and maximum signal to noise ratio is maintained in the digital signal and DAC process.&amp;lt;ref&amp;gt;A system using today&#039;s 24-bit converters is unlikely to appreciate any overall gain in system performance with such an arrangement. A digitally-controlled analog gain element typically introduces significant noise and distortion.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The [http://replaygain.hydrogenaudio.org/proposal original ReplayGain proposal] (an [http://replay.waybackmachine.org/20090306202649/http://www.replaygain.org/ archive] is also available) was developed by David Robinson and was published 10 July 2001. Additional updates were published by David Robinson through 10 October 2001.&lt;br /&gt;
&lt;br /&gt;
The following acknowledgement was included with the original proposal, &amp;quot;The algorithm to calculate an ideal replay gain has grown from my research into human hearing, with many additional ideas drawn from the work of E. Zwicker, and Brian Moore. I am currently completing my PhD at the University of Essex, and have been funded by the EPSRC.&amp;quot; Additionally David Robinson credited Glen Sawyer (Snelg) and Jim Casaburi (Walrus) for software contributions and Bob Katz and Matt Ashland for ideas.&lt;br /&gt;
&lt;br /&gt;
This updated ReplayGain specification reflecting current and recommended practice was prepared by Kevin Gross in 2011.&lt;br /&gt;
&lt;br /&gt;
==Contact==&lt;br /&gt;
For ReplayGain-related questions or contributions, please post in the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio] section of the Hydrogen Audio forums.&lt;br /&gt;
 &lt;br /&gt;
==Appendix==&lt;br /&gt;
# [[ReplayGain legacy metadata formats]]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38806</id>
		<title>ReplayGain</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38806"/>
		<updated>2026-01-23T09:12:44Z</updated>

		<summary type="html">&lt;p&gt;Skamp: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;ReplayGain&#039;&#039;&#039; is the name of a technique invented to achieve the same perceived playback loudness of audio files. It defines an algorithm to measure the &#039;&#039;&#039;perceived&#039;&#039;&#039; loudness of audio data.&lt;br /&gt;
&lt;br /&gt;
ReplayGain allows the loudness of each song within a collection of songs to be consistent. This is called &#039;Track Gain&#039; (or &#039;Radio Gain&#039; in earlier parlance). It also allows the loudness of a specific sub-collection (an &amp;quot;album&amp;quot;) to be consistent with the rest of the collection, while allowing the dynamics from song to song on the album to remain intact. This is called &#039;Album Gain&#039; (or &#039;Audiophile Gain&#039; in earlier parlance). This is especially important when listening to classical music albums, because quiet tracks need to remain a certain degree quieter than the louder ones.&lt;br /&gt;
&lt;br /&gt;
ReplayGain is different from [[Normalization|peak normalization]]. Peak normalization merely ensures that the peak amplitude reaches a certain level. This does not ensure equal loudness. The ReplayGain technique measures the &#039;&#039;effective power&#039;&#039; of the waveform (i.e. the RMS power after applying an &amp;quot;equal loudness contour&amp;quot;), and then adjusts the amplitude of the waveform accordingly. The result is that Replay Gained waveforms are usually more uniformly amplified than peak-normalized waveforms.&lt;br /&gt;
&lt;br /&gt;
==Target loudness==&lt;br /&gt;
The target loudness of all ReplayGain utilities is 89&amp;amp;nbsp;dB SPL when replayed in an SMPTE RP 200 calibrated system (an early departure from the proposal, endorsed by its author&amp;lt;ref&amp;gt;[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=83397&amp;amp;view=findpost&amp;amp;p=721854 Does Replay gain work differtly in Media monkey]&amp;lt;/ref&amp;gt;) &amp;amp;mdash; the ReplayGain proposal and SMPTE recommendation are 6&amp;amp;nbsp;dB lower.&amp;lt;ref&amp;gt;[http://www.mars.org/mailman/public/mad-dev/2004-February/000993.html ReplayGain discussion at mad-dev]&amp;lt;/ref&amp;gt; The target loudness may be more commonly known and understood as &#039;&#039;&#039;-18&#039;&#039;&#039;&amp;amp;nbsp;&#039;&#039;&#039;[https://en.wikipedia.org/wiki/LUFS LUFS]&#039;&#039;&#039; (&#039;&#039;Loudness Units relative to Full Scale&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Some utilities have realized the inadequacies of the classic ReplayGain loudness calculation, switching to a more modern algorithm ([https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en ITU-R BS.1770]). However, the way it was integrated was extremely &#039;&#039;ad hoc&#039;&#039;, at least until a draft of a [[ReplayGain 2.0 specification|revised specification]] started being written.&lt;br /&gt;
&lt;br /&gt;
==Clipping==&lt;br /&gt;
Audio is generally recorded such that the loudest sounds don&#039;t clip, but the use of ReplayGain can cause clipping if the average volume of a song is below the target level. That is, upon playback, the volume of a quiet song is increased, so the parts of the song with above-average loudness, especially in the bass frequencies, will exceed the limits of the format and will be distorted. Whether this distortion is audible depends on the sounds in question, and the listener&#039;s sensitivity.&lt;br /&gt;
&lt;br /&gt;
Implementations deal with the risk of clipping in different ways. Some have a &amp;quot;pre-amp&amp;quot; feature which reduces (or boosts) the original audio&#039;s level by a certain amount before doing whatever is needed for ReplayGain. Some have a &amp;quot;prevent clipping&amp;quot; feature to reduce the amount of ReplayGain adjustment to whatever amount would keep clipping from occurring, based on peak info stored in the file&#039;s metadata (thus reducing the effectiveness of ReplayGain). Some recommend using a compressor/limiter DSP to prevent or reduce clipping, regardless of whether it was caused by ReplayGain.&lt;br /&gt;
&lt;br /&gt;
An alternative that may reduce the risk of clipping is the [https://tech.ebu.ch/docs/r/r128.pdf EBU R 128] recommendation of a -23&amp;amp;nbsp;LUFS target, but that&#039;s a different standard, and some may find the additional reduction in volume excessive, particularly if it leads to maxing out volume on user hardware. [[Opus]] in particular has adopted that standard, using a global gain as well as &amp;lt;code&amp;gt;R128_TRACK_GAIN&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;R128_ALBUM_GAIN&amp;lt;/code&amp;gt; tags. With ReplayGain, a simple (though somewhat radical) solution is to lower the preamp value by 5&amp;amp;nbsp;dB (or whatever one feels comfortable with) in the playback software. The RG target will always be -18&amp;amp;nbsp;LUFS, regardless of a user&#039;s volume or preamp settings.&lt;br /&gt;
&lt;br /&gt;
== Implementations ==&lt;br /&gt;
There are different ReplayGain implementations, each with its own uses and strength. Most use [[metadata]] to indicate the level of the volume change that the player should make. Some modify the audio data itself, and optionally use metadata as well. There are advantages and disadvantages to both methods.&lt;br /&gt;
&lt;br /&gt;
In the metadata method, information on both types of ReplayGain (Track Gain and Album Gain) can be stored. The volume-change information can be very precise. If audio data was also changed, the metadata can contain &amp;quot;undo&amp;quot; info. Not all audio players/decoders know how to read and use ReplayGain information stored in metadata. And there&#039;s no standard for where and how ReplayGain info is stored; each implementation uses different formats and puts the info in different locations.&lt;br /&gt;
&lt;br /&gt;
In the audio data method, the file&#039;s actual audio data is modified so that its natural/default playback volume is at the target level. In this scenario, only one type of ReplayGain (Track Gain or Album Gain) can be applied. If no &amp;quot;undo&amp;quot; info is saved somewhere, it may not be possible to restore the original audio data. Limitations of the audio file format may prevent precise (finely tuned) gain adjustments with this method. For example, MP3 and AAC files can only be losslessly modified in 1.5 dB steps. Depending on the audio file format, the process may also be lossy in the sense that it could irreversibly push a signal above the format&#039;s maximum amplitude (resulting in clipping) or below the minimum (resulting in silence).&lt;br /&gt;
&lt;br /&gt;
=== Old versus new algorithms ===&lt;br /&gt;
Since the ReplayGain standard does not define tags to specify which algorithm was used (classic or ITU-R BS.1770) or what target was set (RG&#039;s -18&amp;amp;nbsp;LUFS, EBU R 128&#039;s -23&amp;amp;nbsp;LUFS, or any other target set by the user or some piece of software), there may be confusion as to how the results were produced. Typically, utilities that ship with reference encoders (FLAC / metaflac, Vorbis / vorbisgain, WavPack / wvgain, Musepack / mpcgain…) use the original RG algorithm, which can produce values that differ from newer tools by several decibels in certain cases. Generally speaking, it is recommended to run other utilities or players that implement the ITU-R BS.1770 algorithm, although it may not be obvious which algorithm they use at first glance. Their documentation may provide that information.&lt;br /&gt;
&lt;br /&gt;
==== RG1, RG2 ====&lt;br /&gt;
Although there are many references online, and within ReplayGain scanners, about version 1 vs. version 2 of the ReplayGain standard, at the time of writing this, there is (admittedly) only one ReplayGain standard. The core principle, as well as the 4 tags from the original specification, have not changed. More tags have been proposed but they are still subject to debate. As a rule of thumb, tools that advertise &amp;quot;ReplayGain&amp;amp;nbsp;2&amp;quot; compliance employ the newer, more accurate ITU-R BS.1770 algorithm. [[foobar2000]] labels it &amp;quot;EBU R128&amp;quot; but it essentially means the same thing. Should a better algorithm be developed in the future, it will still work towards fulfilling ReplayGain&#039;s original goals, and probably write the same tags.&lt;br /&gt;
&lt;br /&gt;
=== MP3Gain ===&lt;br /&gt;
[[MP3Gain]] is an implementation of classic ReplayGain. It can be used to just analyze files &amp;amp; recommend changes or to also modify the gain. If modifying the gain, it always modifies the global gain fields in the MP3 audio data. It can add somewhat precise metadata, including undo info. The gain can be modified to any target dB, or it can be changed by a specified amount. For balance correction, user-specified changes can even be made on just one channel in simple L/R stereo-mode files (not joint stereo).&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]]&lt;br /&gt;
* Method: Audio + Meta (in APE tag), or Audio only&lt;br /&gt;
* APE tag fields (ASCII bytes):&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values for this file. 3 digits, zero-padded if necessary.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_ALBUM_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values across a set of files scanned as an album. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_UNDO +###,+###,N&amp;lt;/code&amp;gt; - the global gain adjustment to restore the original values in the left and right channels, respectively, followed by an indicator of whether to wrap at the extremes (&amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; means no, &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; means yes). The adjustment values are 3 digits, zero-padded, preceded by a sign (&amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;).&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Examples: &amp;lt;code&amp;gt;+0.424046&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-10.38500&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Example: &amp;lt;code&amp;gt;0.149923&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Optional.&lt;br /&gt;
* Limitations: Although the metadata, if written, contains precise adjustment &amp;amp; peak values, the audio data modifications are limited to 1.5dB steps and may become irreversible (however, that&#039;s a very rare condition; see the [https://hydrogenaud.io/index.php/topic,34154.0.html &amp;quot;mp3gain is NOT lossless&amp;quot; forum thread])&lt;br /&gt;
* http://mp3gain.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== AACGain ===&lt;br /&gt;
[[AACGain]] is a modified version of MP3Gain that works on both MP3 and AAC files.&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]], [[AAC]] (with or without MP4 container)&lt;br /&gt;
* Method: Audio + Meta, or Audio only&lt;br /&gt;
* Limitations: Limited to 1.5dB steps mode, may become irreversible (same caveat as for MP3Gain)&lt;br /&gt;
* http://aacgain.altosdesign.com/&lt;br /&gt;
&lt;br /&gt;
=== [[LAME]] ===&lt;br /&gt;
* Method: Header ([http://gabriel.mp3-tech.org/mp3infotag.html mp3infotag])&lt;br /&gt;
* Notes:&lt;br /&gt;
** Uses the classic RG algorithm.&lt;br /&gt;
** Tags added during encoding; not supported by any player yet; Track Gain only&lt;br /&gt;
** Replay Gaining MP3&#039;s is usually done using MP3Gain (see [[ReplayGain#MP3Gain|above]]) or [[ReplayGain#foobar2000 ReplayGain scanner|foobar2000]]&lt;br /&gt;
* http://lame.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== [[Musepack]] ReplayGain ===&lt;br /&gt;
* Method: Header (similar to Meta data method)&lt;br /&gt;
* Notes: Uses the classic RG algorithm. ReplayGain values are stored in the header and ReplayGain is part of the Musepack specifications; therefore any Musepack decoder that does not support ReplayGain can be considered broken.&lt;br /&gt;
* http://www.musepack.net/&lt;br /&gt;
&lt;br /&gt;
=== VorbisGain ===&lt;br /&gt;
* Format: (Ogg) [[Vorbis]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://www.sjeng.org/vorbisgain.html&lt;br /&gt;
** new compiles of VorbisGain at [http://www.rarewares.org/ogg.html www.rarewares.org]&lt;br /&gt;
:&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Andavari has provided a very useful script to integrate VorbisGain, which is a CLI tool, into Windows Explorer. Please (Ogg) [[Vorbis#ReplayGain|check this section]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== FLAC / METAFLAC ===&lt;br /&gt;
* Format: [[Free Lossless Audio Codec|FLAC]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://flac.sf.net&lt;br /&gt;
&lt;br /&gt;
=== WavPack / WVGAIN ===&lt;br /&gt;
* Format: [[WavPack]]&lt;br /&gt;
* Method: Meta (in [[APEv2]] tag)&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://www.wavpack.com&lt;br /&gt;
&lt;br /&gt;
=== Wavegain ===&lt;br /&gt;
* Format: waveform&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* Limitations: Irreversible&lt;br /&gt;
* http://www.rarewares.org/others.php#wavegain&lt;br /&gt;
&lt;br /&gt;
=== MusicPlayer ===&lt;br /&gt;
* Custom implementation, inspired by MP3Gain.&lt;br /&gt;
* Format: any that FFmpeg supports&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Limitations: Doesn&#039;t modify the files at all. Stores the value in own database. Used only for playback.&lt;br /&gt;
* https://github.com/albertz/music-player&lt;br /&gt;
&lt;br /&gt;
=== [[foobar2000]] ReplayGain scanner ===&lt;br /&gt;
* Since v1.1.6, defaults to ITU-R BS.1770 analysis (although it labels it EBU R128), but can be configured to use the &amp;quot;Classic ReplayGain&amp;quot; algorithm instead. The ITU-R BS.1770 implementation uses a reference level of -18&amp;amp;nbsp;LUFS instead of -23, in order to retain compatibility with the ReplayGain standard.&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] (default) or [[APEv2]] tags.&lt;br /&gt;
** [[Musepack]]: Values written to header.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[Opus]]: Values written to [[Vorbis comment]] and/or file header.&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags. As with MP3, it is also an option to apply gain via a separate function.&lt;br /&gt;
** [[MP4]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain). Can write chosen Gain value to Apple&#039;s SoundCheck&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[TAK]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[TTA]]: Values written to [[APEv2]] or [[ID3v2]] tags.&lt;br /&gt;
** [[WMA]]: Values written to WMA tags.&lt;br /&gt;
** Modules ([[MOD]] etc.): Optionally saved into [[APEv2]] tags.&lt;br /&gt;
** Any non-taggable format or format supported by FFmpeg can store RG values in a database or external tag with a component.&lt;br /&gt;
** A separate function can be invoked to apply the tagged Track or Album Gain to the global gain fields in MP3, MP4 (AAC), or Opus files, and rewrite any existing tags to account for the peak change and compensate for the difference from 89&amp;amp;nbsp;dB. The 89&amp;amp;nbsp;dB reference level for tags isn&#039;t configurable, but the reference level applied to the global gain fields is.&lt;br /&gt;
** Can automatically copy Track or Album gain values to Apple&#039;s SoundCheck tag in MP4 files or any format that supports ID3v2 to effectively add ReplayGain support to Apple&#039;s players.&lt;br /&gt;
* https://foobar2000.org/&lt;br /&gt;
&lt;br /&gt;
=== [[MediaMonkey]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[APEv2]] or [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[WAV]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[MPC]]: Internal gain Structure.&lt;br /&gt;
* In addition to tags, all ReplayGain values are also stored in MediaMonkey&#039;s MDB database&lt;br /&gt;
* Album/Audiophile ReplayGain not supported until v3.0 (Dec 2007); support during burning &amp;amp; ripping added in 3.1 (Jun 2009)&lt;br /&gt;
* Also capable of (irreversibly) changing the volume of MP3 tracks, similar to [[MP3Gain]]&lt;br /&gt;
* http://www.mediamonkey.com/&lt;br /&gt;
&lt;br /&gt;
=== [[Winamp]] ReplayGain scanner===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in Windows Media Audio tags.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[MP4]]&lt;br /&gt;
** [[TAK]]: Values written to [[APEv2]] tags.&lt;br /&gt;
* Support Album/Track Gain&lt;br /&gt;
&lt;br /&gt;
=== [[loudgain]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** MP2, [[MP3]]: Values written to [[ID3v2]] tags (ID3v2.3/ID3v2.4 selectable).&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Speex]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[Opus]]: Values written to [[Vorbis comment]], based on -23&amp;amp;nbsp;LUFS Opus standard. Only &amp;lt;code&amp;gt;R128_TRACK_GAIN&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;R128_ALBUM_GAIN&amp;lt;/code&amp;gt; are written, but the calculated &#039;&#039;true peak&#039;&#039; value can still be used to reduce the gain values ([[Clipping]] prevention).&lt;br /&gt;
** [[MP4]], [[M4A]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain). ReplayGain values are stored under &amp;lt;code&amp;gt;----:com.apple.iTunes:…&amp;lt;/code&amp;gt;. This is for [[AAC]] and [[ALAC]] in [[MPEG-4]] containers.&lt;br /&gt;
** [[ASF]], [[Windows Media Audio|WMA]]: Values written to WMA tags, no prefix.&lt;br /&gt;
** [[WAV]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] (ID3v2.3/ID3v2.4 selectable) format. Using the &amp;lt;code&amp;gt;bext&amp;lt;/code&amp;gt; chunk (for BWF v2) isn’t (yet) supported, but won’t be destroyed on writing.&lt;br /&gt;
** [[Audio Interchange File Format|AIFF]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] format.&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[Monkey&#039;s Audio]] (APE): Values written to [[APEv2]] tags.&lt;br /&gt;
* Follows EBU R128, ITU BS.1770 and the [[ReplayGain 2.0 specification|revised ReplayGain specification]].&lt;br /&gt;
* &#039;&#039;Never&#039;&#039; touches the actual audio data but &#039;&#039;only writes RG2 tags&#039;&#039;.&lt;br /&gt;
* Uses &#039;&#039;true peak&#039;&#039; values calculated by oversampling to 192&amp;amp;nbsp;kHz, using a custom polyphase FIR interpolator that will oversample 4x for sample rates &amp;lt; 96&amp;amp;nbsp;kHz, 2x for sample rates &amp;lt; 192&amp;amp;nbsp;kHz and leave the signal unchanged for 192&amp;amp;nbsp;kHz.&lt;br /&gt;
* &#039;&#039;Clipping prevention&#039;&#039; can be used to lower the ReplayGain values to a safe margin (default -1&amp;amp;nbsp;dBTP, can be changed).&lt;br /&gt;
* Many options for special cases: force RG tags upper-/lowercase, add extra tags (LRA, Reference loudness), strip unwanted tag types (APEv2 from MP2/MP3, ID3 from WavPack), tab-delimited table output for analysis with CSV file.&lt;br /&gt;
* &#039;&#039;Linux&#039;&#039; Free and Open Source software, can be installed on &#039;&#039;MacOS&#039;&#039; using &#039;&#039;HomeBrew&#039;&#039;, on &#039;&#039;Windows 10&#039;&#039; using the Linux &#039;&#039;bash&#039;&#039;.&lt;br /&gt;
* Also installs a &amp;lt;code&amp;gt;rgbpm&amp;lt;/code&amp;gt; bash script for mass-tagging, which can be adapted to the user’s needs.&lt;br /&gt;
* &#039;&#039;&#039;Warning:&#039;&#039;&#039; Loudgain relies on standard libraries like &#039;&#039;TagLib&#039;&#039;. Linux distros (except rolling releases) sometimes deliver outdated libraries, so be sure you use the latest version of &#039;&#039;TagLib&#039;&#039;. Version 1.11.1 had a nasty bug for a while that [https://hydrogenaud.io/index.php/topic,118085.msg974957.html#msg974957 could corrupt Ogg Vorbis files]. This has been fixed in the meantime but the TagLib version not updated. Loudgain comes with a (slower) static version called &amp;lt;code&amp;gt;loudgain.static&amp;lt;/code&amp;gt; in the repo’s &amp;lt;code&amp;gt;/bin&amp;lt;/code&amp;gt; folder that doesn’t expose the bug and can also be used on older Linux versions (like Ubuntu 14.04, Linux Mint 17).&lt;br /&gt;
* https://github.com/Moonbase59/loudgain&lt;br /&gt;
* Bug tracker: https://github.com/Moonbase59/loudgain/issues&lt;br /&gt;
&lt;br /&gt;
=== [[rsgain]] ===&lt;br /&gt;
rsgain is a newer ReplayGain command line utility designed with a &amp;quot;batteries included&amp;quot; philosophy, use the newer ITU-R BS.1770 algorithm.&lt;br /&gt;
&lt;br /&gt;
Features:&lt;br /&gt;
* Cross-platform Windows&amp;amp;nbsp;/&amp;amp;nbsp;macOS&amp;amp;nbsp;/&amp;amp;nbsp;Linux&lt;br /&gt;
* Supports all popular audio formats&lt;br /&gt;
* Simplified &amp;quot;Easy Mode&amp;quot; command line syntax supports recursive, directory-based scanning&lt;br /&gt;
* Multithreaded scanning option that provides significant speed improvement with full library scans&lt;br /&gt;
* Option to skip files with existing ReplayGain metadata&lt;br /&gt;
* Scan presets allow the user to save advanced settings for consistent use&lt;br /&gt;
&lt;br /&gt;
== Players support ==&lt;br /&gt;
ReplayGain being present in the specs of the FLAC, Musepack, and APE formats, any player that support those formats usually supports ReplayGain.&lt;br /&gt;
&lt;br /&gt;
The situation with MP3 is rather different, as it was not part of the MP3 specs. The APEv2 tags metadata implementation is somewhat becoming the de-facto standard.&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
* [[foobar2000]] supports ReplayGain in all possible aspects.&lt;br /&gt;
* [[Winamp]] supports ReplayGain in album or track mode.&lt;br /&gt;
* [[MediaMonkey]] supports ReplayGain, with many configuration options.&lt;br /&gt;
* [[XMPlay]] recently implemented ReplayGain&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;...and probably others.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
* [[XMMS]]. Reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], [[Musepack]], (Ogg) [[Vorbis]] ..&lt;br /&gt;
:For [[MP3]], use the CVS version of the [http://xmms-mad.sourceforge.net/ xmms-mad] mp3 plugin (it&#039;s not yet released as binary, furthermore not available in distribs&#039; versions for now. Meanwhile binaries are available here: [http://perso.crans.org/~krempp/xmms-mad/ custom binaries])&lt;br /&gt;
* [[amarok]]. By using the amarok-script [http://kde-apps.org/content/show.php?content=26073 ReplayGain]&lt;br /&gt;
:And possibly others, since [http://developer.kde.org/~wheeler/taglib.html TagLib] added support for [[APEv2]] tags in [[MP3]] files, players using this library (like [[amaroK]] and [[JuK]]) might support that kind of ReplayGain tags in the near future.&lt;br /&gt;
* [http://www.sacredchao.net/quodlibet Quod Libet] reads ReplayGain from (Ogg) [[Vorbis]], [[MP3]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:Requires support to be enabled (via the appropriate python bindings and libraries) for the above formats. Does not support ReplayGain values stored in [[APEv2]] tags in [[MP3]]s. ReplayGain values are stored in RVA2 id3v2.4 frames. See the [http://www.sacredchao.net/quodlibet/wiki/Development/ID3Notes Quod Libet RVA2 / ReplayGain notes].&lt;br /&gt;
* [http://www.musicpd.org/ Music Player Daemon] (MPD) reads ReplayGain from (Ogg) [[Vorbis]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:foobar2000-style TXXX frames in [[MP3]]s are also supported in the latest development releases.&lt;br /&gt;
* [http://www.mplayerhq.hu/ MPlayer]. Mplayer support for ReplayGain is codec dependent.&lt;br /&gt;
:Codecs that are known to support ReplayGain: vorbis&lt;br /&gt;
:Because of this, you need to prioritize the codecs that support it, or choose it individually on the command line.  To add it to the command line, add an -ac [codec] option after each file that you want to choose the codec for, or at the beginning to make it apply to all files listed.  To prioritize the codecs by default, list them in a line in mplayer.conf:&lt;br /&gt;
 ac=[codec],[othercodec],vorbis,mad,&lt;br /&gt;
* [http://idjc.sourceforge.net/ IDJC] (Internet DJ Console) reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], (Ogg) FLAC, (Ogg) [[Vorbis]], MP2 (audio), [[MP3]], [[Opus]], but only the &#039;&#039;lowercase&#039;&#039; tags. There is a [https://sourceforge.net/p/idjc/bugs/100/ ticket] open to handle tags case-insensitively.&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
* [https://www.videolan.org/vlc/ VLC] supports ReplayGain in many file formats, but usually only the &#039;&#039;uppercase&#039;&#039; variant of the tags.&lt;br /&gt;
* [https://kodi.tv/ KODI] reads ReplayGain from nearly all formats, but usually only the &#039;&#039;lowercase&#039;&#039; variant of the tags.&lt;br /&gt;
&lt;br /&gt;
=== Portable devices ===&lt;br /&gt;
[http://www.rockbox.org/ Rockbox] supports ReplayGain (in album or track mode) for most formats, including  WMA, MP1/2/3, AAC, ALAC, Musepack, Monkey&#039;s Audio, Wavpack, FLAC and Vorbis.  &amp;lt;br&amp;gt;Note that ReplayGain is only supported when using the respective codec&#039;s native tagging format.  For example:  ReplayGain stored in APEv2 tags is not supported for MP3, rather ID3v2.x tags are expected.&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Fuze with firmware 1.02.26 and 2.02.26&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Clip+&lt;br /&gt;
&lt;br /&gt;
The iPod features &#039;&#039;Soundcheck&#039;&#039;, which seems to produce roughly the same normalization gains as ReplayGain, but doesn&#039;t provide an Album Gain.&lt;br /&gt;
&lt;br /&gt;
=== Hi-Fi ===&lt;br /&gt;
Slim Devices, a company owned by Logitech Inc, supports ReplayGain on both of their hi-end audiophile players, known as the [[Slim Devices Transporter|Transporter]] and the [[Slim Devices Squeezebox|Squeezebox]].&lt;br /&gt;
&lt;br /&gt;
BluOS also supports ReplayGain with the selection of album- or track-gain and a so called Smart option that decides between the two by itself.&lt;br /&gt;
NAD devices that use BluOS consequently also support ReplayGain.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;references/&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[ReplayGain specification]]&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Replay_Gain ReplayGain] at Wikipedia&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain.html ReplayGain using foobar2000] (how to use ReplayGain in Windows using foobar2000).&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain-in-Linux.html ReplayGain in Linux] (how to use ReplayGain in Linux using foobar2000 and Wine, or using metaflac or vorbisgain).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Technical]]&lt;br /&gt;
[[index.php?title=Category:Metadata]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38805</id>
		<title>ReplayGain</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38805"/>
		<updated>2026-01-23T09:09:58Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Clarification about possible clipping with the ReplayGain target level.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;ReplayGain&#039;&#039;&#039; is the name of a technique invented to achieve the same perceived playback loudness of audio files. It defines an algorithm to measure the &#039;&#039;&#039;perceived&#039;&#039;&#039; loudness of audio data.&lt;br /&gt;
&lt;br /&gt;
ReplayGain allows the loudness of each song within a collection of songs to be consistent. This is called &#039;Track Gain&#039; (or &#039;Radio Gain&#039; in earlier parlance). It also allows the loudness of a specific sub-collection (an &amp;quot;album&amp;quot;) to be consistent with the rest of the collection, while allowing the dynamics from song to song on the album to remain intact. This is called &#039;Album Gain&#039; (or &#039;Audiophile Gain&#039; in earlier parlance). This is especially important when listening to classical music albums, because quiet tracks need to remain a certain degree quieter than the louder ones.&lt;br /&gt;
&lt;br /&gt;
ReplayGain is different from [[Normalization|peak normalization]]. Peak normalization merely ensures that the peak amplitude reaches a certain level. This does not ensure equal loudness. The ReplayGain technique measures the &#039;&#039;effective power&#039;&#039; of the waveform (i.e. the RMS power after applying an &amp;quot;equal loudness contour&amp;quot;), and then adjusts the amplitude of the waveform accordingly. The result is that Replay Gained waveforms are usually more uniformly amplified than peak-normalized waveforms.&lt;br /&gt;
&lt;br /&gt;
==Target loudness==&lt;br /&gt;
The target loudness of all ReplayGain utilities is 89&amp;amp;nbsp;dB SPL when replayed in an SMPTE RP 200 calibrated system (an early departure from the proposal, endorsed by its author&amp;lt;ref&amp;gt;[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=83397&amp;amp;view=findpost&amp;amp;p=721854 Does Replay gain work differtly in Media monkey]&amp;lt;/ref&amp;gt;) &amp;amp;mdash; the ReplayGain proposal and SMPTE recommendation are 6&amp;amp;nbsp;dB lower.&amp;lt;ref&amp;gt;[http://www.mars.org/mailman/public/mad-dev/2004-February/000993.html ReplayGain discussion at mad-dev]&amp;lt;/ref&amp;gt; The target loudness may be more commonly known and understood as &#039;&#039;&#039;-18&#039;&#039;&#039;&amp;amp;nbsp;&#039;&#039;&#039;[https://en.wikipedia.org/wiki/LUFS LUFS]&#039;&#039;&#039; (&#039;&#039;Loudness Units relative to Full Scale&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Some utilities have realized the inadequacies of the classic ReplayGain loudness calculation, switching to a more modern algorithm ([https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en ITU-R BS.1770]). However, the way it was integrated was extremely &#039;&#039;ad hoc&#039;&#039;, at least until a draft of a [[ReplayGain 2.0 specification|revised specification]] started being written.&lt;br /&gt;
&lt;br /&gt;
==Clipping==&lt;br /&gt;
Audio is generally recorded such that the loudest sounds don&#039;t clip, but the use of ReplayGain can cause clipping if the average volume of a song is below the target level. That is, upon playback, the volume of a quiet song is increased, so the parts of the song with above-average loudness, especially in the bass frequencies, will exceed the limits of the format and will be distorted. Whether this distortion is audible depends on the sounds in question, and the listener&#039;s sensitivity.&lt;br /&gt;
&lt;br /&gt;
Implementations deal with the risk of clipping in different ways. Some have a &amp;quot;pre-amp&amp;quot; feature which reduces (or boosts) the original audio&#039;s level by a certain amount before doing whatever is needed for ReplayGain. Some have a &amp;quot;prevent clipping&amp;quot; feature to reduce the amount of ReplayGain adjustment to whatever amount would keep clipping from occurring, based on peak info stored in the file&#039;s metadata (thus reducing the effectiveness of ReplayGain). Some recommend using a compressor/limiter DSP to prevent or reduce clipping, regardless of whether it was caused by ReplayGain.&lt;br /&gt;
&lt;br /&gt;
An alternative that may reduce the risk of clipping is the [https://tech.ebu.ch/docs/r/r128.pdf EBU R 128] recommendation of a &#039;&#039;&#039;-23&#039;&#039;&#039;&amp;amp;nbsp;&#039;&#039;&#039;LUFS&#039;&#039;&#039; target, but that&#039;s a different standard, and some may find the additional reduction in volume excessive, particularly if it leads to maxing out volume on user hardware. [[Opus]] in particular has adopted that standard, using a global gain as well as &amp;lt;code&amp;gt;R128_TRACK_GAIN&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;R128_ALBUM_GAIN&amp;lt;/code&amp;gt; tags. With ReplayGain, a simple (though somewhat radical) solution is to lower the preamp value by 5&amp;amp;nbsp;dB (or whatever one feels comfortable with) in the playback software.&lt;br /&gt;
&lt;br /&gt;
== Implementations ==&lt;br /&gt;
There are different ReplayGain implementations, each with its own uses and strength. Most use [[metadata]] to indicate the level of the volume change that the player should make. Some modify the audio data itself, and optionally use metadata as well. There are advantages and disadvantages to both methods.&lt;br /&gt;
&lt;br /&gt;
In the metadata method, information on both types of ReplayGain (Track Gain and Album Gain) can be stored. The volume-change information can be very precise. If audio data was also changed, the metadata can contain &amp;quot;undo&amp;quot; info. Not all audio players/decoders know how to read and use ReplayGain information stored in metadata. And there&#039;s no standard for where and how ReplayGain info is stored; each implementation uses different formats and puts the info in different locations.&lt;br /&gt;
&lt;br /&gt;
In the audio data method, the file&#039;s actual audio data is modified so that its natural/default playback volume is at the target level. In this scenario, only one type of ReplayGain (Track Gain or Album Gain) can be applied. If no &amp;quot;undo&amp;quot; info is saved somewhere, it may not be possible to restore the original audio data. Limitations of the audio file format may prevent precise (finely tuned) gain adjustments with this method. For example, MP3 and AAC files can only be losslessly modified in 1.5 dB steps. Depending on the audio file format, the process may also be lossy in the sense that it could irreversibly push a signal above the format&#039;s maximum amplitude (resulting in clipping) or below the minimum (resulting in silence).&lt;br /&gt;
&lt;br /&gt;
=== Old versus new algorithms ===&lt;br /&gt;
Since the ReplayGain standard does not define tags to specify which algorithm was used (classic or ITU-R BS.1770) or what target was set (RG&#039;s -18&amp;amp;nbsp;LUFS, EBU R 128&#039;s -23&amp;amp;nbsp;LUFS, or any other target set by the user or some piece of software), there may be confusion as to how the results were produced. Typically, utilities that ship with reference encoders (FLAC / metaflac, Vorbis / vorbisgain, WavPack / wvgain, Musepack / mpcgain…) use the original RG algorithm, which can produce values that differ from newer tools by several decibels in certain cases. Generally speaking, it is recommended to run other utilities or players that implement the ITU-R BS.1770 algorithm, although it may not be obvious which algorithm they use at first glance. Their documentation may provide that information.&lt;br /&gt;
&lt;br /&gt;
==== RG1, RG2 ====&lt;br /&gt;
Although there are many references online, and within ReplayGain scanners, about version 1 vs. version 2 of the ReplayGain standard, at the time of writing this, there is (admittedly) only one ReplayGain standard. The core principle, as well as the 4 tags from the original specification, have not changed. More tags have been proposed but they are still subject to debate. As a rule of thumb, tools that advertise &amp;quot;ReplayGain&amp;amp;nbsp;2&amp;quot; compliance employ the newer, more accurate ITU-R BS.1770 algorithm. [[foobar2000]] labels it &amp;quot;EBU R128&amp;quot; but it essentially means the same thing. Should a better algorithm be developed in the future, it will still work towards fulfilling ReplayGain&#039;s original goals, and probably write the same tags.&lt;br /&gt;
&lt;br /&gt;
=== MP3Gain ===&lt;br /&gt;
[[MP3Gain]] is an implementation of classic ReplayGain. It can be used to just analyze files &amp;amp; recommend changes or to also modify the gain. If modifying the gain, it always modifies the global gain fields in the MP3 audio data. It can add somewhat precise metadata, including undo info. The gain can be modified to any target dB, or it can be changed by a specified amount. For balance correction, user-specified changes can even be made on just one channel in simple L/R stereo-mode files (not joint stereo).&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]]&lt;br /&gt;
* Method: Audio + Meta (in APE tag), or Audio only&lt;br /&gt;
* APE tag fields (ASCII bytes):&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values for this file. 3 digits, zero-padded if necessary.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_ALBUM_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values across a set of files scanned as an album. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_UNDO +###,+###,N&amp;lt;/code&amp;gt; - the global gain adjustment to restore the original values in the left and right channels, respectively, followed by an indicator of whether to wrap at the extremes (&amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; means no, &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; means yes). The adjustment values are 3 digits, zero-padded, preceded by a sign (&amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;).&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Examples: &amp;lt;code&amp;gt;+0.424046&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-10.38500&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Example: &amp;lt;code&amp;gt;0.149923&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Optional.&lt;br /&gt;
* Limitations: Although the metadata, if written, contains precise adjustment &amp;amp; peak values, the audio data modifications are limited to 1.5dB steps and may become irreversible (however, that&#039;s a very rare condition; see the [https://hydrogenaud.io/index.php/topic,34154.0.html &amp;quot;mp3gain is NOT lossless&amp;quot; forum thread])&lt;br /&gt;
* http://mp3gain.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== AACGain ===&lt;br /&gt;
[[AACGain]] is a modified version of MP3Gain that works on both MP3 and AAC files.&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]], [[AAC]] (with or without MP4 container)&lt;br /&gt;
* Method: Audio + Meta, or Audio only&lt;br /&gt;
* Limitations: Limited to 1.5dB steps mode, may become irreversible (same caveat as for MP3Gain)&lt;br /&gt;
* http://aacgain.altosdesign.com/&lt;br /&gt;
&lt;br /&gt;
=== [[LAME]] ===&lt;br /&gt;
* Method: Header ([http://gabriel.mp3-tech.org/mp3infotag.html mp3infotag])&lt;br /&gt;
* Notes:&lt;br /&gt;
** Uses the classic RG algorithm.&lt;br /&gt;
** Tags added during encoding; not supported by any player yet; Track Gain only&lt;br /&gt;
** Replay Gaining MP3&#039;s is usually done using MP3Gain (see [[ReplayGain#MP3Gain|above]]) or [[ReplayGain#foobar2000 ReplayGain scanner|foobar2000]]&lt;br /&gt;
* http://lame.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== [[Musepack]] ReplayGain ===&lt;br /&gt;
* Method: Header (similar to Meta data method)&lt;br /&gt;
* Notes: Uses the classic RG algorithm. ReplayGain values are stored in the header and ReplayGain is part of the Musepack specifications; therefore any Musepack decoder that does not support ReplayGain can be considered broken.&lt;br /&gt;
* http://www.musepack.net/&lt;br /&gt;
&lt;br /&gt;
=== VorbisGain ===&lt;br /&gt;
* Format: (Ogg) [[Vorbis]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://www.sjeng.org/vorbisgain.html&lt;br /&gt;
** new compiles of VorbisGain at [http://www.rarewares.org/ogg.html www.rarewares.org]&lt;br /&gt;
:&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Andavari has provided a very useful script to integrate VorbisGain, which is a CLI tool, into Windows Explorer. Please (Ogg) [[Vorbis#ReplayGain|check this section]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== FLAC / METAFLAC ===&lt;br /&gt;
* Format: [[Free Lossless Audio Codec|FLAC]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://flac.sf.net&lt;br /&gt;
&lt;br /&gt;
=== WavPack / WVGAIN ===&lt;br /&gt;
* Format: [[WavPack]]&lt;br /&gt;
* Method: Meta (in [[APEv2]] tag)&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://www.wavpack.com&lt;br /&gt;
&lt;br /&gt;
=== Wavegain ===&lt;br /&gt;
* Format: waveform&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* Limitations: Irreversible&lt;br /&gt;
* http://www.rarewares.org/others.php#wavegain&lt;br /&gt;
&lt;br /&gt;
=== MusicPlayer ===&lt;br /&gt;
* Custom implementation, inspired by MP3Gain.&lt;br /&gt;
* Format: any that FFmpeg supports&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Limitations: Doesn&#039;t modify the files at all. Stores the value in own database. Used only for playback.&lt;br /&gt;
* https://github.com/albertz/music-player&lt;br /&gt;
&lt;br /&gt;
=== [[foobar2000]] ReplayGain scanner ===&lt;br /&gt;
* Since v1.1.6, defaults to ITU-R BS.1770 analysis (although it labels it EBU R128), but can be configured to use the &amp;quot;Classic ReplayGain&amp;quot; algorithm instead. The ITU-R BS.1770 implementation uses a reference level of -18&amp;amp;nbsp;LUFS instead of -23, in order to retain compatibility with the ReplayGain standard.&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] (default) or [[APEv2]] tags.&lt;br /&gt;
** [[Musepack]]: Values written to header.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[Opus]]: Values written to [[Vorbis comment]] and/or file header.&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags. As with MP3, it is also an option to apply gain via a separate function.&lt;br /&gt;
** [[MP4]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain). Can write chosen Gain value to Apple&#039;s SoundCheck&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[TAK]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[TTA]]: Values written to [[APEv2]] or [[ID3v2]] tags.&lt;br /&gt;
** [[WMA]]: Values written to WMA tags.&lt;br /&gt;
** Modules ([[MOD]] etc.): Optionally saved into [[APEv2]] tags.&lt;br /&gt;
** Any non-taggable format or format supported by FFmpeg can store RG values in a database or external tag with a component.&lt;br /&gt;
** A separate function can be invoked to apply the tagged Track or Album Gain to the global gain fields in MP3, MP4 (AAC), or Opus files, and rewrite any existing tags to account for the peak change and compensate for the difference from 89&amp;amp;nbsp;dB. The 89&amp;amp;nbsp;dB reference level for tags isn&#039;t configurable, but the reference level applied to the global gain fields is.&lt;br /&gt;
** Can automatically copy Track or Album gain values to Apple&#039;s SoundCheck tag in MP4 files or any format that supports ID3v2 to effectively add ReplayGain support to Apple&#039;s players.&lt;br /&gt;
* https://foobar2000.org/&lt;br /&gt;
&lt;br /&gt;
=== [[MediaMonkey]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[APEv2]] or [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[WAV]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[MPC]]: Internal gain Structure.&lt;br /&gt;
* In addition to tags, all ReplayGain values are also stored in MediaMonkey&#039;s MDB database&lt;br /&gt;
* Album/Audiophile ReplayGain not supported until v3.0 (Dec 2007); support during burning &amp;amp; ripping added in 3.1 (Jun 2009)&lt;br /&gt;
* Also capable of (irreversibly) changing the volume of MP3 tracks, similar to [[MP3Gain]]&lt;br /&gt;
* http://www.mediamonkey.com/&lt;br /&gt;
&lt;br /&gt;
=== [[Winamp]] ReplayGain scanner===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in Windows Media Audio tags.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[MP4]]&lt;br /&gt;
** [[TAK]]: Values written to [[APEv2]] tags.&lt;br /&gt;
* Support Album/Track Gain&lt;br /&gt;
&lt;br /&gt;
=== [[loudgain]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** MP2, [[MP3]]: Values written to [[ID3v2]] tags (ID3v2.3/ID3v2.4 selectable).&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Speex]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[Opus]]: Values written to [[Vorbis comment]], based on -23&amp;amp;nbsp;LUFS Opus standard. Only &amp;lt;code&amp;gt;R128_TRACK_GAIN&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;R128_ALBUM_GAIN&amp;lt;/code&amp;gt; are written, but the calculated &#039;&#039;true peak&#039;&#039; value can still be used to reduce the gain values ([[Clipping]] prevention).&lt;br /&gt;
** [[MP4]], [[M4A]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain). ReplayGain values are stored under &amp;lt;code&amp;gt;----:com.apple.iTunes:…&amp;lt;/code&amp;gt;. This is for [[AAC]] and [[ALAC]] in [[MPEG-4]] containers.&lt;br /&gt;
** [[ASF]], [[Windows Media Audio|WMA]]: Values written to WMA tags, no prefix.&lt;br /&gt;
** [[WAV]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] (ID3v2.3/ID3v2.4 selectable) format. Using the &amp;lt;code&amp;gt;bext&amp;lt;/code&amp;gt; chunk (for BWF v2) isn’t (yet) supported, but won’t be destroyed on writing.&lt;br /&gt;
** [[Audio Interchange File Format|AIFF]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] format.&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[Monkey&#039;s Audio]] (APE): Values written to [[APEv2]] tags.&lt;br /&gt;
* Follows EBU R128, ITU BS.1770 and the [[ReplayGain 2.0 specification|revised ReplayGain specification]].&lt;br /&gt;
* &#039;&#039;Never&#039;&#039; touches the actual audio data but &#039;&#039;only writes RG2 tags&#039;&#039;.&lt;br /&gt;
* Uses &#039;&#039;true peak&#039;&#039; values calculated by oversampling to 192&amp;amp;nbsp;kHz, using a custom polyphase FIR interpolator that will oversample 4x for sample rates &amp;lt; 96&amp;amp;nbsp;kHz, 2x for sample rates &amp;lt; 192&amp;amp;nbsp;kHz and leave the signal unchanged for 192&amp;amp;nbsp;kHz.&lt;br /&gt;
* &#039;&#039;Clipping prevention&#039;&#039; can be used to lower the ReplayGain values to a safe margin (default -1&amp;amp;nbsp;dBTP, can be changed).&lt;br /&gt;
* Many options for special cases: force RG tags upper-/lowercase, add extra tags (LRA, Reference loudness), strip unwanted tag types (APEv2 from MP2/MP3, ID3 from WavPack), tab-delimited table output for analysis with CSV file.&lt;br /&gt;
* &#039;&#039;Linux&#039;&#039; Free and Open Source software, can be installed on &#039;&#039;MacOS&#039;&#039; using &#039;&#039;HomeBrew&#039;&#039;, on &#039;&#039;Windows 10&#039;&#039; using the Linux &#039;&#039;bash&#039;&#039;.&lt;br /&gt;
* Also installs a &amp;lt;code&amp;gt;rgbpm&amp;lt;/code&amp;gt; bash script for mass-tagging, which can be adapted to the user’s needs.&lt;br /&gt;
* &#039;&#039;&#039;Warning:&#039;&#039;&#039; Loudgain relies on standard libraries like &#039;&#039;TagLib&#039;&#039;. Linux distros (except rolling releases) sometimes deliver outdated libraries, so be sure you use the latest version of &#039;&#039;TagLib&#039;&#039;. Version 1.11.1 had a nasty bug for a while that [https://hydrogenaud.io/index.php/topic,118085.msg974957.html#msg974957 could corrupt Ogg Vorbis files]. This has been fixed in the meantime but the TagLib version not updated. Loudgain comes with a (slower) static version called &amp;lt;code&amp;gt;loudgain.static&amp;lt;/code&amp;gt; in the repo’s &amp;lt;code&amp;gt;/bin&amp;lt;/code&amp;gt; folder that doesn’t expose the bug and can also be used on older Linux versions (like Ubuntu 14.04, Linux Mint 17).&lt;br /&gt;
* https://github.com/Moonbase59/loudgain&lt;br /&gt;
* Bug tracker: https://github.com/Moonbase59/loudgain/issues&lt;br /&gt;
&lt;br /&gt;
=== [[rsgain]] ===&lt;br /&gt;
rsgain is a newer ReplayGain command line utility designed with a &amp;quot;batteries included&amp;quot; philosophy, use the newer ITU-R BS.1770 algorithm.&lt;br /&gt;
&lt;br /&gt;
Features:&lt;br /&gt;
* Cross-platform Windows&amp;amp;nbsp;/&amp;amp;nbsp;macOS&amp;amp;nbsp;/&amp;amp;nbsp;Linux&lt;br /&gt;
* Supports all popular audio formats&lt;br /&gt;
* Simplified &amp;quot;Easy Mode&amp;quot; command line syntax supports recursive, directory-based scanning&lt;br /&gt;
* Multithreaded scanning option that provides significant speed improvement with full library scans&lt;br /&gt;
* Option to skip files with existing ReplayGain metadata&lt;br /&gt;
* Scan presets allow the user to save advanced settings for consistent use&lt;br /&gt;
&lt;br /&gt;
== Players support ==&lt;br /&gt;
ReplayGain being present in the specs of the FLAC, Musepack, and APE formats, any player that support those formats usually supports ReplayGain.&lt;br /&gt;
&lt;br /&gt;
The situation with MP3 is rather different, as it was not part of the MP3 specs. The APEv2 tags metadata implementation is somewhat becoming the de-facto standard.&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
* [[foobar2000]] supports ReplayGain in all possible aspects.&lt;br /&gt;
* [[Winamp]] supports ReplayGain in album or track mode.&lt;br /&gt;
* [[MediaMonkey]] supports ReplayGain, with many configuration options.&lt;br /&gt;
* [[XMPlay]] recently implemented ReplayGain&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;...and probably others.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
* [[XMMS]]. Reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], [[Musepack]], (Ogg) [[Vorbis]] ..&lt;br /&gt;
:For [[MP3]], use the CVS version of the [http://xmms-mad.sourceforge.net/ xmms-mad] mp3 plugin (it&#039;s not yet released as binary, furthermore not available in distribs&#039; versions for now. Meanwhile binaries are available here: [http://perso.crans.org/~krempp/xmms-mad/ custom binaries])&lt;br /&gt;
* [[amarok]]. By using the amarok-script [http://kde-apps.org/content/show.php?content=26073 ReplayGain]&lt;br /&gt;
:And possibly others, since [http://developer.kde.org/~wheeler/taglib.html TagLib] added support for [[APEv2]] tags in [[MP3]] files, players using this library (like [[amaroK]] and [[JuK]]) might support that kind of ReplayGain tags in the near future.&lt;br /&gt;
* [http://www.sacredchao.net/quodlibet Quod Libet] reads ReplayGain from (Ogg) [[Vorbis]], [[MP3]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:Requires support to be enabled (via the appropriate python bindings and libraries) for the above formats. Does not support ReplayGain values stored in [[APEv2]] tags in [[MP3]]s. ReplayGain values are stored in RVA2 id3v2.4 frames. See the [http://www.sacredchao.net/quodlibet/wiki/Development/ID3Notes Quod Libet RVA2 / ReplayGain notes].&lt;br /&gt;
* [http://www.musicpd.org/ Music Player Daemon] (MPD) reads ReplayGain from (Ogg) [[Vorbis]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:foobar2000-style TXXX frames in [[MP3]]s are also supported in the latest development releases.&lt;br /&gt;
* [http://www.mplayerhq.hu/ MPlayer]. Mplayer support for ReplayGain is codec dependent.&lt;br /&gt;
:Codecs that are known to support ReplayGain: vorbis&lt;br /&gt;
:Because of this, you need to prioritize the codecs that support it, or choose it individually on the command line.  To add it to the command line, add an -ac [codec] option after each file that you want to choose the codec for, or at the beginning to make it apply to all files listed.  To prioritize the codecs by default, list them in a line in mplayer.conf:&lt;br /&gt;
 ac=[codec],[othercodec],vorbis,mad,&lt;br /&gt;
* [http://idjc.sourceforge.net/ IDJC] (Internet DJ Console) reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], (Ogg) FLAC, (Ogg) [[Vorbis]], MP2 (audio), [[MP3]], [[Opus]], but only the &#039;&#039;lowercase&#039;&#039; tags. There is a [https://sourceforge.net/p/idjc/bugs/100/ ticket] open to handle tags case-insensitively.&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
* [https://www.videolan.org/vlc/ VLC] supports ReplayGain in many file formats, but usually only the &#039;&#039;uppercase&#039;&#039; variant of the tags.&lt;br /&gt;
* [https://kodi.tv/ KODI] reads ReplayGain from nearly all formats, but usually only the &#039;&#039;lowercase&#039;&#039; variant of the tags.&lt;br /&gt;
&lt;br /&gt;
=== Portable devices ===&lt;br /&gt;
[http://www.rockbox.org/ Rockbox] supports ReplayGain (in album or track mode) for most formats, including  WMA, MP1/2/3, AAC, ALAC, Musepack, Monkey&#039;s Audio, Wavpack, FLAC and Vorbis.  &amp;lt;br&amp;gt;Note that ReplayGain is only supported when using the respective codec&#039;s native tagging format.  For example:  ReplayGain stored in APEv2 tags is not supported for MP3, rather ID3v2.x tags are expected.&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Fuze with firmware 1.02.26 and 2.02.26&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Clip+&lt;br /&gt;
&lt;br /&gt;
The iPod features &#039;&#039;Soundcheck&#039;&#039;, which seems to produce roughly the same normalization gains as ReplayGain, but doesn&#039;t provide an Album Gain.&lt;br /&gt;
&lt;br /&gt;
=== Hi-Fi ===&lt;br /&gt;
Slim Devices, a company owned by Logitech Inc, supports ReplayGain on both of their hi-end audiophile players, known as the [[Slim Devices Transporter|Transporter]] and the [[Slim Devices Squeezebox|Squeezebox]].&lt;br /&gt;
&lt;br /&gt;
BluOS also supports ReplayGain with the selection of album- or track-gain and a so called Smart option that decides between the two by itself.&lt;br /&gt;
NAD devices that use BluOS consequently also support ReplayGain.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;references/&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[ReplayGain specification]]&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Replay_Gain ReplayGain] at Wikipedia&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain.html ReplayGain using foobar2000] (how to use ReplayGain in Windows using foobar2000).&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain-in-Linux.html ReplayGain in Linux] (how to use ReplayGain in Linux using foobar2000 and Wine, or using metaflac or vorbisgain).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Technical]]&lt;br /&gt;
[[index.php?title=Category:Metadata]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38801</id>
		<title>Revised ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38801"/>
		<updated>2026-01-22T21:42:32Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Proposed tag: REPLAYGAIN_ALGORITHM&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;4&amp;quot;&amp;gt;&#039;&#039;This is a proposed update to the [[ReplayGain 1.0 specification|original ReplayGain specification]]. This proposal is currently &#039;&#039;&#039;Under Construction&#039;&#039;&#039;. Please discuss this proposal on the [[Talk:ReplayGain 2.0 specification|discussion page]] or the [https://hydrogenaudio.org/index.php/topic,129032.0.html dedicated thread on Hydrogenaudio].&#039;&#039; --[[User:Skamp|Skamp]] 22:10 CET, January 22, 2026&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although music is encoded to a digital format with a clearly defined maximum peak amplitude, and although most recordings are normalized to utilize this peak amplitude, not all recordings sound equally loud. This is because once this peak amplitude is reached, perceived loudness can be further increased through signal-processing techniques such as dynamic range compression and equalization.&amp;lt;ref&amp;gt;Source: Wikipedia - [http://en.wikipedia.org/wiki/Loudness_war Loudness war]&amp;lt;/ref&amp;gt; Therefore, the loudness of a given album has more to do with the year of issue or the whim of the producer than the intended emotional effect. Because of this, a random play through a music collection can have one leaping for the volume control every other track.&lt;br /&gt;
&lt;br /&gt;
There is a solution to this annoyance: within each audio file, information can be stored about what volume change would be required to play each track or album at a standard loudness, and players can use this &amp;quot;replay gain&amp;quot; information to automatically nudge the volume up or down as required.&lt;br /&gt;
&lt;br /&gt;
The ReplayGain specification is a standard which defines an appropriate reference level, explains a way of calculating and representing the ideal replay gain for a given track or album, and provides guidance for players to make the required volume adjustment during playback. The standard also specifies a means to prevent clipping when the calculated replay gain exceeds the limits of digital audio, and it describes how the replay gain information is stored within audio files.&lt;br /&gt;
&lt;br /&gt;
==Loudness measurement==&lt;br /&gt;
Loudness is a subjective measure of the intensity of sound. The correlation of perceived loudness to sound pressure level is determined by the peculiarities of the auditory system.&lt;br /&gt;
&lt;br /&gt;
The [[ReplayGain 1.0 specification|original ReplayGain specification]] described a loudness measurement system which included a weighting filter, root mean square (RMS) measurement and statistical processing that model human perception of loudness in both the frequency and time domains.&lt;br /&gt;
&lt;br /&gt;
Since original ReplayGain proposal in 2001, the science, practice and standards for loudness normalization have been advanced significantly. The current industry standard approach to loudness measurement is described by the International Telecommunications Union&amp;lt;ref&amp;gt;http://www.itu.int/en/Pages/default.aspx&amp;lt;/ref&amp;gt; (ITU) as BS.1770. The most recent version of this standard is known as ITU BS.1770-5&amp;lt;ref&amp;gt;https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en&amp;lt;/ref&amp;gt; and was published in December 2023. The ITU work is freely available and is not believed to be encumbered by any patent issues. The ITU BS.1770-2 standard has been adopted in the United States by the [http://www.atsc.org ATSC] as [http://www.atsc.org/cms/standards/a_85-2011a.pdf A/85] and in Europe by the [http://www.ebu.ch European Broadcast Union] as [http://tech.ebu.ch/docs/tech/tech3343.pdf EBU R-128] for broadcast audio. &lt;br /&gt;
&lt;br /&gt;
BS.1770 uses a &amp;quot;K-weighted&amp;quot; RMS measurement. This weighting function is significantly less complex than the inverted Fletcher-Munson weighting used by the original ReplayGain algorithm. A gating function designed measure the loudness of foreground components in the audio program. The gate in BS.1770 performs a similar function as the statistical processing in the original RG specification. &lt;br /&gt;
&lt;br /&gt;
The computation required for BS.1770 loudness measurement is reduced compared to the original RG technique. Nevertheless, BS.1770 has been shown in several academic studies to be equally or more effective than the RG algorithm in modeling human loudness perception on music program as well as other material such as podcasts, television programs and movies.&amp;lt;ref&amp;gt;Paul Nygren. [http://www.speech.kth.se/prod/publications/files/3319.pdf Achieving equal loudness between audio files]. KTH Royal Institute of Technology&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Martin Wolters; Harald Mundt; Jeffrey Riedmiller (May 2010). [http://www.aes.org/e-lib/browse.cfm?elib=15341 Loudness Normalization In The Age Of Portable Media Players]. Audio Engineering Society.&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Esben Skovenborg; Søren H. Nielsen (October 2004). [http://web.archive.org/web/20120208024743/http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf Evaluation of Different Loudness Models with Music and Speech Material]. Audio Engineering Society. Archived from [http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf the original] on 2012-02-08.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recent RG implementations use BS.1770 for loudness measurement. It is expected the ITU standard will evolve over time to meet the needs of broadcasters and governments. It is the intent of the ReplayGain community that RG follow any future backwards-compatible improvements to loudness measurement using the BS.1770 standard.&lt;br /&gt;
&lt;br /&gt;
==Reference level==&lt;br /&gt;
&lt;br /&gt;
Classic ReplayGain is calibrated to a pink noise reference signal with a RMS level 14&amp;amp;nbsp;dB below a full-scale sinusoid. This reference signal is used to establish a reference level. ReplayGain will apply no gain or attenuation to the reference signal or any program material which has the same loudness measurements as the reference signal.&lt;br /&gt;
&lt;br /&gt;
BS-1770 defines a loudness scale for program material. The units of BS.1770 loudness measurements are in Loudness Units [relative to] Full Scale (LUFS). LUFS can be treated like decibels.&lt;br /&gt;
&lt;br /&gt;
In order to maintain backwards compatibility with classic RG, newer RG uses a -18&amp;amp;nbsp;LUFS reference, which based on lots of music, can give similar loudness compared to classic RG.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
The loudness measurement of the RG1 reference signal is NOT -18 LUFS; &lt;br /&gt;
The original -20 RMS dBFS one is -20.36 LUFS, and the -14 RMS dbFS one would be -15.36 LUFS.&lt;br /&gt;
&lt;br /&gt;
We picked -18 here is the result of analyzing actual music. &lt;br /&gt;
&lt;br /&gt;
Check what 2Bdecided said here: https://hydrogenaud.io/index.php/topic,109076.msg899298.html#msg899298&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Gain calculation==&lt;br /&gt;
RG achieves loudness compensated playback by applying gain (or attenuation) dependent on the measured loudness of the audio file relative to the established reference level. The gain is calculated as follows:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG=L_{r}-L&amp;lt;/math&amp;gt;&lt;br /&gt;
Where:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG&amp;lt;/math&amp;gt; is the replay gain adjustment in decibels,&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{r}&amp;lt;/math&amp;gt; is the -18&amp;amp;nbsp;LUFS reference level&lt;br /&gt;
:&amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; is the measured loudness of the audio file in LUFS.&lt;br /&gt;
&lt;br /&gt;
Gain is positive if the loudness of the audio file is lower than the reference level. The gain is negative (representing an attenuation) if the loudness of the audio file is higher than the reference level. The gain is stored as metadata with the audio file as described below and is used by players to adjust output volume of tracks as they are played as described in [[ReplayGain 2.0 specification#Player requirements|Player requirements]] below.&lt;br /&gt;
&lt;br /&gt;
==Metadata==&lt;br /&gt;
For ReplayGain to do its work during playback, four values must be stored as metadata&amp;lt;ref&amp;gt;Metadata is &amp;quot;data about data.&amp;quot; For example, the ID3 &#039;&#039;de facto&#039;&#039; standard provides a way to store artist, title, album title, track number, and other metadata in data blocks called &amp;quot;tags&amp;quot; immediately before or after the audio data in an MP3 file. Other metadata storage/tagging standards and conventions exist for other audio file formats.&amp;lt;/ref&amp;gt; with or within the audio file:&lt;br /&gt;
# Peak track amplitude&lt;br /&gt;
# Peak album amplitude&lt;br /&gt;
# Track replay gain&lt;br /&gt;
# Album replay gain&lt;br /&gt;
&lt;br /&gt;
If calculated for an individual track, the loudness measurement (as specified above) yields track replay gain. If calculated on an album basis, with all tracks concatenated to make one long audio file, the loudness measurement yields album replay gain.&lt;br /&gt;
&lt;br /&gt;
===Replay gain===&lt;br /&gt;
Under some listening conditions, it&#039;s useful to have every track sound equally loud. The problem with a track-by-track approach is that tracks which should be quiet in the context of the album on which they reside will be brought up to the level of all the rest. For casual listening, or in a noisy background, this can be a good thing. For serious listening, it does not respect the intent of the artist or mastering engineer; a tender ballad track will be blasting at the same loudness as a hard rock track on the same album. It&#039;s generally ideal to leave the intentional loudness differences between tracks in place, yet still correct for unmusical and annoying loudness differences between albums. To accomplish this, ReplayGain suggests that two different gain adjustments should be stored as metadata with each sound file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Album replay gain&#039;&#039; represents the ideal listening gain for an entire album. ReplayGain reads the collection of tracks that comprise an album, and calculates a single replay gain for the whole set. This single gain can be used for playback of all tracks of the album. Intentionally quiet tracks then stay appropriately quieter than the rest. It still solves the basic problem (annoying, unwanted level differences between discs) because quiet or loud discs are still adjusted overall&amp;amp;mdash;so the pop CD that&#039;s 20&amp;amp;nbsp;dB louder than the classical CD will be brought into line.&lt;br /&gt;
&lt;br /&gt;
===Peak amplitude===&lt;br /&gt;
Scanning a track or album for the peak amplitude can be a time-consuming process. Therefore, it&#039;s helpful if this single value is stored as metadata. This is used to predict whether the required replay gain adjustment will cause clipping during playback.&lt;br /&gt;
&lt;br /&gt;
The maximum peak amplitude value is stored as a floating point number, where 1.0 represents digital full scale. As with replay gain values, separate peak amplitude values are stored per track and per album.&lt;br /&gt;
&lt;br /&gt;
For uncompressed files simply, scanners store the maximum absolute sample value held in the file on any channel for positive or negative excursion. The single sample value should be converted to a floating-point representation, such that digital full scale is equivalent to a value of 1.0.&lt;br /&gt;
&lt;br /&gt;
Psychoacoustically coded audio, such as MP3, does not exist as a sequence of samples until it is decoded. Psychoacoustic coding of a heavily limited file can lead to sample values larger than digital full scale upon decoding. The coded files must be decoded using a fully compliant decoder that allows peak overflows (i.e. has headroom) and may result in peak amplitude values greater than 1.0.&lt;br /&gt;
&lt;br /&gt;
==Metadata format==&lt;br /&gt;
From the standpoint of metadata storage, each audio file format presents a unique situation. There are three favored schemes defined for storage of ReplayGain metadata: &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; and &#039;&#039;&#039;APEv2&#039;&#039;&#039;. A survey of file formats is listed below with metadata schemes in order of preference for each:&lt;br /&gt;
* .aac (Advanced Audio Coding raw format) &amp;amp;ndash; No metadata support (use .mp4 instead)&lt;br /&gt;
* .aiff, .aif, .aifc (Apple Interchange File Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID3&amp;quot; IFF chunk)&lt;br /&gt;
* .ape, .apl (Monkey&#039;s Audio) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .bwf (Broadcast Wave Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in RIFF chunk)&lt;br /&gt;
* .flac (Free Lossless Audio Codec) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .mp3 (MPEG audio layer 3) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, LAME VBR proposed tag specification&lt;br /&gt;
* .mp4 also .m4a, .m4b, .m4p, m4r (MPEG-4 Part 14) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID32&amp;quot; box)&lt;br /&gt;
* .mpc (Musepack) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .ogg (Ogg Vorbis) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;, same for other Ogg codecs&lt;br /&gt;
* .opus (Ogg Opus) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; available&lt;br /&gt;
** standard {{code|R128_TRACK_GAIN}} and {{code|R128_ALBUM_GAIN}} (MUST adjust for -23 LUFS) comment keys may be preferable (used by {{code|loudgain}})&lt;br /&gt;
* .tta (True Audio) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .asf, .wma (Windows Media audio) - &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; in Extended Content Description Object&lt;br /&gt;
** {{code|loudgain}} instead uses native ASF/WMA attributes (itself a key-value storage) via TagLib, which is more sensible&lt;br /&gt;
* .wav (Windows PCM) &amp;amp;ndash; No metadata support (use .bwf instead)&lt;br /&gt;
** ID3 RIFF chunk possible (used by {{code|loudgain}})&lt;br /&gt;
* .wv (WavePak) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===ID3v2===&lt;br /&gt;
The ID3v2 standard&amp;lt;ref&amp;gt;The ID3v2 format is explained at [http://www.id3.org/ www.id3.org]. The most useful document is the [http://www.id3.org/id3v2.3.0.html ID3v2 v2.3.0 standard]. Although this document has been superseded by v2.4.0, the earlier document is complete (rather than an update), and in indexed HTML form. As such, it represents a better technical introduction to ID3v2.&amp;lt;/ref&amp;gt; defines a &#039;&#039;tag&#039;&#039; which is situated before the data in an MP3 file.&amp;lt;ref&amp;gt;The original ID3 (v1) tags resided at the end of the file, and contained a few fields of information. The ID3v1 tag is not extensible and therefore cannot support ReplayGain metadata.&amp;lt;/ref&amp;gt; ID3 is used primarily with MP3 audio files but means of adapting the system to other file types have been developed.&lt;br /&gt;
&lt;br /&gt;
The ID3v2 tag is divided into &#039;&#039;frames&#039;&#039;. The preferred means of storing ReplayGain metadata is use of &#039;&#039;TXXX&#039;&#039; key/value pair frames. Two other legacy schemes for storing ReplayGain metadata exist: [[ReplayGain legacy metadata formats#ID3v2 RGAD|RGAD]] and [[ReplayGain legacy metadata formats#ID3v2 RVA2|RVA2]]. These formats are documented in the [[ReplayGain legacy metadata formats|appendix]]. Players may choose to look for these formats if metadata in the &#039;&#039;TXXX&#039;&#039; format is not found in the ID3v2 tag. New scanners may write these older formats in addition to the newer (TXXX) ones if they wish to remain backwards compatible with older players.&lt;br /&gt;
&lt;br /&gt;
ReplayGain uses four TXXX frames. The header of a TXXX frame is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Frame ID       $54 58 58 58 (&amp;quot;TXXX&amp;quot;) &lt;br /&gt;
 Size           $xx xx xx xx (size of frame excluding this header)&lt;br /&gt;
 Flags          $40 $00      (discard frame if audio data is altered)&lt;br /&gt;
&lt;br /&gt;
Frame data is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Text encoding  $00          (ISO-8859-1 encoding)&lt;br /&gt;
 Description    &amp;lt;key string&amp;gt; $00&lt;br /&gt;
 Value          &amp;lt;value string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The four frames associated with ReplayGain metadata use the following key/value pairs&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Table 3: Metadata keys and value formatting&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
|-&lt;br /&gt;
|Track replay gain&lt;br /&gt;
|REPLAYGAIN_TRACK_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak track amplitude&lt;br /&gt;
|REPLAYGAIN_TRACK_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|-&lt;br /&gt;
|Album replay gain&lt;br /&gt;
|REPLAYGAIN_ALBUM_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak album amplitude&lt;br /&gt;
|REPLAYGAIN_ALBUM_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Gains are specified textually in decibels. Negative gains (attenuation) are prefixed with a &#039;-&#039;. Positive gains have no prefix. Integral portion of the gain (a) may be one or two numeric (0-9) digits. If there is no integral portion the field is &#039;0&#039;. The decimal portion of the gain (bb) is two numeric digits. Gains are suffixed with a space followed by &#039;dB&#039;.&lt;br /&gt;
&lt;br /&gt;
Peak levels are specified textually as a positive decimal. Peak level is a dimensionless quantity with 1.000000 representing full scale. No suffix is included on peak values. The integer field (c) is typically 1 or 0. Six numeric digits in the decimal field (dddddd) is adequate to accurately represent peak values for 16-bit audio data.&lt;br /&gt;
&lt;br /&gt;
A robust player should be prepared to parse the following variations in either replay gain or peak level metadata:&lt;br /&gt;
*Positive gains with leading &#039;+&#039;&lt;br /&gt;
*More or fewer significant digits than specified in any field&lt;br /&gt;
*Leading zeros or spaces in integer fields&lt;br /&gt;
*Missing or malformed &#039;dB&#039; suffix (e.g. no space between numeric digits and suffix, alternate capitalization)&lt;br /&gt;
*Alternate capitalization of keys&lt;br /&gt;
&lt;br /&gt;
Other formatting errors indicate more severe problems and should result in player ignoring data as if the frame did not exist.&lt;br /&gt;
&lt;br /&gt;
===Vorbis comments===&lt;br /&gt;
A Vorbis comment&amp;lt;ref&amp;gt;[http://www.xiph.org/vorbis/doc/v-comment.html Vorbis comment metadata format]. ReplayGain metadata is documented on the [http://wiki.xiph.org/VorbisComment#Replay_Gain Xiph Wiki].&amp;lt;/ref&amp;gt; uses an ASCII &amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; format. When Vorbis comments are used, the four ReplayGain metadata items are stored as separate comments. The &#039;&#039;keys&#039;&#039; and formatting for &#039;&#039;values&#039;&#039; is the same as specified for ID3v2. Keys and values are required by the Vorbis comment specification to b separated by &#039;=&#039; (equal character).&lt;br /&gt;
&lt;br /&gt;
===APEv2===&lt;br /&gt;
The APEv2 metadata format&amp;lt;ref&amp;gt;[http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification APEv2 Specification at Hydrogen Audio Wiki]&amp;lt;/ref&amp;gt; also organizes data into key/value pairs. Keys are ASCII format. A flags field allows support for several value formats including UTF-8 and binary. Under APEv2, ReplayGain meta data is stored using the same keys and data as ASCII values in the same format as specified for ID3v2.&lt;br /&gt;
&lt;br /&gt;
===De-Facto extensions===&lt;br /&gt;
MusicBrainz Picard and [http://github.com/Moonbase59/loudgain#tags-written-andor-deleted LoudGain] also support the following additional tags, named using the same conventions:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Extension metadata keys&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
!Purpose&lt;br /&gt;
|-&lt;br /&gt;
|Track range&lt;br /&gt;
|REPLAYGAIN_TRACK_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|rowspan=2 | Indicates dynamics (R-128 Loudness Range / LRA), may guide pre-amplification&lt;br /&gt;
|-&lt;br /&gt;
|Album range&lt;br /&gt;
|REPLAYGAIN_ALBUM_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Reference loudness&lt;br /&gt;
|REPLAYGAIN_REFERENCE_LOUDNESS&lt;br /&gt;
|[-]a.bb LUFS&lt;br /&gt;
| Use alternative reference levels; change ref levels without re-scanning the file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Proposed extension(s) ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Extension metadata keys&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
!Purpose&lt;br /&gt;
|-&lt;br /&gt;
|Algorithm&lt;br /&gt;
|REPLAYGAIN_ALGORITHM&lt;br /&gt;
|ITU-R BS.1770&lt;br /&gt;
|Method to produce values&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Player requirements==&lt;br /&gt;
[[File:RG_Player_control.gif‎|frame|Figure 8: Example ReplayGain control panel]]&lt;br /&gt;
&lt;br /&gt;
Loudness normalization, pre-amplification and clipping prevention are the operations performed by a ReplayGain player.&lt;br /&gt;
&lt;br /&gt;
===Loudness normalization===&lt;br /&gt;
To properly normalize loudness, the player needs to determine if the user desires Track style level normalization (all tracks same loudness), or Album style level normalization (all albums same loudness, tracks of an album played at the same relative level as on the original release). This option should be selectable in the ReplayGain control panel (Figure 8). The player reads the corresponding gain metadata value from the file and scales the audio data as appropriate. Scaling the audio data simply means multiplying each sample value by a constant value. This constant is given by:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;10^\frac{gain}{20}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, in words, replay gain divided by 20 all raised to the power of ten.&amp;lt;ref&amp;gt;After any such operation, it&#039;s a good idea to dither the result. If this calculation and the pre-amp are implemented separately, then dither should only be added to the final result, just before the result is truncated back to 16 bits, or 24, or 8, as limited by the soundcard&amp;amp;mdash;not the file (i.e. after ReplayGain adjustment, an 8-bit file should be sent to a 16-bit soundcard at 16-bits).&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the file only contains one of the replay gain adjustments (e.g. Album) but the user has requested the other (Track), then the player should use the one that is available (in this case, Album). If neither (Track or Album) gain metadata is available, then the player needs to choose a suitable default gain. Potential choices include unity gain (0 dB) or an average of gains from other tracks in the album or playlist.&lt;br /&gt;
&lt;br /&gt;
===Pre-amplification===&lt;br /&gt;
Although the calibration level used by ReplayGain suggests that the average level of an audio track should be 14&amp;amp;nbsp;dB below full scale, some pop music is dynamically compressed to peak at 0&amp;amp;nbsp;dB and average around 3&amp;amp;nbsp;dB below full scale. This means that, when the replay gain is applied, the level of such tracks will be reduced by 11&amp;amp;nbsp;dB! If users are listening to a mixture of highly compressed and more dynamic tracks, ReplayGain will make the listening experience more pleasurable by bringing the level of the compressed tracks down into line with that of the others. However, if users are only listening to highly compressed music, then they may complain that all their files are now too quiet.&amp;lt;ref&amp;gt;This problem can be especially noticeable on portable players with limited output or gain.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To address this problem, a pre-amp feature should be incorporated into the player. A user-supplied pre-amp setting is an adjustment to the calculated replay gain. It should default to perform no adjustment. This means that casual users will experience a moderate reduction in the loudness of their compressed pop music. Less-compressed material can generally be played at the same loudness without clipping. Normalization of more dynamic material may cause clipping or invoke the [[ReplayGain 2.0 specification#Clipping prevention|clipping prevention]] mechanism (see below). Power users and audiophiles can reduce the pre-amp gain to enjoy the full dynamic range of all of their music.&lt;br /&gt;
&lt;br /&gt;
If enabled, the player should read the user selected pre-amp gain, and scale the audio signal by the appropriate amount. For example, a +6&amp;amp;nbsp;dB gain requires a scale of 10&amp;lt;sup&amp;gt;6/20&amp;lt;/sup&amp;gt;, which is approximately 2. The replay gain and pre-amp scale factors can be combined&amp;lt;ref&amp;gt;Scale factors in  Decibel units are added to produce the same effect as multiplying scale factors in linear units.&amp;lt;/ref&amp;gt; for simplicity and ease of processing.&lt;br /&gt;
&lt;br /&gt;
===Clipping prevention===&lt;br /&gt;
ReplayGain&#039;s suggestion of a -14&amp;amp;nbsp;dB average playback level leaves sufficient headroom for the bulk of modern recordings. Nevertheless, there exists the possibility that after application of replay gain and pre-amp adjustment, a track may exceed full scale during its dynamic peaks. Without intervention, this will result in clipping, a severe form of distortion. Factors introducing the possibility of clipping include:&lt;br /&gt;
&lt;br /&gt;
# Recordings from certain genres and certain periods in the history of commercial recordings require additional headroom. Although these recordings can be accommodated through a downwards adjustment of the pre-amp setting, it may be difficult to determine a safe adjustment and it may be undesirable to lower average level to accommodate the rare track which requires it. &lt;br /&gt;
# ReplayGain will make loud dynamically compressed tracks quieter, and quiet dynamically uncompressed tracks louder. The average levels will then be similar, but the quiet tracks will actually have louder peaks. If the user pushes the pre-amp gain upwards the peaks of the (originally) quieter tracks will be pushed well over full scale.&lt;br /&gt;
# In coded audio (e.g. MP3 files) a file that was hard-limited to digital full scale before encoding will often be pushed over the limit by the psychoacoustic compression. A decoder with headroom can recover the over full scale signal by reducing the gain.&lt;br /&gt;
&lt;br /&gt;
ReplayGain suggests two possible solutions which prevent clipping in these situations. A player should support one or both of these.&lt;br /&gt;
&lt;br /&gt;
====Audio limiting====&lt;br /&gt;
In situation 2 above, the user clearly wants all the music to sound very loud. To give them their wish, any signal which would peak above digital full scale should be hard limited at just below digital full scale. This is also useful at lower pre-amp gains, where it allows the average level of classical music to be raised to that of pop music, without distorting. The exact type of nature limiting or compression an implementation choice for the player.&amp;lt;ref&amp;gt;Something like the Hard Limiter found in Cool Edit Pro (Syntrillium) would be appropriate for pop music at least.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reduced gain====&lt;br /&gt;
The audiophile user will not want any compression or limiting on the signal. In this case the only option is to automatically and temporarily reduce the pre-amp gain below the user-selected setting for tracks where clipping would otherwise occur. Clipping can be predicted by examining the peak level of the track or album being played.&lt;br /&gt;
&lt;br /&gt;
The player must read the peak amplitude metadata. If peak level metadata is unavailable, the player should assume a peak level of 1.0. If the peak level for both track and album is stored as metadata in the file, it is possible to calculate if, following the replay gain adjustment and pre-amp gain, the signal will clip at some point. If it won&#039;t, then no further action is necessary. &lt;br /&gt;
&lt;br /&gt;
An overall scale factor for loudness normalization taking into account replay gain, pre-amp setting and clipping prevention through gain reduction is given below.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;min( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{peak amplitude} )&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;!-- use this when tex is fixed: :&amp;lt;math&amp;gt;\operatorname{min}( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{L_{\mathrm{peak}}} )&amp;lt;/math&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hardware implementation===&lt;br /&gt;
The above three steps are appropriate to software players operating on the digital signal in order to scale it. However, it is possible to send the digital signal to the DAC without level correction, and to place an attenuator in the analogue signal path. The attenuator can then be driven by the Replay Gain value. The clipping problem can be addressed by providing adequate headroom in the analog circuitry. Bit transparency and maximum signal to noise ratio is maintained in the digital signal and DAC process.&amp;lt;ref&amp;gt;A system using today&#039;s 24-bit converters is unlikely to appreciate any overall gain in system performance with such an arrangement. A digitally-controlled analog gain element typically introduces significant noise and distortion.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The [http://replaygain.hydrogenaudio.org/proposal original ReplayGain proposal] (an [http://replay.waybackmachine.org/20090306202649/http://www.replaygain.org/ archive] is also available) was developed by David Robinson and was published 10 July 2001. Additional updates were published by David Robinson through 10 October 2001.&lt;br /&gt;
&lt;br /&gt;
The following acknowledgement was included with the original proposal, &amp;quot;The algorithm to calculate an ideal replay gain has grown from my research into human hearing, with many additional ideas drawn from the work of E. Zwicker, and Brian Moore. I am currently completing my PhD at the University of Essex, and have been funded by the EPSRC.&amp;quot; Additionally David Robinson credited Glen Sawyer (Snelg) and Jim Casaburi (Walrus) for software contributions and Bob Katz and Matt Ashland for ideas.&lt;br /&gt;
&lt;br /&gt;
This updated ReplayGain specification reflecting current and recommended practice was prepared by Kevin Gross in 2011.&lt;br /&gt;
&lt;br /&gt;
==Contact==&lt;br /&gt;
For ReplayGain-related questions or contributions, please post in the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio] section of the Hydrogen Audio forums.&lt;br /&gt;
 &lt;br /&gt;
==Appendix==&lt;br /&gt;
# [[ReplayGain legacy metadata formats]]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38800</id>
		<title>Revised ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38800"/>
		<updated>2026-01-22T21:12:21Z</updated>

		<summary type="html">&lt;p&gt;Skamp: changed the disclaimer to my name, and linked to the updated HA thread&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;DISPLAYTITLE&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;4&amp;quot;&amp;gt;&#039;&#039;This is a proposed update to the [[ReplayGain 1.0 specification|original ReplayGain specification]]. This proposal is currently &#039;&#039;&#039;Under Construction&#039;&#039;&#039;. Please discuss this proposal on the [[Talk:ReplayGain 2.0 specification|discussion page]] or the [https://hydrogenaudio.org/index.php/topic,129032.0.html dedicated thread on Hydrogenaudio].&#039;&#039; --[[User:Skamp|Skamp]] 22:10 CET, January 22, 2026&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although music is encoded to a digital format with a clearly defined maximum peak amplitude, and although most recordings are normalized to utilize this peak amplitude, not all recordings sound equally loud. This is because once this peak amplitude is reached, perceived loudness can be further increased through signal-processing techniques such as dynamic range compression and equalization.&amp;lt;ref&amp;gt;Source: Wikipedia - [http://en.wikipedia.org/wiki/Loudness_war Loudness war]&amp;lt;/ref&amp;gt; Therefore, the loudness of a given album has more to do with the year of issue or the whim of the producer than the intended emotional effect. Because of this, a random play through a music collection can have one leaping for the volume control every other track.&lt;br /&gt;
&lt;br /&gt;
There is a solution to this annoyance: within each audio file, information can be stored about what volume change would be required to play each track or album at a standard loudness, and players can use this &amp;quot;replay gain&amp;quot; information to automatically nudge the volume up or down as required.&lt;br /&gt;
&lt;br /&gt;
The ReplayGain specification is a standard which defines an appropriate reference level, explains a way of calculating and representing the ideal replay gain for a given track or album, and provides guidance for players to make the required volume adjustment during playback. The standard also specifies a means to prevent clipping when the calculated replay gain exceeds the limits of digital audio, and it describes how the replay gain information is stored within audio files.&lt;br /&gt;
&lt;br /&gt;
==Loudness measurement==&lt;br /&gt;
Loudness is a subjective measure of the intensity of sound. The correlation of perceived loudness to sound pressure level is determined by the peculiarities of the auditory system.&lt;br /&gt;
&lt;br /&gt;
The [[ReplayGain 1.0 specification|original ReplayGain specification]] described a loudness measurement system which included a weighting filter, root mean square (RMS) measurement and statistical processing that model human perception of loudness in both the frequency and time domains.&lt;br /&gt;
&lt;br /&gt;
Since original ReplayGain proposal in 2001, the science, practice and standards for loudness normalization have been advanced significantly. The current industry standard approach to loudness measurement is described by the International Telecommunications Union&amp;lt;ref&amp;gt;http://www.itu.int/en/Pages/default.aspx&amp;lt;/ref&amp;gt; (ITU) as BS.1770. The most recent version of this standard is known as ITU BS.1770-5&amp;lt;ref&amp;gt;https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en&amp;lt;/ref&amp;gt; and was published in December 2023. The ITU work is freely available and is not believed to be encumbered by any patent issues. The ITU BS.1770-2 standard has been adopted in the United States by the [http://www.atsc.org ATSC] as [http://www.atsc.org/cms/standards/a_85-2011a.pdf A/85] and in Europe by the [http://www.ebu.ch European Broadcast Union] as [http://tech.ebu.ch/docs/tech/tech3343.pdf EBU R-128] for broadcast audio. &lt;br /&gt;
&lt;br /&gt;
BS.1770 uses a &amp;quot;K-weighted&amp;quot; RMS measurement. This weighting function is significantly less complex than the inverted Fletcher-Munson weighting used by the original ReplayGain algorithm. A gating function designed measure the loudness of foreground components in the audio program. The gate in BS.1770 performs a similar function as the statistical processing in the original RG specification. &lt;br /&gt;
&lt;br /&gt;
The computation required for BS.1770 loudness measurement is reduced compared to the original RG technique. Nevertheless, BS.1770 has been shown in several academic studies to be equally or more effective than the RG algorithm in modeling human loudness perception on music program as well as other material such as podcasts, television programs and movies.&amp;lt;ref&amp;gt;Paul Nygren. [http://www.speech.kth.se/prod/publications/files/3319.pdf Achieving equal loudness between audio files]. KTH Royal Institute of Technology&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Martin Wolters; Harald Mundt; Jeffrey Riedmiller (May 2010). [http://www.aes.org/e-lib/browse.cfm?elib=15341 Loudness Normalization In The Age Of Portable Media Players]. Audio Engineering Society.&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Esben Skovenborg; Søren H. Nielsen (October 2004). [http://web.archive.org/web/20120208024743/http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf Evaluation of Different Loudness Models with Music and Speech Material]. Audio Engineering Society. Archived from [http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf the original] on 2012-02-08.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recent RG implementations use BS.1770 for loudness measurement. It is expected the ITU standard will evolve over time to meet the needs of broadcasters and governments. It is the intent of the ReplayGain community that RG follow any future backwards-compatible improvements to loudness measurement using the BS.1770 standard.&lt;br /&gt;
&lt;br /&gt;
==Reference level==&lt;br /&gt;
&lt;br /&gt;
Classic ReplayGain is calibrated to a pink noise reference signal with a RMS level 14&amp;amp;nbsp;dB below a full-scale sinusoid. This reference signal is used to establish a reference level. ReplayGain will apply no gain or attenuation to the reference signal or any program material which has the same loudness measurements as the reference signal.&lt;br /&gt;
&lt;br /&gt;
BS-1770 defines a loudness scale for program material. The units of BS.1770 loudness measurements are in Loudness Units [relative to] Full Scale (LUFS). LUFS can be treated like decibels.&lt;br /&gt;
&lt;br /&gt;
In order to maintain backwards compatibility with classic RG, newer RG uses a -18&amp;amp;nbsp;LUFS reference, which based on lots of music, can give similar loudness compared to classic RG.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
The loudness measurement of the RG1 reference signal is NOT -18 LUFS; &lt;br /&gt;
The original -20 RMS dBFS one is -20.36 LUFS, and the -14 RMS dbFS one would be -15.36 LUFS.&lt;br /&gt;
&lt;br /&gt;
We picked -18 here is the result of analyzing actual music. &lt;br /&gt;
&lt;br /&gt;
Check what 2Bdecided said here: https://hydrogenaud.io/index.php/topic,109076.msg899298.html#msg899298&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Gain calculation==&lt;br /&gt;
RG achieves loudness compensated playback by applying gain (or attenuation) dependent on the measured loudness of the audio file relative to the established reference level. The gain is calculated as follows:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG=L_{r}-L&amp;lt;/math&amp;gt;&lt;br /&gt;
Where:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG&amp;lt;/math&amp;gt; is the replay gain adjustment in decibels,&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{r}&amp;lt;/math&amp;gt; is the -18&amp;amp;nbsp;LUFS reference level&lt;br /&gt;
:&amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; is the measured loudness of the audio file in LUFS.&lt;br /&gt;
&lt;br /&gt;
Gain is positive if the loudness of the audio file is lower than the reference level. The gain is negative (representing an attenuation) if the loudness of the audio file is higher than the reference level. The gain is stored as metadata with the audio file as described below and is used by players to adjust output volume of tracks as they are played as described in [[ReplayGain 2.0 specification#Player requirements|Player requirements]] below.&lt;br /&gt;
&lt;br /&gt;
==Metadata==&lt;br /&gt;
For ReplayGain to do its work during playback, four values must be stored as metadata&amp;lt;ref&amp;gt;Metadata is &amp;quot;data about data.&amp;quot; For example, the ID3 &#039;&#039;de facto&#039;&#039; standard provides a way to store artist, title, album title, track number, and other metadata in data blocks called &amp;quot;tags&amp;quot; immediately before or after the audio data in an MP3 file. Other metadata storage/tagging standards and conventions exist for other audio file formats.&amp;lt;/ref&amp;gt; with or within the audio file:&lt;br /&gt;
# Peak track amplitude&lt;br /&gt;
# Peak album amplitude&lt;br /&gt;
# Track replay gain&lt;br /&gt;
# Album replay gain&lt;br /&gt;
&lt;br /&gt;
If calculated for an individual track, the loudness measurement (as specified above) yields track replay gain. If calculated on an album basis, with all tracks concatenated to make one long audio file, the loudness measurement yields album replay gain.&lt;br /&gt;
&lt;br /&gt;
===Replay gain===&lt;br /&gt;
Under some listening conditions, it&#039;s useful to have every track sound equally loud. The problem with a track-by-track approach is that tracks which should be quiet in the context of the album on which they reside will be brought up to the level of all the rest. For casual listening, or in a noisy background, this can be a good thing. For serious listening, it does not respect the intent of the artist or mastering engineer; a tender ballad track will be blasting at the same loudness as a hard rock track on the same album. It&#039;s generally ideal to leave the intentional loudness differences between tracks in place, yet still correct for unmusical and annoying loudness differences between albums. To accomplish this, ReplayGain suggests that two different gain adjustments should be stored as metadata with each sound file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Album replay gain&#039;&#039; represents the ideal listening gain for an entire album. ReplayGain reads the collection of tracks that comprise an album, and calculates a single replay gain for the whole set. This single gain can be used for playback of all tracks of the album. Intentionally quiet tracks then stay appropriately quieter than the rest. It still solves the basic problem (annoying, unwanted level differences between discs) because quiet or loud discs are still adjusted overall&amp;amp;mdash;so the pop CD that&#039;s 20&amp;amp;nbsp;dB louder than the classical CD will be brought into line.&lt;br /&gt;
&lt;br /&gt;
===Peak amplitude===&lt;br /&gt;
Scanning a track or album for the peak amplitude can be a time-consuming process. Therefore, it&#039;s helpful if this single value is stored as metadata. This is used to predict whether the required replay gain adjustment will cause clipping during playback.&lt;br /&gt;
&lt;br /&gt;
The maximum peak amplitude value is stored as a floating point number, where 1.0 represents digital full scale. As with replay gain values, separate peak amplitude values are stored per track and per album.&lt;br /&gt;
&lt;br /&gt;
For uncompressed files simply, scanners store the maximum absolute sample value held in the file on any channel for positive or negative excursion. The single sample value should be converted to a floating-point representation, such that digital full scale is equivalent to a value of 1.0.&lt;br /&gt;
&lt;br /&gt;
Psychoacoustically coded audio, such as MP3, does not exist as a sequence of samples until it is decoded. Psychoacoustic coding of a heavily limited file can lead to sample values larger than digital full scale upon decoding. The coded files must be decoded using a fully compliant decoder that allows peak overflows (i.e. has headroom) and may result in peak amplitude values greater than 1.0.&lt;br /&gt;
&lt;br /&gt;
==Metadata format==&lt;br /&gt;
From the standpoint of metadata storage, each audio file format presents a unique situation. There are three favored schemes defined for storage of ReplayGain metadata: &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; and &#039;&#039;&#039;APEv2&#039;&#039;&#039;. A survey of file formats is listed below with metadata schemes in order of preference for each:&lt;br /&gt;
* .aac (Advanced Audio Coding raw format) &amp;amp;ndash; No metadata support (use .mp4 instead)&lt;br /&gt;
* .aiff, .aif, .aifc (Apple Interchange File Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID3&amp;quot; IFF chunk)&lt;br /&gt;
* .ape, .apl (Monkey&#039;s Audio) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .bwf (Broadcast Wave Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in RIFF chunk)&lt;br /&gt;
* .flac (Free Lossless Audio Codec) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .mp3 (MPEG audio layer 3) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, LAME VBR proposed tag specification&lt;br /&gt;
* .mp4 also .m4a, .m4b, .m4p, m4r (MPEG-4 Part 14) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID32&amp;quot; box)&lt;br /&gt;
* .mpc (Musepack) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .ogg (Ogg Vorbis) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;, same for other Ogg codecs&lt;br /&gt;
* .opus (Ogg Opus) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; available&lt;br /&gt;
** standard {{code|R128_TRACK_GAIN}} and {{code|R128_ALBUM_GAIN}} (MUST adjust for -23 LUFS) comment keys may be preferable (used by {{code|loudgain}})&lt;br /&gt;
* .tta (True Audio) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .asf, .wma (Windows Media audio) - &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; in Extended Content Description Object&lt;br /&gt;
** {{code|loudgain}} instead uses native ASF/WMA attributes (itself a key-value storage) via TagLib, which is more sensible&lt;br /&gt;
* .wav (Windows PCM) &amp;amp;ndash; No metadata support (use .bwf instead)&lt;br /&gt;
** ID3 RIFF chunk possible (used by {{code|loudgain}})&lt;br /&gt;
* .wv (WavePak) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===ID3v2===&lt;br /&gt;
The ID3v2 standard&amp;lt;ref&amp;gt;The ID3v2 format is explained at [http://www.id3.org/ www.id3.org]. The most useful document is the [http://www.id3.org/id3v2.3.0.html ID3v2 v2.3.0 standard]. Although this document has been superseded by v2.4.0, the earlier document is complete (rather than an update), and in indexed HTML form. As such, it represents a better technical introduction to ID3v2.&amp;lt;/ref&amp;gt; defines a &#039;&#039;tag&#039;&#039; which is situated before the data in an MP3 file.&amp;lt;ref&amp;gt;The original ID3 (v1) tags resided at the end of the file, and contained a few fields of information. The ID3v1 tag is not extensible and therefore cannot support ReplayGain metadata.&amp;lt;/ref&amp;gt; ID3 is used primarily with MP3 audio files but means of adapting the system to other file types have been developed.&lt;br /&gt;
&lt;br /&gt;
The ID3v2 tag is divided into &#039;&#039;frames&#039;&#039;. The preferred means of storing ReplayGain metadata is use of &#039;&#039;TXXX&#039;&#039; key/value pair frames. Two other legacy schemes for storing ReplayGain metadata exist: [[ReplayGain legacy metadata formats#ID3v2 RGAD|RGAD]] and [[ReplayGain legacy metadata formats#ID3v2 RVA2|RVA2]]. These formats are documented in the [[ReplayGain legacy metadata formats|appendix]]. Players may choose to look for these formats if metadata in the &#039;&#039;TXXX&#039;&#039; format is not found in the ID3v2 tag. New scanners may write these older formats in addition to the newer (TXXX) ones if they wish to remain backwards compatible with older players.&lt;br /&gt;
&lt;br /&gt;
ReplayGain uses four TXXX frames. The header of a TXXX frame is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Frame ID       $54 58 58 58 (&amp;quot;TXXX&amp;quot;) &lt;br /&gt;
 Size           $xx xx xx xx (size of frame excluding this header)&lt;br /&gt;
 Flags          $40 $00      (discard frame if audio data is altered)&lt;br /&gt;
&lt;br /&gt;
Frame data is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Text encoding  $00          (ISO-8859-1 encoding)&lt;br /&gt;
 Description    &amp;lt;key string&amp;gt; $00&lt;br /&gt;
 Value          &amp;lt;value string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The four frames associated with ReplayGain metadata use the following key/value pairs&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Table 3: Metadata keys and value formatting&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
|-&lt;br /&gt;
|Track replay gain&lt;br /&gt;
|REPLAYGAIN_TRACK_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak track amplitude&lt;br /&gt;
|REPLAYGAIN_TRACK_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|-&lt;br /&gt;
|Album replay gain&lt;br /&gt;
|REPLAYGAIN_ALBUM_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak album amplitude&lt;br /&gt;
|REPLAYGAIN_ALBUM_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Gains are specified textually in decibels. Negative gains (attenuation) are prefixed with a &#039;-&#039;. Positive gains have no prefix. Integral portion of the gain (a) may be one or two numeric (0-9) digits. If there is no integral portion the field is &#039;0&#039;. The decimal portion of the gain (bb) is two numeric digits. Gains are suffixed with a space followed by &#039;dB&#039;.&lt;br /&gt;
&lt;br /&gt;
Peak levels are specified textually as a positive decimal. Peak level is a dimensionless quantity with 1.000000 representing full scale. No suffix is included on peak values. The integer field (c) is typically 1 or 0. Six numeric digits in the decimal field (dddddd) is adequate to accurately represent peak values for 16-bit audio data.&lt;br /&gt;
&lt;br /&gt;
A robust player should be prepared to parse the following variations in either replay gain or peak level metadata:&lt;br /&gt;
*Positive gains with leading &#039;+&#039;&lt;br /&gt;
*More or fewer significant digits than specified in any field&lt;br /&gt;
*Leading zeros or spaces in integer fields&lt;br /&gt;
*Missing or malformed &#039;dB&#039; suffix (e.g. no space between numeric digits and suffix, alternate capitalization)&lt;br /&gt;
*Alternate capitalization of keys&lt;br /&gt;
&lt;br /&gt;
Other formatting errors indicate more severe problems and should result in player ignoring data as if the frame did not exist.&lt;br /&gt;
&lt;br /&gt;
===Vorbis comments===&lt;br /&gt;
A Vorbis comment&amp;lt;ref&amp;gt;[http://www.xiph.org/vorbis/doc/v-comment.html Vorbis comment metadata format]. ReplayGain metadata is documented on the [http://wiki.xiph.org/VorbisComment#Replay_Gain Xiph Wiki].&amp;lt;/ref&amp;gt; uses an ASCII &amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; format. When Vorbis comments are used, the four ReplayGain metadata items are stored as separate comments. The &#039;&#039;keys&#039;&#039; and formatting for &#039;&#039;values&#039;&#039; is the same as specified for ID3v2. Keys and values are required by the Vorbis comment specification to b separated by &#039;=&#039; (equal character).&lt;br /&gt;
&lt;br /&gt;
===APEv2===&lt;br /&gt;
The APEv2 metadata format&amp;lt;ref&amp;gt;[http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification APEv2 Specification at Hydrogen Audio Wiki]&amp;lt;/ref&amp;gt; also organizes data into key/value pairs. Keys are ASCII format. A flags field allows support for several value formats including UTF-8 and binary. Under APEv2, ReplayGain meta data is stored using the same keys and data as ASCII values in the same format as specified for ID3v2.&lt;br /&gt;
&lt;br /&gt;
===De-Facto extensions===&lt;br /&gt;
MusicBrainz Picard and [http://github.com/Moonbase59/loudgain#tags-written-andor-deleted LoudGain] also support the following additional tags, named using the same conventions:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Extension metadata keys&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!alue format&lt;br /&gt;
! Purpose&lt;br /&gt;
|-&lt;br /&gt;
|Track range&lt;br /&gt;
|REPLAYGAIN_TRACK_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|rowspan=2 | Indicates dynamics (R-128 Loudness Range / LRA), may guide pre-amplification&lt;br /&gt;
|-&lt;br /&gt;
|Album range&lt;br /&gt;
|REPLAYGAIN_ALBUM_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Reference loudness&lt;br /&gt;
|REPLAYGAIN_REFERENCE_LOUDNESS&lt;br /&gt;
|[-]a.bb LUFS&lt;br /&gt;
| Use alternative reference levels; change ref levels without re-scanning the file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Player requirements==&lt;br /&gt;
[[File:RG_Player_control.gif‎|frame|Figure 8: Example ReplayGain control panel]]&lt;br /&gt;
&lt;br /&gt;
Loudness normalization, pre-amplification and clipping prevention are the operations performed by a ReplayGain player.&lt;br /&gt;
&lt;br /&gt;
===Loudness normalization===&lt;br /&gt;
To properly normalize loudness, the player needs to determine if the user desires Track style level normalization (all tracks same loudness), or Album style level normalization (all albums same loudness, tracks of an album played at the same relative level as on the original release). This option should be selectable in the ReplayGain control panel (Figure 8). The player reads the corresponding gain metadata value from the file and scales the audio data as appropriate. Scaling the audio data simply means multiplying each sample value by a constant value. This constant is given by:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;10^\frac{gain}{20}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, in words, replay gain divided by 20 all raised to the power of ten.&amp;lt;ref&amp;gt;After any such operation, it&#039;s a good idea to dither the result. If this calculation and the pre-amp are implemented separately, then dither should only be added to the final result, just before the result is truncated back to 16 bits, or 24, or 8, as limited by the soundcard&amp;amp;mdash;not the file (i.e. after ReplayGain adjustment, an 8-bit file should be sent to a 16-bit soundcard at 16-bits).&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the file only contains one of the replay gain adjustments (e.g. Album) but the user has requested the other (Track), then the player should use the one that is available (in this case, Album). If neither (Track or Album) gain metadata is available, then the player needs to choose a suitable default gain. Potential choices include unity gain (0 dB) or an average of gains from other tracks in the album or playlist.&lt;br /&gt;
&lt;br /&gt;
===Pre-amplification===&lt;br /&gt;
Although the calibration level used by ReplayGain suggests that the average level of an audio track should be 14&amp;amp;nbsp;dB below full scale, some pop music is dynamically compressed to peak at 0&amp;amp;nbsp;dB and average around 3&amp;amp;nbsp;dB below full scale. This means that, when the replay gain is applied, the level of such tracks will be reduced by 11&amp;amp;nbsp;dB! If users are listening to a mixture of highly compressed and more dynamic tracks, ReplayGain will make the listening experience more pleasurable by bringing the level of the compressed tracks down into line with that of the others. However, if users are only listening to highly compressed music, then they may complain that all their files are now too quiet.&amp;lt;ref&amp;gt;This problem can be especially noticeable on portable players with limited output or gain.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To address this problem, a pre-amp feature should be incorporated into the player. A user-supplied pre-amp setting is an adjustment to the calculated replay gain. It should default to perform no adjustment. This means that casual users will experience a moderate reduction in the loudness of their compressed pop music. Less-compressed material can generally be played at the same loudness without clipping. Normalization of more dynamic material may cause clipping or invoke the [[ReplayGain 2.0 specification#Clipping prevention|clipping prevention]] mechanism (see below). Power users and audiophiles can reduce the pre-amp gain to enjoy the full dynamic range of all of their music.&lt;br /&gt;
&lt;br /&gt;
If enabled, the player should read the user selected pre-amp gain, and scale the audio signal by the appropriate amount. For example, a +6&amp;amp;nbsp;dB gain requires a scale of 10&amp;lt;sup&amp;gt;6/20&amp;lt;/sup&amp;gt;, which is approximately 2. The replay gain and pre-amp scale factors can be combined&amp;lt;ref&amp;gt;Scale factors in  Decibel units are added to produce the same effect as multiplying scale factors in linear units.&amp;lt;/ref&amp;gt; for simplicity and ease of processing.&lt;br /&gt;
&lt;br /&gt;
===Clipping prevention===&lt;br /&gt;
ReplayGain&#039;s suggestion of a -14&amp;amp;nbsp;dB average playback level leaves sufficient headroom for the bulk of modern recordings. Nevertheless, there exists the possibility that after application of replay gain and pre-amp adjustment, a track may exceed full scale during its dynamic peaks. Without intervention, this will result in clipping, a severe form of distortion. Factors introducing the possibility of clipping include:&lt;br /&gt;
&lt;br /&gt;
# Recordings from certain genres and certain periods in the history of commercial recordings require additional headroom. Although these recordings can be accommodated through a downwards adjustment of the pre-amp setting, it may be difficult to determine a safe adjustment and it may be undesirable to lower average level to accommodate the rare track which requires it. &lt;br /&gt;
# ReplayGain will make loud dynamically compressed tracks quieter, and quiet dynamically uncompressed tracks louder. The average levels will then be similar, but the quiet tracks will actually have louder peaks. If the user pushes the pre-amp gain upwards the peaks of the (originally) quieter tracks will be pushed well over full scale.&lt;br /&gt;
# In coded audio (e.g. MP3 files) a file that was hard-limited to digital full scale before encoding will often be pushed over the limit by the psychoacoustic compression. A decoder with headroom can recover the over full scale signal by reducing the gain.&lt;br /&gt;
&lt;br /&gt;
ReplayGain suggests two possible solutions which prevent clipping in these situations. A player should support one or both of these.&lt;br /&gt;
&lt;br /&gt;
====Audio limiting====&lt;br /&gt;
In situation 2 above, the user clearly wants all the music to sound very loud. To give them their wish, any signal which would peak above digital full scale should be hard limited at just below digital full scale. This is also useful at lower pre-amp gains, where it allows the average level of classical music to be raised to that of pop music, without distorting. The exact type of nature limiting or compression an implementation choice for the player.&amp;lt;ref&amp;gt;Something like the Hard Limiter found in Cool Edit Pro (Syntrillium) would be appropriate for pop music at least.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reduced gain====&lt;br /&gt;
The audiophile user will not want any compression or limiting on the signal. In this case the only option is to automatically and temporarily reduce the pre-amp gain below the user-selected setting for tracks where clipping would otherwise occur. Clipping can be predicted by examining the peak level of the track or album being played.&lt;br /&gt;
&lt;br /&gt;
The player must read the peak amplitude metadata. If peak level metadata is unavailable, the player should assume a peak level of 1.0. If the peak level for both track and album is stored as metadata in the file, it is possible to calculate if, following the replay gain adjustment and pre-amp gain, the signal will clip at some point. If it won&#039;t, then no further action is necessary. &lt;br /&gt;
&lt;br /&gt;
An overall scale factor for loudness normalization taking into account replay gain, pre-amp setting and clipping prevention through gain reduction is given below.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;min( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{peak amplitude} )&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;!-- use this when tex is fixed: :&amp;lt;math&amp;gt;\operatorname{min}( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{L_{\mathrm{peak}}} )&amp;lt;/math&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hardware implementation===&lt;br /&gt;
The above three steps are appropriate to software players operating on the digital signal in order to scale it. However, it is possible to send the digital signal to the DAC without level correction, and to place an attenuator in the analogue signal path. The attenuator can then be driven by the Replay Gain value. The clipping problem can be addressed by providing adequate headroom in the analog circuitry. Bit transparency and maximum signal to noise ratio is maintained in the digital signal and DAC process.&amp;lt;ref&amp;gt;A system using today&#039;s 24-bit converters is unlikely to appreciate any overall gain in system performance with such an arrangement. A digitally-controlled analog gain element typically introduces significant noise and distortion.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The [http://replaygain.hydrogenaudio.org/proposal original ReplayGain proposal] (an [http://replay.waybackmachine.org/20090306202649/http://www.replaygain.org/ archive] is also available) was developed by David Robinson and was published 10 July 2001. Additional updates were published by David Robinson through 10 October 2001.&lt;br /&gt;
&lt;br /&gt;
The following acknowledgement was included with the original proposal, &amp;quot;The algorithm to calculate an ideal replay gain has grown from my research into human hearing, with many additional ideas drawn from the work of E. Zwicker, and Brian Moore. I am currently completing my PhD at the University of Essex, and have been funded by the EPSRC.&amp;quot; Additionally David Robinson credited Glen Sawyer (Snelg) and Jim Casaburi (Walrus) for software contributions and Bob Katz and Matt Ashland for ideas.&lt;br /&gt;
&lt;br /&gt;
This updated ReplayGain specification reflecting current and recommended practice was prepared by Kevin Gross in 2011.&lt;br /&gt;
&lt;br /&gt;
==Contact==&lt;br /&gt;
For ReplayGain-related questions or contributions, please post in the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio] section of the Hydrogen Audio forums.&lt;br /&gt;
 &lt;br /&gt;
==Appendix==&lt;br /&gt;
# [[ReplayGain legacy metadata formats]]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Original_ReplayGain_specification&amp;diff=38799</id>
		<title>Original ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Original_ReplayGain_specification&amp;diff=38799"/>
		<updated>2026-01-22T20:27:50Z</updated>

		<summary type="html">&lt;p&gt;Skamp: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Although music is encoded to a digital format with a clearly defined maximum peak amplitude, and although most recordings are normalized to utilize this peak amplitude, not all recordings sound equally loud. This is because once this peak amplitude is reached, perceived loudness can be further increased through signal-processing techniques such as dynamic range compression and equalization.&amp;lt;ref&amp;gt;Source: Wikipedia - [http://en.wikipedia.org/wiki/Loudness_war Loudness war]&amp;lt;/ref&amp;gt; Therefore, the loudness of a given album has more to do with the year of issue or the whim of the producer than the intended emotional effect. Because of this, a random play through a music collection can have one leaping for the volume control every other track.&lt;br /&gt;
&lt;br /&gt;
There is a solution to this annoyance: within each audio file, information can be stored about what volume change would be required to play each track or album at a standard loudness, and players can use this &amp;quot;replay gain&amp;quot; information to automatically nudge the volume up or down as required.&lt;br /&gt;
&lt;br /&gt;
The ReplayGain specification is a standard which defines an appropriate reference level, explains a way of calculating and representing the ideal replay gain for a given track or album, and provides guidance for players to make the required volume adjustment during playback. The standard also specifies a means to prevent clipping when the calculated replay gain exceeds the limits of digital audio, and it describes how the replay gain information is stored within audio files.&lt;br /&gt;
&lt;br /&gt;
==Loudness measurement==&lt;br /&gt;
Loudness is a subjective measure of the intensity of sound. The correlation of perceived loudness to sound pressure level is determined by the peculiarities of the auditory system. ReplayGain attempts to model those peculiarities with the following measurement procedure.&lt;br /&gt;
&lt;br /&gt;
===Loudness filter===&lt;br /&gt;
[[File:RG_Equal_loudness_all.gif‎|frame|Figure 1: Loudness filter target response (blue), high-pass response (green) and composite response (red)]]&lt;br /&gt;
&lt;br /&gt;
The human ear does not perceive sounds of all frequencies as having equal loudness. For example, a full-scale sine wave at 1 kHz sounds much louder than a full scale sine wave at 100 Hz, even though the two have identical energy. To account for this, the signal is filtered by an inverted approximation of the equal loudness curves (sometimes referred to as Fletcher&amp;amp;ndash;Munson curves) which describe the sensitivity of the ear as a function of frequency. The desired filter response derived from the equal loudness curves is shown in figure 1 (blue).&lt;br /&gt;
&lt;br /&gt;
At higher frequencies a 10th order IIR filter designed by MATLAB&#039;s &amp;quot;yulewalk&amp;quot; function is an excellent approximation to the target. This is cascaded with a 2nd order Butterworth high pass filter, with a high pass frequency of 150 Hz (Figure 1 [green]). The resulting combined response (Figure 1 [red]) is close to the target response, and is used by ReplayGain.&lt;br /&gt;
&lt;br /&gt;
[[File:RG_IIR-filter.png|frame|Figure 2: IIR filter topology used by &amp;quot;yulewalk&amp;quot; and Butterworth filter components]]&lt;br /&gt;
&lt;br /&gt;
The filter topology used for the components of the loudness filter is shown in figure 2. The filter coefficients for 48 and 44.1&amp;amp;nbsp;kHz sample rates are given for the Butterworth and &amp;quot;yulewalk&amp;quot; components in tables 1 and 2 respectively. When using other sample rates, coefficients must be transformed to maintain the same filter response.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|+Table 1a: Butterworth filter coefficients (F&amp;lt;sub&amp;gt;s&amp;lt;/sub&amp;gt;=48&amp;amp;nbsp;kHz)&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; |&lt;br /&gt;
| &#039;&#039;b(0)&#039;&#039;&lt;br /&gt;
| 0.98621192462708&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(1)&#039;&#039; || 1.97223372919527 || &#039;&#039;b(1)&#039;&#039; || -1.97242384925416&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(2)&#039;&#039; || -0.97261396931306 || &#039;&#039;b(2)&#039;&#039; || 0.98621192462708&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|+Table 1b: Butterworth filter coefficients (F&amp;lt;sub&amp;gt;s&amp;lt;/sub&amp;gt;=44.1&amp;amp;nbsp;kHz)&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; |&lt;br /&gt;
| &#039;&#039;b(0)&#039;&#039;&lt;br /&gt;
| 0.98500175787242&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(1)&#039;&#039; || 1.96977855582618 || &#039;&#039;b(1)&#039;&#039; || -1.97000351574484&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(2)&#039;&#039; || -0.97022847566350 || &#039;&#039;b(2)&#039;&#039; || 0.98500175787242&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|+Table 2a: &amp;quot;Yulewalk&amp;quot; filter coefficients (F&amp;lt;sub&amp;gt;s&amp;lt;/sub&amp;gt;=48&amp;amp;nbsp;kHz)&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; |&lt;br /&gt;
| &#039;&#039;b(0)&#039;&#039;&lt;br /&gt;
| 0.03857599435200&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(1)&#039;&#039; || 3.84664617118067 || &#039;&#039;b(1)&#039;&#039; || -0.02160367184185&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(2)&#039;&#039; || -7.81501653005538 || &#039;&#039;b(2)&#039;&#039; || -0.00123395316851&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(3)&#039;&#039; || 11.34170355132042 || &#039;&#039;b(3)&#039;&#039; || -0.00009291677959&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(4)&#039;&#039; || -13.05504219327545 || &#039;&#039;b(4)&#039;&#039; || -0.01655260341619&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(5)&#039;&#039; || 12.28759895145294 || &#039;&#039;b(5)&#039;&#039; || 0.02161526843274&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(6)&#039;&#039; || -9.48293806319790 || &#039;&#039;b(6)&#039;&#039; || -0.02074045215285&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(7)&#039;&#039; || 5.87257861775999 || &#039;&#039;b(7)&#039;&#039; || 0.00594298065125&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(8)&#039;&#039; || -2.75465861874613 || &#039;&#039;b(8)&#039;&#039; || 0.00306428023191&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(9)&#039;&#039; || 0.86984376593551 || &#039;&#039;b(9)&#039;&#039; || 0.00012025322027&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(10)&#039;&#039; || -0.13919314567432 || &#039;&#039;b(10)&#039;&#039; || 0.00288463683916&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|+Table 2b: &amp;quot;Yulewalk&amp;quot; filter coefficients (F&amp;lt;sub&amp;gt;s&amp;lt;/sub&amp;gt;=44.1&amp;amp;nbsp;kHz)&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; |&lt;br /&gt;
| &#039;&#039;b(0)&#039;&#039;&lt;br /&gt;
| 0.05418656406430&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(1)&#039;&#039; || 3.47845948550071 || &#039;&#039;b(1)&#039;&#039; || -0.02911007808948&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(2)&#039;&#039; || -6.36317777566148 || &#039;&#039;b(2)&#039;&#039; || -0.00848709379851&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(3)&#039;&#039; || 8.54751527471874 || &#039;&#039;b(3)&#039;&#039; || -0.00851165645469&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(4)&#039;&#039; || -9.47693607801280 || &#039;&#039;b(4)&#039;&#039; || -0.00834990904936&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(5)&#039;&#039; || 8.81498681370155 || &#039;&#039;b(5)&#039;&#039; || 0.02245293253339&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(6)&#039;&#039; || -6.85401540936998 || &#039;&#039;b(6)&#039;&#039; || -0.02596338512915&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(7)&#039;&#039; || 4.39470996079559 || &#039;&#039;b(7)&#039;&#039; || 0.01624864962975&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(8)&#039;&#039; || -2.19611684890774 || &#039;&#039;b(8)&#039;&#039; || -0.00240879051584&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(9)&#039;&#039; || 0.75104302451432 || &#039;&#039;b(9)&#039;&#039; || 0.00674613682247&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(10)&#039;&#039; || -0.13149317958808 || &#039;&#039;b(10)&#039;&#039; || -0.00187763777362&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Input samples from the audio file to be analysed must be run in cascade manner through both of these filter components before being analysed further.&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RMS level calculation===&lt;br /&gt;
Next, the energy during each moment of the signal is determined by calculating the Root Mean Square (RMS) of the filtered signal every 50ms.&amp;lt;ref&amp;gt;The block length of 50ms was chosen after studying the effect of values between 25ms and 1s. 25ms was too short to accurately reflect the perceived loudness of some sounds. Beyond 50ms there was little change (after statistical processing). For this reason, 50ms was chosen.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The signal is chopped into 50ms long blocks. Then, for each block:&amp;lt;ref&amp;gt;If these steps are read backward, it should be clear why the process is called Root Mean Square averaging.&amp;lt;/ref&amp;gt;&lt;br /&gt;
# Every sample value is squared (multiplied by itself).&lt;br /&gt;
# The mean average is taken.&lt;br /&gt;
# The square root of the average is calculated.&lt;br /&gt;
&lt;br /&gt;
For stereo signals, in step 3, the mean average of all squared samples from both channels over the 50ms measurement interval is taken.&amp;lt;ref&amp;gt;One could sum channels of a stereo signal to mono before calculating the RMS level, but then any out-of-phase components (having the opposite signal on each channel) would cancel out to zero (i.e. silence). That&#039;s not how humans perceive them, so it&#039;s not a good solution.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of this calculation is then converted to a decibel representation as follows:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;L=20 \log_{10} \frac{2{L_{RMS}}}{L_{p-p}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{RMS}&amp;lt;/math&amp;gt; is the RMS value calculated above&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{p-p}&amp;lt;/math&amp;gt; is the maximum peak-to-peak range of the samples in the audio file&lt;br /&gt;
&lt;br /&gt;
===Statistical processing===&lt;br /&gt;
Where the average energy level of a signal varies with time, the louder moments contribute most to perception of overall loudness. For example, in human speech, over half the time is silence, but the perceived loudness of speech is primarily determined by the levels between silences.&lt;br /&gt;
&lt;br /&gt;
A good method to determine the overall perceived loudness is to sort the RMS values into numerical order, and then pick a value near the top of the list. For highly compressed pop music (e.g. Figure 5(c), where there are many values near the top), the choice makes little difference. For speech and classical music (Figures 5(a) and 5(b) respectively), the choice makes a huge difference. The value which most accurately matches human perception of perceived loudness is 95%,&amp;lt;ref&amp;gt;Based on experiments performed by David Robinson, &amp;quot;I tried values from 70% to 95%. For highly compressed pop music, the choice makes little difference. For speech and classical music, the choice makes a huge difference. The value which most accurately matches human perception of perceived loudness is around 95%, so this value is used by Replay Level.&amp;quot;&amp;lt;/ref&amp;gt; so this value is used by ReplayGain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Figure 5: Loudness histograms&amp;quot;&amp;gt;&lt;br /&gt;
File:RG_Statistical_speech.gif‎‎|(a) Speech&lt;br /&gt;
File:RG_Statistical_classic.gif‎‎|(b) Classical music&lt;br /&gt;
File:RG_Statistical_pop.gif‎‎|(c) Pop music&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference level==&lt;br /&gt;
The audio industry does not have a standard for playback system calibration, but in the movie industry a calibration standard has been defined by the Society of Motion Picture and Television Engineers (SMPTE).&amp;lt;ref&amp;gt;SMPTE RP 200:2002 &amp;amp;ndash; Relative and Absolute Sound Pressure Levels for Motion-Picture Multichannel Sound Systems &amp;amp;ndash; Applicable for Analog Photographic Film Audio, Digital Photographic Film Audio and D-Cinema&amp;lt;/ref&amp;gt; The standard states that a single channel pink noise signal with an RMS level of -20 dB relative to a full-scale sinusoid&amp;lt;ref&amp;gt;&amp;quot;dB relative to a full-scale sinusoid&amp;quot; is preferred over &amp;quot;dBFS&amp;quot; as a unit of measure in this specification because there is some ambiguity whether the reference for dBFS is a full-scale square wave (peak reference) or a sine wave (RMS reference).&amp;lt;/ref&amp;gt; should be reproduced at 83 dB SPL.&amp;lt;ref&amp;gt;Measured using a C-weighted, slow averaging SPL meter.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ReplayGain adapts the SMPTE calibration concept for music playback. Under ReplayGain, audio is played so that its loudness, as measured using the procedures described in [[Original ReplayGain specification#Loudness measurement|Loudness measurement]] above, matches the loudness of a pink noise signal with an RMS level of -14 dB relative to a full-scale sinusoid,&amp;lt;ref&amp;gt;The initial ReplayGain proposal used the same -20 dB reference used by SMPTE. The reference was raised to -14 dB early on in ReplayGain development. This reference is used in all current ReplayGain implementations.&amp;lt;/ref&amp;gt; also measured using the procedures described above.&lt;br /&gt;
&lt;br /&gt;
In ReplayGain implementations, the reference level is described in terms of the SMPTE SPL playback level. By the SMPTE definition, the 83 dB SPL reference corresponds to -20FS dB system headroom. The -14 dB headroom used by ReplayGain therefore corresponds to an 89 dB SPL playback level on a SMPTE calibrated system and so is said to be operating with an 89 dB reference level.&lt;br /&gt;
&lt;br /&gt;
SMPTE cinema calibration calls for a single channel of pink noise reproduced through a single loudspeaker. In music applications, the ideal level of the music is actually the loudness when both speakers are in use. So, ReplayGain is calibrated to two channels of pink noise.&amp;lt;ref&amp;gt;In reality, a monophonic pink noise wave file is used, and ReplayGain automatically assumes the file is being played through both speakers, as would any monophonic file.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Gain calculation==&lt;br /&gt;
RG achieves loudness compensated playback by applying gain (or attenuation) dependent on the measured loudness of the audio file relative to the established reference level. The gain is calculated as follows:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG=L_{n14}-L&amp;lt;/math&amp;gt;&lt;br /&gt;
Where all quantities are expressed in decibels:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG&amp;lt;/math&amp;gt; is the replay gain adjustment,&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{n14}&amp;lt;/math&amp;gt; is the measured loudness of the -14 dB pink noise reference and&lt;br /&gt;
:&amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; is the measured loudness of the audio file.&lt;br /&gt;
&lt;br /&gt;
Replay gain is positive if the loudness of the audio file is lower than the pink noise reference. The gain is negative (representing an attenuation) if the loudness of the audio file is higher than that of the reference. The gain is stored as metadata with the audio file as described below and is used by players to adjust output volume of tracks as they are played as described in [[Original ReplayGain specification#Player requirements|Player requirements]] below.&lt;br /&gt;
&lt;br /&gt;
==Metadata==&lt;br /&gt;
For ReplayGain to do its work during playback, four values must be stored as metadata&amp;lt;ref&amp;gt;Metadata is &amp;quot;data about data.&amp;quot; For example, the ID3 &#039;&#039;de facto&#039;&#039; standard provides a way to store artist, title, album title, track number, and other metadata in data blocks called &amp;quot;tags&amp;quot; immediately before or after the audio data in an MP3 file. Other metadata storage/tagging standards and conventions exist for other audio file formats.&amp;lt;/ref&amp;gt; with or within the audio file:&lt;br /&gt;
# Peak track amplitude&lt;br /&gt;
# Peak album amplitude&lt;br /&gt;
# Track replay gain&lt;br /&gt;
# Album replay gain&lt;br /&gt;
&lt;br /&gt;
If calculated for an individual track, the loudness measurement (as specified above) yields track replay gain. If calculated on an album basis, with all tracks concatenated to make one long audio file, the loudness measurement yields album replay gain.&lt;br /&gt;
&lt;br /&gt;
===Replay gain===&lt;br /&gt;
Under some listening conditions, it&#039;s useful to have every track sound equally loud. The problem with a track-by-track approach is that tracks which should be quiet in the context of the album on which they reside will be brought up to the level of all the rest. For casual listening, or in a noisy background, this can be a good thing. For serious listening, it does not respect the intent of the artist or mastering engineer; a tender ballad track will be blasting at the same loudness as a hard rock track on the same album. It&#039;s generally ideal to leave the intentional loudness differences between tracks in place, yet still correct for unmusical and annoying loudness differences between albums. To accomplish this, ReplayGain suggests that two different gain adjustments should be stored as metadata with each sound file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Album replay gain&#039;&#039; represents the ideal listening gain for an entire album. ReplayGain reads the collection of tracks that comprise a album, and calculates a single replay gain for the whole set. This single gain can be used for playback of all tracks of the album. Intentionally quiet tracks then stay appropriately quieter than the rest. It still solves the basic problem (annoying, unwanted level differences between discs) because quiet or loud discs are still adjusted overall&amp;amp;mdash;so the pop CD that&#039;s 20 dB louder than the classical CD will be brought into line.&lt;br /&gt;
&lt;br /&gt;
===Peak amplitude===&lt;br /&gt;
Scanning a track or album for the peak amplitude can be a time-consuming process. Therefore, it&#039;s helpful if this single value is stored as metadata. This is used to predict whether the required replay gain adjustment will cause clipping during playback.&lt;br /&gt;
&lt;br /&gt;
The maximum peak amplitude value is stored as a floating point number, where 1.0 represents digital full scale. As with replay gain values, separate peak amplitude values are stored per track and per album.&lt;br /&gt;
&lt;br /&gt;
For uncompressed files simply, scanners store the maximum absolute sample value held in the file on any channel for positive or negative excursion. The single sample value should be converted to a floating-point representation, such that digital full scale is equivalent to a value of 1.0.&lt;br /&gt;
&lt;br /&gt;
Psychoacoustically coded audio, such as MP3, does not exist as a sequence of samples until it is decoded. Psychoacoustic coding of a heavily limited file can lead to sample values larger than digital full scale upon decoding. The coded files must be decoded using a fully compliant decoder that allows peak overflows (i.e. has headroom) and may result in peak amplitude values greater than 1.0.&lt;br /&gt;
&lt;br /&gt;
==Metadata format==&lt;br /&gt;
From the standpoint of metadata storage, each audio file format presents a unique situation. There are three favored schemes defined for storage of ReplayGain metadata: &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; and &#039;&#039;&#039;APEv2&#039;&#039;&#039;. A survey of file formats is listed below with metadata schemes in order of preference for each:&lt;br /&gt;
* .aac (Advanced Audio Coding raw format) &amp;amp;ndash; No metadata support (use .mp4 instead)&lt;br /&gt;
* .aiff, .aif, .aifc (Apple Interchange File Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID3&amp;quot; IFF chunk)&lt;br /&gt;
* .ape, .apl (Monkey&#039;s Audio) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .bwf (Broadcast Wave Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in RIFF chunk)&lt;br /&gt;
* .flac (Free Lossless Audio Codec) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .mp3 (MPEG audio layer 3) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, LAME VBR proposed tag specification&lt;br /&gt;
* .mp4 also .m4a, .m4b, .m4p, m4r (MPEG-4 Part 14) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID32&amp;quot; box)&lt;br /&gt;
* .mpc (Musepack) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .ogg (Ogg Vorbis) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .tta (True Audio) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .wma (Windows Media audio) - &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; in Extended Content Description Object&lt;br /&gt;
* .wav (Windows PCM) &amp;amp;ndash; No metadata support (use .bwf instead)&lt;br /&gt;
* .wv (WavePak) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===ID3v2===&lt;br /&gt;
The ID3v2 standard&amp;lt;ref&amp;gt;The ID3v2 format is explained at [http://www.id3.org/ www.id3.org]. The most useful document is the [http://www.id3.org/id3v2.3.0.html ID3v2 v2.3.0 standard]. Although this document has been superseded by v2.4.0, the earlier document is complete (rather than an update), and in indexed HTML form. As such, it represents a better technical introduction to ID3v2.&amp;lt;/ref&amp;gt; defines a &#039;&#039;tag&#039;&#039; which is situated before the data in an MP3 file.&amp;lt;ref&amp;gt;The original ID3 (v1) tags resided at the end of the file, and contained a few fields of information. The ID3v1 tag is not extensible and therefore cannot support ReplayGain metadata.&amp;lt;/ref&amp;gt; ID3 is used primarily with MP3 audio files but means of adapting the system to other file types have been developed.&lt;br /&gt;
&lt;br /&gt;
The ID3v2 tag is divided into &#039;&#039;frames&#039;&#039;. The preferred means of storing ReplayGain metadata is use of &#039;&#039;TXXX&#039;&#039; key/value pair frames. Two other legacy schemes for storing ReplayGain metadata exist: [[ReplayGain legacy metadata formats#ID3v2 RGAD|RGAD]] and [[ReplayGain legacy metadata formats#ID3v2 RVA2|RVA2]]. These formats are documented in the [[ReplayGain legacy metadata formats|appendix]]. Players may choose to look for these formats if metadata in the &#039;&#039;TXXX&#039;&#039; format is not found in the ID3v2 tag. New scanners may write these older formats in addition to the newer (TXXX) ones if they wish to remain backwards compatible with older players.&lt;br /&gt;
&lt;br /&gt;
ReplayGain uses four TXXX frames. The header of a TXXX frame is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Frame ID       $54 58 58 58 (&amp;quot;TXXX&amp;quot;) &lt;br /&gt;
 Size           $xx xx xx xx (size of frame excluding this header)&lt;br /&gt;
 Flags          $40 $00      (discard frame if audio data is altered)&lt;br /&gt;
&lt;br /&gt;
Frame data is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Text encoding  $00          (ISO-8859-1 encoding)&lt;br /&gt;
 Description    &amp;lt;key string&amp;gt; $00&lt;br /&gt;
 Value          &amp;lt;value string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The four frames associated with ReplayGain metadata use the following key/value pairs&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Table 3: Metadata keys and value formatting&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
|-&lt;br /&gt;
|Track replay gain&lt;br /&gt;
|REPLAYGAIN_TRACK_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak track amplitude&lt;br /&gt;
|REPLAYGAIN_TRACK_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|-&lt;br /&gt;
|Album replay gain&lt;br /&gt;
|REPLAYGAIN_ALBUM_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak album amplitude&lt;br /&gt;
|REPLAYGAIN_ALBUM_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Gains are specified textually in decibels. Negative gains (attenuation) are prefixed with a &#039;-&#039;. Positive gains have no prefix. Integral portion of the gain (a) may be one or two numeric (0-9) digits. If there is no integral portion the field is &#039;0&#039;. The decimal portion of the gain (bb) is two numeric digits. Gains are suffixed with a space followed by &#039;dB&#039;.&lt;br /&gt;
&lt;br /&gt;
Peak levels are specified textually as a positive decimal. Peak level is a dimensionless quantity with 1.000000 representing full scale. No suffix is included on peak values. The integer field (c) is typically 1 or 0. Six numeric digits in the decimal field (dddddd) is adequate to accurately represent peak values for 16-bit audio data.&lt;br /&gt;
&lt;br /&gt;
A robust player should be prepared to parse the following variations in either replay gain or peak level metadata:&lt;br /&gt;
*Positive gains with leading &#039;+&#039;&lt;br /&gt;
*More or fewer significant digits than specified in any field&lt;br /&gt;
*Leading zeros or spaces in integer fields&lt;br /&gt;
*Missing or malformed &#039;dB&#039; suffix (e.g. no space between numeric digits and suffix, alternate capitalization)&lt;br /&gt;
*Alternate capitalization of keys&lt;br /&gt;
&lt;br /&gt;
Other formatting errors indicate more severe problems and should result in player ignoring data as if the frame did not exist.&lt;br /&gt;
&lt;br /&gt;
===Vorbis comments===&lt;br /&gt;
A Vorbis comment&amp;lt;ref&amp;gt;[http://www.xiph.org/vorbis/doc/v-comment.html Vorbis comment metadata format]. ReplayGain metadata is documented on the [http://wiki.xiph.org/VorbisComment#Replay_Gain Xiph Wiki].&amp;lt;/ref&amp;gt; uses an ASCII &amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; format. When Vorbis comments are used, the four ReplayGain metadata items are stored as separate comments. The &#039;&#039;keys&#039;&#039; and formatting for &#039;&#039;values&#039;&#039; is the same as specified for ID3v2. Keys and values are required by the Vorbis comment specification to be separated by &#039;=&#039; (equal character).&lt;br /&gt;
&lt;br /&gt;
===APEv2===&lt;br /&gt;
The APEv2 metadata format&amp;lt;ref&amp;gt;[http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification APEv2 Specification at Hydrogen Audio Wiki]&amp;lt;/ref&amp;gt; also organizes data into key/value pairs. Keys are ASCII format. A flags field allows support for several value formats including UTF-8 and binary. Under APEv2, ReplayGain meta data is stored using the same keys and data as ASCII values in the same format as specified for ID3v2.&lt;br /&gt;
&lt;br /&gt;
==Player requirements==&lt;br /&gt;
[[File:RG_Player_control.gif‎|frame|Figure 8: Example ReplayGain control panel]]&lt;br /&gt;
&lt;br /&gt;
Loudness normalization, pre-amplification and clipping prevention are the operations performed by a ReplayGain player.&lt;br /&gt;
&lt;br /&gt;
===Loudness normalization===&lt;br /&gt;
To properly normalize loudness, the player needs to determine if the user desires Track style level normalization (all tracks same loudness), or Album style level normalization (all albums same loudness, tracks of an album played at the same relative level as on the original release). This option should be selectable in the ReplayGain control panel (Figure 8). The player reads the corresponding gain metadata value from the file and scales the audio data as appropriate. Scaling the audio data simply means multiplying each sample value by a constant value. This constant is given by:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;10^\frac{gain}{20}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, in words, ten raised to the power of one-twentieth of replay gain.&amp;lt;ref&amp;gt; After any such operation, it&#039;s a good idea to dither the result. If this calculation and the pre-amp are implemented separately, then dither should only be added to the final result, just before the result is truncated back to 16 bits, or 24, or 8, as limited by the soundcard&amp;amp;mdash;not the file (i.e. after ReplayGain adjustment, an 8-bit file should be sent to a 16-bit soundcard at 16-bits).&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the file only contains one of the replay gain adjustments (e.g. Album) but the user has requested the other (Track), then the player should use the one that is available (in this case, Album). If neither (Track or Album) gain metadata is available, then the player needs to choose a suitable default gain. Potential choices include unity gain (0 dB) or an average of gains from other tracks in the album or playlist.&lt;br /&gt;
&lt;br /&gt;
===Pre-amplification===&lt;br /&gt;
Although the calibration level used by ReplayGain suggests that the average level of an audio track should be 14 dB below full scale, some pop music is dynamically compressed to peak at 0 dB and average around 3 dB below full scale. This means that, when the replay gain is applied, the level of such tracks will be reduced by 11 dB! If users are listening to a mixture of highly compressed and more dynamic tracks, ReplayGain will make the listening experience more pleasurable by bringing the level of the compressed tracks down into line with that of the others. However, if users are only listening to highly compressed music, then they may complain that all their files are now too quiet.&amp;lt;ref&amp;gt;This problem can be especially noticeable on portable players with limited output or gain.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To address this problem, a pre-amp feature should be incorporated into the player. A user-supplied pre-amp setting is an adjustment to the calculated replay gain. It should default to perform no adjustment. This means that casual users will experience a moderate reduction in the loudness of their compressed pop music. Less-compressed material can generally be played at the same loudness without clipping. Normalization of more dynamic material may cause clipping or invoke the [[Original ReplayGain specification#Clipping prevention|clipping prevention]] mechanism (see below). Power users and audiophiles can reduce the pre-amp gain to enjoy the full dynamic range of all of their music.&lt;br /&gt;
&lt;br /&gt;
If enabled, the player should read the user selected pre-amp gain, and scale the audio signal by the appropriate amount. For example, a +6 dB gain requires a scale of 10&amp;lt;sup&amp;gt;6/20&amp;lt;/sup&amp;gt;, which is approximately 2. The replay gain and pre-amp scale factors can be combined&amp;lt;ref&amp;gt;Scale factors in  Decibel units are added to produce the same effect as multiplying scale factors in linear units.&amp;lt;/ref&amp;gt; for simplicity and ease of processing.&lt;br /&gt;
&lt;br /&gt;
===Clipping prevention===&lt;br /&gt;
ReplayGain&#039;s suggestion of a -14 dB average playback level leaves sufficient headroom for the bulk of modern recordings. Nevertheless, there exists the possibility that after application of replay gain and pre-amp adjustment, a track may exceed full scale during its dynamic peaks. Without intervention, this will result in clipping, a severe form of distortion. Factors introducing the possibility of clipping include:&lt;br /&gt;
&lt;br /&gt;
# Recordings from certain genres and certain periods in the history of commercial recordings require additional headroom. Although these recordings can be accommodated through a downwards adjustment of the pre-amp setting, it may be difficult to determine a safe adjustment and it may be undesirable to lower average level to accommodate the rare track which requires it. &lt;br /&gt;
# ReplayGain will make loud dynamically compressed tracks quieter, and quiet dynamically uncompressed tracks louder. The average levels will then be similar, but the quiet tracks will actually have louder peaks. If the user pushes the pre-amp gain upwards the peaks of the (originally) quieter tracks will be pushed well over full scale.&lt;br /&gt;
# In coded audio (e.g. MP3 files) a file that was hard-limited to digital full scale before encoding will often be pushed over the limit by the psychoacoustic compression. A decoder with headroom can recover the over full scale signal by reducing the gain.&lt;br /&gt;
&lt;br /&gt;
ReplayGain suggests two possible solutions which prevent clipping in these situations. A player should support one or both of these.&lt;br /&gt;
&lt;br /&gt;
====Audio limiting====&lt;br /&gt;
In situation 2 above, the user clearly wants all the music to sound very loud. To give them their wish, any signal which would peak above digital full scale should be hard limited at just below digital full scale. This is also useful at lower pre-amp gains, where it allows the average level of classical music to be raised to that of pop music, without distorting. The exact type of nature limiting or compression an implementation choice for the player.&amp;lt;ref&amp;gt;Something like the Hard Limiter found in Cool Edit Pro (Syntrillium) would be appropriate for pop music at least.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reduced gain====&lt;br /&gt;
The audiophile user will not want any compression or limiting on the signal. In this case the only option is to automatically and temporarily reduce the pre-amp gain below the user-selected setting for tracks where clipping would otherwise occur. Clipping can be predicted by examining the peak level of the track or album being played.&lt;br /&gt;
&lt;br /&gt;
The player must read the peak amplitude metadata. If peak level metadata is unavailable, the player should assume a peak level of 1.0. If the peak level for both track and album is stored as metadata in the file, it is possible to calculate if, following the replay gain adjustment and pre-amp gain, the signal will clip at some point. If it won&#039;t, then no further action is necessary. &lt;br /&gt;
&lt;br /&gt;
An overall scale factor for loudness normalization taking into account replay gain, pre-amp setting and clipping prevention through gain reduction is given below.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;min( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{peak amplitude} )&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hardware implementation===&lt;br /&gt;
The above three steps are appropriate to software players operating on the digital signal in order to scale it. However, it is possible to send the digital signal to the DAC without level correction, and to place an attenuator in the analogue signal path. The attenuator can then be driven by the Replay Gain value. The clipping problem can be addressed by providing adequate headroom in the analog circuitry. Bit transparency and maximum signal to noise ratio is maintained in the digital signal and DAC process.&amp;lt;ref&amp;gt;A system using today&#039;s 24-bit converters is unlikely to appreciate any overall gain in system performance with such an arrangement. A digitally-controlled analog gain element typically introduces significant noise and distortion.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The [http://replaygain.hydrogenaudio.org/proposal original ReplayGain proposal] (an [http://replay.waybackmachine.org/20090306202649/http://www.replaygain.org/ archive] is also available) was developed by David Robinson and was published 10 July 2001. Additional updates were published by David Robinson through 10 October 2001.&lt;br /&gt;
&lt;br /&gt;
The following acknowledgement was included with the original proposal, &amp;quot;The algorithm to calculate an ideal replay gain has grown from my research into human hearing, with many additional ideas drawn from the work of E. Zwicker, and Brian Moore. I am currently completing my PhD at the University of Essex, and have been funded by the EPSRC.&amp;quot; Additionally David Robinson credited Glen Sawyer (Snelg) and Jim Casaburi (Walrus) for software contributions and Bob Katz and Matt Ashland for ideas.&lt;br /&gt;
&lt;br /&gt;
This updated ReplayGain specification reflecting current and recommended practice was prepared by Kevin Gross in 2011.&lt;br /&gt;
&lt;br /&gt;
==Contact==&lt;br /&gt;
For ReplayGain-related questions or contributions, please post in the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio] section of the Hydrogen Audio forums.&lt;br /&gt;
 &lt;br /&gt;
==Appendix==&lt;br /&gt;
# [[ReplayGain legacy metadata formats]]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
: &#039;&#039;This is not a normative part of the specification.&#039;&#039;&lt;br /&gt;
* [[Revised ReplayGain specification]] (draft)&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38798</id>
		<title>ReplayGain</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38798"/>
		<updated>2026-01-22T20:24:53Z</updated>

		<summary type="html">&lt;p&gt;Skamp: More clarification about mentions of RG1 and RG2, online and elsewhere.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;ReplayGain&#039;&#039;&#039; is the name of a technique invented to achieve the same perceived playback loudness of audio files. It defines an algorithm to measure the &#039;&#039;&#039;perceived&#039;&#039;&#039; loudness of audio data.&lt;br /&gt;
&lt;br /&gt;
ReplayGain allows the loudness of each song within a collection of songs to be consistent. This is called &#039;Track Gain&#039; (or &#039;Radio Gain&#039; in earlier parlance). It also allows the loudness of a specific sub-collection (an &amp;quot;album&amp;quot;) to be consistent with the rest of the collection, while allowing the dynamics from song to song on the album to remain intact. This is called &#039;Album Gain&#039; (or &#039;Audiophile Gain&#039; in earlier parlance). This is especially important when listening to classical music albums, because quiet tracks need to remain a certain degree quieter than the louder ones.&lt;br /&gt;
&lt;br /&gt;
ReplayGain is different from [[Normalization|peak normalization]]. Peak normalization merely ensures that the peak amplitude reaches a certain level. This does not ensure equal loudness. The ReplayGain technique measures the &#039;&#039;effective power&#039;&#039; of the waveform (i.e. the RMS power after applying an &amp;quot;equal loudness contour&amp;quot;), and then adjusts the amplitude of the waveform accordingly. The result is that Replay Gained waveforms are usually more uniformly amplified than peak-normalized waveforms.&lt;br /&gt;
&lt;br /&gt;
==Target loudness==&lt;br /&gt;
The target loudness of almost all ReplayGain utilities is 89&amp;amp;nbsp;dB SPL when replayed in an SMPTE RP 200 calibrated system (an early departure from the proposal, endorsed by its author&amp;lt;ref&amp;gt;[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=83397&amp;amp;view=findpost&amp;amp;p=721854 Does Replay gain work differtly in Media monkey]&amp;lt;/ref&amp;gt;) &amp;amp;mdash; the ReplayGain proposal and SMPTE recommendation are 6&amp;amp;nbsp;dB lower.&amp;lt;ref&amp;gt;[http://www.mars.org/mailman/public/mad-dev/2004-February/000993.html ReplayGain discussion at mad-dev]&amp;lt;/ref&amp;gt; The target loudness may be more commonly known and understood as &#039;&#039;&#039;-18&#039;&#039;&#039;&amp;amp;nbsp;&#039;&#039;&#039;[https://en.wikipedia.org/wiki/LUFS LUFS]&#039;&#039;&#039; (&#039;&#039;Loudness Units relative to Full Scale&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Some utilities have realized the inadequacies of the classic ReplayGain loudness calculation, switching to a more modern algorithm ([https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en ITU-R BS.1770]). However, the way it was integrated was extremely &#039;&#039;ad hoc&#039;&#039;, at least until a draft of a [[ReplayGain 2.0 specification|revised specification]] started being written.&lt;br /&gt;
&lt;br /&gt;
==Clipping==&lt;br /&gt;
Audio is generally recorded such that the loudest sounds don&#039;t clip, but the use of ReplayGain can cause clipping if the average volume of a song is below the target level. That is, upon playback, the volume of a quiet song is increased, so the parts of the song with above-average loudness, especially in the bass frequencies, will exceed the limits of the format and will be distorted. Whether this distortion is audible depends on the sounds in question, and the listener&#039;s sensitivity.&lt;br /&gt;
&lt;br /&gt;
Implementations deal with the risk of clipping in different ways. Some have a &amp;quot;pre-amp&amp;quot; feature which reduces (or boosts) the original audio&#039;s level by a certain amount before doing whatever is needed for ReplayGain. Some have a &amp;quot;prevent clipping&amp;quot; feature to reduce the amount of ReplayGain adjustment to whatever amount would keep clipping from occurring, based on peak info stored in the file&#039;s metadata (thus reducing the effectiveness of ReplayGain). Some recommend using a compressor/limiter DSP to prevent or reduce clipping, regardless of whether it was caused by ReplayGain.&lt;br /&gt;
&lt;br /&gt;
An alternative that may reduce the risk of clipping is the [https://tech.ebu.ch/docs/r/r128.pdf EBU R 128] recommendation of a &#039;&#039;&#039;-23&#039;&#039;&#039;&amp;amp;nbsp;&#039;&#039;&#039;LUFS&#039;&#039;&#039; target, although some may find the additional reduction in volume excessive, particularly if it leads to maxing out volume on user hardware. [[Opus]] in particular has adopted that recommendation.&lt;br /&gt;
&lt;br /&gt;
== Implementations ==&lt;br /&gt;
There are different ReplayGain implementations, each with its own uses and strength. Most use [[metadata]] to indicate the level of the volume change that the player should make. Some modify the audio data itself, and optionally use metadata as well. There are advantages and disadvantages to both methods.&lt;br /&gt;
&lt;br /&gt;
In the metadata method, information on both types of ReplayGain (Track Gain and Album Gain) can be stored. The volume-change information can be very precise. If audio data was also changed, the metadata can contain &amp;quot;undo&amp;quot; info. Not all audio players/decoders know how to read and use ReplayGain information stored in metadata. And there&#039;s no standard for where and how ReplayGain info is stored; each implementation uses different formats and puts the info in different locations.&lt;br /&gt;
&lt;br /&gt;
In the audio data method, the file&#039;s actual audio data is modified so that its natural/default playback volume is at the target level. In this scenario, only one type of ReplayGain (Track Gain or Album Gain) can be applied. If no &amp;quot;undo&amp;quot; info is saved somewhere, it may not be possible to restore the original audio data. Limitations of the audio file format may prevent precise (finely tuned) gain adjustments with this method. For example, MP3 and AAC files can only be losslessly modified in 1.5 dB steps. Depending on the audio file format, the process may also be lossy in the sense that it could irreversibly push a signal above the format&#039;s maximum amplitude (resulting in clipping) or below the minimum (resulting in silence).&lt;br /&gt;
&lt;br /&gt;
=== Old versus new algorithms ===&lt;br /&gt;
Since the ReplayGain standard does not define tags to specify which algorithm was used (classic or ITU-R BS.1770) or what target was set (RG&#039;s -18&amp;amp;nbsp;LUFS, EBU R 128&#039;s -23&amp;amp;nbsp;LUFS, or any other target set by the user or some piece of software), there may be confusion as to how the results were produced. Typically, utilities that ship with reference encoders (FLAC / metaflac, Vorbis / vorbisgain, WavPack / wvgain, Musepack / mpcgain…) use the original RG algorithm, which can produce values that differ from newer tools by several decibels in certain cases. Generally speaking, it is recommended to run other utilities or players that implement the ITU-R BS.1770 algorithm, although it may not be obvious which algorithm they use at first glance. Their documentation may provide that information.&lt;br /&gt;
&lt;br /&gt;
==== RG1, RG2 ====&lt;br /&gt;
Although there are many references online, and within ReplayGain scanners, about version 1 vs. version 2 of the ReplayGain standard, at the time of writing this, there is (admittedly) only one ReplayGain standard. The core principle, as well as the 4 tags from the original specification, have not changed. More tags have been proposed but they are still subject to debate. As a rule of thumb, tools that advertise &amp;quot;ReplayGain&amp;amp;nbsp;2&amp;quot; compliance employ the newer, more accurate ITU-R BS.1770 algorithm. [[foobar2000]] labels it &amp;quot;EBU R128&amp;quot; but it essentially means the same thing. Should a better algorithm be developed in the future, it will still work towards fulfilling ReplayGain&#039;s original goals, and probably write the same tags.&lt;br /&gt;
&lt;br /&gt;
=== MP3Gain ===&lt;br /&gt;
[[MP3Gain]] is an implementation of classic ReplayGain. It can be used to just analyze files &amp;amp; recommend changes or to also modify the gain. If modifying the gain, it always modifies the global gain fields in the MP3 audio data. It can add somewhat precise metadata, including undo info. The gain can be modified to any target dB, or it can be changed by a specified amount. For balance correction, user-specified changes can even be made on just one channel in simple L/R stereo-mode files (not joint stereo).&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]]&lt;br /&gt;
* Method: Audio + Meta (in APE tag), or Audio only&lt;br /&gt;
* APE tag fields (ASCII bytes):&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values for this file. 3 digits, zero-padded if necessary.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_ALBUM_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values across a set of files scanned as an album. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_UNDO +###,+###,N&amp;lt;/code&amp;gt; - the global gain adjustment to restore the original values in the left and right channels, respectively, followed by an indicator of whether to wrap at the extremes (&amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; means no, &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; means yes). The adjustment values are 3 digits, zero-padded, preceded by a sign (&amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;).&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Examples: &amp;lt;code&amp;gt;+0.424046&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-10.38500&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Example: &amp;lt;code&amp;gt;0.149923&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Optional.&lt;br /&gt;
* Limitations: Although the metadata, if written, contains precise adjustment &amp;amp; peak values, the audio data modifications are limited to 1.5dB steps and may become irreversible (however, that&#039;s a very rare condition; see the [https://hydrogenaud.io/index.php/topic,34154.0.html &amp;quot;mp3gain is NOT lossless&amp;quot; forum thread])&lt;br /&gt;
* http://mp3gain.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== AACGain ===&lt;br /&gt;
[[AACGain]] is a modified version of MP3Gain that works on both MP3 and AAC files.&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]], [[AAC]] (with or without MP4 container)&lt;br /&gt;
* Method: Audio + Meta, or Audio only&lt;br /&gt;
* Limitations: Limited to 1.5dB steps mode, may become irreversible (same caveat as for MP3Gain)&lt;br /&gt;
* http://aacgain.altosdesign.com/&lt;br /&gt;
&lt;br /&gt;
=== [[LAME]] ===&lt;br /&gt;
* Method: Header ([http://gabriel.mp3-tech.org/mp3infotag.html mp3infotag])&lt;br /&gt;
* Notes:&lt;br /&gt;
** Uses the classic RG algorithm.&lt;br /&gt;
** Tags added during encoding; not supported by any player yet; Track Gain only&lt;br /&gt;
** Replay Gaining MP3&#039;s is usually done using MP3Gain (see [[ReplayGain#MP3Gain|above]]) or [[ReplayGain#foobar2000 ReplayGain scanner|foobar2000]]&lt;br /&gt;
* http://lame.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== [[Musepack]] ReplayGain ===&lt;br /&gt;
* Method: Header (similar to Meta data method)&lt;br /&gt;
* Notes: Uses the classic RG algorithm. ReplayGain values are stored in the header and ReplayGain is part of the Musepack specifications; therefore any Musepack decoder that does not support ReplayGain can be considered broken.&lt;br /&gt;
* http://www.musepack.net/&lt;br /&gt;
&lt;br /&gt;
=== VorbisGain ===&lt;br /&gt;
* Format: (Ogg) [[Vorbis]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://www.sjeng.org/vorbisgain.html&lt;br /&gt;
** new compiles of VorbisGain at [http://www.rarewares.org/ogg.html www.rarewares.org]&lt;br /&gt;
:&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Andavari has provided a very useful script to integrate VorbisGain, which is a CLI tool, into Windows Explorer. Please (Ogg) [[Vorbis#ReplayGain|check this section]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== FLAC / METAFLAC ===&lt;br /&gt;
* Format: [[Free Lossless Audio Codec|FLAC]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://flac.sf.net&lt;br /&gt;
&lt;br /&gt;
=== WavPack / WVGAIN ===&lt;br /&gt;
* Format: [[WavPack]]&lt;br /&gt;
* Method: Meta (in [[APEv2]] tag)&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://www.wavpack.com&lt;br /&gt;
&lt;br /&gt;
=== Wavegain ===&lt;br /&gt;
* Format: waveform&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* Limitations: Irreversible&lt;br /&gt;
* http://www.rarewares.org/others.php#wavegain&lt;br /&gt;
&lt;br /&gt;
=== MusicPlayer ===&lt;br /&gt;
* Custom implementation, not derived from the original MP3Gain one (but inspired from). As far as I know, all other implementations are directly derived from the MP3Gain (gain_analysis.c, which is GPL) source.&lt;br /&gt;
* Format: any that FFmpeg supports&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Limitations: Doesn&#039;t modify the files at all. Stores the value in own database. Used only for playback.&lt;br /&gt;
* https://github.com/albertz/music-player&lt;br /&gt;
&lt;br /&gt;
=== [[foobar2000]] ReplayGain scanner ===&lt;br /&gt;
* Since v1.1.6, defaults to ITU-R BS.1770 analysis (although it labels it EBU R128), but can be configured to use the &amp;quot;Classic ReplayGain&amp;quot; algorithm instead. The ITU-R BS.1770 implementation uses a reference level of -18&amp;amp;nbsp;LUFS instead of -23, in order to retain compatibility with the ReplayGain standard.&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] (default) or [[APEv2]] tags. A separate function can be invoked to apply the tagged Track or Album Gain to the MP3 global gain fields (as MP3Gain does), and rewrite any existing tags to account for the peak change and compensate for the difference from 89&amp;amp;nbsp;dB. The 89&amp;amp;nbsp;dB reference level for tags isn&#039;t configurable, but the reference level applied to the global gain fields is (it&#039;s under Preferences &amp;gt; Advanced &amp;gt; Tools &amp;gt; ReplayGain Scanner &amp;gt; Target MP3 alteration volume level).&lt;br /&gt;
** [[Musepack]]: Values written to header.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags. As with MP3, it is also an option to apply gain via a separate function.&lt;br /&gt;
** [[MP4]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain).&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** Modules ([[MOD]] etc.): Optionally saved into [[APEv2]] tags.&lt;br /&gt;
* https://foobar2000.org/&lt;br /&gt;
&lt;br /&gt;
=== [[MediaMonkey]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[APEv2]] or [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[WAV]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[MPC]]: Internal gain Structure.&lt;br /&gt;
* In addition to tags, all ReplayGain values are also stored in MediaMonkey&#039;s MDB database&lt;br /&gt;
* Album/Audiophile ReplayGain not supported until v3.0 (Dec 2007); support during burning &amp;amp; ripping added in 3.1 (Jun 2009)&lt;br /&gt;
* Also capable of (irreversibly) changing the volume of MP3 tracks, similar to [[MP3Gain]]&lt;br /&gt;
* http://www.mediamonkey.com/&lt;br /&gt;
&lt;br /&gt;
=== [[Winamp]] ReplayGain scanner===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in Windows Media Audio tags.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[MP4]]&lt;br /&gt;
** [[TAK]]: Values written to [[APEv2]] tags.&lt;br /&gt;
* Support Album/Track Gain&lt;br /&gt;
&lt;br /&gt;
=== [[loudgain]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** MP2, [[MP3]]: Values written to [[ID3v2]] tags (ID3v2.3/ID3v2.4 selectable).&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Speex]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[Opus]]: Values written to [[Vorbis comment]], based on -23&amp;amp;nbsp;LUFS Opus standard. Only &amp;lt;code&amp;gt;R128_TRACK_GAIN&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;R128_ALBUM_GAIN&amp;lt;/code&amp;gt; are written, but the calculated &#039;&#039;true peak&#039;&#039; value can still be used to reduce the gain values ([[Clipping]] prevention).&lt;br /&gt;
** [[MP4]], [[M4A]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain). ReplayGain values are stored under &amp;lt;code&amp;gt;----:com.apple.iTunes:…&amp;lt;/code&amp;gt;. This is for [[AAC]] and [[ALAC]] in [[MPEG-4]] containers.&lt;br /&gt;
** [[ASF]], [[Windows Media Audio|WMA]]: Values written to WMA tags, no prefix.&lt;br /&gt;
** [[WAV]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] (ID3v2.3/ID3v2.4 selectable) format. Using the &amp;lt;code&amp;gt;bext&amp;lt;/code&amp;gt; chunk (for BWF v2) isn’t (yet) supported, but won’t be destroyed on writing.&lt;br /&gt;
** [[Audio Interchange File Format|AIFF]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] format.&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[Monkey&#039;s Audio]] (APE): Values written to [[APEv2]] tags.&lt;br /&gt;
* Follows EBU R128, ITU BS.1770 and the [[ReplayGain 2.0 specification|revised ReplayGain specification]].&lt;br /&gt;
* &#039;&#039;Never&#039;&#039; touches the actual audio data but &#039;&#039;only writes RG2 tags&#039;&#039;.&lt;br /&gt;
* Uses &#039;&#039;true peak&#039;&#039; values calculated by oversampling to 192&amp;amp;nbsp;kHz, using a custom polyphase FIR interpolator that will oversample 4x for sample rates &amp;lt; 96&amp;amp;nbsp;kHz, 2x for sample rates &amp;lt; 192&amp;amp;nbsp;kHz and leave the signal unchanged for 192&amp;amp;nbsp;kHz.&lt;br /&gt;
* &#039;&#039;Clipping prevention&#039;&#039; can be used to lower the ReplayGain values to a safe margin (default -1&amp;amp;nbsp;dBTP, can be changed).&lt;br /&gt;
* Many options for special cases: force RG tags upper-/lowercase, add extra tags (LRA, Reference loudness), strip unwanted tag types (APEv2 from MP2/MP3, ID3 from WavPack), tab-delimited table output for analysis with CSV file.&lt;br /&gt;
* &#039;&#039;Linux&#039;&#039; Free and Open Source software, can be installed on &#039;&#039;MacOS&#039;&#039; using &#039;&#039;HomeBrew&#039;&#039;, on &#039;&#039;Windows 10&#039;&#039; using the Linux &#039;&#039;bash&#039;&#039;.&lt;br /&gt;
* Also installs a &amp;lt;code&amp;gt;rgbpm&amp;lt;/code&amp;gt; bash script for mass-tagging, which can be adapted to the user’s needs.&lt;br /&gt;
* &#039;&#039;&#039;Warning:&#039;&#039;&#039; Loudgain relies on standard libraries like &#039;&#039;TagLib&#039;&#039;. Linux distros (except rolling releases) sometimes deliver outdated libraries, so be sure you use the latest version of &#039;&#039;TagLib&#039;&#039;. Version 1.11.1 had a nasty bug for a while that [https://hydrogenaud.io/index.php/topic,118085.msg974957.html#msg974957 could corrupt Ogg Vorbis files]. This has been fixed in the meantime but the TagLib version not updated. Loudgain comes with a (slower) static version called &amp;lt;code&amp;gt;loudgain.static&amp;lt;/code&amp;gt; in the repo’s &amp;lt;code&amp;gt;/bin&amp;lt;/code&amp;gt; folder that doesn’t expose the bug and can also be used on older Linux versions (like Ubuntu 14.04, Linux Mint 17).&lt;br /&gt;
* https://github.com/Moonbase59/loudgain&lt;br /&gt;
* Bug tracker: https://github.com/Moonbase59/loudgain/issues&lt;br /&gt;
&lt;br /&gt;
=== [[rsgain]] ===&lt;br /&gt;
rsgain is a newer ReplayGain command line utility designed with a &amp;quot;batteries included&amp;quot; philosophy, use the newer ITU-R BS.1770 algorithm.&lt;br /&gt;
&lt;br /&gt;
Features:&lt;br /&gt;
* Cross-platform Windows&amp;amp;nbsp;/&amp;amp;nbsp;macOS&amp;amp;nbsp;/&amp;amp;nbsp;Linux&lt;br /&gt;
* Supports all popular audio formats&lt;br /&gt;
* Simplified &amp;quot;Easy Mode&amp;quot; command line syntax supports recursive, directory-based scanning&lt;br /&gt;
* Multithreaded scanning option that provides significant speed improvement with full library scans&lt;br /&gt;
* Option to skip files with existing ReplayGain metadata&lt;br /&gt;
* Scan presets allow the user to save advanced settings for consistent use&lt;br /&gt;
&lt;br /&gt;
== Players support ==&lt;br /&gt;
ReplayGain being present in the specs of the FLAC, Musepack, and APE formats, any player that support those formats usually supports ReplayGain.&lt;br /&gt;
&lt;br /&gt;
The situation with MP3 is rather different, as it was not part of the MP3 specs. The APEv2 tags metadata implementation is somewhat becoming the de-facto standard.&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
* [[foobar2000]] supports ReplayGain in all possible aspects.&lt;br /&gt;
* [[Winamp]] supports ReplayGain in album or track mode.&lt;br /&gt;
* [[MediaMonkey]] supports ReplayGain, with many configuration options.&lt;br /&gt;
* [[XMPlay]] recently implemented ReplayGain&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;...and probably others.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
* [[XMMS]]. Reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], [[Musepack]], (Ogg) [[Vorbis]] ..&lt;br /&gt;
:For [[MP3]], use the CVS version of the [http://xmms-mad.sourceforge.net/ xmms-mad] mp3 plugin (it&#039;s not yet released as binary, furthermore not available in distribs&#039; versions for now. Meanwhile binaries are available here: [http://perso.crans.org/~krempp/xmms-mad/ custom binaries])&lt;br /&gt;
* [[amarok]]. By using the amarok-script [http://kde-apps.org/content/show.php?content=26073 ReplayGain]&lt;br /&gt;
:And possibly others, since [http://developer.kde.org/~wheeler/taglib.html TagLib] added support for [[APEv2]] tags in [[MP3]] files, players using this library (like [[amaroK]] and [[JuK]]) might support that kind of ReplayGain tags in the near future.&lt;br /&gt;
* [http://www.sacredchao.net/quodlibet Quod Libet] reads ReplayGain from (Ogg) [[Vorbis]], [[MP3]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:Requires support to be enabled (via the appropriate python bindings and libraries) for the above formats. Does not support ReplayGain values stored in [[APEv2]] tags in [[MP3]]s. ReplayGain values are stored in RVA2 id3v2.4 frames. See the [http://www.sacredchao.net/quodlibet/wiki/Development/ID3Notes Quod Libet RVA2 / ReplayGain notes].&lt;br /&gt;
* [http://www.musicpd.org/ Music Player Daemon] (MPD) reads ReplayGain from (Ogg) [[Vorbis]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:foobar2000-style TXXX frames in [[MP3]]s are also supported in the latest development releases.&lt;br /&gt;
* [http://www.mplayerhq.hu/ MPlayer]. Mplayer support for ReplayGain is codec dependent.&lt;br /&gt;
:Codecs that are known to support ReplayGain: vorbis&lt;br /&gt;
:Because of this, you need to prioritize the codecs that support it, or choose it individually on the command line.  To add it to the command line, add an -ac [codec] option after each file that you want to choose the codec for, or at the beginning to make it apply to all files listed.  To prioritize the codecs by default, list them in a line in mplayer.conf:&lt;br /&gt;
 ac=[codec],[othercodec],vorbis,mad,&lt;br /&gt;
* [http://idjc.sourceforge.net/ IDJC] (Internet DJ Console) reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], (Ogg) FLAC, (Ogg) [[Vorbis]], MP2 (audio), [[MP3]], [[Opus]], but only the &#039;&#039;lowercase&#039;&#039; tags. There is a [https://sourceforge.net/p/idjc/bugs/100/ ticket] open to handle tags case-insensitively.&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
* [https://www.videolan.org/vlc/ VLC] supports ReplayGain in many file formats, but usually only the &#039;&#039;uppercase&#039;&#039; variant of the tags.&lt;br /&gt;
* [https://kodi.tv/ KODI] reads ReplayGain from nearly all formats, but usually only the &#039;&#039;lowercase&#039;&#039; variant of the tags.&lt;br /&gt;
&lt;br /&gt;
=== Portable devices ===&lt;br /&gt;
[http://www.rockbox.org/ Rockbox] supports ReplayGain (in album or track mode) for most formats, including  WMA, MP1/2/3, AAC, ALAC, Musepack, Monkey&#039;s Audio, Wavpack, FLAC and Vorbis.  &amp;lt;br&amp;gt;Note that ReplayGain is only supported when using the respective codec&#039;s native tagging format.  For example:  ReplayGain stored in APEv2 tags is not supported for MP3, rather ID3v2.x tags are expected.&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Fuze with firmware 1.02.26 and 2.02.26&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Clip+&lt;br /&gt;
&lt;br /&gt;
The iPod features &#039;&#039;Soundcheck&#039;&#039;, which seems to produce roughly the same normalization gains as ReplayGain, but doesn&#039;t provide an Album Gain.&lt;br /&gt;
&lt;br /&gt;
=== Hi-Fi ===&lt;br /&gt;
Slim Devices, a company owned by Logitech Inc, supports ReplayGain on both of their hi-end audiophile players, known as the [[Slim Devices Transporter|Transporter]] and the [[Slim Devices Squeezebox|Squeezebox]].&lt;br /&gt;
&lt;br /&gt;
BluOS also supports ReplayGain with the selection of album- or track-gain and a so called Smart option that decides between the two by itself.&lt;br /&gt;
NAD devices that use BluOS consequently also support ReplayGain.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;references/&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[ReplayGain specification]]&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Replay_Gain ReplayGain] at Wikipedia&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain.html ReplayGain using foobar2000] (how to use ReplayGain in Windows using foobar2000).&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain-in-Linux.html ReplayGain in Linux] (how to use ReplayGain in Linux using foobar2000 and Wine, or using metaflac or vorbisgain).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Technical]]&lt;br /&gt;
[[index.php?title=Category:Metadata]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38797</id>
		<title>ReplayGain</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38797"/>
		<updated>2026-01-22T20:09:01Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Added a paragraph to alleviate the confusion between reference tools using the classic RG algorithm, versus newer tools that use the newer algorithm.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;ReplayGain&#039;&#039;&#039; is the name of a technique invented to achieve the same perceived playback loudness of audio files. It defines an algorithm to measure the &#039;&#039;&#039;perceived&#039;&#039;&#039; loudness of audio data.&lt;br /&gt;
&lt;br /&gt;
ReplayGain allows the loudness of each song within a collection of songs to be consistent. This is called &#039;Track Gain&#039; (or &#039;Radio Gain&#039; in earlier parlance). It also allows the loudness of a specific sub-collection (an &amp;quot;album&amp;quot;) to be consistent with the rest of the collection, while allowing the dynamics from song to song on the album to remain intact. This is called &#039;Album Gain&#039; (or &#039;Audiophile Gain&#039; in earlier parlance). This is especially important when listening to classical music albums, because quiet tracks need to remain a certain degree quieter than the louder ones.&lt;br /&gt;
&lt;br /&gt;
ReplayGain is different from [[Normalization|peak normalization]]. Peak normalization merely ensures that the peak amplitude reaches a certain level. This does not ensure equal loudness. The ReplayGain technique measures the &#039;&#039;effective power&#039;&#039; of the waveform (i.e. the RMS power after applying an &amp;quot;equal loudness contour&amp;quot;), and then adjusts the amplitude of the waveform accordingly. The result is that Replay Gained waveforms are usually more uniformly amplified than peak-normalized waveforms.&lt;br /&gt;
&lt;br /&gt;
==Target loudness==&lt;br /&gt;
The target loudness of almost all ReplayGain utilities is 89&amp;amp;nbsp;dB SPL when replayed in an SMPTE RP 200 calibrated system (an early departure from the proposal, endorsed by its author&amp;lt;ref&amp;gt;[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=83397&amp;amp;view=findpost&amp;amp;p=721854 Does Replay gain work differtly in Media monkey]&amp;lt;/ref&amp;gt;) &amp;amp;mdash; the ReplayGain proposal and SMPTE recommendation are 6&amp;amp;nbsp;dB lower.&amp;lt;ref&amp;gt;[http://www.mars.org/mailman/public/mad-dev/2004-February/000993.html ReplayGain discussion at mad-dev]&amp;lt;/ref&amp;gt; The target loudness may be more commonly known and understood as &#039;&#039;&#039;-18&#039;&#039;&#039;&amp;amp;nbsp;&#039;&#039;&#039;[https://en.wikipedia.org/wiki/LUFS LUFS]&#039;&#039;&#039; (&#039;&#039;Loudness Units relative to Full Scale&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Some utilities have realized the inadequacies of the classic ReplayGain loudness calculation, switching to a more modern algorithm ([https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en ITU-R BS.1770]). However, the way it was integrated was extremely &#039;&#039;ad hoc&#039;&#039;, at least until a draft of a [[ReplayGain 2.0 specification|revised specification]] started being written.&lt;br /&gt;
&lt;br /&gt;
==Clipping==&lt;br /&gt;
Audio is generally recorded such that the loudest sounds don&#039;t clip, but the use of ReplayGain can cause clipping if the average volume of a song is below the target level. That is, upon playback, the volume of a quiet song is increased, so the parts of the song with above-average loudness, especially in the bass frequencies, will exceed the limits of the format and will be distorted. Whether this distortion is audible depends on the sounds in question, and the listener&#039;s sensitivity.&lt;br /&gt;
&lt;br /&gt;
Implementations deal with the risk of clipping in different ways. Some have a &amp;quot;pre-amp&amp;quot; feature which reduces (or boosts) the original audio&#039;s level by a certain amount before doing whatever is needed for ReplayGain. Some have a &amp;quot;prevent clipping&amp;quot; feature to reduce the amount of ReplayGain adjustment to whatever amount would keep clipping from occurring, based on peak info stored in the file&#039;s metadata (thus reducing the effectiveness of ReplayGain). Some recommend using a compressor/limiter DSP to prevent or reduce clipping, regardless of whether it was caused by ReplayGain.&lt;br /&gt;
&lt;br /&gt;
An alternative that may reduce the risk of clipping is the [https://tech.ebu.ch/docs/r/r128.pdf EBU R 128] recommendation of a &#039;&#039;&#039;-23&#039;&#039;&#039;&amp;amp;nbsp;&#039;&#039;&#039;LUFS&#039;&#039;&#039; target, although some may find the additional reduction in volume excessive, particularly if it leads to maxing out volume on user hardware. [[Opus]] in particular has adopted that recommendation.&lt;br /&gt;
&lt;br /&gt;
== Implementations ==&lt;br /&gt;
There are different ReplayGain implementations, each with its own uses and strength. Most use [[metadata]] to indicate the level of the volume change that the player should make. Some modify the audio data itself, and optionally use metadata as well. There are advantages and disadvantages to both methods.&lt;br /&gt;
&lt;br /&gt;
In the metadata method, information on both types of ReplayGain (Track Gain and Album Gain) can be stored. The volume-change information can be very precise. If audio data was also changed, the metadata can contain &amp;quot;undo&amp;quot; info. Not all audio players/decoders know how to read and use ReplayGain information stored in metadata. And there&#039;s no standard for where and how ReplayGain info is stored; each implementation uses different formats and puts the info in different locations.&lt;br /&gt;
&lt;br /&gt;
In the audio data method, the file&#039;s actual audio data is modified so that its natural/default playback volume is at the target level. In this scenario, only one type of ReplayGain (Track Gain or Album Gain) can be applied. If no &amp;quot;undo&amp;quot; info is saved somewhere, it may not be possible to restore the original audio data. Limitations of the audio file format may prevent precise (finely tuned) gain adjustments with this method. For example, MP3 and AAC files can only be losslessly modified in 1.5 dB steps. Depending on the audio file format, the process may also be lossy in the sense that it could irreversibly push a signal above the format&#039;s maximum amplitude (resulting in clipping) or below the minimum (resulting in silence).&lt;br /&gt;
&lt;br /&gt;
=== Old versus new algorithms ===&lt;br /&gt;
Since the ReplayGain standard does not define tags to specify which algorithm was used (classic or ITU-R BS.1770) or what target was set (RG&#039;s -18&amp;amp;nbsp;LUFS, EBU R 128&#039;s -23&amp;amp;nbsp;LUFS, or any other target set by the user or some piece of software), there may be confusion as to how the results were produced. Typically, utilities that ship with reference encoders (FLAC / metaflac, Vorbis / vorbisgain, WavPack / wvgain, Musepack / mpcgain…) use the original RG algorithm, which can produce values that differ from newer tools by several decibels in certain cases. Generally speaking, it is recommended to run other utilities or players that implement the ITU-R BS.1770 algorithm, although it may not be obvious which algorithm they use at first glance. Their documentation may provide that information.&lt;br /&gt;
&lt;br /&gt;
=== MP3Gain ===&lt;br /&gt;
[[MP3Gain]] is an implementation of classic ReplayGain. It can be used to just analyze files &amp;amp; recommend changes or to also modify the gain. If modifying the gain, it always modifies the global gain fields in the MP3 audio data. It can add somewhat precise metadata, including undo info. The gain can be modified to any target dB, or it can be changed by a specified amount. For balance correction, user-specified changes can even be made on just one channel in simple L/R stereo-mode files (not joint stereo).&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]]&lt;br /&gt;
* Method: Audio + Meta (in APE tag), or Audio only&lt;br /&gt;
* APE tag fields (ASCII bytes):&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values for this file. 3 digits, zero-padded if necessary.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_ALBUM_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values across a set of files scanned as an album. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_UNDO +###,+###,N&amp;lt;/code&amp;gt; - the global gain adjustment to restore the original values in the left and right channels, respectively, followed by an indicator of whether to wrap at the extremes (&amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; means no, &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; means yes). The adjustment values are 3 digits, zero-padded, preceded by a sign (&amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;).&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Examples: &amp;lt;code&amp;gt;+0.424046&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-10.38500&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Example: &amp;lt;code&amp;gt;0.149923&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Optional.&lt;br /&gt;
* Limitations: Although the metadata, if written, contains precise adjustment &amp;amp; peak values, the audio data modifications are limited to 1.5dB steps and may become irreversible (however, that&#039;s a very rare condition; see the [https://hydrogenaud.io/index.php/topic,34154.0.html &amp;quot;mp3gain is NOT lossless&amp;quot; forum thread])&lt;br /&gt;
* http://mp3gain.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== AACGain ===&lt;br /&gt;
[[AACGain]] is a modified version of MP3Gain that works on both MP3 and AAC files.&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]], [[AAC]] (with or without MP4 container)&lt;br /&gt;
* Method: Audio + Meta, or Audio only&lt;br /&gt;
* Limitations: Limited to 1.5dB steps mode, may become irreversible (same caveat as for MP3Gain)&lt;br /&gt;
* http://aacgain.altosdesign.com/&lt;br /&gt;
&lt;br /&gt;
=== [[LAME]] ===&lt;br /&gt;
* Method: Header ([http://gabriel.mp3-tech.org/mp3infotag.html mp3infotag])&lt;br /&gt;
* Notes:&lt;br /&gt;
** Uses the classic RG algorithm.&lt;br /&gt;
** Tags added during encoding; not supported by any player yet; Track Gain only&lt;br /&gt;
** Replay Gaining MP3&#039;s is usually done using MP3Gain (see [[ReplayGain#MP3Gain|above]]) or [[ReplayGain#foobar2000 ReplayGain scanner|foobar2000]]&lt;br /&gt;
* http://lame.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== [[Musepack]] ReplayGain ===&lt;br /&gt;
* Method: Header (similar to Meta data method)&lt;br /&gt;
* Notes: Uses the classic RG algorithm. ReplayGain values are stored in the header and ReplayGain is part of the Musepack specifications; therefore any Musepack decoder that does not support ReplayGain can be considered broken.&lt;br /&gt;
* http://www.musepack.net/&lt;br /&gt;
&lt;br /&gt;
=== VorbisGain ===&lt;br /&gt;
* Format: (Ogg) [[Vorbis]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://www.sjeng.org/vorbisgain.html&lt;br /&gt;
** new compiles of VorbisGain at [http://www.rarewares.org/ogg.html www.rarewares.org]&lt;br /&gt;
:&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Andavari has provided a very useful script to integrate VorbisGain, which is a CLI tool, into Windows Explorer. Please (Ogg) [[Vorbis#ReplayGain|check this section]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== FLAC / METAFLAC ===&lt;br /&gt;
* Format: [[Free Lossless Audio Codec|FLAC]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://flac.sf.net&lt;br /&gt;
&lt;br /&gt;
=== WavPack / WVGAIN ===&lt;br /&gt;
* Format: [[WavPack]]&lt;br /&gt;
* Method: Meta (in [[APEv2]] tag)&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* http://www.wavpack.com&lt;br /&gt;
&lt;br /&gt;
=== Wavegain ===&lt;br /&gt;
* Format: waveform&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Uses the classic RG algorithm.&lt;br /&gt;
* Limitations: Irreversible&lt;br /&gt;
* http://www.rarewares.org/others.php#wavegain&lt;br /&gt;
&lt;br /&gt;
=== MusicPlayer ===&lt;br /&gt;
* Custom implementation, not derived from the original MP3Gain one (but inspired from). As far as I know, all other implementations are directly derived from the MP3Gain (gain_analysis.c, which is GPL) source.&lt;br /&gt;
* Format: any that FFmpeg supports&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Limitations: Doesn&#039;t modify the files at all. Stores the value in own database. Used only for playback.&lt;br /&gt;
* https://github.com/albertz/music-player&lt;br /&gt;
&lt;br /&gt;
=== [[foobar2000]] ReplayGain scanner ===&lt;br /&gt;
* Since v1.1.6, defaults to ITU-R BS.1770 analysis (although it labels it EBU R128), but can be configured to use the &amp;quot;Classic ReplayGain&amp;quot; algorithm instead. The ITU-R BS.1770 implementation uses a reference level of -18&amp;amp;nbsp;LUFS instead of -23, in order to retain compatibility with the ReplayGain standard.&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] (default) or [[APEv2]] tags. A separate function can be invoked to apply the tagged Track or Album Gain to the MP3 global gain fields (as MP3Gain does), and rewrite any existing tags to account for the peak change and compensate for the difference from 89&amp;amp;nbsp;dB. The 89&amp;amp;nbsp;dB reference level for tags isn&#039;t configurable, but the reference level applied to the global gain fields is (it&#039;s under Preferences &amp;gt; Advanced &amp;gt; Tools &amp;gt; ReplayGain Scanner &amp;gt; Target MP3 alteration volume level).&lt;br /&gt;
** [[Musepack]]: Values written to header.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags. As with MP3, it is also an option to apply gain via a separate function.&lt;br /&gt;
** [[MP4]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain).&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** Modules ([[MOD]] etc.): Optionally saved into [[APEv2]] tags.&lt;br /&gt;
* https://foobar2000.org/&lt;br /&gt;
&lt;br /&gt;
=== [[MediaMonkey]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[APEv2]] or [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[WAV]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[MPC]]: Internal gain Structure.&lt;br /&gt;
* In addition to tags, all ReplayGain values are also stored in MediaMonkey&#039;s MDB database&lt;br /&gt;
* Album/Audiophile ReplayGain not supported until v3.0 (Dec 2007); support during burning &amp;amp; ripping added in 3.1 (Jun 2009)&lt;br /&gt;
* Also capable of (irreversibly) changing the volume of MP3 tracks, similar to [[MP3Gain]]&lt;br /&gt;
* http://www.mediamonkey.com/&lt;br /&gt;
&lt;br /&gt;
=== [[Winamp]] ReplayGain scanner===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in Windows Media Audio tags.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[MP4]]&lt;br /&gt;
** [[TAK]]: Values written to [[APEv2]] tags.&lt;br /&gt;
* Support Album/Track Gain&lt;br /&gt;
&lt;br /&gt;
=== [[loudgain]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** MP2, [[MP3]]: Values written to [[ID3v2]] tags (ID3v2.3/ID3v2.4 selectable).&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Speex]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[Opus]]: Values written to [[Vorbis comment]], based on -23&amp;amp;nbsp;LUFS Opus standard. Only &amp;lt;code&amp;gt;R128_TRACK_GAIN&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;R128_ALBUM_GAIN&amp;lt;/code&amp;gt; are written, but the calculated &#039;&#039;true peak&#039;&#039; value can still be used to reduce the gain values ([[Clipping]] prevention).&lt;br /&gt;
** [[MP4]], [[M4A]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain). ReplayGain values are stored under &amp;lt;code&amp;gt;----:com.apple.iTunes:…&amp;lt;/code&amp;gt;. This is for [[AAC]] and [[ALAC]] in [[MPEG-4]] containers.&lt;br /&gt;
** [[ASF]], [[Windows Media Audio|WMA]]: Values written to WMA tags, no prefix.&lt;br /&gt;
** [[WAV]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] (ID3v2.3/ID3v2.4 selectable) format. Using the &amp;lt;code&amp;gt;bext&amp;lt;/code&amp;gt; chunk (for BWF v2) isn’t (yet) supported, but won’t be destroyed on writing.&lt;br /&gt;
** [[Audio Interchange File Format|AIFF]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] format.&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[Monkey&#039;s Audio]] (APE): Values written to [[APEv2]] tags.&lt;br /&gt;
* Follows EBU R128, ITU BS.1770 and the [[ReplayGain 2.0 specification|revised ReplayGain specification]].&lt;br /&gt;
* &#039;&#039;Never&#039;&#039; touches the actual audio data but &#039;&#039;only writes RG2 tags&#039;&#039;.&lt;br /&gt;
* Uses &#039;&#039;true peak&#039;&#039; values calculated by oversampling to 192&amp;amp;nbsp;kHz, using a custom polyphase FIR interpolator that will oversample 4x for sample rates &amp;lt; 96&amp;amp;nbsp;kHz, 2x for sample rates &amp;lt; 192&amp;amp;nbsp;kHz and leave the signal unchanged for 192&amp;amp;nbsp;kHz.&lt;br /&gt;
* &#039;&#039;Clipping prevention&#039;&#039; can be used to lower the ReplayGain values to a safe margin (default -1&amp;amp;nbsp;dBTP, can be changed).&lt;br /&gt;
* Many options for special cases: force RG tags upper-/lowercase, add extra tags (LRA, Reference loudness), strip unwanted tag types (APEv2 from MP2/MP3, ID3 from WavPack), tab-delimited table output for analysis with CSV file.&lt;br /&gt;
* &#039;&#039;Linux&#039;&#039; Free and Open Source software, can be installed on &#039;&#039;MacOS&#039;&#039; using &#039;&#039;HomeBrew&#039;&#039;, on &#039;&#039;Windows 10&#039;&#039; using the Linux &#039;&#039;bash&#039;&#039;.&lt;br /&gt;
* Also installs a &amp;lt;code&amp;gt;rgbpm&amp;lt;/code&amp;gt; bash script for mass-tagging, which can be adapted to the user’s needs.&lt;br /&gt;
* &#039;&#039;&#039;Warning:&#039;&#039;&#039; Loudgain relies on standard libraries like &#039;&#039;TagLib&#039;&#039;. Linux distros (except rolling releases) sometimes deliver outdated libraries, so be sure you use the latest version of &#039;&#039;TagLib&#039;&#039;. Version 1.11.1 had a nasty bug for a while that [https://hydrogenaud.io/index.php/topic,118085.msg974957.html#msg974957 could corrupt Ogg Vorbis files]. This has been fixed in the meantime but the TagLib version not updated. Loudgain comes with a (slower) static version called &amp;lt;code&amp;gt;loudgain.static&amp;lt;/code&amp;gt; in the repo’s &amp;lt;code&amp;gt;/bin&amp;lt;/code&amp;gt; folder that doesn’t expose the bug and can also be used on older Linux versions (like Ubuntu 14.04, Linux Mint 17).&lt;br /&gt;
* https://github.com/Moonbase59/loudgain&lt;br /&gt;
* Bug tracker: https://github.com/Moonbase59/loudgain/issues&lt;br /&gt;
&lt;br /&gt;
=== [[rsgain]] ===&lt;br /&gt;
rsgain is a newer ReplayGain command line utility designed with a &amp;quot;batteries included&amp;quot; philosophy, use the newer ITU-R BS.1770 algorithm.&lt;br /&gt;
&lt;br /&gt;
Features:&lt;br /&gt;
* Cross-platform Windows&amp;amp;nbsp;/&amp;amp;nbsp;macOS&amp;amp;nbsp;/&amp;amp;nbsp;Linux&lt;br /&gt;
* Supports all popular audio formats&lt;br /&gt;
* Simplified &amp;quot;Easy Mode&amp;quot; command line syntax supports recursive, directory-based scanning&lt;br /&gt;
* Multithreaded scanning option that provides significant speed improvement with full library scans&lt;br /&gt;
* Option to skip files with existing ReplayGain metadata&lt;br /&gt;
* Scan presets allow the user to save advanced settings for consistent use&lt;br /&gt;
&lt;br /&gt;
== Players support ==&lt;br /&gt;
ReplayGain being present in the specs of the FLAC, Musepack, and APE formats, any player that support those formats usually supports ReplayGain.&lt;br /&gt;
&lt;br /&gt;
The situation with MP3 is rather different, as it was not part of the MP3 specs. The APEv2 tags metadata implementation is somewhat becoming the de-facto standard.&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
* [[foobar2000]] supports ReplayGain in all possible aspects.&lt;br /&gt;
* [[Winamp]] supports ReplayGain in album or track mode.&lt;br /&gt;
* [[MediaMonkey]] supports ReplayGain, with many configuration options.&lt;br /&gt;
* [[XMPlay]] recently implemented ReplayGain&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;...and probably others.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
* [[XMMS]]. Reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], [[Musepack]], (Ogg) [[Vorbis]] ..&lt;br /&gt;
:For [[MP3]], use the CVS version of the [http://xmms-mad.sourceforge.net/ xmms-mad] mp3 plugin (it&#039;s not yet released as binary, furthermore not available in distribs&#039; versions for now. Meanwhile binaries are available here: [http://perso.crans.org/~krempp/xmms-mad/ custom binaries])&lt;br /&gt;
* [[amarok]]. By using the amarok-script [http://kde-apps.org/content/show.php?content=26073 ReplayGain]&lt;br /&gt;
:And possibly others, since [http://developer.kde.org/~wheeler/taglib.html TagLib] added support for [[APEv2]] tags in [[MP3]] files, players using this library (like [[amaroK]] and [[JuK]]) might support that kind of ReplayGain tags in the near future.&lt;br /&gt;
* [http://www.sacredchao.net/quodlibet Quod Libet] reads ReplayGain from (Ogg) [[Vorbis]], [[MP3]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:Requires support to be enabled (via the appropriate python bindings and libraries) for the above formats. Does not support ReplayGain values stored in [[APEv2]] tags in [[MP3]]s. ReplayGain values are stored in RVA2 id3v2.4 frames. See the [http://www.sacredchao.net/quodlibet/wiki/Development/ID3Notes Quod Libet RVA2 / ReplayGain notes].&lt;br /&gt;
* [http://www.musicpd.org/ Music Player Daemon] (MPD) reads ReplayGain from (Ogg) [[Vorbis]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:foobar2000-style TXXX frames in [[MP3]]s are also supported in the latest development releases.&lt;br /&gt;
* [http://www.mplayerhq.hu/ MPlayer]. Mplayer support for ReplayGain is codec dependent.&lt;br /&gt;
:Codecs that are known to support ReplayGain: vorbis&lt;br /&gt;
:Because of this, you need to prioritize the codecs that support it, or choose it individually on the command line.  To add it to the command line, add an -ac [codec] option after each file that you want to choose the codec for, or at the beginning to make it apply to all files listed.  To prioritize the codecs by default, list them in a line in mplayer.conf:&lt;br /&gt;
 ac=[codec],[othercodec],vorbis,mad,&lt;br /&gt;
* [http://idjc.sourceforge.net/ IDJC] (Internet DJ Console) reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], (Ogg) FLAC, (Ogg) [[Vorbis]], MP2 (audio), [[MP3]], [[Opus]], but only the &#039;&#039;lowercase&#039;&#039; tags. There is a [https://sourceforge.net/p/idjc/bugs/100/ ticket] open to handle tags case-insensitively.&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
* [https://www.videolan.org/vlc/ VLC] supports ReplayGain in many file formats, but usually only the &#039;&#039;uppercase&#039;&#039; variant of the tags.&lt;br /&gt;
* [https://kodi.tv/ KODI] reads ReplayGain from nearly all formats, but usually only the &#039;&#039;lowercase&#039;&#039; variant of the tags.&lt;br /&gt;
&lt;br /&gt;
=== Portable devices ===&lt;br /&gt;
[http://www.rockbox.org/ Rockbox] supports ReplayGain (in album or track mode) for most formats, including  WMA, MP1/2/3, AAC, ALAC, Musepack, Monkey&#039;s Audio, Wavpack, FLAC and Vorbis.  &amp;lt;br&amp;gt;Note that ReplayGain is only supported when using the respective codec&#039;s native tagging format.  For example:  ReplayGain stored in APEv2 tags is not supported for MP3, rather ID3v2.x tags are expected.&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Fuze with firmware 1.02.26 and 2.02.26&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Clip+&lt;br /&gt;
&lt;br /&gt;
The iPod features &#039;&#039;Soundcheck&#039;&#039;, which seems to produce roughly the same normalization gains as ReplayGain, but doesn&#039;t provide an Album Gain.&lt;br /&gt;
&lt;br /&gt;
=== Hi-Fi ===&lt;br /&gt;
Slim Devices, a company owned by Logitech Inc, supports ReplayGain on both of their hi-end audiophile players, known as the [[Slim Devices Transporter|Transporter]] and the [[Slim Devices Squeezebox|Squeezebox]].&lt;br /&gt;
&lt;br /&gt;
BluOS also supports ReplayGain with the selection of album- or track-gain and a so called Smart option that decides between the two by itself.&lt;br /&gt;
NAD devices that use BluOS consequently also support ReplayGain.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;references/&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[ReplayGain specification]]&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Replay_Gain ReplayGain] at Wikipedia&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain.html ReplayGain using foobar2000] (how to use ReplayGain in Windows using foobar2000).&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain-in-Linux.html ReplayGain in Linux] (how to use ReplayGain in Linux using foobar2000 and Wine, or using metaflac or vorbisgain).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Technical]]&lt;br /&gt;
[[index.php?title=Category:Metadata]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38796</id>
		<title>Revised ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38796"/>
		<updated>2026-01-22T19:30:35Z</updated>

		<summary type="html">&lt;p&gt;Skamp: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;DISPLAYTITLE&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;4&amp;quot;&amp;gt;&#039;&#039;This is a proposed update to the [[ReplayGain 1.0 specification|original ReplayGain specification]]. This proposal is currently &#039;&#039;&#039;Under Construction&#039;&#039;&#039;. Please discuss this proposal on the [[Talk:ReplayGain 2.0 specification|discussion page]] or the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio forum].&#039;&#039; --[[User:Notat|Notat]] 23:42, 8 October 2012 (CEST)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although music is encoded to a digital format with a clearly defined maximum peak amplitude, and although most recordings are normalized to utilize this peak amplitude, not all recordings sound equally loud. This is because once this peak amplitude is reached, perceived loudness can be further increased through signal-processing techniques such as dynamic range compression and equalization.&amp;lt;ref&amp;gt;Source: Wikipedia - [http://en.wikipedia.org/wiki/Loudness_war Loudness war]&amp;lt;/ref&amp;gt; Therefore, the loudness of a given album has more to do with the year of issue or the whim of the producer than the intended emotional effect. Because of this, a random play through a music collection can have one leaping for the volume control every other track.&lt;br /&gt;
&lt;br /&gt;
There is a solution to this annoyance: within each audio file, information can be stored about what volume change would be required to play each track or album at a standard loudness, and players can use this &amp;quot;replay gain&amp;quot; information to automatically nudge the volume up or down as required.&lt;br /&gt;
&lt;br /&gt;
The ReplayGain specification is a standard which defines an appropriate reference level, explains a way of calculating and representing the ideal replay gain for a given track or album, and provides guidance for players to make the required volume adjustment during playback. The standard also specifies a means to prevent clipping when the calculated replay gain exceeds the limits of digital audio, and it describes how the replay gain information is stored within audio files.&lt;br /&gt;
&lt;br /&gt;
==Loudness measurement==&lt;br /&gt;
Loudness is a subjective measure of the intensity of sound. The correlation of perceived loudness to sound pressure level is determined by the peculiarities of the auditory system.&lt;br /&gt;
&lt;br /&gt;
The [[ReplayGain 1.0 specification|original ReplayGain specification]] described a loudness measurement system which included a weighting filter, root mean square (RMS) measurement and statistical processing that model human perception of loudness in both the frequency and time domains.&lt;br /&gt;
&lt;br /&gt;
Since original ReplayGain proposal in 2001, the science, practice and standards for loudness normalization have been advanced significantly. The current industry standard approach to loudness measurement is described by the International Telecommunications Union&amp;lt;ref&amp;gt;http://www.itu.int/en/Pages/default.aspx&amp;lt;/ref&amp;gt; (ITU) as BS.1770. The most recent version of this standard is known as ITU BS.1770-5&amp;lt;ref&amp;gt;https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en&amp;lt;/ref&amp;gt; and was published in December 2023. The ITU work is freely available and is not believed to be encumbered by any patent issues. The ITU BS.1770-2 standard has been adopted in the United States by the [http://www.atsc.org ATSC] as [http://www.atsc.org/cms/standards/a_85-2011a.pdf A/85] and in Europe by the [http://www.ebu.ch European Broadcast Union] as [http://tech.ebu.ch/docs/tech/tech3343.pdf EBU R-128] for broadcast audio. &lt;br /&gt;
&lt;br /&gt;
BS.1770 uses a &amp;quot;K-weighted&amp;quot; RMS measurement. This weighting function is significantly less complex than the inverted Fletcher-Munson weighting used by the original ReplayGain algorithm. A gating function designed measure the loudness of foreground components in the audio program. The gate in BS.1770 performs a similar function as the statistical processing in the original RG specification. &lt;br /&gt;
&lt;br /&gt;
The computation required for BS.1770 loudness measurement is reduced compared to the original RG technique. Nevertheless, BS.1770 has been shown in several academic studies to be equally or more effective than the RG algorithm in modeling human loudness perception on music program as well as other material such as podcasts, television programs and movies.&amp;lt;ref&amp;gt;Paul Nygren. [http://www.speech.kth.se/prod/publications/files/3319.pdf Achieving equal loudness between audio files]. KTH Royal Institute of Technology&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Martin Wolters; Harald Mundt; Jeffrey Riedmiller (May 2010). [http://www.aes.org/e-lib/browse.cfm?elib=15341 Loudness Normalization In The Age Of Portable Media Players]. Audio Engineering Society.&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Esben Skovenborg; Søren H. Nielsen (October 2004). [http://web.archive.org/web/20120208024743/http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf Evaluation of Different Loudness Models with Music and Speech Material]. Audio Engineering Society. Archived from [http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf the original] on 2012-02-08.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recent RG implementations use BS.1770 for loudness measurement. It is expected the ITU standard will evolve over time to meet the needs of broadcasters and governments. It is the intent of the ReplayGain community that RG follow any future backwards-compatible improvements to loudness measurement using the BS.1770 standard.&lt;br /&gt;
&lt;br /&gt;
==Reference level==&lt;br /&gt;
&lt;br /&gt;
Classic ReplayGain is calibrated to a pink noise reference signal with a RMS level 14&amp;amp;nbsp;dB below a full-scale sinusoid. This reference signal is used to establish a reference level. ReplayGain will apply no gain or attenuation to the reference signal or any program material which has the same loudness measurements as the reference signal.&lt;br /&gt;
&lt;br /&gt;
BS-1770 defines a loudness scale for program material. The units of BS.1770 loudness measurements are in Loudness Units [relative to] Full Scale (LUFS). LUFS can be treated like decibels.&lt;br /&gt;
&lt;br /&gt;
In order to maintain backwards compatibility with classic RG, newer RG uses a -18&amp;amp;nbsp;LUFS reference, which based on lots of music, can give similar loudness compared to classic RG.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
The loudness measurement of the RG1 reference signal is NOT -18 LUFS; &lt;br /&gt;
The original -20 RMS dBFS one is -20.36 LUFS, and the -14 RMS dbFS one would be -15.36 LUFS.&lt;br /&gt;
&lt;br /&gt;
We picked -18 here is the result of analyzing actual music. &lt;br /&gt;
&lt;br /&gt;
Check what 2Bdecided said here: https://hydrogenaud.io/index.php/topic,109076.msg899298.html#msg899298&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Gain calculation==&lt;br /&gt;
RG achieves loudness compensated playback by applying gain (or attenuation) dependent on the measured loudness of the audio file relative to the established reference level. The gain is calculated as follows:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG=L_{r}-L&amp;lt;/math&amp;gt;&lt;br /&gt;
Where:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG&amp;lt;/math&amp;gt; is the replay gain adjustment in decibels,&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{r}&amp;lt;/math&amp;gt; is the -18&amp;amp;nbsp;LUFS reference level&lt;br /&gt;
:&amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; is the measured loudness of the audio file in LUFS.&lt;br /&gt;
&lt;br /&gt;
Gain is positive if the loudness of the audio file is lower than the reference level. The gain is negative (representing an attenuation) if the loudness of the audio file is higher than the reference level. The gain is stored as metadata with the audio file as described below and is used by players to adjust output volume of tracks as they are played as described in [[ReplayGain 2.0 specification#Player requirements|Player requirements]] below.&lt;br /&gt;
&lt;br /&gt;
==Metadata==&lt;br /&gt;
For ReplayGain to do its work during playback, four values must be stored as metadata&amp;lt;ref&amp;gt;Metadata is &amp;quot;data about data.&amp;quot; For example, the ID3 &#039;&#039;de facto&#039;&#039; standard provides a way to store artist, title, album title, track number, and other metadata in data blocks called &amp;quot;tags&amp;quot; immediately before or after the audio data in an MP3 file. Other metadata storage/tagging standards and conventions exist for other audio file formats.&amp;lt;/ref&amp;gt; with or within the audio file:&lt;br /&gt;
# Peak track amplitude&lt;br /&gt;
# Peak album amplitude&lt;br /&gt;
# Track replay gain&lt;br /&gt;
# Album replay gain&lt;br /&gt;
&lt;br /&gt;
If calculated for an individual track, the loudness measurement (as specified above) yields track replay gain. If calculated on an album basis, with all tracks concatenated to make one long audio file, the loudness measurement yields album replay gain.&lt;br /&gt;
&lt;br /&gt;
===Replay gain===&lt;br /&gt;
Under some listening conditions, it&#039;s useful to have every track sound equally loud. The problem with a track-by-track approach is that tracks which should be quiet in the context of the album on which they reside will be brought up to the level of all the rest. For casual listening, or in a noisy background, this can be a good thing. For serious listening, it does not respect the intent of the artist or mastering engineer; a tender ballad track will be blasting at the same loudness as a hard rock track on the same album. It&#039;s generally ideal to leave the intentional loudness differences between tracks in place, yet still correct for unmusical and annoying loudness differences between albums. To accomplish this, ReplayGain suggests that two different gain adjustments should be stored as metadata with each sound file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Album replay gain&#039;&#039; represents the ideal listening gain for an entire album. ReplayGain reads the collection of tracks that comprise an album, and calculates a single replay gain for the whole set. This single gain can be used for playback of all tracks of the album. Intentionally quiet tracks then stay appropriately quieter than the rest. It still solves the basic problem (annoying, unwanted level differences between discs) because quiet or loud discs are still adjusted overall&amp;amp;mdash;so the pop CD that&#039;s 20&amp;amp;nbsp;dB louder than the classical CD will be brought into line.&lt;br /&gt;
&lt;br /&gt;
===Peak amplitude===&lt;br /&gt;
Scanning a track or album for the peak amplitude can be a time-consuming process. Therefore, it&#039;s helpful if this single value is stored as metadata. This is used to predict whether the required replay gain adjustment will cause clipping during playback.&lt;br /&gt;
&lt;br /&gt;
The maximum peak amplitude value is stored as a floating point number, where 1.0 represents digital full scale. As with replay gain values, separate peak amplitude values are stored per track and per album.&lt;br /&gt;
&lt;br /&gt;
For uncompressed files simply, scanners store the maximum absolute sample value held in the file on any channel for positive or negative excursion. The single sample value should be converted to a floating-point representation, such that digital full scale is equivalent to a value of 1.0.&lt;br /&gt;
&lt;br /&gt;
Psychoacoustically coded audio, such as MP3, does not exist as a sequence of samples until it is decoded. Psychoacoustic coding of a heavily limited file can lead to sample values larger than digital full scale upon decoding. The coded files must be decoded using a fully compliant decoder that allows peak overflows (i.e. has headroom) and may result in peak amplitude values greater than 1.0.&lt;br /&gt;
&lt;br /&gt;
==Metadata format==&lt;br /&gt;
From the standpoint of metadata storage, each audio file format presents a unique situation. There are three favored schemes defined for storage of ReplayGain metadata: &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; and &#039;&#039;&#039;APEv2&#039;&#039;&#039;. A survey of file formats is listed below with metadata schemes in order of preference for each:&lt;br /&gt;
* .aac (Advanced Audio Coding raw format) &amp;amp;ndash; No metadata support (use .mp4 instead)&lt;br /&gt;
* .aiff, .aif, .aifc (Apple Interchange File Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID3&amp;quot; IFF chunk)&lt;br /&gt;
* .ape, .apl (Monkey&#039;s Audio) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .bwf (Broadcast Wave Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in RIFF chunk)&lt;br /&gt;
* .flac (Free Lossless Audio Codec) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .mp3 (MPEG audio layer 3) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, LAME VBR proposed tag specification&lt;br /&gt;
* .mp4 also .m4a, .m4b, .m4p, m4r (MPEG-4 Part 14) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID32&amp;quot; box)&lt;br /&gt;
* .mpc (Musepack) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .ogg (Ogg Vorbis) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;, same for other Ogg codecs&lt;br /&gt;
* .opus (Ogg Opus) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; available&lt;br /&gt;
** standard {{code|R128_TRACK_GAIN}} and {{code|R128_ALBUM_GAIN}} (MUST adjust for -23 LUFS) comment keys may be preferable (used by {{code|loudgain}})&lt;br /&gt;
* .tta (True Audio) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .asf, .wma (Windows Media audio) - &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; in Extended Content Description Object&lt;br /&gt;
** {{code|loudgain}} instead uses native ASF/WMA attributes (itself a key-value storage) via TagLib, which is more sensible&lt;br /&gt;
* .wav (Windows PCM) &amp;amp;ndash; No metadata support (use .bwf instead)&lt;br /&gt;
** ID3 RIFF chunk possible (used by {{code|loudgain}})&lt;br /&gt;
* .wv (WavePak) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===ID3v2===&lt;br /&gt;
The ID3v2 standard&amp;lt;ref&amp;gt;The ID3v2 format is explained at [http://www.id3.org/ www.id3.org]. The most useful document is the [http://www.id3.org/id3v2.3.0.html ID3v2 v2.3.0 standard]. Although this document has been superseded by v2.4.0, the earlier document is complete (rather than an update), and in indexed HTML form. As such, it represents a better technical introduction to ID3v2.&amp;lt;/ref&amp;gt; defines a &#039;&#039;tag&#039;&#039; which is situated before the data in an MP3 file.&amp;lt;ref&amp;gt;The original ID3 (v1) tags resided at the end of the file, and contained a few fields of information. The ID3v1 tag is not extensible and therefore cannot support ReplayGain metadata.&amp;lt;/ref&amp;gt; ID3 is used primarily with MP3 audio files but means of adapting the system to other file types have been developed.&lt;br /&gt;
&lt;br /&gt;
The ID3v2 tag is divided into &#039;&#039;frames&#039;&#039;. The preferred means of storing ReplayGain metadata is use of &#039;&#039;TXXX&#039;&#039; key/value pair frames. Two other legacy schemes for storing ReplayGain metadata exist: [[ReplayGain legacy metadata formats#ID3v2 RGAD|RGAD]] and [[ReplayGain legacy metadata formats#ID3v2 RVA2|RVA2]]. These formats are documented in the [[ReplayGain legacy metadata formats|appendix]]. Players may choose to look for these formats if metadata in the &#039;&#039;TXXX&#039;&#039; format is not found in the ID3v2 tag. New scanners may write these older formats in addition to the newer (TXXX) ones if they wish to remain backwards compatible with older players.&lt;br /&gt;
&lt;br /&gt;
ReplayGain uses four TXXX frames. The header of a TXXX frame is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Frame ID       $54 58 58 58 (&amp;quot;TXXX&amp;quot;) &lt;br /&gt;
 Size           $xx xx xx xx (size of frame excluding this header)&lt;br /&gt;
 Flags          $40 $00      (discard frame if audio data is altered)&lt;br /&gt;
&lt;br /&gt;
Frame data is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Text encoding  $00          (ISO-8859-1 encoding)&lt;br /&gt;
 Description    &amp;lt;key string&amp;gt; $00&lt;br /&gt;
 Value          &amp;lt;value string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The four frames associated with ReplayGain metadata use the following key/value pairs&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Table 3: Metadata keys and value formatting&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
|-&lt;br /&gt;
|Track replay gain&lt;br /&gt;
|REPLAYGAIN_TRACK_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak track amplitude&lt;br /&gt;
|REPLAYGAIN_TRACK_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|-&lt;br /&gt;
|Album replay gain&lt;br /&gt;
|REPLAYGAIN_ALBUM_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak album amplitude&lt;br /&gt;
|REPLAYGAIN_ALBUM_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Gains are specified textually in decibels. Negative gains (attenuation) are prefixed with a &#039;-&#039;. Positive gains have no prefix. Integral portion of the gain (a) may be one or two numeric (0-9) digits. If there is no integral portion the field is &#039;0&#039;. The decimal portion of the gain (bb) is two numeric digits. Gains are suffixed with a space followed by &#039;dB&#039;.&lt;br /&gt;
&lt;br /&gt;
Peak levels are specified textually as a positive decimal. Peak level is a dimensionless quantity with 1.000000 representing full scale. No suffix is included on peak values. The integer field (c) is typically 1 or 0. Six numeric digits in the decimal field (dddddd) is adequate to accurately represent peak values for 16-bit audio data.&lt;br /&gt;
&lt;br /&gt;
A robust player should be prepared to parse the following variations in either replay gain or peak level metadata:&lt;br /&gt;
*Positive gains with leading &#039;+&#039;&lt;br /&gt;
*More or fewer significant digits than specified in any field&lt;br /&gt;
*Leading zeros or spaces in integer fields&lt;br /&gt;
*Missing or malformed &#039;dB&#039; suffix (e.g. no space between numeric digits and suffix, alternate capitalization)&lt;br /&gt;
*Alternate capitalization of keys&lt;br /&gt;
&lt;br /&gt;
Other formatting errors indicate more severe problems and should result in player ignoring data as if the frame did not exist.&lt;br /&gt;
&lt;br /&gt;
===Vorbis comments===&lt;br /&gt;
A Vorbis comment&amp;lt;ref&amp;gt;[http://www.xiph.org/vorbis/doc/v-comment.html Vorbis comment metadata format]. ReplayGain metadata is documented on the [http://wiki.xiph.org/VorbisComment#Replay_Gain Xiph Wiki].&amp;lt;/ref&amp;gt; uses an ASCII &amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; format. When Vorbis comments are used, the four ReplayGain metadata items are stored as separate comments. The &#039;&#039;keys&#039;&#039; and formatting for &#039;&#039;values&#039;&#039; is the same as specified for ID3v2. Keys and values are required by the Vorbis comment specification to b separated by &#039;=&#039; (equal character).&lt;br /&gt;
&lt;br /&gt;
===APEv2===&lt;br /&gt;
The APEv2 metadata format&amp;lt;ref&amp;gt;[http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification APEv2 Specification at Hydrogen Audio Wiki]&amp;lt;/ref&amp;gt; also organizes data into key/value pairs. Keys are ASCII format. A flags field allows support for several value formats including UTF-8 and binary. Under APEv2, ReplayGain meta data is stored using the same keys and data as ASCII values in the same format as specified for ID3v2.&lt;br /&gt;
&lt;br /&gt;
===De-Facto extensions===&lt;br /&gt;
MusicBrainz Picard and [http://github.com/Moonbase59/loudgain#tags-written-andor-deleted LoudGain] also support the following additional tags, named using the same conventions:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Extension metadata keys&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!alue format&lt;br /&gt;
! Purpose&lt;br /&gt;
|-&lt;br /&gt;
|Track range&lt;br /&gt;
|REPLAYGAIN_TRACK_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|rowspan=2 | Indicates dynamics (R-128 Loudness Range / LRA), may guide pre-amplification&lt;br /&gt;
|-&lt;br /&gt;
|Album range&lt;br /&gt;
|REPLAYGAIN_ALBUM_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Reference loudness&lt;br /&gt;
|REPLAYGAIN_REFERENCE_LOUDNESS&lt;br /&gt;
|[-]a.bb LUFS&lt;br /&gt;
| Use alternative reference levels; change ref levels without re-scanning the file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Player requirements==&lt;br /&gt;
[[File:RG_Player_control.gif‎|frame|Figure 8: Example ReplayGain control panel]]&lt;br /&gt;
&lt;br /&gt;
Loudness normalization, pre-amplification and clipping prevention are the operations performed by a ReplayGain player.&lt;br /&gt;
&lt;br /&gt;
===Loudness normalization===&lt;br /&gt;
To properly normalize loudness, the player needs to determine if the user desires Track style level normalization (all tracks same loudness), or Album style level normalization (all albums same loudness, tracks of an album played at the same relative level as on the original release). This option should be selectable in the ReplayGain control panel (Figure 8). The player reads the corresponding gain metadata value from the file and scales the audio data as appropriate. Scaling the audio data simply means multiplying each sample value by a constant value. This constant is given by:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;10^\frac{gain}{20}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, in words, replay gain divided by 20 all raised to the power of ten.&amp;lt;ref&amp;gt;After any such operation, it&#039;s a good idea to dither the result. If this calculation and the pre-amp are implemented separately, then dither should only be added to the final result, just before the result is truncated back to 16 bits, or 24, or 8, as limited by the soundcard&amp;amp;mdash;not the file (i.e. after ReplayGain adjustment, an 8-bit file should be sent to a 16-bit soundcard at 16-bits).&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the file only contains one of the replay gain adjustments (e.g. Album) but the user has requested the other (Track), then the player should use the one that is available (in this case, Album). If neither (Track or Album) gain metadata is available, then the player needs to choose a suitable default gain. Potential choices include unity gain (0 dB) or an average of gains from other tracks in the album or playlist.&lt;br /&gt;
&lt;br /&gt;
===Pre-amplification===&lt;br /&gt;
Although the calibration level used by ReplayGain suggests that the average level of an audio track should be 14&amp;amp;nbsp;dB below full scale, some pop music is dynamically compressed to peak at 0&amp;amp;nbsp;dB and average around 3&amp;amp;nbsp;dB below full scale. This means that, when the replay gain is applied, the level of such tracks will be reduced by 11&amp;amp;nbsp;dB! If users are listening to a mixture of highly compressed and more dynamic tracks, ReplayGain will make the listening experience more pleasurable by bringing the level of the compressed tracks down into line with that of the others. However, if users are only listening to highly compressed music, then they may complain that all their files are now too quiet.&amp;lt;ref&amp;gt;This problem can be especially noticeable on portable players with limited output or gain.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To address this problem, a pre-amp feature should be incorporated into the player. A user-supplied pre-amp setting is an adjustment to the calculated replay gain. It should default to perform no adjustment. This means that casual users will experience a moderate reduction in the loudness of their compressed pop music. Less-compressed material can generally be played at the same loudness without clipping. Normalization of more dynamic material may cause clipping or invoke the [[ReplayGain 2.0 specification#Clipping prevention|clipping prevention]] mechanism (see below). Power users and audiophiles can reduce the pre-amp gain to enjoy the full dynamic range of all of their music.&lt;br /&gt;
&lt;br /&gt;
If enabled, the player should read the user selected pre-amp gain, and scale the audio signal by the appropriate amount. For example, a +6&amp;amp;nbsp;dB gain requires a scale of 10&amp;lt;sup&amp;gt;6/20&amp;lt;/sup&amp;gt;, which is approximately 2. The replay gain and pre-amp scale factors can be combined&amp;lt;ref&amp;gt;Scale factors in  Decibel units are added to produce the same effect as multiplying scale factors in linear units.&amp;lt;/ref&amp;gt; for simplicity and ease of processing.&lt;br /&gt;
&lt;br /&gt;
===Clipping prevention===&lt;br /&gt;
ReplayGain&#039;s suggestion of a -14&amp;amp;nbsp;dB average playback level leaves sufficient headroom for the bulk of modern recordings. Nevertheless, there exists the possibility that after application of replay gain and pre-amp adjustment, a track may exceed full scale during its dynamic peaks. Without intervention, this will result in clipping, a severe form of distortion. Factors introducing the possibility of clipping include:&lt;br /&gt;
&lt;br /&gt;
# Recordings from certain genres and certain periods in the history of commercial recordings require additional headroom. Although these recordings can be accommodated through a downwards adjustment of the pre-amp setting, it may be difficult to determine a safe adjustment and it may be undesirable to lower average level to accommodate the rare track which requires it. &lt;br /&gt;
# ReplayGain will make loud dynamically compressed tracks quieter, and quiet dynamically uncompressed tracks louder. The average levels will then be similar, but the quiet tracks will actually have louder peaks. If the user pushes the pre-amp gain upwards the peaks of the (originally) quieter tracks will be pushed well over full scale.&lt;br /&gt;
# In coded audio (e.g. MP3 files) a file that was hard-limited to digital full scale before encoding will often be pushed over the limit by the psychoacoustic compression. A decoder with headroom can recover the over full scale signal by reducing the gain.&lt;br /&gt;
&lt;br /&gt;
ReplayGain suggests two possible solutions which prevent clipping in these situations. A player should support one or both of these.&lt;br /&gt;
&lt;br /&gt;
====Audio limiting====&lt;br /&gt;
In situation 2 above, the user clearly wants all the music to sound very loud. To give them their wish, any signal which would peak above digital full scale should be hard limited at just below digital full scale. This is also useful at lower pre-amp gains, where it allows the average level of classical music to be raised to that of pop music, without distorting. The exact type of nature limiting or compression an implementation choice for the player.&amp;lt;ref&amp;gt;Something like the Hard Limiter found in Cool Edit Pro (Syntrillium) would be appropriate for pop music at least.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reduced gain====&lt;br /&gt;
The audiophile user will not want any compression or limiting on the signal. In this case the only option is to automatically and temporarily reduce the pre-amp gain below the user-selected setting for tracks where clipping would otherwise occur. Clipping can be predicted by examining the peak level of the track or album being played.&lt;br /&gt;
&lt;br /&gt;
The player must read the peak amplitude metadata. If peak level metadata is unavailable, the player should assume a peak level of 1.0. If the peak level for both track and album is stored as metadata in the file, it is possible to calculate if, following the replay gain adjustment and pre-amp gain, the signal will clip at some point. If it won&#039;t, then no further action is necessary. &lt;br /&gt;
&lt;br /&gt;
An overall scale factor for loudness normalization taking into account replay gain, pre-amp setting and clipping prevention through gain reduction is given below.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;min( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{peak amplitude} )&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;!-- use this when tex is fixed: :&amp;lt;math&amp;gt;\operatorname{min}( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{L_{\mathrm{peak}}} )&amp;lt;/math&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hardware implementation===&lt;br /&gt;
The above three steps are appropriate to software players operating on the digital signal in order to scale it. However, it is possible to send the digital signal to the DAC without level correction, and to place an attenuator in the analogue signal path. The attenuator can then be driven by the Replay Gain value. The clipping problem can be addressed by providing adequate headroom in the analog circuitry. Bit transparency and maximum signal to noise ratio is maintained in the digital signal and DAC process.&amp;lt;ref&amp;gt;A system using today&#039;s 24-bit converters is unlikely to appreciate any overall gain in system performance with such an arrangement. A digitally-controlled analog gain element typically introduces significant noise and distortion.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The [http://replaygain.hydrogenaudio.org/proposal original ReplayGain proposal] (an [http://replay.waybackmachine.org/20090306202649/http://www.replaygain.org/ archive] is also available) was developed by David Robinson and was published 10 July 2001. Additional updates were published by David Robinson through 10 October 2001.&lt;br /&gt;
&lt;br /&gt;
The following acknowledgement was included with the original proposal, &amp;quot;The algorithm to calculate an ideal replay gain has grown from my research into human hearing, with many additional ideas drawn from the work of E. Zwicker, and Brian Moore. I am currently completing my PhD at the University of Essex, and have been funded by the EPSRC.&amp;quot; Additionally David Robinson credited Glen Sawyer (Snelg) and Jim Casaburi (Walrus) for software contributions and Bob Katz and Matt Ashland for ideas.&lt;br /&gt;
&lt;br /&gt;
This updated ReplayGain specification reflecting current and recommended practice was prepared by Kevin Gross in 2011.&lt;br /&gt;
&lt;br /&gt;
==Contact==&lt;br /&gt;
For ReplayGain-related questions or contributions, please post in the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio] section of the Hydrogen Audio forums.&lt;br /&gt;
 &lt;br /&gt;
==Appendix==&lt;br /&gt;
# [[ReplayGain legacy metadata formats]]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Talk:ReplayGain_1.0_specification&amp;diff=38795</id>
		<title>Talk:ReplayGain 1.0 specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Talk:ReplayGain_1.0_specification&amp;diff=38795"/>
		<updated>2026-01-22T19:29:14Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Skamp moved page Talk:ReplayGain 1.0 specification to Talk:Original ReplayGain specification: Confusion about having two distinct, numbered versions of ReplayGain&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Talk:Original ReplayGain specification]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Talk:Original_ReplayGain_specification&amp;diff=38794</id>
		<title>Talk:Original ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Talk:Original_ReplayGain_specification&amp;diff=38794"/>
		<updated>2026-01-22T19:29:14Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Skamp moved page Talk:ReplayGain 1.0 specification to Talk:Original ReplayGain specification: Confusion about having two distinct, numbered versions of ReplayGain&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Musepack ==&lt;br /&gt;
&lt;br /&gt;
Hi, there is an inaccuracy about Musepack files. Although they use APEv2 for metadata, replaygain is stored in the file header by specification, see [http://trac.musepack.net/trac/wiki/SV8Specification here]. Actually, this is the first format introducing APEv2 tags and native replaygain support.&lt;br /&gt;
So, every musepack compliant player must read the RG data from the header rather then APEv2.&lt;br /&gt;
[[User:Antonski|Antonski]] 14:19, 4 May 2011 (UTC)&lt;br /&gt;
&lt;br /&gt;
==Development discussion threads==&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=1709 Flaw in ReplayGain spec]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=62374 Replay Gain Site, Why does it look like a museum?]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=83397 Does Replay gain work differtly in Media monkey, Foobar and Media Monkey given 2 differnt Results]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=85536 Replay Gain specification, update in progress]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=69568 ReplayGain equal loudness filter]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=85834 Replay Gain tagging, ID3, LAME, Others?]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=86745 ReplayGain player recommendations]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=87442 ReplayGain specification complete, official launch 25 March proposed]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification&amp;diff=38793</id>
		<title>ReplayGain 1.0 specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification&amp;diff=38793"/>
		<updated>2026-01-22T19:29:14Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Skamp moved page ReplayGain 1.0 specification to Original ReplayGain specification: Confusion about having two distinct, numbered versions of ReplayGain&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Original ReplayGain specification]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Original_ReplayGain_specification&amp;diff=38792</id>
		<title>Original ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Original_ReplayGain_specification&amp;diff=38792"/>
		<updated>2026-01-22T19:29:14Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Skamp moved page ReplayGain 1.0 specification to Original ReplayGain specification: Confusion about having two distinct, numbered versions of ReplayGain&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Although music is encoded to a digital format with a clearly defined maximum peak amplitude, and although most recordings are normalized to utilize this peak amplitude, not all recordings sound equally loud. This is because once this peak amplitude is reached, perceived loudness can be further increased through signal-processing techniques such as dynamic range compression and equalization.&amp;lt;ref&amp;gt;Source: Wikipedia - [http://en.wikipedia.org/wiki/Loudness_war Loudness war]&amp;lt;/ref&amp;gt; Therefore, the loudness of a given album has more to do with the year of issue or the whim of the producer than the intended emotional effect. Because of this, a random play through a music collection can have one leaping for the volume control every other track.&lt;br /&gt;
&lt;br /&gt;
There is a solution to this annoyance: within each audio file, information can be stored about what volume change would be required to play each track or album at a standard loudness, and players can use this &amp;quot;replay gain&amp;quot; information to automatically nudge the volume up or down as required.&lt;br /&gt;
&lt;br /&gt;
The ReplayGain specification is a standard which defines an appropriate reference level, explains a way of calculating and representing the ideal replay gain for a given track or album, and provides guidance for players to make the required volume adjustment during playback. The standard also specifies a means to prevent clipping when the calculated replay gain exceeds the limits of digital audio, and it describes how the replay gain information is stored within audio files.&lt;br /&gt;
&lt;br /&gt;
==Loudness measurement==&lt;br /&gt;
Loudness is a subjective measure of the intensity of sound. The correlation of perceived loudness to sound pressure level is determined by the peculiarities of the auditory system. ReplayGain attempts to model those peculiarities with the following measurement procedure.&lt;br /&gt;
&lt;br /&gt;
===Loudness filter===&lt;br /&gt;
[[File:RG_Equal_loudness_all.gif‎|frame|Figure 1: Loudness filter target response (blue), high-pass response (green) and composite response (red)]]&lt;br /&gt;
&lt;br /&gt;
The human ear does not perceive sounds of all frequencies as having equal loudness. For example, a full-scale sine wave at 1 kHz sounds much louder than a full scale sine wave at 100 Hz, even though the two have identical energy. To account for this, the signal is filtered by an inverted approximation of the equal loudness curves (sometimes referred to as Fletcher&amp;amp;ndash;Munson curves) which describe the sensitivity of the ear as a function of frequency. The desired filter response derived from the equal loudness curves is shown in figure 1 (blue).&lt;br /&gt;
&lt;br /&gt;
At higher frequencies a 10th order IIR filter designed by MATLAB&#039;s &amp;quot;yulewalk&amp;quot; function is an excellent approximation to the target. This is cascaded with a 2nd order Butterworth high pass filter, with a high pass frequency of 150 Hz (Figure 1 [green]). The resulting combined response (Figure 1 [red]) is close to the target response, and is used by ReplayGain.&lt;br /&gt;
&lt;br /&gt;
[[File:RG_IIR-filter.png|frame|Figure 2: IIR filter topology used by &amp;quot;yulewalk&amp;quot; and Butterworth filter components]]&lt;br /&gt;
&lt;br /&gt;
The filter topology used for the components of the loudness filter is shown in figure 2. The filter coefficients for 48 and 44.1&amp;amp;nbsp;kHz sample rates are given for the Butterworth and &amp;quot;yulewalk&amp;quot; components in tables 1 and 2 respectively. When using other sample rates, coefficients must be transformed to maintain the same filter response.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|+Table 1a: Butterworth filter coefficients (F&amp;lt;sub&amp;gt;s&amp;lt;/sub&amp;gt;=48&amp;amp;nbsp;kHz)&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; |&lt;br /&gt;
| &#039;&#039;b(0)&#039;&#039;&lt;br /&gt;
| 0.98621192462708&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(1)&#039;&#039; || 1.97223372919527 || &#039;&#039;b(1)&#039;&#039; || -1.97242384925416&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(2)&#039;&#039; || -0.97261396931306 || &#039;&#039;b(2)&#039;&#039; || 0.98621192462708&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|+Table 1b: Butterworth filter coefficients (F&amp;lt;sub&amp;gt;s&amp;lt;/sub&amp;gt;=44.1&amp;amp;nbsp;kHz)&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; |&lt;br /&gt;
| &#039;&#039;b(0)&#039;&#039;&lt;br /&gt;
| 0.98500175787242&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(1)&#039;&#039; || 1.96977855582618 || &#039;&#039;b(1)&#039;&#039; || -1.97000351574484&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(2)&#039;&#039; || -0.97022847566350 || &#039;&#039;b(2)&#039;&#039; || 0.98500175787242&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|+Table 2a: &amp;quot;Yulewalk&amp;quot; filter coefficients (F&amp;lt;sub&amp;gt;s&amp;lt;/sub&amp;gt;=48&amp;amp;nbsp;kHz)&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; |&lt;br /&gt;
| &#039;&#039;b(0)&#039;&#039;&lt;br /&gt;
| 0.03857599435200&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(1)&#039;&#039; || 3.84664617118067 || &#039;&#039;b(1)&#039;&#039; || -0.02160367184185&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(2)&#039;&#039; || -7.81501653005538 || &#039;&#039;b(2)&#039;&#039; || -0.00123395316851&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(3)&#039;&#039; || 11.34170355132042 || &#039;&#039;b(3)&#039;&#039; || -0.00009291677959&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(4)&#039;&#039; || -13.05504219327545 || &#039;&#039;b(4)&#039;&#039; || -0.01655260341619&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(5)&#039;&#039; || 12.28759895145294 || &#039;&#039;b(5)&#039;&#039; || 0.02161526843274&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(6)&#039;&#039; || -9.48293806319790 || &#039;&#039;b(6)&#039;&#039; || -0.02074045215285&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(7)&#039;&#039; || 5.87257861775999 || &#039;&#039;b(7)&#039;&#039; || 0.00594298065125&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(8)&#039;&#039; || -2.75465861874613 || &#039;&#039;b(8)&#039;&#039; || 0.00306428023191&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(9)&#039;&#039; || 0.86984376593551 || &#039;&#039;b(9)&#039;&#039; || 0.00012025322027&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(10)&#039;&#039; || -0.13919314567432 || &#039;&#039;b(10)&#039;&#039; || 0.00288463683916&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|+Table 2b: &amp;quot;Yulewalk&amp;quot; filter coefficients (F&amp;lt;sub&amp;gt;s&amp;lt;/sub&amp;gt;=44.1&amp;amp;nbsp;kHz)&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; |&lt;br /&gt;
| &#039;&#039;b(0)&#039;&#039;&lt;br /&gt;
| 0.05418656406430&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(1)&#039;&#039; || 3.47845948550071 || &#039;&#039;b(1)&#039;&#039; || -0.02911007808948&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(2)&#039;&#039; || -6.36317777566148 || &#039;&#039;b(2)&#039;&#039; || -0.00848709379851&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(3)&#039;&#039; || 8.54751527471874 || &#039;&#039;b(3)&#039;&#039; || -0.00851165645469&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(4)&#039;&#039; || -9.47693607801280 || &#039;&#039;b(4)&#039;&#039; || -0.00834990904936&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(5)&#039;&#039; || 8.81498681370155 || &#039;&#039;b(5)&#039;&#039; || 0.02245293253339&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(6)&#039;&#039; || -6.85401540936998 || &#039;&#039;b(6)&#039;&#039; || -0.02596338512915&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(7)&#039;&#039; || 4.39470996079559 || &#039;&#039;b(7)&#039;&#039; || 0.01624864962975&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(8)&#039;&#039; || -2.19611684890774 || &#039;&#039;b(8)&#039;&#039; || -0.00240879051584&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(9)&#039;&#039; || 0.75104302451432 || &#039;&#039;b(9)&#039;&#039; || 0.00674613682247&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;a(10)&#039;&#039; || -0.13149317958808 || &#039;&#039;b(10)&#039;&#039; || -0.00187763777362&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Input samples from the audio file to be analysed must be run in cascade manner through both of these filter components before being analysed further.&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RMS level calculation===&lt;br /&gt;
Next, the energy during each moment of the signal is determined by calculating the Root Mean Square (RMS) of the filtered signal every 50ms.&amp;lt;ref&amp;gt;The block length of 50ms was chosen after studying the effect of values between 25ms and 1s. 25ms was too short to accurately reflect the perceived loudness of some sounds. Beyond 50ms there was little change (after statistical processing). For this reason, 50ms was chosen.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The signal is chopped into 50ms long blocks. Then, for each block:&amp;lt;ref&amp;gt;If these steps are read backward, it should be clear why the process is called Root Mean Square averaging.&amp;lt;/ref&amp;gt;&lt;br /&gt;
# Every sample value is squared (multiplied by itself).&lt;br /&gt;
# The mean average is taken.&lt;br /&gt;
# The square root of the average is calculated.&lt;br /&gt;
&lt;br /&gt;
For stereo signals, in step 3, the mean average of all squared samples from both channels over the 50ms measurement interval is taken.&amp;lt;ref&amp;gt;One could sum channels of a stereo signal to mono before calculating the RMS level, but then any out-of-phase components (having the opposite signal on each channel) would cancel out to zero (i.e. silence). That&#039;s not how humans perceive them, so it&#039;s not a good solution.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of this calculation is then converted to a decibel representation as follows:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;L=20 \log_{10} \frac{2{L_{RMS}}}{L_{p-p}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{RMS}&amp;lt;/math&amp;gt; is the RMS value calculated above&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{p-p}&amp;lt;/math&amp;gt; is the maximum peak-to-peak range of the samples in the audio file&lt;br /&gt;
&lt;br /&gt;
===Statistical processing===&lt;br /&gt;
Where the average energy level of a signal varies with time, the louder moments contribute most to perception of overall loudness. For example, in human speech, over half the time is silence, but the perceived loudness of speech is primarily determined by the levels between silences.&lt;br /&gt;
&lt;br /&gt;
A good method to determine the overall perceived loudness is to sort the RMS values into numerical order, and then pick a value near the top of the list. For highly compressed pop music (e.g. Figure 5(c), where there are many values near the top), the choice makes little difference. For speech and classical music (Figures 5(a) and 5(b) respectively), the choice makes a huge difference. The value which most accurately matches human perception of perceived loudness is 95%,&amp;lt;ref&amp;gt;Based on experiments performed by David Robinson, &amp;quot;I tried values from 70% to 95%. For highly compressed pop music, the choice makes little difference. For speech and classical music, the choice makes a huge difference. The value which most accurately matches human perception of perceived loudness is around 95%, so this value is used by Replay Level.&amp;quot;&amp;lt;/ref&amp;gt; so this value is used by ReplayGain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Figure 5: Loudness histograms&amp;quot;&amp;gt;&lt;br /&gt;
File:RG_Statistical_speech.gif‎‎|(a) Speech&lt;br /&gt;
File:RG_Statistical_classic.gif‎‎|(b) Classical music&lt;br /&gt;
File:RG_Statistical_pop.gif‎‎|(c) Pop music&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference level==&lt;br /&gt;
The audio industry does not have a standard for playback system calibration, but in the movie industry a calibration standard has been defined by the Society of Motion Picture and Television Engineers (SMPTE).&amp;lt;ref&amp;gt;SMPTE RP 200:2002 &amp;amp;ndash; Relative and Absolute Sound Pressure Levels for Motion-Picture Multichannel Sound Systems &amp;amp;ndash; Applicable for Analog Photographic Film Audio, Digital Photographic Film Audio and D-Cinema&amp;lt;/ref&amp;gt; The standard states that a single channel pink noise signal with an RMS level of -20 dB relative to a full-scale sinusoid&amp;lt;ref&amp;gt;&amp;quot;dB relative to a full-scale sinusoid&amp;quot; is preferred over &amp;quot;dBFS&amp;quot; as a unit of measure in this specification because there is some ambiguity whether the reference for dBFS is a full-scale square wave (peak reference) or a sine wave (RMS reference).&amp;lt;/ref&amp;gt; should be reproduced at 83 dB SPL.&amp;lt;ref&amp;gt;Measured using a C-weighted, slow averaging SPL meter.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ReplayGain adapts the SMPTE calibration concept for music playback. Under ReplayGain, audio is played so that its loudness, as measured using the procedures described in [[#Loudness measurement|Loudness measurement]] above, matches the loudness of a pink noise signal with an RMS level of -14 dB relative to a full-scale sinusoid,&amp;lt;ref&amp;gt;The initial ReplayGain proposal used the same -20 dB reference used by SMPTE. The reference was raised to -14 dB early on in ReplayGain development. This reference is used in all current ReplayGain implementations.&amp;lt;/ref&amp;gt; also measured using the procedures described above.&lt;br /&gt;
&lt;br /&gt;
In ReplayGain implementations, the reference level is described in terms of the SMPTE SPL playback level. By the SMPTE definition, the 83 dB SPL reference corresponds to -20FS dB system headroom. The -14 dB headroom used by ReplayGain therefore corresponds to an 89 dB SPL playback level on a SMPTE calibrated system and so is said to be operating with an 89 dB reference level.&lt;br /&gt;
&lt;br /&gt;
SMPTE cinema calibration calls for a single channel of pink noise reproduced through a single loudspeaker. In music applications, the ideal level of the music is actually the loudness when both speakers are in use. So, ReplayGain is calibrated to two channels of pink noise.&amp;lt;ref&amp;gt;In reality, a monophonic pink noise wave file is used, and ReplayGain automatically assumes the file is being played through both speakers, as would any monophonic file.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Gain calculation==&lt;br /&gt;
RG achieves loudness compensated playback by applying gain (or attenuation) dependent on the measured loudness of the audio file relative to the established reference level. The gain is calculated as follows:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG=L_{n14}-L&amp;lt;/math&amp;gt;&lt;br /&gt;
Where all quantities are expressed in decibels:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG&amp;lt;/math&amp;gt; is the replay gain adjustment,&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{n14}&amp;lt;/math&amp;gt; is the measured loudness of the -14 dB pink noise reference and&lt;br /&gt;
:&amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; is the measured loudness of the audio file.&lt;br /&gt;
&lt;br /&gt;
Replay gain is positive if the loudness of the audio file is lower than the pink noise reference. The gain is negative (representing an attenuation) if the loudness of the audio file is higher than that of the reference. The gain is stored as metadata with the audio file as described below and is used by players to adjust output volume of tracks as they are played as described in [[#Player requirements|Player requirements]] below.&lt;br /&gt;
&lt;br /&gt;
==Metadata==&lt;br /&gt;
For ReplayGain to do its work during playback, four values must be stored as metadata&amp;lt;ref&amp;gt;Metadata is &amp;quot;data about data.&amp;quot; For example, the ID3 &#039;&#039;de facto&#039;&#039; standard provides a way to store artist, title, album title, track number, and other metadata in data blocks called &amp;quot;tags&amp;quot; immediately before or after the audio data in an MP3 file. Other metadata storage/tagging standards and conventions exist for other audio file formats.&amp;lt;/ref&amp;gt; with or within the audio file:&lt;br /&gt;
# Peak track amplitude&lt;br /&gt;
# Peak album amplitude&lt;br /&gt;
# Track replay gain&lt;br /&gt;
# Album replay gain&lt;br /&gt;
&lt;br /&gt;
If calculated for an individual track, the loudness measurement (as specified above) yields track replay gain. If calculated on an album basis, with all tracks concatenated to make one long audio file, the loudness measurement yields album replay gain.&lt;br /&gt;
&lt;br /&gt;
===Replay gain===&lt;br /&gt;
Under some listening conditions, it&#039;s useful to have every track sound equally loud. The problem with a track-by-track approach is that tracks which should be quiet in the context of the album on which they reside will be brought up to the level of all the rest. For casual listening, or in a noisy background, this can be a good thing. For serious listening, it does not respect the intent of the artist or mastering engineer; a tender ballad track will be blasting at the same loudness as a hard rock track on the same album. It&#039;s generally ideal to leave the intentional loudness differences between tracks in place, yet still correct for unmusical and annoying loudness differences between albums. To accomplish this, ReplayGain suggests that two different gain adjustments should be stored as metadata with each sound file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Album replay gain&#039;&#039; represents the ideal listening gain for an entire album. ReplayGain reads the collection of tracks that comprise a album, and calculates a single replay gain for the whole set. This single gain can be used for playback of all tracks of the album. Intentionally quiet tracks then stay appropriately quieter than the rest. It still solves the basic problem (annoying, unwanted level differences between discs) because quiet or loud discs are still adjusted overall&amp;amp;mdash;so the pop CD that&#039;s 20 dB louder than the classical CD will be brought into line.&lt;br /&gt;
&lt;br /&gt;
===Peak amplitude===&lt;br /&gt;
Scanning a track or album for the peak amplitude can be a time-consuming process. Therefore, it&#039;s helpful if this single value is stored as metadata. This is used to predict whether the required replay gain adjustment will cause clipping during playback.&lt;br /&gt;
&lt;br /&gt;
The maximum peak amplitude value is stored as a floating point number, where 1.0 represents digital full scale. As with replay gain values, separate peak amplitude values are stored per track and per album.&lt;br /&gt;
&lt;br /&gt;
For uncompressed files simply, scanners store the maximum absolute sample value held in the file on any channel for positive or negative excursion. The single sample value should be converted to a floating-point representation, such that digital full scale is equivalent to a value of 1.0.&lt;br /&gt;
&lt;br /&gt;
Psychoacoustically coded audio, such as MP3, does not exist as a sequence of samples until it is decoded. Psychoacoustic coding of a heavily limited file can lead to sample values larger than digital full scale upon decoding. The coded files must be decoded using a fully compliant decoder that allows peak overflows (i.e. has headroom) and may result in peak amplitude values greater than 1.0.&lt;br /&gt;
&lt;br /&gt;
==Metadata format==&lt;br /&gt;
From the standpoint of metadata storage, each audio file format presents a unique situation. There are three favored schemes defined for storage of ReplayGain metadata: &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; and &#039;&#039;&#039;APEv2&#039;&#039;&#039;. A survey of file formats is listed below with metadata schemes in order of preference for each:&lt;br /&gt;
* .aac (Advanced Audio Coding raw format) &amp;amp;ndash; No metadata support (use .mp4 instead)&lt;br /&gt;
* .aiff, .aif, .aifc (Apple Interchange File Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID3&amp;quot; IFF chunk)&lt;br /&gt;
* .ape, .apl (Monkey&#039;s Audio) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .bwf (Broadcast Wave Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in RIFF chunk)&lt;br /&gt;
* .flac (Free Lossless Audio Codec) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .mp3 (MPEG audio layer 3) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, LAME VBR proposed tag specification&lt;br /&gt;
* .mp4 also .m4a, .m4b, .m4p, m4r (MPEG-4 Part 14) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID32&amp;quot; box)&lt;br /&gt;
* .mpc (Musepack) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .ogg (Ogg Vorbis) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .tta (True Audio) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .wma (Windows Media audio) - &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; in Extended Content Description Object&lt;br /&gt;
* .wav (Windows PCM) &amp;amp;ndash; No metadata support (use .bwf instead)&lt;br /&gt;
* .wv (WavePak) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===ID3v2===&lt;br /&gt;
The ID3v2 standard&amp;lt;ref&amp;gt;The ID3v2 format is explained at [http://www.id3.org/ www.id3.org]. The most useful document is the [http://www.id3.org/id3v2.3.0.html ID3v2 v2.3.0 standard]. Although this document has been superseded by v2.4.0, the earlier document is complete (rather than an update), and in indexed HTML form. As such, it represents a better technical introduction to ID3v2.&amp;lt;/ref&amp;gt; defines a &#039;&#039;tag&#039;&#039; which is situated before the data in an MP3 file.&amp;lt;ref&amp;gt;The original ID3 (v1) tags resided at the end of the file, and contained a few fields of information. The ID3v1 tag is not extensible and therefore cannot support ReplayGain metadata.&amp;lt;/ref&amp;gt; ID3 is used primarily with MP3 audio files but means of adapting the system to other file types have been developed.&lt;br /&gt;
&lt;br /&gt;
The ID3v2 tag is divided into &#039;&#039;frames&#039;&#039;. The preferred means of storing ReplayGain metadata is use of &#039;&#039;TXXX&#039;&#039; key/value pair frames. Two other legacy schemes for storing ReplayGain metadata exist: [[ReplayGain_legacy_metadata_formats#ID3v2_RGAD|RGAD]] and [[ReplayGain_legacy_metadata_formats#ID3v2_RVA2|RVA2]]. These formats are documented in the [[ReplayGain legacy metadata formats|appendix]]. Players may choose to look for these formats if metadata in the &#039;&#039;TXXX&#039;&#039; format is not found in the ID3v2 tag. New scanners may write these older formats in addition to the newer (TXXX) ones if they wish to remain backwards compatible with older players.&lt;br /&gt;
&lt;br /&gt;
ReplayGain uses four TXXX frames. The header of a TXXX frame is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Frame ID       $54 58 58 58 (&amp;quot;TXXX&amp;quot;) &lt;br /&gt;
 Size           $xx xx xx xx (size of frame excluding this header)&lt;br /&gt;
 Flags          $40 $00      (discard frame if audio data is altered)&lt;br /&gt;
&lt;br /&gt;
Frame data is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Text encoding  $00          (ISO-8859-1 encoding)&lt;br /&gt;
 Description    &amp;lt;key string&amp;gt; $00&lt;br /&gt;
 Value          &amp;lt;value string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The four frames associated with ReplayGain metadata use the following key/value pairs&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Table 3: Metadata keys and value formatting&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
|-&lt;br /&gt;
|Track replay gain&lt;br /&gt;
|REPLAYGAIN_TRACK_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak track amplitude&lt;br /&gt;
|REPLAYGAIN_TRACK_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|-&lt;br /&gt;
|Album replay gain&lt;br /&gt;
|REPLAYGAIN_ALBUM_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak album amplitude&lt;br /&gt;
|REPLAYGAIN_ALBUM_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Gains are specified textually in decibels. Negative gains (attenuation) are prefixed with a &#039;-&#039;. Positive gains have no prefix. Integral portion of the gain (a) may be one or two numeric (0-9) digits. If there is no integral portion the field is &#039;0&#039;. The decimal portion of the gain (bb) is two numeric digits. Gains are suffixed with a space followed by &#039;dB&#039;.&lt;br /&gt;
&lt;br /&gt;
Peak levels are specified textually as a positive decimal. Peak level is a dimensionless quantity with 1.000000 representing full scale. No suffix is included on peak values. The integer field (c) is typically 1 or 0. Six numeric digits in the decimal field (dddddd) is adequate to accurately represent peak values for 16-bit audio data.&lt;br /&gt;
&lt;br /&gt;
A robust player should be prepared to parse the following variations in either replay gain or peak level metadata:&lt;br /&gt;
*Positive gains with leading &#039;+&#039;&lt;br /&gt;
*More or fewer significant digits than specified in any field&lt;br /&gt;
*Leading zeros or spaces in integer fields&lt;br /&gt;
*Missing or malformed &#039;dB&#039; suffix (e.g. no space between numeric digits and suffix, alternate capitalization)&lt;br /&gt;
*Alternate capitalization of keys&lt;br /&gt;
&lt;br /&gt;
Other formatting errors indicate more severe problems and should result in player ignoring data as if the frame did not exist.&lt;br /&gt;
&lt;br /&gt;
===Vorbis comments===&lt;br /&gt;
A Vorbis comment&amp;lt;ref&amp;gt;[http://www.xiph.org/vorbis/doc/v-comment.html Vorbis comment metadata format]. ReplayGain metadata is documented on the [http://wiki.xiph.org/VorbisComment#Replay_Gain Xiph Wiki].&amp;lt;/ref&amp;gt; uses an ASCII &amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; format. When Vorbis comments are used, the four ReplayGain metadata items are stored as separate comments. The &#039;&#039;keys&#039;&#039; and formatting for &#039;&#039;values&#039;&#039; is the same as specified for ID3v2. Keys and values are required by the Vorbis comment specification to be separated by &#039;=&#039; (equal character).&lt;br /&gt;
&lt;br /&gt;
===APEv2===&lt;br /&gt;
The APEv2 metadata format&amp;lt;ref&amp;gt;[http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification APEv2 Specification at Hydrogen Audio Wiki]&amp;lt;/ref&amp;gt; also organizes data into key/value pairs. Keys are ASCII format. A flags field allows support for several value formats including UTF-8 and binary. Under APEv2, ReplayGain meta data is stored using the same keys and data as ASCII values in the same format as specified for ID3v2.&lt;br /&gt;
&lt;br /&gt;
==Player requirements==&lt;br /&gt;
[[File:RG_Player_control.gif‎|frame|Figure 8: Example ReplayGain control panel]]&lt;br /&gt;
&lt;br /&gt;
Loudness normalization, pre-amplification and clipping prevention are the operations performed by a ReplayGain player.&lt;br /&gt;
&lt;br /&gt;
===Loudness normalization===&lt;br /&gt;
To properly normalize loudness, the player needs to determine if the user desires Track style level normalization (all tracks same loudness), or Album style level normalization (all albums same loudness, tracks of an album played at the same relative level as on the original release). This option should be selectable in the ReplayGain control panel (Figure 8). The player reads the corresponding gain metadata value from the file and scales the audio data as appropriate. Scaling the audio data simply means multiplying each sample value by a constant value. This constant is given by:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;10^\frac{gain}{20}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, in words, ten raised to the power of one-twentieth of replay gain.&amp;lt;ref&amp;gt; After any such operation, it&#039;s a good idea to dither the result. If this calculation and the pre-amp are implemented separately, then dither should only be added to the final result, just before the result is truncated back to 16 bits, or 24, or 8, as limited by the soundcard&amp;amp;mdash;not the file (i.e. after ReplayGain adjustment, an 8-bit file should be sent to a 16-bit soundcard at 16-bits).&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the file only contains one of the replay gain adjustments (e.g. Album) but the user has requested the other (Track), then the player should use the one that is available (in this case, Album). If neither (Track or Album) gain metadata is available, then the player needs to choose a suitable default gain. Potential choices include unity gain (0 dB) or an average of gains from other tracks in the album or playlist.&lt;br /&gt;
&lt;br /&gt;
===Pre-amplification===&lt;br /&gt;
Although the calibration level used by ReplayGain suggests that the average level of an audio track should be 14 dB below full scale, some pop music is dynamically compressed to peak at 0 dB and average around 3 dB below full scale. This means that, when the replay gain is applied, the level of such tracks will be reduced by 11 dB! If users are listening to a mixture of highly compressed and more dynamic tracks, ReplayGain will make the listening experience more pleasurable by bringing the level of the compressed tracks down into line with that of the others. However, if users are only listening to highly compressed music, then they may complain that all their files are now too quiet.&amp;lt;ref&amp;gt;This problem can be especially noticeable on portable players with limited output or gain.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To address this problem, a pre-amp feature should be incorporated into the player. A user-supplied pre-amp setting is an adjustment to the calculated replay gain. It should default to perform no adjustment. This means that casual users will experience a moderate reduction in the loudness of their compressed pop music. Less-compressed material can generally be played at the same loudness without clipping. Normalization of more dynamic material may cause clipping or invoke the [[#Clipping prevention|clipping prevention]] mechanism (see below). Power users and audiophiles can reduce the pre-amp gain to enjoy the full dynamic range of all of their music.&lt;br /&gt;
&lt;br /&gt;
If enabled, the player should read the user selected pre-amp gain, and scale the audio signal by the appropriate amount. For example, a +6 dB gain requires a scale of 10&amp;lt;sup&amp;gt;6/20&amp;lt;/sup&amp;gt;, which is approximately 2. The replay gain and pre-amp scale factors can be combined&amp;lt;ref&amp;gt;Scale factors in  Decibel units are added to produce the same effect as multiplying scale factors in linear units.&amp;lt;/ref&amp;gt; for simplicity and ease of processing.&lt;br /&gt;
&lt;br /&gt;
===Clipping prevention===&lt;br /&gt;
ReplayGain&#039;s suggestion of a -14 dB average playback level leaves sufficient headroom for the bulk of modern recordings. Nevertheless, there exists the possibility that after application of replay gain and pre-amp adjustment, a track may exceed full scale during its dynamic peaks. Without intervention, this will result in clipping, a severe form of distortion. Factors introducing the possibility of clipping include:&lt;br /&gt;
&lt;br /&gt;
# Recordings from certain genres and certain periods in the history of commercial recordings require additional headroom. Although these recordings can be accommodated through a downwards adjustment of the pre-amp setting, it may be difficult to determine a safe adjustment and it may be undesirable to lower average level to accommodate the rare track which requires it. &lt;br /&gt;
# ReplayGain will make loud dynamically compressed tracks quieter, and quiet dynamically uncompressed tracks louder. The average levels will then be similar, but the quiet tracks will actually have louder peaks. If the user pushes the pre-amp gain upwards the peaks of the (originally) quieter tracks will be pushed well over full scale.&lt;br /&gt;
# In coded audio (e.g. MP3 files) a file that was hard-limited to digital full scale before encoding will often be pushed over the limit by the psychoacoustic compression. A decoder with headroom can recover the over full scale signal by reducing the gain.&lt;br /&gt;
&lt;br /&gt;
ReplayGain suggests two possible solutions which prevent clipping in these situations. A player should support one or both of these.&lt;br /&gt;
&lt;br /&gt;
====Audio limiting====&lt;br /&gt;
In situation 2 above, the user clearly wants all the music to sound very loud. To give them their wish, any signal which would peak above digital full scale should be hard limited at just below digital full scale. This is also useful at lower pre-amp gains, where it allows the average level of classical music to be raised to that of pop music, without distorting. The exact type of nature limiting or compression an implementation choice for the player.&amp;lt;ref&amp;gt;Something like the Hard Limiter found in Cool Edit Pro (Syntrillium) would be appropriate for pop music at least.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reduced gain====&lt;br /&gt;
The audiophile user will not want any compression or limiting on the signal. In this case the only option is to automatically and temporarily reduce the pre-amp gain below the user-selected setting for tracks where clipping would otherwise occur. Clipping can be predicted by examining the peak level of the track or album being played.&lt;br /&gt;
&lt;br /&gt;
The player must read the peak amplitude metadata. If peak level metadata is unavailable, the player should assume a peak level of 1.0. If the peak level for both track and album is stored as metadata in the file, it is possible to calculate if, following the replay gain adjustment and pre-amp gain, the signal will clip at some point. If it won&#039;t, then no further action is necessary. &lt;br /&gt;
&lt;br /&gt;
An overall scale factor for loudness normalization taking into account replay gain, pre-amp setting and clipping prevention through gain reduction is given below.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;min( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{peak amplitude} )&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hardware implementation===&lt;br /&gt;
The above three steps are appropriate to software players operating on the digital signal in order to scale it. However, it is possible to send the digital signal to the DAC without level correction, and to place an attenuator in the analogue signal path. The attenuator can then be driven by the Replay Gain value. The clipping problem can be addressed by providing adequate headroom in the analog circuitry. Bit transparency and maximum signal to noise ratio is maintained in the digital signal and DAC process.&amp;lt;ref&amp;gt;A system using today&#039;s 24-bit converters is unlikely to appreciate any overall gain in system performance with such an arrangement. A digitally-controlled analog gain element typically introduces significant noise and distortion.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The [http://replaygain.hydrogenaudio.org/proposal original ReplayGain proposal] (an [http://replay.waybackmachine.org/20090306202649/http://www.replaygain.org/ archive] is also available) was developed by David Robinson and was published 10 July 2001. Additional updates were published by David Robinson through 10 October 2001.&lt;br /&gt;
&lt;br /&gt;
The following acknowledgement was included with the original proposal, &amp;quot;The algorithm to calculate an ideal replay gain has grown from my research into human hearing, with many additional ideas drawn from the work of E. Zwicker, and Brian Moore. I am currently completing my PhD at the University of Essex, and have been funded by the EPSRC.&amp;quot; Additionally David Robinson credited Glen Sawyer (Snelg) and Jim Casaburi (Walrus) for software contributions and Bob Katz and Matt Ashland for ideas.&lt;br /&gt;
&lt;br /&gt;
This updated ReplayGain specification reflecting current and recommended practice was prepared by Kevin Gross in 2011.&lt;br /&gt;
&lt;br /&gt;
==Contact==&lt;br /&gt;
For ReplayGain-related questions or contributions, please post in the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio] section of the Hydrogen Audio forums.&lt;br /&gt;
 &lt;br /&gt;
==Appendix==&lt;br /&gt;
# [[ReplayGain legacy metadata formats]]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
: &#039;&#039;This is not a normative part of the specification.&#039;&#039;&lt;br /&gt;
* [[ReplayGain 2.0 specification]] (draft)&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Talk:ReplayGain_2.0_specification&amp;diff=38791</id>
		<title>Talk:ReplayGain 2.0 specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Talk:ReplayGain_2.0_specification&amp;diff=38791"/>
		<updated>2026-01-22T19:28:27Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Skamp moved page Talk:ReplayGain 2.0 specification to Talk:Revised ReplayGain specification: There is confusion about having two distinct, numbered specifications for ReplayGain&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Talk:Revised ReplayGain specification]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Talk:Revised_ReplayGain_specification&amp;diff=38790</id>
		<title>Talk:Revised ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Talk:Revised_ReplayGain_specification&amp;diff=38790"/>
		<updated>2026-01-22T19:28:27Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Skamp moved page Talk:ReplayGain 2.0 specification to Talk:Revised ReplayGain specification: There is confusion about having two distinct, numbered specifications for ReplayGain&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Improvement discussion threads==&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=15445 Improving ReplayGain, some ideas for Devs etc]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=89841 ReplayGain2, ReplayGain2 proposal]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=85614 ReplayGain album gain problem]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=84769 ReplayGain when converting 5.1 to 2]&lt;br /&gt;
&lt;br /&gt;
===R128===&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=85978 R128GAIN: An EBU R128 compliant loudness scanner]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=86116 libebur128 - (yet another) EBU R 128 implementation]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=86424 R128 versus ReplayGain, The cage match begins here.]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=88498 ReplayGain: Foobar2000 results differ from MP3Gain and MetaFLAC ones]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=88778 replaygain and R 128]&lt;br /&gt;
&lt;br /&gt;
==External resources==&lt;br /&gt;
*[http://www.dolby.com/uploadedFiles/Assets/US/Doc/Professional/AES128-Loudness-Normalization-Portable-Media-Players.pdf Loudness Normalization in the Age of Portable Media Players]&lt;br /&gt;
*[http://music-loudness.com/PDFs/Loudness_Alliance_White_Paper_final_v1.pdf Loudness Normalization: The Future of File-Based Playback]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=ReplayGain_2.0_specification&amp;diff=38789</id>
		<title>ReplayGain 2.0 specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=ReplayGain_2.0_specification&amp;diff=38789"/>
		<updated>2026-01-22T19:28:27Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Skamp moved page ReplayGain 2.0 specification to Revised ReplayGain specification: There is confusion about having two distinct, numbered specifications for ReplayGain&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Revised ReplayGain specification]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38788</id>
		<title>Revised ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38788"/>
		<updated>2026-01-22T19:28:27Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Skamp moved page ReplayGain 2.0 specification to Revised ReplayGain specification: There is confusion about having two distinct, numbered specifications for ReplayGain&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;DISPLAYTITLE&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;4&amp;quot;&amp;gt;&#039;&#039;This is a proposed update to the [[ReplayGain 1.0 specification|original ReplayGain specification]]. This proposal is currently &#039;&#039;&#039;Under Construction&#039;&#039;&#039;. Please discuss this proposal on the [[Talk:ReplayGain 2.0 specification|discussion page]] or the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio forum].&#039;&#039; --[[User:Notat|Notat]] 23:42, 8 October 2012 (CEST)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although music is encoded to a digital format with a clearly defined maximum peak amplitude, and although most recordings are normalized to utilize this peak amplitude, not all recordings sound equally loud. This is because once this peak amplitude is reached, perceived loudness can be further increased through signal-processing techniques such as dynamic range compression and equalization.&amp;lt;ref&amp;gt;Source: Wikipedia - [http://en.wikipedia.org/wiki/Loudness_war Loudness war]&amp;lt;/ref&amp;gt; Therefore, the loudness of a given album has more to do with the year of issue or the whim of the producer than the intended emotional effect. Because of this, a random play through a music collection can have one leaping for the volume control every other track.&lt;br /&gt;
&lt;br /&gt;
There is a solution to this annoyance: within each audio file, information can be stored about what volume change would be required to play each track or album at a standard loudness, and players can use this &amp;quot;replay gain&amp;quot; information to automatically nudge the volume up or down as required.&lt;br /&gt;
&lt;br /&gt;
The ReplayGain specification is a standard which defines an appropriate reference level, explains a way of calculating and representing the ideal replay gain for a given track or album, and provides guidance for players to make the required volume adjustment during playback. The standard also specifies a means to prevent clipping when the calculated replay gain exceeds the limits of digital audio, and it describes how the replay gain information is stored within audio files.&lt;br /&gt;
&lt;br /&gt;
==Loudness measurement==&lt;br /&gt;
Loudness is a subjective measure of the intensity of sound. The correlation of perceived loudness to sound pressure level is determined by the peculiarities of the auditory system.&lt;br /&gt;
&lt;br /&gt;
The original [[ReplayGain 1.0 specification|ReplayGain specification]] described a loudness measurement system which included a weighting filter, root mean square (RMS) measurement and statistical processing that model human perception of loudness in both the frequency and time domains.&lt;br /&gt;
&lt;br /&gt;
Since original ReplayGain proposal in 2001, the science, practice and standards for loudness normalization have been advanced significantly. The current industry standard approach to loudness measurement is described by the International Telecommunications Union&amp;lt;ref&amp;gt;http://www.itu.int/en/Pages/default.aspx&amp;lt;/ref&amp;gt; (ITU) as BS.1770. The most recent version of this standard is known as ITU BS.1770-5&amp;lt;ref&amp;gt;https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en&amp;lt;/ref&amp;gt; and was published in December 2023. The ITU work is freely available and is not believed to be encumbered by any patent issues. The ITU BS.1770-2 standard has been adopted in the United States by the [http://www.atsc.org ATSC] as [http://www.atsc.org/cms/standards/a_85-2011a.pdf A/85] and in Europe by the [http://www.ebu.ch European Broadcast Union] as [http://tech.ebu.ch/docs/tech/tech3343.pdf EBU R-128] for broadcast audio. &lt;br /&gt;
&lt;br /&gt;
BS.1770 uses a &amp;quot;K-weighted&amp;quot; RMS measurement. This weighting function is significantly less complex than the inverted Fletcher-Munson weighting used by the original ReplayGain algorithm. A gating function designed measure the loudness of foreground components in the audio program. The gate in BS.1770 performs a similar function as the statistical processing in the original RG specification. &lt;br /&gt;
&lt;br /&gt;
The computation required for BS.1770 loudness measurement is reduced compared to the original RG technique. Nevertheless, BS.1770 has been shown in several academic studies to be equally or more effective than the RG algorithm in modeling human loudness perception on music program as well as other material such as podcasts, television programs and movies.&amp;lt;ref&amp;gt;Paul Nygren. [http://www.speech.kth.se/prod/publications/files/3319.pdf Achieving equal loudness between audio files]. KTH Royal Institute of Technology&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Martin Wolters; Harald Mundt; Jeffrey Riedmiller (May 2010). [http://www.aes.org/e-lib/browse.cfm?elib=15341 Loudness Normalization In The Age Of Portable Media Players]. Audio Engineering Society.&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Esben Skovenborg; Søren H. Nielsen (October 2004). [http://web.archive.org/web/20120208024743/http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf Evaluation of Different Loudness Models with Music and Speech Material]. Audio Engineering Society. Archived from [http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf the original] on 2012-02-08.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recent RG implementations use BS.1770 for loudness measurement. It is expected the ITU standard will evolve over time to meet the needs of broadcasters and governments. It is the intent of the ReplayGain community that RG follow any future backwards-compatible improvements to loudness measurement using the BS.1770 standard.&lt;br /&gt;
&lt;br /&gt;
==Reference level==&lt;br /&gt;
&lt;br /&gt;
Classic ReplayGain is calibrated to a pink noise reference signal with a RMS level 14&amp;amp;nbsp;dB below a full-scale sinusoid. This reference signal is used to establish a reference level. ReplayGain will apply no gain or attenuation to the reference signal or any program material which has the same loudness measurements as the reference signal.&lt;br /&gt;
&lt;br /&gt;
BS-1770 defines a loudness scale for program material. The units of BS.1770 loudness measurements are in Loudness Units [relative to] Full Scale (LUFS). LUFS can be treated like decibels.&lt;br /&gt;
&lt;br /&gt;
In order to maintain backwards compatibility with classic RG, newer RG uses a -18&amp;amp;nbsp;LUFS reference, which based on lots of music, can give similar loudness compared to classic RG.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
The loudness measurement of the RG1 reference signal is NOT -18 LUFS; &lt;br /&gt;
The original -20 RMS dBFS one is -20.36 LUFS, and the -14 RMS dbFS one would be -15.36 LUFS.&lt;br /&gt;
&lt;br /&gt;
We picked -18 here is the result of analyzing actual music. &lt;br /&gt;
&lt;br /&gt;
Check what 2Bdecided said here: https://hydrogenaud.io/index.php/topic,109076.msg899298.html#msg899298&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Gain calculation==&lt;br /&gt;
RG achieves loudness compensated playback by applying gain (or attenuation) dependent on the measured loudness of the audio file relative to the established reference level. The gain is calculated as follows:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG=L_{r}-L&amp;lt;/math&amp;gt;&lt;br /&gt;
Where:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG&amp;lt;/math&amp;gt; is the replay gain adjustment in decibels,&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{r}&amp;lt;/math&amp;gt; is the -18&amp;amp;nbsp;LUFS reference level&lt;br /&gt;
:&amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; is the measured loudness of the audio file in LUFS.&lt;br /&gt;
&lt;br /&gt;
Gain is positive if the loudness of the audio file is lower than the reference level. The gain is negative (representing an attenuation) if the loudness of the audio file is higher than the reference level. The gain is stored as metadata with the audio file as described below and is used by players to adjust output volume of tracks as they are played as described in [[ReplayGain 2.0 specification#Player requirements|Player requirements]] below.&lt;br /&gt;
&lt;br /&gt;
==Metadata==&lt;br /&gt;
For ReplayGain to do its work during playback, four values must be stored as metadata&amp;lt;ref&amp;gt;Metadata is &amp;quot;data about data.&amp;quot; For example, the ID3 &#039;&#039;de facto&#039;&#039; standard provides a way to store artist, title, album title, track number, and other metadata in data blocks called &amp;quot;tags&amp;quot; immediately before or after the audio data in an MP3 file. Other metadata storage/tagging standards and conventions exist for other audio file formats.&amp;lt;/ref&amp;gt; with or within the audio file:&lt;br /&gt;
# Peak track amplitude&lt;br /&gt;
# Peak album amplitude&lt;br /&gt;
# Track replay gain&lt;br /&gt;
# Album replay gain&lt;br /&gt;
&lt;br /&gt;
If calculated for an individual track, the loudness measurement (as specified above) yields track replay gain. If calculated on an album basis, with all tracks concatenated to make one long audio file, the loudness measurement yields album replay gain.&lt;br /&gt;
&lt;br /&gt;
===Replay gain===&lt;br /&gt;
Under some listening conditions, it&#039;s useful to have every track sound equally loud. The problem with a track-by-track approach is that tracks which should be quiet in the context of the album on which they reside will be brought up to the level of all the rest. For casual listening, or in a noisy background, this can be a good thing. For serious listening, it does not respect the intent of the artist or mastering engineer; a tender ballad track will be blasting at the same loudness as a hard rock track on the same album. It&#039;s generally ideal to leave the intentional loudness differences between tracks in place, yet still correct for unmusical and annoying loudness differences between albums. To accomplish this, ReplayGain suggests that two different gain adjustments should be stored as metadata with each sound file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Album replay gain&#039;&#039; represents the ideal listening gain for an entire album. ReplayGain reads the collection of tracks that comprise an album, and calculates a single replay gain for the whole set. This single gain can be used for playback of all tracks of the album. Intentionally quiet tracks then stay appropriately quieter than the rest. It still solves the basic problem (annoying, unwanted level differences between discs) because quiet or loud discs are still adjusted overall&amp;amp;mdash;so the pop CD that&#039;s 20&amp;amp;nbsp;dB louder than the classical CD will be brought into line.&lt;br /&gt;
&lt;br /&gt;
===Peak amplitude===&lt;br /&gt;
Scanning a track or album for the peak amplitude can be a time-consuming process. Therefore, it&#039;s helpful if this single value is stored as metadata. This is used to predict whether the required replay gain adjustment will cause clipping during playback.&lt;br /&gt;
&lt;br /&gt;
The maximum peak amplitude value is stored as a floating point number, where 1.0 represents digital full scale. As with replay gain values, separate peak amplitude values are stored per track and per album.&lt;br /&gt;
&lt;br /&gt;
For uncompressed files simply, scanners store the maximum absolute sample value held in the file on any channel for positive or negative excursion. The single sample value should be converted to a floating-point representation, such that digital full scale is equivalent to a value of 1.0.&lt;br /&gt;
&lt;br /&gt;
Psychoacoustically coded audio, such as MP3, does not exist as a sequence of samples until it is decoded. Psychoacoustic coding of a heavily limited file can lead to sample values larger than digital full scale upon decoding. The coded files must be decoded using a fully compliant decoder that allows peak overflows (i.e. has headroom) and may result in peak amplitude values greater than 1.0.&lt;br /&gt;
&lt;br /&gt;
==Metadata format==&lt;br /&gt;
From the standpoint of metadata storage, each audio file format presents a unique situation. There are three favored schemes defined for storage of ReplayGain metadata: &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; and &#039;&#039;&#039;APEv2&#039;&#039;&#039;. A survey of file formats is listed below with metadata schemes in order of preference for each:&lt;br /&gt;
* .aac (Advanced Audio Coding raw format) &amp;amp;ndash; No metadata support (use .mp4 instead)&lt;br /&gt;
* .aiff, .aif, .aifc (Apple Interchange File Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID3&amp;quot; IFF chunk)&lt;br /&gt;
* .ape, .apl (Monkey&#039;s Audio) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .bwf (Broadcast Wave Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in RIFF chunk)&lt;br /&gt;
* .flac (Free Lossless Audio Codec) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .mp3 (MPEG audio layer 3) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, LAME VBR proposed tag specification&lt;br /&gt;
* .mp4 also .m4a, .m4b, .m4p, m4r (MPEG-4 Part 14) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID32&amp;quot; box)&lt;br /&gt;
* .mpc (Musepack) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .ogg (Ogg Vorbis) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;, same for other Ogg codecs&lt;br /&gt;
* .opus (Ogg Opus) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; available&lt;br /&gt;
** standard {{code|R128_TRACK_GAIN}} and {{code|R128_ALBUM_GAIN}} (MUST adjust for -23 LUFS) comment keys may be preferable (used by {{code|loudgain}})&lt;br /&gt;
* .tta (True Audio) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .asf, .wma (Windows Media audio) - &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; in Extended Content Description Object&lt;br /&gt;
** {{code|loudgain}} instead uses native ASF/WMA attributes (itself a key-value storage) via TagLib, which is more sensible&lt;br /&gt;
* .wav (Windows PCM) &amp;amp;ndash; No metadata support (use .bwf instead)&lt;br /&gt;
** ID3 RIFF chunk possible (used by {{code|loudgain}})&lt;br /&gt;
* .wv (WavePak) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===ID3v2===&lt;br /&gt;
The ID3v2 standard&amp;lt;ref&amp;gt;The ID3v2 format is explained at [http://www.id3.org/ www.id3.org]. The most useful document is the [http://www.id3.org/id3v2.3.0.html ID3v2 v2.3.0 standard]. Although this document has been superseded by v2.4.0, the earlier document is complete (rather than an update), and in indexed HTML form. As such, it represents a better technical introduction to ID3v2.&amp;lt;/ref&amp;gt; defines a &#039;&#039;tag&#039;&#039; which is situated before the data in an MP3 file.&amp;lt;ref&amp;gt;The original ID3 (v1) tags resided at the end of the file, and contained a few fields of information. The ID3v1 tag is not extensible and therefore cannot support ReplayGain metadata.&amp;lt;/ref&amp;gt; ID3 is used primarily with MP3 audio files but means of adapting the system to other file types have been developed.&lt;br /&gt;
&lt;br /&gt;
The ID3v2 tag is divided into &#039;&#039;frames&#039;&#039;. The preferred means of storing ReplayGain metadata is use of &#039;&#039;TXXX&#039;&#039; key/value pair frames. Two other legacy schemes for storing ReplayGain metadata exist: [[ReplayGain legacy metadata formats#ID3v2 RGAD|RGAD]] and [[ReplayGain legacy metadata formats#ID3v2 RVA2|RVA2]]. These formats are documented in the [[ReplayGain legacy metadata formats|appendix]]. Players may choose to look for these formats if metadata in the &#039;&#039;TXXX&#039;&#039; format is not found in the ID3v2 tag. New scanners may write these older formats in addition to the newer (TXXX) ones if they wish to remain backwards compatible with older players.&lt;br /&gt;
&lt;br /&gt;
ReplayGain uses four TXXX frames. The header of a TXXX frame is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Frame ID       $54 58 58 58 (&amp;quot;TXXX&amp;quot;) &lt;br /&gt;
 Size           $xx xx xx xx (size of frame excluding this header)&lt;br /&gt;
 Flags          $40 $00      (discard frame if audio data is altered)&lt;br /&gt;
&lt;br /&gt;
Frame data is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Text encoding  $00          (ISO-8859-1 encoding)&lt;br /&gt;
 Description    &amp;lt;key string&amp;gt; $00&lt;br /&gt;
 Value          &amp;lt;value string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The four frames associated with ReplayGain metadata use the following key/value pairs&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Table 3: Metadata keys and value formatting&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
|-&lt;br /&gt;
|Track replay gain&lt;br /&gt;
|REPLAYGAIN_TRACK_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak track amplitude&lt;br /&gt;
|REPLAYGAIN_TRACK_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|-&lt;br /&gt;
|Album replay gain&lt;br /&gt;
|REPLAYGAIN_ALBUM_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak album amplitude&lt;br /&gt;
|REPLAYGAIN_ALBUM_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Gains are specified textually in decibels. Negative gains (attenuation) are prefixed with a &#039;-&#039;. Positive gains have no prefix. Integral portion of the gain (a) may be one or two numeric (0-9) digits. If there is no integral portion the field is &#039;0&#039;. The decimal portion of the gain (bb) is two numeric digits. Gains are suffixed with a space followed by &#039;dB&#039;.&lt;br /&gt;
&lt;br /&gt;
Peak levels are specified textually as a positive decimal. Peak level is a dimensionless quantity with 1.000000 representing full scale. No suffix is included on peak values. The integer field (c) is typically 1 or 0. Six numeric digits in the decimal field (dddddd) is adequate to accurately represent peak values for 16-bit audio data.&lt;br /&gt;
&lt;br /&gt;
A robust player should be prepared to parse the following variations in either replay gain or peak level metadata:&lt;br /&gt;
*Positive gains with leading &#039;+&#039;&lt;br /&gt;
*More or fewer significant digits than specified in any field&lt;br /&gt;
*Leading zeros or spaces in integer fields&lt;br /&gt;
*Missing or malformed &#039;dB&#039; suffix (e.g. no space between numeric digits and suffix, alternate capitalization)&lt;br /&gt;
*Alternate capitalization of keys&lt;br /&gt;
&lt;br /&gt;
Other formatting errors indicate more severe problems and should result in player ignoring data as if the frame did not exist.&lt;br /&gt;
&lt;br /&gt;
===Vorbis comments===&lt;br /&gt;
A Vorbis comment&amp;lt;ref&amp;gt;[http://www.xiph.org/vorbis/doc/v-comment.html Vorbis comment metadata format]. ReplayGain metadata is documented on the [http://wiki.xiph.org/VorbisComment#Replay_Gain Xiph Wiki].&amp;lt;/ref&amp;gt; uses an ASCII &amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; format. When Vorbis comments are used, the four ReplayGain metadata items are stored as separate comments. The &#039;&#039;keys&#039;&#039; and formatting for &#039;&#039;values&#039;&#039; is the same as specified for ID3v2. Keys and values are required by the Vorbis comment specification to b separated by &#039;=&#039; (equal character).&lt;br /&gt;
&lt;br /&gt;
===APEv2===&lt;br /&gt;
The APEv2 metadata format&amp;lt;ref&amp;gt;[http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification APEv2 Specification at Hydrogen Audio Wiki]&amp;lt;/ref&amp;gt; also organizes data into key/value pairs. Keys are ASCII format. A flags field allows support for several value formats including UTF-8 and binary. Under APEv2, ReplayGain meta data is stored using the same keys and data as ASCII values in the same format as specified for ID3v2.&lt;br /&gt;
&lt;br /&gt;
===De-Facto extensions===&lt;br /&gt;
MusicBrainz Picard and [http://github.com/Moonbase59/loudgain#tags-written-andor-deleted LoudGain] also support the following additional tags, named using the same conventions:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Extension metadata keys&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!alue format&lt;br /&gt;
! Purpose&lt;br /&gt;
|-&lt;br /&gt;
|Track range&lt;br /&gt;
|REPLAYGAIN_TRACK_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|rowspan=2 | Indicates dynamics (R-128 Loudness Range / LRA), may guide pre-amplification&lt;br /&gt;
|-&lt;br /&gt;
|Album range&lt;br /&gt;
|REPLAYGAIN_ALBUM_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Reference loudness&lt;br /&gt;
|REPLAYGAIN_REFERENCE_LOUDNESS&lt;br /&gt;
|[-]a.bb LUFS&lt;br /&gt;
| Use alternative reference levels; change ref levels without re-scanning the file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Player requirements==&lt;br /&gt;
[[File:RG_Player_control.gif‎|frame|Figure 8: Example ReplayGain control panel]]&lt;br /&gt;
&lt;br /&gt;
Loudness normalization, pre-amplification and clipping prevention are the operations performed by a ReplayGain player.&lt;br /&gt;
&lt;br /&gt;
===Loudness normalization===&lt;br /&gt;
To properly normalize loudness, the player needs to determine if the user desires Track style level normalization (all tracks same loudness), or Album style level normalization (all albums same loudness, tracks of an album played at the same relative level as on the original release). This option should be selectable in the ReplayGain control panel (Figure 8). The player reads the corresponding gain metadata value from the file and scales the audio data as appropriate. Scaling the audio data simply means multiplying each sample value by a constant value. This constant is given by:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;10^\frac{gain}{20}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, in words, replay gain divided by 20 all raised to the power of ten.&amp;lt;ref&amp;gt;After any such operation, it&#039;s a good idea to dither the result. If this calculation and the pre-amp are implemented separately, then dither should only be added to the final result, just before the result is truncated back to 16 bits, or 24, or 8, as limited by the soundcard&amp;amp;mdash;not the file (i.e. after ReplayGain adjustment, an 8-bit file should be sent to a 16-bit soundcard at 16-bits).&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the file only contains one of the replay gain adjustments (e.g. Album) but the user has requested the other (Track), then the player should use the one that is available (in this case, Album). If neither (Track or Album) gain metadata is available, then the player needs to choose a suitable default gain. Potential choices include unity gain (0 dB) or an average of gains from other tracks in the album or playlist.&lt;br /&gt;
&lt;br /&gt;
===Pre-amplification===&lt;br /&gt;
Although the calibration level used by ReplayGain suggests that the average level of an audio track should be 14&amp;amp;nbsp;dB below full scale, some pop music is dynamically compressed to peak at 0&amp;amp;nbsp;dB and average around 3&amp;amp;nbsp;dB below full scale. This means that, when the replay gain is applied, the level of such tracks will be reduced by 11&amp;amp;nbsp;dB! If users are listening to a mixture of highly compressed and more dynamic tracks, ReplayGain will make the listening experience more pleasurable by bringing the level of the compressed tracks down into line with that of the others. However, if users are only listening to highly compressed music, then they may complain that all their files are now too quiet.&amp;lt;ref&amp;gt;This problem can be especially noticeable on portable players with limited output or gain.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To address this problem, a pre-amp feature should be incorporated into the player. A user-supplied pre-amp setting is an adjustment to the calculated replay gain. It should default to perform no adjustment. This means that casual users will experience a moderate reduction in the loudness of their compressed pop music. Less-compressed material can generally be played at the same loudness without clipping. Normalization of more dynamic material may cause clipping or invoke the [[ReplayGain 2.0 specification#Clipping prevention|clipping prevention]] mechanism (see below). Power users and audiophiles can reduce the pre-amp gain to enjoy the full dynamic range of all of their music.&lt;br /&gt;
&lt;br /&gt;
If enabled, the player should read the user selected pre-amp gain, and scale the audio signal by the appropriate amount. For example, a +6&amp;amp;nbsp;dB gain requires a scale of 10&amp;lt;sup&amp;gt;6/20&amp;lt;/sup&amp;gt;, which is approximately 2. The replay gain and pre-amp scale factors can be combined&amp;lt;ref&amp;gt;Scale factors in  Decibel units are added to produce the same effect as multiplying scale factors in linear units.&amp;lt;/ref&amp;gt; for simplicity and ease of processing.&lt;br /&gt;
&lt;br /&gt;
===Clipping prevention===&lt;br /&gt;
ReplayGain&#039;s suggestion of a -14&amp;amp;nbsp;dB average playback level leaves sufficient headroom for the bulk of modern recordings. Nevertheless, there exists the possibility that after application of replay gain and pre-amp adjustment, a track may exceed full scale during its dynamic peaks. Without intervention, this will result in clipping, a severe form of distortion. Factors introducing the possibility of clipping include:&lt;br /&gt;
&lt;br /&gt;
# Recordings from certain genres and certain periods in the history of commercial recordings require additional headroom. Although these recordings can be accommodated through a downwards adjustment of the pre-amp setting, it may be difficult to determine a safe adjustment and it may be undesirable to lower average level to accommodate the rare track which requires it. &lt;br /&gt;
# ReplayGain will make loud dynamically compressed tracks quieter, and quiet dynamically uncompressed tracks louder. The average levels will then be similar, but the quiet tracks will actually have louder peaks. If the user pushes the pre-amp gain upwards the peaks of the (originally) quieter tracks will be pushed well over full scale.&lt;br /&gt;
# In coded audio (e.g. MP3 files) a file that was hard-limited to digital full scale before encoding will often be pushed over the limit by the psychoacoustic compression. A decoder with headroom can recover the over full scale signal by reducing the gain.&lt;br /&gt;
&lt;br /&gt;
ReplayGain suggests two possible solutions which prevent clipping in these situations. A player should support one or both of these.&lt;br /&gt;
&lt;br /&gt;
====Audio limiting====&lt;br /&gt;
In situation 2 above, the user clearly wants all the music to sound very loud. To give them their wish, any signal which would peak above digital full scale should be hard limited at just below digital full scale. This is also useful at lower pre-amp gains, where it allows the average level of classical music to be raised to that of pop music, without distorting. The exact type of nature limiting or compression an implementation choice for the player.&amp;lt;ref&amp;gt;Something like the Hard Limiter found in Cool Edit Pro (Syntrillium) would be appropriate for pop music at least.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reduced gain====&lt;br /&gt;
The audiophile user will not want any compression or limiting on the signal. In this case the only option is to automatically and temporarily reduce the pre-amp gain below the user-selected setting for tracks where clipping would otherwise occur. Clipping can be predicted by examining the peak level of the track or album being played.&lt;br /&gt;
&lt;br /&gt;
The player must read the peak amplitude metadata. If peak level metadata is unavailable, the player should assume a peak level of 1.0. If the peak level for both track and album is stored as metadata in the file, it is possible to calculate if, following the replay gain adjustment and pre-amp gain, the signal will clip at some point. If it won&#039;t, then no further action is necessary. &lt;br /&gt;
&lt;br /&gt;
An overall scale factor for loudness normalization taking into account replay gain, pre-amp setting and clipping prevention through gain reduction is given below.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;min( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{peak amplitude} )&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;!-- use this when tex is fixed: :&amp;lt;math&amp;gt;\operatorname{min}( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{L_{\mathrm{peak}}} )&amp;lt;/math&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hardware implementation===&lt;br /&gt;
The above three steps are appropriate to software players operating on the digital signal in order to scale it. However, it is possible to send the digital signal to the DAC without level correction, and to place an attenuator in the analogue signal path. The attenuator can then be driven by the Replay Gain value. The clipping problem can be addressed by providing adequate headroom in the analog circuitry. Bit transparency and maximum signal to noise ratio is maintained in the digital signal and DAC process.&amp;lt;ref&amp;gt;A system using today&#039;s 24-bit converters is unlikely to appreciate any overall gain in system performance with such an arrangement. A digitally-controlled analog gain element typically introduces significant noise and distortion.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The [http://replaygain.hydrogenaudio.org/proposal original ReplayGain proposal] (an [http://replay.waybackmachine.org/20090306202649/http://www.replaygain.org/ archive] is also available) was developed by David Robinson and was published 10 July 2001. Additional updates were published by David Robinson through 10 October 2001.&lt;br /&gt;
&lt;br /&gt;
The following acknowledgement was included with the original proposal, &amp;quot;The algorithm to calculate an ideal replay gain has grown from my research into human hearing, with many additional ideas drawn from the work of E. Zwicker, and Brian Moore. I am currently completing my PhD at the University of Essex, and have been funded by the EPSRC.&amp;quot; Additionally David Robinson credited Glen Sawyer (Snelg) and Jim Casaburi (Walrus) for software contributions and Bob Katz and Matt Ashland for ideas.&lt;br /&gt;
&lt;br /&gt;
This updated ReplayGain specification reflecting current and recommended practice was prepared by Kevin Gross in 2011.&lt;br /&gt;
&lt;br /&gt;
==Contact==&lt;br /&gt;
For ReplayGain-related questions or contributions, please post in the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio] section of the Hydrogen Audio forums.&lt;br /&gt;
 &lt;br /&gt;
==Appendix==&lt;br /&gt;
# [[ReplayGain legacy metadata formats]]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38787</id>
		<title>Revised ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38787"/>
		<updated>2026-01-22T19:26:43Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Changed &amp;quot;ReplayGain 1.0 specification&amp;quot; to &amp;quot;the original ReplayGain specification&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;DISPLAYTITLE&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;4&amp;quot;&amp;gt;&#039;&#039;This is a proposed update to the [[ReplayGain 1.0 specification|original ReplayGain specification]]. This proposal is currently &#039;&#039;&#039;Under Construction&#039;&#039;&#039;. Please discuss this proposal on the [[Talk:ReplayGain 2.0 specification|discussion page]] or the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio forum].&#039;&#039; --[[User:Notat|Notat]] 23:42, 8 October 2012 (CEST)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although music is encoded to a digital format with a clearly defined maximum peak amplitude, and although most recordings are normalized to utilize this peak amplitude, not all recordings sound equally loud. This is because once this peak amplitude is reached, perceived loudness can be further increased through signal-processing techniques such as dynamic range compression and equalization.&amp;lt;ref&amp;gt;Source: Wikipedia - [http://en.wikipedia.org/wiki/Loudness_war Loudness war]&amp;lt;/ref&amp;gt; Therefore, the loudness of a given album has more to do with the year of issue or the whim of the producer than the intended emotional effect. Because of this, a random play through a music collection can have one leaping for the volume control every other track.&lt;br /&gt;
&lt;br /&gt;
There is a solution to this annoyance: within each audio file, information can be stored about what volume change would be required to play each track or album at a standard loudness, and players can use this &amp;quot;replay gain&amp;quot; information to automatically nudge the volume up or down as required.&lt;br /&gt;
&lt;br /&gt;
The ReplayGain specification is a standard which defines an appropriate reference level, explains a way of calculating and representing the ideal replay gain for a given track or album, and provides guidance for players to make the required volume adjustment during playback. The standard also specifies a means to prevent clipping when the calculated replay gain exceeds the limits of digital audio, and it describes how the replay gain information is stored within audio files.&lt;br /&gt;
&lt;br /&gt;
==Loudness measurement==&lt;br /&gt;
Loudness is a subjective measure of the intensity of sound. The correlation of perceived loudness to sound pressure level is determined by the peculiarities of the auditory system.&lt;br /&gt;
&lt;br /&gt;
The original [[ReplayGain 1.0 specification|ReplayGain specification]] described a loudness measurement system which included a weighting filter, root mean square (RMS) measurement and statistical processing that model human perception of loudness in both the frequency and time domains.&lt;br /&gt;
&lt;br /&gt;
Since original ReplayGain proposal in 2001, the science, practice and standards for loudness normalization have been advanced significantly. The current industry standard approach to loudness measurement is described by the International Telecommunications Union&amp;lt;ref&amp;gt;http://www.itu.int/en/Pages/default.aspx&amp;lt;/ref&amp;gt; (ITU) as BS.1770. The most recent version of this standard is known as ITU BS.1770-5&amp;lt;ref&amp;gt;https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en&amp;lt;/ref&amp;gt; and was published in December 2023. The ITU work is freely available and is not believed to be encumbered by any patent issues. The ITU BS.1770-2 standard has been adopted in the United States by the [http://www.atsc.org ATSC] as [http://www.atsc.org/cms/standards/a_85-2011a.pdf A/85] and in Europe by the [http://www.ebu.ch European Broadcast Union] as [http://tech.ebu.ch/docs/tech/tech3343.pdf EBU R-128] for broadcast audio. &lt;br /&gt;
&lt;br /&gt;
BS.1770 uses a &amp;quot;K-weighted&amp;quot; RMS measurement. This weighting function is significantly less complex than the inverted Fletcher-Munson weighting used by the original ReplayGain algorithm. A gating function designed measure the loudness of foreground components in the audio program. The gate in BS.1770 performs a similar function as the statistical processing in the original RG specification. &lt;br /&gt;
&lt;br /&gt;
The computation required for BS.1770 loudness measurement is reduced compared to the original RG technique. Nevertheless, BS.1770 has been shown in several academic studies to be equally or more effective than the RG algorithm in modeling human loudness perception on music program as well as other material such as podcasts, television programs and movies.&amp;lt;ref&amp;gt;Paul Nygren. [http://www.speech.kth.se/prod/publications/files/3319.pdf Achieving equal loudness between audio files]. KTH Royal Institute of Technology&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Martin Wolters; Harald Mundt; Jeffrey Riedmiller (May 2010). [http://www.aes.org/e-lib/browse.cfm?elib=15341 Loudness Normalization In The Age Of Portable Media Players]. Audio Engineering Society.&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Esben Skovenborg; Søren H. Nielsen (October 2004). [http://web.archive.org/web/20120208024743/http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf Evaluation of Different Loudness Models with Music and Speech Material]. Audio Engineering Society. Archived from [http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf the original] on 2012-02-08.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recent RG implementations use BS.1770 for loudness measurement. It is expected the ITU standard will evolve over time to meet the needs of broadcasters and governments. It is the intent of the ReplayGain community that RG follow any future backwards-compatible improvements to loudness measurement using the BS.1770 standard.&lt;br /&gt;
&lt;br /&gt;
==Reference level==&lt;br /&gt;
&lt;br /&gt;
Classic ReplayGain is calibrated to a pink noise reference signal with a RMS level 14&amp;amp;nbsp;dB below a full-scale sinusoid. This reference signal is used to establish a reference level. ReplayGain will apply no gain or attenuation to the reference signal or any program material which has the same loudness measurements as the reference signal.&lt;br /&gt;
&lt;br /&gt;
BS-1770 defines a loudness scale for program material. The units of BS.1770 loudness measurements are in Loudness Units [relative to] Full Scale (LUFS). LUFS can be treated like decibels.&lt;br /&gt;
&lt;br /&gt;
In order to maintain backwards compatibility with classic RG, newer RG uses a -18&amp;amp;nbsp;LUFS reference, which based on lots of music, can give similar loudness compared to classic RG.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
The loudness measurement of the RG1 reference signal is NOT -18 LUFS; &lt;br /&gt;
The original -20 RMS dBFS one is -20.36 LUFS, and the -14 RMS dbFS one would be -15.36 LUFS.&lt;br /&gt;
&lt;br /&gt;
We picked -18 here is the result of analyzing actual music. &lt;br /&gt;
&lt;br /&gt;
Check what 2Bdecided said here: https://hydrogenaud.io/index.php/topic,109076.msg899298.html#msg899298&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Gain calculation==&lt;br /&gt;
RG achieves loudness compensated playback by applying gain (or attenuation) dependent on the measured loudness of the audio file relative to the established reference level. The gain is calculated as follows:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG=L_{r}-L&amp;lt;/math&amp;gt;&lt;br /&gt;
Where:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG&amp;lt;/math&amp;gt; is the replay gain adjustment in decibels,&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{r}&amp;lt;/math&amp;gt; is the -18&amp;amp;nbsp;LUFS reference level&lt;br /&gt;
:&amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; is the measured loudness of the audio file in LUFS.&lt;br /&gt;
&lt;br /&gt;
Gain is positive if the loudness of the audio file is lower than the reference level. The gain is negative (representing an attenuation) if the loudness of the audio file is higher than the reference level. The gain is stored as metadata with the audio file as described below and is used by players to adjust output volume of tracks as they are played as described in [[ReplayGain 2.0 specification#Player requirements|Player requirements]] below.&lt;br /&gt;
&lt;br /&gt;
==Metadata==&lt;br /&gt;
For ReplayGain to do its work during playback, four values must be stored as metadata&amp;lt;ref&amp;gt;Metadata is &amp;quot;data about data.&amp;quot; For example, the ID3 &#039;&#039;de facto&#039;&#039; standard provides a way to store artist, title, album title, track number, and other metadata in data blocks called &amp;quot;tags&amp;quot; immediately before or after the audio data in an MP3 file. Other metadata storage/tagging standards and conventions exist for other audio file formats.&amp;lt;/ref&amp;gt; with or within the audio file:&lt;br /&gt;
# Peak track amplitude&lt;br /&gt;
# Peak album amplitude&lt;br /&gt;
# Track replay gain&lt;br /&gt;
# Album replay gain&lt;br /&gt;
&lt;br /&gt;
If calculated for an individual track, the loudness measurement (as specified above) yields track replay gain. If calculated on an album basis, with all tracks concatenated to make one long audio file, the loudness measurement yields album replay gain.&lt;br /&gt;
&lt;br /&gt;
===Replay gain===&lt;br /&gt;
Under some listening conditions, it&#039;s useful to have every track sound equally loud. The problem with a track-by-track approach is that tracks which should be quiet in the context of the album on which they reside will be brought up to the level of all the rest. For casual listening, or in a noisy background, this can be a good thing. For serious listening, it does not respect the intent of the artist or mastering engineer; a tender ballad track will be blasting at the same loudness as a hard rock track on the same album. It&#039;s generally ideal to leave the intentional loudness differences between tracks in place, yet still correct for unmusical and annoying loudness differences between albums. To accomplish this, ReplayGain suggests that two different gain adjustments should be stored as metadata with each sound file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Album replay gain&#039;&#039; represents the ideal listening gain for an entire album. ReplayGain reads the collection of tracks that comprise an album, and calculates a single replay gain for the whole set. This single gain can be used for playback of all tracks of the album. Intentionally quiet tracks then stay appropriately quieter than the rest. It still solves the basic problem (annoying, unwanted level differences between discs) because quiet or loud discs are still adjusted overall&amp;amp;mdash;so the pop CD that&#039;s 20&amp;amp;nbsp;dB louder than the classical CD will be brought into line.&lt;br /&gt;
&lt;br /&gt;
===Peak amplitude===&lt;br /&gt;
Scanning a track or album for the peak amplitude can be a time-consuming process. Therefore, it&#039;s helpful if this single value is stored as metadata. This is used to predict whether the required replay gain adjustment will cause clipping during playback.&lt;br /&gt;
&lt;br /&gt;
The maximum peak amplitude value is stored as a floating point number, where 1.0 represents digital full scale. As with replay gain values, separate peak amplitude values are stored per track and per album.&lt;br /&gt;
&lt;br /&gt;
For uncompressed files simply, scanners store the maximum absolute sample value held in the file on any channel for positive or negative excursion. The single sample value should be converted to a floating-point representation, such that digital full scale is equivalent to a value of 1.0.&lt;br /&gt;
&lt;br /&gt;
Psychoacoustically coded audio, such as MP3, does not exist as a sequence of samples until it is decoded. Psychoacoustic coding of a heavily limited file can lead to sample values larger than digital full scale upon decoding. The coded files must be decoded using a fully compliant decoder that allows peak overflows (i.e. has headroom) and may result in peak amplitude values greater than 1.0.&lt;br /&gt;
&lt;br /&gt;
==Metadata format==&lt;br /&gt;
From the standpoint of metadata storage, each audio file format presents a unique situation. There are three favored schemes defined for storage of ReplayGain metadata: &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; and &#039;&#039;&#039;APEv2&#039;&#039;&#039;. A survey of file formats is listed below with metadata schemes in order of preference for each:&lt;br /&gt;
* .aac (Advanced Audio Coding raw format) &amp;amp;ndash; No metadata support (use .mp4 instead)&lt;br /&gt;
* .aiff, .aif, .aifc (Apple Interchange File Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID3&amp;quot; IFF chunk)&lt;br /&gt;
* .ape, .apl (Monkey&#039;s Audio) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .bwf (Broadcast Wave Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in RIFF chunk)&lt;br /&gt;
* .flac (Free Lossless Audio Codec) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .mp3 (MPEG audio layer 3) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, LAME VBR proposed tag specification&lt;br /&gt;
* .mp4 also .m4a, .m4b, .m4p, m4r (MPEG-4 Part 14) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID32&amp;quot; box)&lt;br /&gt;
* .mpc (Musepack) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .ogg (Ogg Vorbis) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;, same for other Ogg codecs&lt;br /&gt;
* .opus (Ogg Opus) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; available&lt;br /&gt;
** standard {{code|R128_TRACK_GAIN}} and {{code|R128_ALBUM_GAIN}} (MUST adjust for -23 LUFS) comment keys may be preferable (used by {{code|loudgain}})&lt;br /&gt;
* .tta (True Audio) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .asf, .wma (Windows Media audio) - &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; in Extended Content Description Object&lt;br /&gt;
** {{code|loudgain}} instead uses native ASF/WMA attributes (itself a key-value storage) via TagLib, which is more sensible&lt;br /&gt;
* .wav (Windows PCM) &amp;amp;ndash; No metadata support (use .bwf instead)&lt;br /&gt;
** ID3 RIFF chunk possible (used by {{code|loudgain}})&lt;br /&gt;
* .wv (WavePak) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===ID3v2===&lt;br /&gt;
The ID3v2 standard&amp;lt;ref&amp;gt;The ID3v2 format is explained at [http://www.id3.org/ www.id3.org]. The most useful document is the [http://www.id3.org/id3v2.3.0.html ID3v2 v2.3.0 standard]. Although this document has been superseded by v2.4.0, the earlier document is complete (rather than an update), and in indexed HTML form. As such, it represents a better technical introduction to ID3v2.&amp;lt;/ref&amp;gt; defines a &#039;&#039;tag&#039;&#039; which is situated before the data in an MP3 file.&amp;lt;ref&amp;gt;The original ID3 (v1) tags resided at the end of the file, and contained a few fields of information. The ID3v1 tag is not extensible and therefore cannot support ReplayGain metadata.&amp;lt;/ref&amp;gt; ID3 is used primarily with MP3 audio files but means of adapting the system to other file types have been developed.&lt;br /&gt;
&lt;br /&gt;
The ID3v2 tag is divided into &#039;&#039;frames&#039;&#039;. The preferred means of storing ReplayGain metadata is use of &#039;&#039;TXXX&#039;&#039; key/value pair frames. Two other legacy schemes for storing ReplayGain metadata exist: [[ReplayGain legacy metadata formats#ID3v2 RGAD|RGAD]] and [[ReplayGain legacy metadata formats#ID3v2 RVA2|RVA2]]. These formats are documented in the [[ReplayGain legacy metadata formats|appendix]]. Players may choose to look for these formats if metadata in the &#039;&#039;TXXX&#039;&#039; format is not found in the ID3v2 tag. New scanners may write these older formats in addition to the newer (TXXX) ones if they wish to remain backwards compatible with older players.&lt;br /&gt;
&lt;br /&gt;
ReplayGain uses four TXXX frames. The header of a TXXX frame is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Frame ID       $54 58 58 58 (&amp;quot;TXXX&amp;quot;) &lt;br /&gt;
 Size           $xx xx xx xx (size of frame excluding this header)&lt;br /&gt;
 Flags          $40 $00      (discard frame if audio data is altered)&lt;br /&gt;
&lt;br /&gt;
Frame data is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Text encoding  $00          (ISO-8859-1 encoding)&lt;br /&gt;
 Description    &amp;lt;key string&amp;gt; $00&lt;br /&gt;
 Value          &amp;lt;value string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The four frames associated with ReplayGain metadata use the following key/value pairs&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Table 3: Metadata keys and value formatting&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
|-&lt;br /&gt;
|Track replay gain&lt;br /&gt;
|REPLAYGAIN_TRACK_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak track amplitude&lt;br /&gt;
|REPLAYGAIN_TRACK_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|-&lt;br /&gt;
|Album replay gain&lt;br /&gt;
|REPLAYGAIN_ALBUM_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak album amplitude&lt;br /&gt;
|REPLAYGAIN_ALBUM_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Gains are specified textually in decibels. Negative gains (attenuation) are prefixed with a &#039;-&#039;. Positive gains have no prefix. Integral portion of the gain (a) may be one or two numeric (0-9) digits. If there is no integral portion the field is &#039;0&#039;. The decimal portion of the gain (bb) is two numeric digits. Gains are suffixed with a space followed by &#039;dB&#039;.&lt;br /&gt;
&lt;br /&gt;
Peak levels are specified textually as a positive decimal. Peak level is a dimensionless quantity with 1.000000 representing full scale. No suffix is included on peak values. The integer field (c) is typically 1 or 0. Six numeric digits in the decimal field (dddddd) is adequate to accurately represent peak values for 16-bit audio data.&lt;br /&gt;
&lt;br /&gt;
A robust player should be prepared to parse the following variations in either replay gain or peak level metadata:&lt;br /&gt;
*Positive gains with leading &#039;+&#039;&lt;br /&gt;
*More or fewer significant digits than specified in any field&lt;br /&gt;
*Leading zeros or spaces in integer fields&lt;br /&gt;
*Missing or malformed &#039;dB&#039; suffix (e.g. no space between numeric digits and suffix, alternate capitalization)&lt;br /&gt;
*Alternate capitalization of keys&lt;br /&gt;
&lt;br /&gt;
Other formatting errors indicate more severe problems and should result in player ignoring data as if the frame did not exist.&lt;br /&gt;
&lt;br /&gt;
===Vorbis comments===&lt;br /&gt;
A Vorbis comment&amp;lt;ref&amp;gt;[http://www.xiph.org/vorbis/doc/v-comment.html Vorbis comment metadata format]. ReplayGain metadata is documented on the [http://wiki.xiph.org/VorbisComment#Replay_Gain Xiph Wiki].&amp;lt;/ref&amp;gt; uses an ASCII &amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; format. When Vorbis comments are used, the four ReplayGain metadata items are stored as separate comments. The &#039;&#039;keys&#039;&#039; and formatting for &#039;&#039;values&#039;&#039; is the same as specified for ID3v2. Keys and values are required by the Vorbis comment specification to b separated by &#039;=&#039; (equal character).&lt;br /&gt;
&lt;br /&gt;
===APEv2===&lt;br /&gt;
The APEv2 metadata format&amp;lt;ref&amp;gt;[http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification APEv2 Specification at Hydrogen Audio Wiki]&amp;lt;/ref&amp;gt; also organizes data into key/value pairs. Keys are ASCII format. A flags field allows support for several value formats including UTF-8 and binary. Under APEv2, ReplayGain meta data is stored using the same keys and data as ASCII values in the same format as specified for ID3v2.&lt;br /&gt;
&lt;br /&gt;
===De-Facto extensions===&lt;br /&gt;
MusicBrainz Picard and [http://github.com/Moonbase59/loudgain#tags-written-andor-deleted LoudGain] also support the following additional tags, named using the same conventions:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Extension metadata keys&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!alue format&lt;br /&gt;
! Purpose&lt;br /&gt;
|-&lt;br /&gt;
|Track range&lt;br /&gt;
|REPLAYGAIN_TRACK_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|rowspan=2 | Indicates dynamics (R-128 Loudness Range / LRA), may guide pre-amplification&lt;br /&gt;
|-&lt;br /&gt;
|Album range&lt;br /&gt;
|REPLAYGAIN_ALBUM_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Reference loudness&lt;br /&gt;
|REPLAYGAIN_REFERENCE_LOUDNESS&lt;br /&gt;
|[-]a.bb LUFS&lt;br /&gt;
| Use alternative reference levels; change ref levels without re-scanning the file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Player requirements==&lt;br /&gt;
[[File:RG_Player_control.gif‎|frame|Figure 8: Example ReplayGain control panel]]&lt;br /&gt;
&lt;br /&gt;
Loudness normalization, pre-amplification and clipping prevention are the operations performed by a ReplayGain player.&lt;br /&gt;
&lt;br /&gt;
===Loudness normalization===&lt;br /&gt;
To properly normalize loudness, the player needs to determine if the user desires Track style level normalization (all tracks same loudness), or Album style level normalization (all albums same loudness, tracks of an album played at the same relative level as on the original release). This option should be selectable in the ReplayGain control panel (Figure 8). The player reads the corresponding gain metadata value from the file and scales the audio data as appropriate. Scaling the audio data simply means multiplying each sample value by a constant value. This constant is given by:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;10^\frac{gain}{20}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, in words, replay gain divided by 20 all raised to the power of ten.&amp;lt;ref&amp;gt;After any such operation, it&#039;s a good idea to dither the result. If this calculation and the pre-amp are implemented separately, then dither should only be added to the final result, just before the result is truncated back to 16 bits, or 24, or 8, as limited by the soundcard&amp;amp;mdash;not the file (i.e. after ReplayGain adjustment, an 8-bit file should be sent to a 16-bit soundcard at 16-bits).&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the file only contains one of the replay gain adjustments (e.g. Album) but the user has requested the other (Track), then the player should use the one that is available (in this case, Album). If neither (Track or Album) gain metadata is available, then the player needs to choose a suitable default gain. Potential choices include unity gain (0 dB) or an average of gains from other tracks in the album or playlist.&lt;br /&gt;
&lt;br /&gt;
===Pre-amplification===&lt;br /&gt;
Although the calibration level used by ReplayGain suggests that the average level of an audio track should be 14&amp;amp;nbsp;dB below full scale, some pop music is dynamically compressed to peak at 0&amp;amp;nbsp;dB and average around 3&amp;amp;nbsp;dB below full scale. This means that, when the replay gain is applied, the level of such tracks will be reduced by 11&amp;amp;nbsp;dB! If users are listening to a mixture of highly compressed and more dynamic tracks, ReplayGain will make the listening experience more pleasurable by bringing the level of the compressed tracks down into line with that of the others. However, if users are only listening to highly compressed music, then they may complain that all their files are now too quiet.&amp;lt;ref&amp;gt;This problem can be especially noticeable on portable players with limited output or gain.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To address this problem, a pre-amp feature should be incorporated into the player. A user-supplied pre-amp setting is an adjustment to the calculated replay gain. It should default to perform no adjustment. This means that casual users will experience a moderate reduction in the loudness of their compressed pop music. Less-compressed material can generally be played at the same loudness without clipping. Normalization of more dynamic material may cause clipping or invoke the [[ReplayGain 2.0 specification#Clipping prevention|clipping prevention]] mechanism (see below). Power users and audiophiles can reduce the pre-amp gain to enjoy the full dynamic range of all of their music.&lt;br /&gt;
&lt;br /&gt;
If enabled, the player should read the user selected pre-amp gain, and scale the audio signal by the appropriate amount. For example, a +6&amp;amp;nbsp;dB gain requires a scale of 10&amp;lt;sup&amp;gt;6/20&amp;lt;/sup&amp;gt;, which is approximately 2. The replay gain and pre-amp scale factors can be combined&amp;lt;ref&amp;gt;Scale factors in  Decibel units are added to produce the same effect as multiplying scale factors in linear units.&amp;lt;/ref&amp;gt; for simplicity and ease of processing.&lt;br /&gt;
&lt;br /&gt;
===Clipping prevention===&lt;br /&gt;
ReplayGain&#039;s suggestion of a -14&amp;amp;nbsp;dB average playback level leaves sufficient headroom for the bulk of modern recordings. Nevertheless, there exists the possibility that after application of replay gain and pre-amp adjustment, a track may exceed full scale during its dynamic peaks. Without intervention, this will result in clipping, a severe form of distortion. Factors introducing the possibility of clipping include:&lt;br /&gt;
&lt;br /&gt;
# Recordings from certain genres and certain periods in the history of commercial recordings require additional headroom. Although these recordings can be accommodated through a downwards adjustment of the pre-amp setting, it may be difficult to determine a safe adjustment and it may be undesirable to lower average level to accommodate the rare track which requires it. &lt;br /&gt;
# ReplayGain will make loud dynamically compressed tracks quieter, and quiet dynamically uncompressed tracks louder. The average levels will then be similar, but the quiet tracks will actually have louder peaks. If the user pushes the pre-amp gain upwards the peaks of the (originally) quieter tracks will be pushed well over full scale.&lt;br /&gt;
# In coded audio (e.g. MP3 files) a file that was hard-limited to digital full scale before encoding will often be pushed over the limit by the psychoacoustic compression. A decoder with headroom can recover the over full scale signal by reducing the gain.&lt;br /&gt;
&lt;br /&gt;
ReplayGain suggests two possible solutions which prevent clipping in these situations. A player should support one or both of these.&lt;br /&gt;
&lt;br /&gt;
====Audio limiting====&lt;br /&gt;
In situation 2 above, the user clearly wants all the music to sound very loud. To give them their wish, any signal which would peak above digital full scale should be hard limited at just below digital full scale. This is also useful at lower pre-amp gains, where it allows the average level of classical music to be raised to that of pop music, without distorting. The exact type of nature limiting or compression an implementation choice for the player.&amp;lt;ref&amp;gt;Something like the Hard Limiter found in Cool Edit Pro (Syntrillium) would be appropriate for pop music at least.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reduced gain====&lt;br /&gt;
The audiophile user will not want any compression or limiting on the signal. In this case the only option is to automatically and temporarily reduce the pre-amp gain below the user-selected setting for tracks where clipping would otherwise occur. Clipping can be predicted by examining the peak level of the track or album being played.&lt;br /&gt;
&lt;br /&gt;
The player must read the peak amplitude metadata. If peak level metadata is unavailable, the player should assume a peak level of 1.0. If the peak level for both track and album is stored as metadata in the file, it is possible to calculate if, following the replay gain adjustment and pre-amp gain, the signal will clip at some point. If it won&#039;t, then no further action is necessary. &lt;br /&gt;
&lt;br /&gt;
An overall scale factor for loudness normalization taking into account replay gain, pre-amp setting and clipping prevention through gain reduction is given below.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;min( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{peak amplitude} )&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;!-- use this when tex is fixed: :&amp;lt;math&amp;gt;\operatorname{min}( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{L_{\mathrm{peak}}} )&amp;lt;/math&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hardware implementation===&lt;br /&gt;
The above three steps are appropriate to software players operating on the digital signal in order to scale it. However, it is possible to send the digital signal to the DAC without level correction, and to place an attenuator in the analogue signal path. The attenuator can then be driven by the Replay Gain value. The clipping problem can be addressed by providing adequate headroom in the analog circuitry. Bit transparency and maximum signal to noise ratio is maintained in the digital signal and DAC process.&amp;lt;ref&amp;gt;A system using today&#039;s 24-bit converters is unlikely to appreciate any overall gain in system performance with such an arrangement. A digitally-controlled analog gain element typically introduces significant noise and distortion.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The [http://replaygain.hydrogenaudio.org/proposal original ReplayGain proposal] (an [http://replay.waybackmachine.org/20090306202649/http://www.replaygain.org/ archive] is also available) was developed by David Robinson and was published 10 July 2001. Additional updates were published by David Robinson through 10 October 2001.&lt;br /&gt;
&lt;br /&gt;
The following acknowledgement was included with the original proposal, &amp;quot;The algorithm to calculate an ideal replay gain has grown from my research into human hearing, with many additional ideas drawn from the work of E. Zwicker, and Brian Moore. I am currently completing my PhD at the University of Essex, and have been funded by the EPSRC.&amp;quot; Additionally David Robinson credited Glen Sawyer (Snelg) and Jim Casaburi (Walrus) for software contributions and Bob Katz and Matt Ashland for ideas.&lt;br /&gt;
&lt;br /&gt;
This updated ReplayGain specification reflecting current and recommended practice was prepared by Kevin Gross in 2011.&lt;br /&gt;
&lt;br /&gt;
==Contact==&lt;br /&gt;
For ReplayGain-related questions or contributions, please post in the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio] section of the Hydrogen Audio forums.&lt;br /&gt;
 &lt;br /&gt;
==Appendix==&lt;br /&gt;
# [[ReplayGain legacy metadata formats]]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38786</id>
		<title>Revised ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38786"/>
		<updated>2026-01-22T19:20:25Z</updated>

		<summary type="html">&lt;p&gt;Skamp: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;DISPLAYTITLE&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;4&amp;quot;&amp;gt;&#039;&#039;This is a proposed update to the [[ReplayGain 1.0 specification|original ReplayGain specification]]. This proposal is currently &#039;&#039;&#039;Under Construction&#039;&#039;&#039;. Please discuss this proposal on the [[Talk:ReplayGain 2.0 specification|discussion page]] or the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio forum].&#039;&#039; --[[User:Notat|Notat]] 23:42, 8 October 2012 (CEST)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although music is encoded to a digital format with a clearly defined maximum peak amplitude, and although most recordings are normalized to utilize this peak amplitude, not all recordings sound equally loud. This is because once this peak amplitude is reached, perceived loudness can be further increased through signal-processing techniques such as dynamic range compression and equalization.&amp;lt;ref&amp;gt;Source: Wikipedia - [http://en.wikipedia.org/wiki/Loudness_war Loudness war]&amp;lt;/ref&amp;gt; Therefore, the loudness of a given album has more to do with the year of issue or the whim of the producer than the intended emotional effect. Because of this, a random play through a music collection can have one leaping for the volume control every other track.&lt;br /&gt;
&lt;br /&gt;
There is a solution to this annoyance: within each audio file, information can be stored about what volume change would be required to play each track or album at a standard loudness, and players can use this &amp;quot;replay gain&amp;quot; information to automatically nudge the volume up or down as required.&lt;br /&gt;
&lt;br /&gt;
The ReplayGain specification is a standard which defines an appropriate reference level, explains a way of calculating and representing the ideal replay gain for a given track or album, and provides guidance for players to make the required volume adjustment during playback. The standard also specifies a means to prevent clipping when the calculated replay gain exceeds the limits of digital audio, and it describes how the replay gain information is stored within audio files.&lt;br /&gt;
&lt;br /&gt;
==Loudness measurement==&lt;br /&gt;
Loudness is a subjective measure of the intensity of sound. The correlation of perceived loudness to sound pressure level is determined by the peculiarities of the auditory system.&lt;br /&gt;
&lt;br /&gt;
The original [http://wiki.hydrogenaudio.org/index.php?title=Replaygain ReplayGain 1.0 specification] described a loudness measurement system which included a weighting filter, root mean square (RMS) measurement and statistical processing that model human perception of loudness in both the frequency and time domains.&lt;br /&gt;
&lt;br /&gt;
Since original ReplayGain proposal in 2001, the science, practice and standards for loudness normalization have been advanced significantly. The current industry standard approach to loudness measurement is described by the International Telecommunications Union&amp;lt;ref&amp;gt;http://www.itu.int/en/Pages/default.aspx&amp;lt;/ref&amp;gt; (ITU) as BS.1770. The most recent version of this standard is known as ITU BS.1770-5&amp;lt;ref&amp;gt;https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en&amp;lt;/ref&amp;gt; and was published in December 2023. The ITU work is freely available and is not believed to be encumbered by any patent issues. The ITU BS.1770-2 standard has been adopted in the United States by the [http://www.atsc.org ATSC] as [http://www.atsc.org/cms/standards/a_85-2011a.pdf A/85] and in Europe by the [http://www.ebu.ch European Broadcast Union] as [http://tech.ebu.ch/docs/tech/tech3343.pdf EBU R-128] for broadcast audio. &lt;br /&gt;
&lt;br /&gt;
BS.1770 uses a &amp;quot;K-weighted&amp;quot; RMS measurement. This weighting function is significantly less complex than the inverted Fletcher-Munson weighting used by the original ReplayGain algorithm. A gating function designed measure the loudness of foreground components in the audio program. The gate in BS.1770 performs a similar function as the statistical processing in the original RG specification. &lt;br /&gt;
&lt;br /&gt;
The computation required for BS.1770 loudness measurement is reduced compared to the original RG technique. Nevertheless, BS.1770 has been shown in several academic studies to be equally or more effective than the RG algorithm in modeling human loudness perception on music program as well as other material such as podcasts, television programs and movies.&amp;lt;ref&amp;gt;Paul Nygren. [http://www.speech.kth.se/prod/publications/files/3319.pdf Achieving equal loudness between audio files]. KTH Royal Institute of Technology&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Martin Wolters; Harald Mundt; Jeffrey Riedmiller (May 2010). [http://www.aes.org/e-lib/browse.cfm?elib=15341 Loudness Normalization In The Age Of Portable Media Players]. Audio Engineering Society.&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Esben Skovenborg; Søren H. Nielsen (October 2004). [http://web.archive.org/web/20120208024743/http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf Evaluation of Different Loudness Models with Music and Speech Material]. Audio Engineering Society. Archived from [http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf the original] on 2012-02-08.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recent RG implementations use BS.1770 for loudness measurement. It is expected the ITU standard will evolve over time to meet the needs of broadcasters and governments. It is the intent of the ReplayGain community that RG follow any future backwards-compatible improvements to loudness measurement using the BS.1770 standard.&lt;br /&gt;
&lt;br /&gt;
==Reference level==&lt;br /&gt;
&lt;br /&gt;
Classic ReplayGain is calibrated to a pink noise reference signal with a RMS level 14&amp;amp;nbsp;dB below a full-scale sinusoid. This reference signal is used to establish a reference level. ReplayGain will apply no gain or attenuation to the reference signal or any program material which has the same loudness measurements as the reference signal.&lt;br /&gt;
&lt;br /&gt;
BS-1770 defines a loudness scale for program material. The units of BS.1770 loudness measurements are in Loudness Units [relative to] Full Scale (LUFS). LUFS can be treated like decibels.&lt;br /&gt;
&lt;br /&gt;
In order to maintain backwards compatibility with classic RG, newer RG uses a -18&amp;amp;nbsp;LUFS reference, which based on lots of music, can give similar loudness compared to classic RG.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
The loudness measurement of the RG1 reference signal is NOT -18 LUFS; &lt;br /&gt;
The original -20 RMS dBFS one is -20.36 LUFS, and the -14 RMS dbFS one would be -15.36 LUFS.&lt;br /&gt;
&lt;br /&gt;
We picked -18 here is the result of analyzing actual music. &lt;br /&gt;
&lt;br /&gt;
Check what 2Bdecided said here: https://hydrogenaud.io/index.php/topic,109076.msg899298.html#msg899298&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Gain calculation==&lt;br /&gt;
RG achieves loudness compensated playback by applying gain (or attenuation) dependent on the measured loudness of the audio file relative to the established reference level. The gain is calculated as follows:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG=L_{r}-L&amp;lt;/math&amp;gt;&lt;br /&gt;
Where:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG&amp;lt;/math&amp;gt; is the replay gain adjustment in decibels,&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{r}&amp;lt;/math&amp;gt; is the -18&amp;amp;nbsp;LUFS reference level&lt;br /&gt;
:&amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; is the measured loudness of the audio file in LUFS.&lt;br /&gt;
&lt;br /&gt;
Gain is positive if the loudness of the audio file is lower than the reference level. The gain is negative (representing an attenuation) if the loudness of the audio file is higher than the reference level. The gain is stored as metadata with the audio file as described below and is used by players to adjust output volume of tracks as they are played as described in [[ReplayGain 2.0 specification#Player requirements|Player requirements]] below.&lt;br /&gt;
&lt;br /&gt;
==Metadata==&lt;br /&gt;
For ReplayGain to do its work during playback, four values must be stored as metadata&amp;lt;ref&amp;gt;Metadata is &amp;quot;data about data.&amp;quot; For example, the ID3 &#039;&#039;de facto&#039;&#039; standard provides a way to store artist, title, album title, track number, and other metadata in data blocks called &amp;quot;tags&amp;quot; immediately before or after the audio data in an MP3 file. Other metadata storage/tagging standards and conventions exist for other audio file formats.&amp;lt;/ref&amp;gt; with or within the audio file:&lt;br /&gt;
# Peak track amplitude&lt;br /&gt;
# Peak album amplitude&lt;br /&gt;
# Track replay gain&lt;br /&gt;
# Album replay gain&lt;br /&gt;
&lt;br /&gt;
If calculated for an individual track, the loudness measurement (as specified above) yields track replay gain. If calculated on an album basis, with all tracks concatenated to make one long audio file, the loudness measurement yields album replay gain.&lt;br /&gt;
&lt;br /&gt;
===Replay gain===&lt;br /&gt;
Under some listening conditions, it&#039;s useful to have every track sound equally loud. The problem with a track-by-track approach is that tracks which should be quiet in the context of the album on which they reside will be brought up to the level of all the rest. For casual listening, or in a noisy background, this can be a good thing. For serious listening, it does not respect the intent of the artist or mastering engineer; a tender ballad track will be blasting at the same loudness as a hard rock track on the same album. It&#039;s generally ideal to leave the intentional loudness differences between tracks in place, yet still correct for unmusical and annoying loudness differences between albums. To accomplish this, ReplayGain suggests that two different gain adjustments should be stored as metadata with each sound file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Album replay gain&#039;&#039; represents the ideal listening gain for an entire album. ReplayGain reads the collection of tracks that comprise an album, and calculates a single replay gain for the whole set. This single gain can be used for playback of all tracks of the album. Intentionally quiet tracks then stay appropriately quieter than the rest. It still solves the basic problem (annoying, unwanted level differences between discs) because quiet or loud discs are still adjusted overall&amp;amp;mdash;so the pop CD that&#039;s 20&amp;amp;nbsp;dB louder than the classical CD will be brought into line.&lt;br /&gt;
&lt;br /&gt;
===Peak amplitude===&lt;br /&gt;
Scanning a track or album for the peak amplitude can be a time-consuming process. Therefore, it&#039;s helpful if this single value is stored as metadata. This is used to predict whether the required replay gain adjustment will cause clipping during playback.&lt;br /&gt;
&lt;br /&gt;
The maximum peak amplitude value is stored as a floating point number, where 1.0 represents digital full scale. As with replay gain values, separate peak amplitude values are stored per track and per album.&lt;br /&gt;
&lt;br /&gt;
For uncompressed files simply, scanners store the maximum absolute sample value held in the file on any channel for positive or negative excursion. The single sample value should be converted to a floating-point representation, such that digital full scale is equivalent to a value of 1.0.&lt;br /&gt;
&lt;br /&gt;
Psychoacoustically coded audio, such as MP3, does not exist as a sequence of samples until it is decoded. Psychoacoustic coding of a heavily limited file can lead to sample values larger than digital full scale upon decoding. The coded files must be decoded using a fully compliant decoder that allows peak overflows (i.e. has headroom) and may result in peak amplitude values greater than 1.0.&lt;br /&gt;
&lt;br /&gt;
==Metadata format==&lt;br /&gt;
From the standpoint of metadata storage, each audio file format presents a unique situation. There are three favored schemes defined for storage of ReplayGain metadata: &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; and &#039;&#039;&#039;APEv2&#039;&#039;&#039;. A survey of file formats is listed below with metadata schemes in order of preference for each:&lt;br /&gt;
* .aac (Advanced Audio Coding raw format) &amp;amp;ndash; No metadata support (use .mp4 instead)&lt;br /&gt;
* .aiff, .aif, .aifc (Apple Interchange File Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID3&amp;quot; IFF chunk)&lt;br /&gt;
* .ape, .apl (Monkey&#039;s Audio) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .bwf (Broadcast Wave Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in RIFF chunk)&lt;br /&gt;
* .flac (Free Lossless Audio Codec) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .mp3 (MPEG audio layer 3) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, LAME VBR proposed tag specification&lt;br /&gt;
* .mp4 also .m4a, .m4b, .m4p, m4r (MPEG-4 Part 14) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID32&amp;quot; box)&lt;br /&gt;
* .mpc (Musepack) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .ogg (Ogg Vorbis) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;, same for other Ogg codecs&lt;br /&gt;
* .opus (Ogg Opus) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; available&lt;br /&gt;
** standard {{code|R128_TRACK_GAIN}} and {{code|R128_ALBUM_GAIN}} (MUST adjust for -23 LUFS) comment keys may be preferable (used by {{code|loudgain}})&lt;br /&gt;
* .tta (True Audio) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .asf, .wma (Windows Media audio) - &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; in Extended Content Description Object&lt;br /&gt;
** {{code|loudgain}} instead uses native ASF/WMA attributes (itself a key-value storage) via TagLib, which is more sensible&lt;br /&gt;
* .wav (Windows PCM) &amp;amp;ndash; No metadata support (use .bwf instead)&lt;br /&gt;
** ID3 RIFF chunk possible (used by {{code|loudgain}})&lt;br /&gt;
* .wv (WavePak) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===ID3v2===&lt;br /&gt;
The ID3v2 standard&amp;lt;ref&amp;gt;The ID3v2 format is explained at [http://www.id3.org/ www.id3.org]. The most useful document is the [http://www.id3.org/id3v2.3.0.html ID3v2 v2.3.0 standard]. Although this document has been superseded by v2.4.0, the earlier document is complete (rather than an update), and in indexed HTML form. As such, it represents a better technical introduction to ID3v2.&amp;lt;/ref&amp;gt; defines a &#039;&#039;tag&#039;&#039; which is situated before the data in an MP3 file.&amp;lt;ref&amp;gt;The original ID3 (v1) tags resided at the end of the file, and contained a few fields of information. The ID3v1 tag is not extensible and therefore cannot support ReplayGain metadata.&amp;lt;/ref&amp;gt; ID3 is used primarily with MP3 audio files but means of adapting the system to other file types have been developed.&lt;br /&gt;
&lt;br /&gt;
The ID3v2 tag is divided into &#039;&#039;frames&#039;&#039;. The preferred means of storing ReplayGain metadata is use of &#039;&#039;TXXX&#039;&#039; key/value pair frames. Two other legacy schemes for storing ReplayGain metadata exist: [[ReplayGain legacy metadata formats#ID3v2 RGAD|RGAD]] and [[ReplayGain legacy metadata formats#ID3v2 RVA2|RVA2]]. These formats are documented in the [[ReplayGain legacy metadata formats|appendix]]. Players may choose to look for these formats if metadata in the &#039;&#039;TXXX&#039;&#039; format is not found in the ID3v2 tag. New scanners may write these older formats in addition to the newer (TXXX) ones if they wish to remain backwards compatible with older players.&lt;br /&gt;
&lt;br /&gt;
ReplayGain uses four TXXX frames. The header of a TXXX frame is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Frame ID       $54 58 58 58 (&amp;quot;TXXX&amp;quot;) &lt;br /&gt;
 Size           $xx xx xx xx (size of frame excluding this header)&lt;br /&gt;
 Flags          $40 $00      (discard frame if audio data is altered)&lt;br /&gt;
&lt;br /&gt;
Frame data is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Text encoding  $00          (ISO-8859-1 encoding)&lt;br /&gt;
 Description    &amp;lt;key string&amp;gt; $00&lt;br /&gt;
 Value          &amp;lt;value string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The four frames associated with ReplayGain metadata use the following key/value pairs&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Table 3: Metadata keys and value formatting&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
|-&lt;br /&gt;
|Track replay gain&lt;br /&gt;
|REPLAYGAIN_TRACK_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak track amplitude&lt;br /&gt;
|REPLAYGAIN_TRACK_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|-&lt;br /&gt;
|Album replay gain&lt;br /&gt;
|REPLAYGAIN_ALBUM_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak album amplitude&lt;br /&gt;
|REPLAYGAIN_ALBUM_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Gains are specified textually in decibels. Negative gains (attenuation) are prefixed with a &#039;-&#039;. Positive gains have no prefix. Integral portion of the gain (a) may be one or two numeric (0-9) digits. If there is no integral portion the field is &#039;0&#039;. The decimal portion of the gain (bb) is two numeric digits. Gains are suffixed with a space followed by &#039;dB&#039;.&lt;br /&gt;
&lt;br /&gt;
Peak levels are specified textually as a positive decimal. Peak level is a dimensionless quantity with 1.000000 representing full scale. No suffix is included on peak values. The integer field (c) is typically 1 or 0. Six numeric digits in the decimal field (dddddd) is adequate to accurately represent peak values for 16-bit audio data.&lt;br /&gt;
&lt;br /&gt;
A robust player should be prepared to parse the following variations in either replay gain or peak level metadata:&lt;br /&gt;
*Positive gains with leading &#039;+&#039;&lt;br /&gt;
*More or fewer significant digits than specified in any field&lt;br /&gt;
*Leading zeros or spaces in integer fields&lt;br /&gt;
*Missing or malformed &#039;dB&#039; suffix (e.g. no space between numeric digits and suffix, alternate capitalization)&lt;br /&gt;
*Alternate capitalization of keys&lt;br /&gt;
&lt;br /&gt;
Other formatting errors indicate more severe problems and should result in player ignoring data as if the frame did not exist.&lt;br /&gt;
&lt;br /&gt;
===Vorbis comments===&lt;br /&gt;
A Vorbis comment&amp;lt;ref&amp;gt;[http://www.xiph.org/vorbis/doc/v-comment.html Vorbis comment metadata format]. ReplayGain metadata is documented on the [http://wiki.xiph.org/VorbisComment#Replay_Gain Xiph Wiki].&amp;lt;/ref&amp;gt; uses an ASCII &amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; format. When Vorbis comments are used, the four ReplayGain metadata items are stored as separate comments. The &#039;&#039;keys&#039;&#039; and formatting for &#039;&#039;values&#039;&#039; is the same as specified for ID3v2. Keys and values are required by the Vorbis comment specification to b separated by &#039;=&#039; (equal character).&lt;br /&gt;
&lt;br /&gt;
===APEv2===&lt;br /&gt;
The APEv2 metadata format&amp;lt;ref&amp;gt;[http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification APEv2 Specification at Hydrogen Audio Wiki]&amp;lt;/ref&amp;gt; also organizes data into key/value pairs. Keys are ASCII format. A flags field allows support for several value formats including UTF-8 and binary. Under APEv2, ReplayGain meta data is stored using the same keys and data as ASCII values in the same format as specified for ID3v2.&lt;br /&gt;
&lt;br /&gt;
===De-Facto extensions===&lt;br /&gt;
MusicBrainz Picard and [http://github.com/Moonbase59/loudgain#tags-written-andor-deleted LoudGain] also support the following additional tags, named using the same conventions:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Extension metadata keys&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!alue format&lt;br /&gt;
! Purpose&lt;br /&gt;
|-&lt;br /&gt;
|Track range&lt;br /&gt;
|REPLAYGAIN_TRACK_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|rowspan=2 | Indicates dynamics (R-128 Loudness Range / LRA), may guide pre-amplification&lt;br /&gt;
|-&lt;br /&gt;
|Album range&lt;br /&gt;
|REPLAYGAIN_ALBUM_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Reference loudness&lt;br /&gt;
|REPLAYGAIN_REFERENCE_LOUDNESS&lt;br /&gt;
|[-]a.bb LUFS&lt;br /&gt;
| Use alternative reference levels; change ref levels without re-scanning the file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Player requirements==&lt;br /&gt;
[[File:RG_Player_control.gif‎|frame|Figure 8: Example ReplayGain control panel]]&lt;br /&gt;
&lt;br /&gt;
Loudness normalization, pre-amplification and clipping prevention are the operations performed by a ReplayGain player.&lt;br /&gt;
&lt;br /&gt;
===Loudness normalization===&lt;br /&gt;
To properly normalize loudness, the player needs to determine if the user desires Track style level normalization (all tracks same loudness), or Album style level normalization (all albums same loudness, tracks of an album played at the same relative level as on the original release). This option should be selectable in the ReplayGain control panel (Figure 8). The player reads the corresponding gain metadata value from the file and scales the audio data as appropriate. Scaling the audio data simply means multiplying each sample value by a constant value. This constant is given by:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;10^\frac{gain}{20}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, in words, replay gain divided by 20 all raised to the power of ten.&amp;lt;ref&amp;gt;After any such operation, it&#039;s a good idea to dither the result. If this calculation and the pre-amp are implemented separately, then dither should only be added to the final result, just before the result is truncated back to 16 bits, or 24, or 8, as limited by the soundcard&amp;amp;mdash;not the file (i.e. after ReplayGain adjustment, an 8-bit file should be sent to a 16-bit soundcard at 16-bits).&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the file only contains one of the replay gain adjustments (e.g. Album) but the user has requested the other (Track), then the player should use the one that is available (in this case, Album). If neither (Track or Album) gain metadata is available, then the player needs to choose a suitable default gain. Potential choices include unity gain (0 dB) or an average of gains from other tracks in the album or playlist.&lt;br /&gt;
&lt;br /&gt;
===Pre-amplification===&lt;br /&gt;
Although the calibration level used by ReplayGain suggests that the average level of an audio track should be 14&amp;amp;nbsp;dB below full scale, some pop music is dynamically compressed to peak at 0&amp;amp;nbsp;dB and average around 3&amp;amp;nbsp;dB below full scale. This means that, when the replay gain is applied, the level of such tracks will be reduced by 11&amp;amp;nbsp;dB! If users are listening to a mixture of highly compressed and more dynamic tracks, ReplayGain will make the listening experience more pleasurable by bringing the level of the compressed tracks down into line with that of the others. However, if users are only listening to highly compressed music, then they may complain that all their files are now too quiet.&amp;lt;ref&amp;gt;This problem can be especially noticeable on portable players with limited output or gain.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To address this problem, a pre-amp feature should be incorporated into the player. A user-supplied pre-amp setting is an adjustment to the calculated replay gain. It should default to perform no adjustment. This means that casual users will experience a moderate reduction in the loudness of their compressed pop music. Less-compressed material can generally be played at the same loudness without clipping. Normalization of more dynamic material may cause clipping or invoke the [[ReplayGain 2.0 specification#Clipping prevention|clipping prevention]] mechanism (see below). Power users and audiophiles can reduce the pre-amp gain to enjoy the full dynamic range of all of their music.&lt;br /&gt;
&lt;br /&gt;
If enabled, the player should read the user selected pre-amp gain, and scale the audio signal by the appropriate amount. For example, a +6&amp;amp;nbsp;dB gain requires a scale of 10&amp;lt;sup&amp;gt;6/20&amp;lt;/sup&amp;gt;, which is approximately 2. The replay gain and pre-amp scale factors can be combined&amp;lt;ref&amp;gt;Scale factors in  Decibel units are added to produce the same effect as multiplying scale factors in linear units.&amp;lt;/ref&amp;gt; for simplicity and ease of processing.&lt;br /&gt;
&lt;br /&gt;
===Clipping prevention===&lt;br /&gt;
ReplayGain&#039;s suggestion of a -14&amp;amp;nbsp;dB average playback level leaves sufficient headroom for the bulk of modern recordings. Nevertheless, there exists the possibility that after application of replay gain and pre-amp adjustment, a track may exceed full scale during its dynamic peaks. Without intervention, this will result in clipping, a severe form of distortion. Factors introducing the possibility of clipping include:&lt;br /&gt;
&lt;br /&gt;
# Recordings from certain genres and certain periods in the history of commercial recordings require additional headroom. Although these recordings can be accommodated through a downwards adjustment of the pre-amp setting, it may be difficult to determine a safe adjustment and it may be undesirable to lower average level to accommodate the rare track which requires it. &lt;br /&gt;
# ReplayGain will make loud dynamically compressed tracks quieter, and quiet dynamically uncompressed tracks louder. The average levels will then be similar, but the quiet tracks will actually have louder peaks. If the user pushes the pre-amp gain upwards the peaks of the (originally) quieter tracks will be pushed well over full scale.&lt;br /&gt;
# In coded audio (e.g. MP3 files) a file that was hard-limited to digital full scale before encoding will often be pushed over the limit by the psychoacoustic compression. A decoder with headroom can recover the over full scale signal by reducing the gain.&lt;br /&gt;
&lt;br /&gt;
ReplayGain suggests two possible solutions which prevent clipping in these situations. A player should support one or both of these.&lt;br /&gt;
&lt;br /&gt;
====Audio limiting====&lt;br /&gt;
In situation 2 above, the user clearly wants all the music to sound very loud. To give them their wish, any signal which would peak above digital full scale should be hard limited at just below digital full scale. This is also useful at lower pre-amp gains, where it allows the average level of classical music to be raised to that of pop music, without distorting. The exact type of nature limiting or compression an implementation choice for the player.&amp;lt;ref&amp;gt;Something like the Hard Limiter found in Cool Edit Pro (Syntrillium) would be appropriate for pop music at least.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reduced gain====&lt;br /&gt;
The audiophile user will not want any compression or limiting on the signal. In this case the only option is to automatically and temporarily reduce the pre-amp gain below the user-selected setting for tracks where clipping would otherwise occur. Clipping can be predicted by examining the peak level of the track or album being played.&lt;br /&gt;
&lt;br /&gt;
The player must read the peak amplitude metadata. If peak level metadata is unavailable, the player should assume a peak level of 1.0. If the peak level for both track and album is stored as metadata in the file, it is possible to calculate if, following the replay gain adjustment and pre-amp gain, the signal will clip at some point. If it won&#039;t, then no further action is necessary. &lt;br /&gt;
&lt;br /&gt;
An overall scale factor for loudness normalization taking into account replay gain, pre-amp setting and clipping prevention through gain reduction is given below.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;min( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{peak amplitude} )&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;!-- use this when tex is fixed: :&amp;lt;math&amp;gt;\operatorname{min}( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{L_{\mathrm{peak}}} )&amp;lt;/math&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hardware implementation===&lt;br /&gt;
The above three steps are appropriate to software players operating on the digital signal in order to scale it. However, it is possible to send the digital signal to the DAC without level correction, and to place an attenuator in the analogue signal path. The attenuator can then be driven by the Replay Gain value. The clipping problem can be addressed by providing adequate headroom in the analog circuitry. Bit transparency and maximum signal to noise ratio is maintained in the digital signal and DAC process.&amp;lt;ref&amp;gt;A system using today&#039;s 24-bit converters is unlikely to appreciate any overall gain in system performance with such an arrangement. A digitally-controlled analog gain element typically introduces significant noise and distortion.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The [http://replaygain.hydrogenaudio.org/proposal original ReplayGain proposal] (an [http://replay.waybackmachine.org/20090306202649/http://www.replaygain.org/ archive] is also available) was developed by David Robinson and was published 10 July 2001. Additional updates were published by David Robinson through 10 October 2001.&lt;br /&gt;
&lt;br /&gt;
The following acknowledgement was included with the original proposal, &amp;quot;The algorithm to calculate an ideal replay gain has grown from my research into human hearing, with many additional ideas drawn from the work of E. Zwicker, and Brian Moore. I am currently completing my PhD at the University of Essex, and have been funded by the EPSRC.&amp;quot; Additionally David Robinson credited Glen Sawyer (Snelg) and Jim Casaburi (Walrus) for software contributions and Bob Katz and Matt Ashland for ideas.&lt;br /&gt;
&lt;br /&gt;
This updated ReplayGain specification reflecting current and recommended practice was prepared by Kevin Gross in 2011.&lt;br /&gt;
&lt;br /&gt;
==Contact==&lt;br /&gt;
For ReplayGain-related questions or contributions, please post in the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio] section of the Hydrogen Audio forums.&lt;br /&gt;
 &lt;br /&gt;
==Appendix==&lt;br /&gt;
# [[ReplayGain legacy metadata formats]]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38785</id>
		<title>Revised ReplayGain specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=Revised_ReplayGain_specification&amp;diff=38785"/>
		<updated>2026-01-22T19:18:11Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Clarified the confusion between ReplayGain having two different versions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;DISPLAYTITLE&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;4&amp;quot;&amp;gt;&#039;&#039;This is a proposed update to the [[ReplayGain 1.0 specification]]. This proposal is currently &#039;&#039;&#039;Under Construction&#039;&#039;&#039;. Please discuss this proposal on the [[Talk:ReplayGain 2.0 specification|discussion page]] or the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio forum].&#039;&#039; --[[User:Notat|Notat]] 23:42, 8 October 2012 (CEST)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although music is encoded to a digital format with a clearly defined maximum peak amplitude, and although most recordings are normalized to utilize this peak amplitude, not all recordings sound equally loud. This is because once this peak amplitude is reached, perceived loudness can be further increased through signal-processing techniques such as dynamic range compression and equalization.&amp;lt;ref&amp;gt;Source: Wikipedia - [http://en.wikipedia.org/wiki/Loudness_war Loudness war]&amp;lt;/ref&amp;gt; Therefore, the loudness of a given album has more to do with the year of issue or the whim of the producer than the intended emotional effect. Because of this, a random play through a music collection can have one leaping for the volume control every other track.&lt;br /&gt;
&lt;br /&gt;
There is a solution to this annoyance: within each audio file, information can be stored about what volume change would be required to play each track or album at a standard loudness, and players can use this &amp;quot;replay gain&amp;quot; information to automatically nudge the volume up or down as required.&lt;br /&gt;
&lt;br /&gt;
The ReplayGain specification is a standard which defines an appropriate reference level, explains a way of calculating and representing the ideal replay gain for a given track or album, and provides guidance for players to make the required volume adjustment during playback. The standard also specifies a means to prevent clipping when the calculated replay gain exceeds the limits of digital audio, and it describes how the replay gain information is stored within audio files.&lt;br /&gt;
&lt;br /&gt;
==Loudness measurement==&lt;br /&gt;
Loudness is a subjective measure of the intensity of sound. The correlation of perceived loudness to sound pressure level is determined by the peculiarities of the auditory system.&lt;br /&gt;
&lt;br /&gt;
The original [http://wiki.hydrogenaudio.org/index.php?title=Replaygain ReplayGain 1.0 specification] described a loudness measurement system which included a weighting filter, root mean square (RMS) measurement and statistical processing that model human perception of loudness in both the frequency and time domains.&lt;br /&gt;
&lt;br /&gt;
Since original ReplayGain proposal in 2001, the science, practice and standards for loudness normalization have been advanced significantly. The current industry standard approach to loudness measurement is described by the International Telecommunications Union&amp;lt;ref&amp;gt;http://www.itu.int/en/Pages/default.aspx&amp;lt;/ref&amp;gt; (ITU) as BS.1770. The most recent version of this standard is known as ITU BS.1770-5&amp;lt;ref&amp;gt;https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en&amp;lt;/ref&amp;gt; and was published in December 2023. The ITU work is freely available and is not believed to be encumbered by any patent issues. The ITU BS.1770-2 standard has been adopted in the United States by the [http://www.atsc.org ATSC] as [http://www.atsc.org/cms/standards/a_85-2011a.pdf A/85] and in Europe by the [http://www.ebu.ch European Broadcast Union] as [http://tech.ebu.ch/docs/tech/tech3343.pdf EBU R-128] for broadcast audio. &lt;br /&gt;
&lt;br /&gt;
BS.1770 uses a &amp;quot;K-weighted&amp;quot; RMS measurement. This weighting function is significantly less complex than the inverted Fletcher-Munson weighting used by the original ReplayGain algorithm. A gating function designed measure the loudness of foreground components in the audio program. The gate in BS.1770 performs a similar function as the statistical processing in the original RG specification. &lt;br /&gt;
&lt;br /&gt;
The computation required for BS.1770 loudness measurement is reduced compared to the original RG technique. Nevertheless, BS.1770 has been shown in several academic studies to be equally or more effective than the RG algorithm in modeling human loudness perception on music program as well as other material such as podcasts, television programs and movies.&amp;lt;ref&amp;gt;Paul Nygren. [http://www.speech.kth.se/prod/publications/files/3319.pdf Achieving equal loudness between audio files]. KTH Royal Institute of Technology&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Martin Wolters; Harald Mundt; Jeffrey Riedmiller (May 2010). [http://www.aes.org/e-lib/browse.cfm?elib=15341 Loudness Normalization In The Age Of Portable Media Players]. Audio Engineering Society.&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;Esben Skovenborg; Søren H. Nielsen (October 2004). [http://web.archive.org/web/20120208024743/http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf Evaluation of Different Loudness Models with Music and Speech Material]. Audio Engineering Society. Archived from [http://www.tcelectronic.com/media/skovenborg_2004_loudness_m.pdf the original] on 2012-02-08.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Recent RG implementations use BS.1770 for loudness measurement. It is expected the ITU standard will evolve over time to meet the needs of broadcasters and governments. It is the intent of the ReplayGain community that RG follow any future backwards-compatible improvements to loudness measurement using the BS.1770 standard.&lt;br /&gt;
&lt;br /&gt;
==Reference level==&lt;br /&gt;
&lt;br /&gt;
Classic ReplayGain is calibrated to a pink noise reference signal with a RMS level 14&amp;amp;nbsp;dB below a full-scale sinusoid. This reference signal is used to establish a reference level. ReplayGain will apply no gain or attenuation to the reference signal or any program material which has the same loudness measurements as the reference signal.&lt;br /&gt;
&lt;br /&gt;
BS-1770 defines a loudness scale for program material. The units of BS.1770 loudness measurements are in Loudness Units [relative to] Full Scale (LUFS). LUFS can be treated like decibels.&lt;br /&gt;
&lt;br /&gt;
In order to maintain backwards compatibility with classic RG, newer RG uses a -18&amp;amp;nbsp;LUFS reference, which based on lots of music, can give similar loudness compared to classic RG.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
The loudness measurement of the RG1 reference signal is NOT -18 LUFS; &lt;br /&gt;
The original -20 RMS dBFS one is -20.36 LUFS, and the -14 RMS dbFS one would be -15.36 LUFS.&lt;br /&gt;
&lt;br /&gt;
We picked -18 here is the result of analyzing actual music. &lt;br /&gt;
&lt;br /&gt;
Check what 2Bdecided said here: https://hydrogenaud.io/index.php/topic,109076.msg899298.html#msg899298&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Gain calculation==&lt;br /&gt;
RG achieves loudness compensated playback by applying gain (or attenuation) dependent on the measured loudness of the audio file relative to the established reference level. The gain is calculated as follows:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG=L_{r}-L&amp;lt;/math&amp;gt;&lt;br /&gt;
Where:&lt;br /&gt;
:&amp;lt;math&amp;gt;RG&amp;lt;/math&amp;gt; is the replay gain adjustment in decibels,&lt;br /&gt;
:&amp;lt;math&amp;gt;L_{r}&amp;lt;/math&amp;gt; is the -18&amp;amp;nbsp;LUFS reference level&lt;br /&gt;
:&amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; is the measured loudness of the audio file in LUFS.&lt;br /&gt;
&lt;br /&gt;
Gain is positive if the loudness of the audio file is lower than the reference level. The gain is negative (representing an attenuation) if the loudness of the audio file is higher than the reference level. The gain is stored as metadata with the audio file as described below and is used by players to adjust output volume of tracks as they are played as described in [[ReplayGain 2.0 specification#Player requirements|Player requirements]] below.&lt;br /&gt;
&lt;br /&gt;
==Metadata==&lt;br /&gt;
For ReplayGain to do its work during playback, four values must be stored as metadata&amp;lt;ref&amp;gt;Metadata is &amp;quot;data about data.&amp;quot; For example, the ID3 &#039;&#039;de facto&#039;&#039; standard provides a way to store artist, title, album title, track number, and other metadata in data blocks called &amp;quot;tags&amp;quot; immediately before or after the audio data in an MP3 file. Other metadata storage/tagging standards and conventions exist for other audio file formats.&amp;lt;/ref&amp;gt; with or within the audio file:&lt;br /&gt;
# Peak track amplitude&lt;br /&gt;
# Peak album amplitude&lt;br /&gt;
# Track replay gain&lt;br /&gt;
# Album replay gain&lt;br /&gt;
&lt;br /&gt;
If calculated for an individual track, the loudness measurement (as specified above) yields track replay gain. If calculated on an album basis, with all tracks concatenated to make one long audio file, the loudness measurement yields album replay gain.&lt;br /&gt;
&lt;br /&gt;
===Replay gain===&lt;br /&gt;
Under some listening conditions, it&#039;s useful to have every track sound equally loud. The problem with a track-by-track approach is that tracks which should be quiet in the context of the album on which they reside will be brought up to the level of all the rest. For casual listening, or in a noisy background, this can be a good thing. For serious listening, it does not respect the intent of the artist or mastering engineer; a tender ballad track will be blasting at the same loudness as a hard rock track on the same album. It&#039;s generally ideal to leave the intentional loudness differences between tracks in place, yet still correct for unmusical and annoying loudness differences between albums. To accomplish this, ReplayGain suggests that two different gain adjustments should be stored as metadata with each sound file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Album replay gain&#039;&#039; represents the ideal listening gain for an entire album. ReplayGain reads the collection of tracks that comprise an album, and calculates a single replay gain for the whole set. This single gain can be used for playback of all tracks of the album. Intentionally quiet tracks then stay appropriately quieter than the rest. It still solves the basic problem (annoying, unwanted level differences between discs) because quiet or loud discs are still adjusted overall&amp;amp;mdash;so the pop CD that&#039;s 20&amp;amp;nbsp;dB louder than the classical CD will be brought into line.&lt;br /&gt;
&lt;br /&gt;
===Peak amplitude===&lt;br /&gt;
Scanning a track or album for the peak amplitude can be a time-consuming process. Therefore, it&#039;s helpful if this single value is stored as metadata. This is used to predict whether the required replay gain adjustment will cause clipping during playback.&lt;br /&gt;
&lt;br /&gt;
The maximum peak amplitude value is stored as a floating point number, where 1.0 represents digital full scale. As with replay gain values, separate peak amplitude values are stored per track and per album.&lt;br /&gt;
&lt;br /&gt;
For uncompressed files simply, scanners store the maximum absolute sample value held in the file on any channel for positive or negative excursion. The single sample value should be converted to a floating-point representation, such that digital full scale is equivalent to a value of 1.0.&lt;br /&gt;
&lt;br /&gt;
Psychoacoustically coded audio, such as MP3, does not exist as a sequence of samples until it is decoded. Psychoacoustic coding of a heavily limited file can lead to sample values larger than digital full scale upon decoding. The coded files must be decoded using a fully compliant decoder that allows peak overflows (i.e. has headroom) and may result in peak amplitude values greater than 1.0.&lt;br /&gt;
&lt;br /&gt;
==Metadata format==&lt;br /&gt;
From the standpoint of metadata storage, each audio file format presents a unique situation. There are three favored schemes defined for storage of ReplayGain metadata: &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; and &#039;&#039;&#039;APEv2&#039;&#039;&#039;. A survey of file formats is listed below with metadata schemes in order of preference for each:&lt;br /&gt;
* .aac (Advanced Audio Coding raw format) &amp;amp;ndash; No metadata support (use .mp4 instead)&lt;br /&gt;
* .aiff, .aif, .aifc (Apple Interchange File Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID3&amp;quot; IFF chunk)&lt;br /&gt;
* .ape, .apl (Monkey&#039;s Audio) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .bwf (Broadcast Wave Format) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in RIFF chunk)&lt;br /&gt;
* .flac (Free Lossless Audio Codec) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;&lt;br /&gt;
* .mp3 (MPEG audio layer 3) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, LAME VBR proposed tag specification&lt;br /&gt;
* .mp4 also .m4a, .m4b, .m4p, m4r (MPEG-4 Part 14) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039; (in &amp;quot;ID32&amp;quot; box)&lt;br /&gt;
* .mpc (Musepack) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .ogg (Ogg Vorbis) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039;, same for other Ogg codecs&lt;br /&gt;
* .opus (Ogg Opus) &amp;amp;ndash; &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; available&lt;br /&gt;
** standard {{code|R128_TRACK_GAIN}} and {{code|R128_ALBUM_GAIN}} (MUST adjust for -23 LUFS) comment keys may be preferable (used by {{code|loudgain}})&lt;br /&gt;
* .tta (True Audio) &amp;amp;ndash; &#039;&#039;&#039;ID3v2&#039;&#039;&#039;, &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
* .asf, .wma (Windows Media audio) - &#039;&#039;&#039;Vorbis comments&#039;&#039;&#039; in Extended Content Description Object&lt;br /&gt;
** {{code|loudgain}} instead uses native ASF/WMA attributes (itself a key-value storage) via TagLib, which is more sensible&lt;br /&gt;
* .wav (Windows PCM) &amp;amp;ndash; No metadata support (use .bwf instead)&lt;br /&gt;
** ID3 RIFF chunk possible (used by {{code|loudgain}})&lt;br /&gt;
* .wv (WavePak) &amp;amp;ndash; &#039;&#039;&#039;APEv2&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===ID3v2===&lt;br /&gt;
The ID3v2 standard&amp;lt;ref&amp;gt;The ID3v2 format is explained at [http://www.id3.org/ www.id3.org]. The most useful document is the [http://www.id3.org/id3v2.3.0.html ID3v2 v2.3.0 standard]. Although this document has been superseded by v2.4.0, the earlier document is complete (rather than an update), and in indexed HTML form. As such, it represents a better technical introduction to ID3v2.&amp;lt;/ref&amp;gt; defines a &#039;&#039;tag&#039;&#039; which is situated before the data in an MP3 file.&amp;lt;ref&amp;gt;The original ID3 (v1) tags resided at the end of the file, and contained a few fields of information. The ID3v1 tag is not extensible and therefore cannot support ReplayGain metadata.&amp;lt;/ref&amp;gt; ID3 is used primarily with MP3 audio files but means of adapting the system to other file types have been developed.&lt;br /&gt;
&lt;br /&gt;
The ID3v2 tag is divided into &#039;&#039;frames&#039;&#039;. The preferred means of storing ReplayGain metadata is use of &#039;&#039;TXXX&#039;&#039; key/value pair frames. Two other legacy schemes for storing ReplayGain metadata exist: [[ReplayGain legacy metadata formats#ID3v2 RGAD|RGAD]] and [[ReplayGain legacy metadata formats#ID3v2 RVA2|RVA2]]. These formats are documented in the [[ReplayGain legacy metadata formats|appendix]]. Players may choose to look for these formats if metadata in the &#039;&#039;TXXX&#039;&#039; format is not found in the ID3v2 tag. New scanners may write these older formats in addition to the newer (TXXX) ones if they wish to remain backwards compatible with older players.&lt;br /&gt;
&lt;br /&gt;
ReplayGain uses four TXXX frames. The header of a TXXX frame is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Frame ID       $54 58 58 58 (&amp;quot;TXXX&amp;quot;) &lt;br /&gt;
 Size           $xx xx xx xx (size of frame excluding this header)&lt;br /&gt;
 Flags          $40 $00      (discard frame if audio data is altered)&lt;br /&gt;
&lt;br /&gt;
Frame data is coded as follows:&lt;br /&gt;
&lt;br /&gt;
 Text encoding  $00          (ISO-8859-1 encoding)&lt;br /&gt;
 Description    &amp;lt;key string&amp;gt; $00&lt;br /&gt;
 Value          &amp;lt;value string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The four frames associated with ReplayGain metadata use the following key/value pairs&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Table 3: Metadata keys and value formatting&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!Value format&lt;br /&gt;
|-&lt;br /&gt;
|Track replay gain&lt;br /&gt;
|REPLAYGAIN_TRACK_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak track amplitude&lt;br /&gt;
|REPLAYGAIN_TRACK_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|-&lt;br /&gt;
|Album replay gain&lt;br /&gt;
|REPLAYGAIN_ALBUM_GAIN&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Peak album amplitude&lt;br /&gt;
|REPLAYGAIN_ALBUM_PEAK&lt;br /&gt;
|c.dddddd&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Gains are specified textually in decibels. Negative gains (attenuation) are prefixed with a &#039;-&#039;. Positive gains have no prefix. Integral portion of the gain (a) may be one or two numeric (0-9) digits. If there is no integral portion the field is &#039;0&#039;. The decimal portion of the gain (bb) is two numeric digits. Gains are suffixed with a space followed by &#039;dB&#039;.&lt;br /&gt;
&lt;br /&gt;
Peak levels are specified textually as a positive decimal. Peak level is a dimensionless quantity with 1.000000 representing full scale. No suffix is included on peak values. The integer field (c) is typically 1 or 0. Six numeric digits in the decimal field (dddddd) is adequate to accurately represent peak values for 16-bit audio data.&lt;br /&gt;
&lt;br /&gt;
A robust player should be prepared to parse the following variations in either replay gain or peak level metadata:&lt;br /&gt;
*Positive gains with leading &#039;+&#039;&lt;br /&gt;
*More or fewer significant digits than specified in any field&lt;br /&gt;
*Leading zeros or spaces in integer fields&lt;br /&gt;
*Missing or malformed &#039;dB&#039; suffix (e.g. no space between numeric digits and suffix, alternate capitalization)&lt;br /&gt;
*Alternate capitalization of keys&lt;br /&gt;
&lt;br /&gt;
Other formatting errors indicate more severe problems and should result in player ignoring data as if the frame did not exist.&lt;br /&gt;
&lt;br /&gt;
===Vorbis comments===&lt;br /&gt;
A Vorbis comment&amp;lt;ref&amp;gt;[http://www.xiph.org/vorbis/doc/v-comment.html Vorbis comment metadata format]. ReplayGain metadata is documented on the [http://wiki.xiph.org/VorbisComment#Replay_Gain Xiph Wiki].&amp;lt;/ref&amp;gt; uses an ASCII &amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; format. When Vorbis comments are used, the four ReplayGain metadata items are stored as separate comments. The &#039;&#039;keys&#039;&#039; and formatting for &#039;&#039;values&#039;&#039; is the same as specified for ID3v2. Keys and values are required by the Vorbis comment specification to b separated by &#039;=&#039; (equal character).&lt;br /&gt;
&lt;br /&gt;
===APEv2===&lt;br /&gt;
The APEv2 metadata format&amp;lt;ref&amp;gt;[http://wiki.hydrogenaudio.org/index.php?title=APEv2_specification APEv2 Specification at Hydrogen Audio Wiki]&amp;lt;/ref&amp;gt; also organizes data into key/value pairs. Keys are ASCII format. A flags field allows support for several value formats including UTF-8 and binary. Under APEv2, ReplayGain meta data is stored using the same keys and data as ASCII values in the same format as specified for ID3v2.&lt;br /&gt;
&lt;br /&gt;
===De-Facto extensions===&lt;br /&gt;
MusicBrainz Picard and [http://github.com/Moonbase59/loudgain#tags-written-andor-deleted LoudGain] also support the following additional tags, named using the same conventions:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Extension metadata keys&lt;br /&gt;
|-&lt;br /&gt;
!Metadata&lt;br /&gt;
!Key&lt;br /&gt;
!alue format&lt;br /&gt;
! Purpose&lt;br /&gt;
|-&lt;br /&gt;
|Track range&lt;br /&gt;
|REPLAYGAIN_TRACK_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|rowspan=2 | Indicates dynamics (R-128 Loudness Range / LRA), may guide pre-amplification&lt;br /&gt;
|-&lt;br /&gt;
|Album range&lt;br /&gt;
|REPLAYGAIN_ALBUM_RANGE&lt;br /&gt;
|[-]a.bb dB&lt;br /&gt;
|-&lt;br /&gt;
|Reference loudness&lt;br /&gt;
|REPLAYGAIN_REFERENCE_LOUDNESS&lt;br /&gt;
|[-]a.bb LUFS&lt;br /&gt;
| Use alternative reference levels; change ref levels without re-scanning the file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Player requirements==&lt;br /&gt;
[[File:RG_Player_control.gif‎|frame|Figure 8: Example ReplayGain control panel]]&lt;br /&gt;
&lt;br /&gt;
Loudness normalization, pre-amplification and clipping prevention are the operations performed by a ReplayGain player.&lt;br /&gt;
&lt;br /&gt;
===Loudness normalization===&lt;br /&gt;
To properly normalize loudness, the player needs to determine if the user desires Track style level normalization (all tracks same loudness), or Album style level normalization (all albums same loudness, tracks of an album played at the same relative level as on the original release). This option should be selectable in the ReplayGain control panel (Figure 8). The player reads the corresponding gain metadata value from the file and scales the audio data as appropriate. Scaling the audio data simply means multiplying each sample value by a constant value. This constant is given by:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;10^\frac{gain}{20}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, in words, replay gain divided by 20 all raised to the power of ten.&amp;lt;ref&amp;gt;After any such operation, it&#039;s a good idea to dither the result. If this calculation and the pre-amp are implemented separately, then dither should only be added to the final result, just before the result is truncated back to 16 bits, or 24, or 8, as limited by the soundcard&amp;amp;mdash;not the file (i.e. after ReplayGain adjustment, an 8-bit file should be sent to a 16-bit soundcard at 16-bits).&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the file only contains one of the replay gain adjustments (e.g. Album) but the user has requested the other (Track), then the player should use the one that is available (in this case, Album). If neither (Track or Album) gain metadata is available, then the player needs to choose a suitable default gain. Potential choices include unity gain (0 dB) or an average of gains from other tracks in the album or playlist.&lt;br /&gt;
&lt;br /&gt;
===Pre-amplification===&lt;br /&gt;
Although the calibration level used by ReplayGain suggests that the average level of an audio track should be 14&amp;amp;nbsp;dB below full scale, some pop music is dynamically compressed to peak at 0&amp;amp;nbsp;dB and average around 3&amp;amp;nbsp;dB below full scale. This means that, when the replay gain is applied, the level of such tracks will be reduced by 11&amp;amp;nbsp;dB! If users are listening to a mixture of highly compressed and more dynamic tracks, ReplayGain will make the listening experience more pleasurable by bringing the level of the compressed tracks down into line with that of the others. However, if users are only listening to highly compressed music, then they may complain that all their files are now too quiet.&amp;lt;ref&amp;gt;This problem can be especially noticeable on portable players with limited output or gain.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To address this problem, a pre-amp feature should be incorporated into the player. A user-supplied pre-amp setting is an adjustment to the calculated replay gain. It should default to perform no adjustment. This means that casual users will experience a moderate reduction in the loudness of their compressed pop music. Less-compressed material can generally be played at the same loudness without clipping. Normalization of more dynamic material may cause clipping or invoke the [[ReplayGain 2.0 specification#Clipping prevention|clipping prevention]] mechanism (see below). Power users and audiophiles can reduce the pre-amp gain to enjoy the full dynamic range of all of their music.&lt;br /&gt;
&lt;br /&gt;
If enabled, the player should read the user selected pre-amp gain, and scale the audio signal by the appropriate amount. For example, a +6&amp;amp;nbsp;dB gain requires a scale of 10&amp;lt;sup&amp;gt;6/20&amp;lt;/sup&amp;gt;, which is approximately 2. The replay gain and pre-amp scale factors can be combined&amp;lt;ref&amp;gt;Scale factors in  Decibel units are added to produce the same effect as multiplying scale factors in linear units.&amp;lt;/ref&amp;gt; for simplicity and ease of processing.&lt;br /&gt;
&lt;br /&gt;
===Clipping prevention===&lt;br /&gt;
ReplayGain&#039;s suggestion of a -14&amp;amp;nbsp;dB average playback level leaves sufficient headroom for the bulk of modern recordings. Nevertheless, there exists the possibility that after application of replay gain and pre-amp adjustment, a track may exceed full scale during its dynamic peaks. Without intervention, this will result in clipping, a severe form of distortion. Factors introducing the possibility of clipping include:&lt;br /&gt;
&lt;br /&gt;
# Recordings from certain genres and certain periods in the history of commercial recordings require additional headroom. Although these recordings can be accommodated through a downwards adjustment of the pre-amp setting, it may be difficult to determine a safe adjustment and it may be undesirable to lower average level to accommodate the rare track which requires it. &lt;br /&gt;
# ReplayGain will make loud dynamically compressed tracks quieter, and quiet dynamically uncompressed tracks louder. The average levels will then be similar, but the quiet tracks will actually have louder peaks. If the user pushes the pre-amp gain upwards the peaks of the (originally) quieter tracks will be pushed well over full scale.&lt;br /&gt;
# In coded audio (e.g. MP3 files) a file that was hard-limited to digital full scale before encoding will often be pushed over the limit by the psychoacoustic compression. A decoder with headroom can recover the over full scale signal by reducing the gain.&lt;br /&gt;
&lt;br /&gt;
ReplayGain suggests two possible solutions which prevent clipping in these situations. A player should support one or both of these.&lt;br /&gt;
&lt;br /&gt;
====Audio limiting====&lt;br /&gt;
In situation 2 above, the user clearly wants all the music to sound very loud. To give them their wish, any signal which would peak above digital full scale should be hard limited at just below digital full scale. This is also useful at lower pre-amp gains, where it allows the average level of classical music to be raised to that of pop music, without distorting. The exact type of nature limiting or compression an implementation choice for the player.&amp;lt;ref&amp;gt;Something like the Hard Limiter found in Cool Edit Pro (Syntrillium) would be appropriate for pop music at least.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reduced gain====&lt;br /&gt;
The audiophile user will not want any compression or limiting on the signal. In this case the only option is to automatically and temporarily reduce the pre-amp gain below the user-selected setting for tracks where clipping would otherwise occur. Clipping can be predicted by examining the peak level of the track or album being played.&lt;br /&gt;
&lt;br /&gt;
The player must read the peak amplitude metadata. If peak level metadata is unavailable, the player should assume a peak level of 1.0. If the peak level for both track and album is stored as metadata in the file, it is possible to calculate if, following the replay gain adjustment and pre-amp gain, the signal will clip at some point. If it won&#039;t, then no further action is necessary. &lt;br /&gt;
&lt;br /&gt;
An overall scale factor for loudness normalization taking into account replay gain, pre-amp setting and clipping prevention through gain reduction is given below.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;min( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{peak amplitude} )&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;!-- use this when tex is fixed: :&amp;lt;math&amp;gt;\operatorname{min}( 10^\frac{RG + G_{pre-amp}}{20}, \frac{1}{L_{\mathrm{peak}}} )&amp;lt;/math&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hardware implementation===&lt;br /&gt;
The above three steps are appropriate to software players operating on the digital signal in order to scale it. However, it is possible to send the digital signal to the DAC without level correction, and to place an attenuator in the analogue signal path. The attenuator can then be driven by the Replay Gain value. The clipping problem can be addressed by providing adequate headroom in the analog circuitry. Bit transparency and maximum signal to noise ratio is maintained in the digital signal and DAC process.&amp;lt;ref&amp;gt;A system using today&#039;s 24-bit converters is unlikely to appreciate any overall gain in system performance with such an arrangement. A digitally-controlled analog gain element typically introduces significant noise and distortion.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The [http://replaygain.hydrogenaudio.org/proposal original ReplayGain proposal] (an [http://replay.waybackmachine.org/20090306202649/http://www.replaygain.org/ archive] is also available) was developed by David Robinson and was published 10 July 2001. Additional updates were published by David Robinson through 10 October 2001.&lt;br /&gt;
&lt;br /&gt;
The following acknowledgement was included with the original proposal, &amp;quot;The algorithm to calculate an ideal replay gain has grown from my research into human hearing, with many additional ideas drawn from the work of E. Zwicker, and Brian Moore. I am currently completing my PhD at the University of Essex, and have been funded by the EPSRC.&amp;quot; Additionally David Robinson credited Glen Sawyer (Snelg) and Jim Casaburi (Walrus) for software contributions and Bob Katz and Matt Ashland for ideas.&lt;br /&gt;
&lt;br /&gt;
This updated ReplayGain specification reflecting current and recommended practice was prepared by Kevin Gross in 2011.&lt;br /&gt;
&lt;br /&gt;
==Contact==&lt;br /&gt;
For ReplayGain-related questions or contributions, please post in the [http://www.hydrogenaudio.org/forums/index.php?showforum=1 General Audio] section of the Hydrogen Audio forums.&lt;br /&gt;
 &lt;br /&gt;
==Appendix==&lt;br /&gt;
# [[ReplayGain legacy metadata formats]]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38784</id>
		<title>ReplayGain</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38784"/>
		<updated>2026-01-22T19:04:42Z</updated>

		<summary type="html">&lt;p&gt;Skamp: fixed typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;ReplayGain&#039;&#039;&#039; is the name of a technique invented to achieve the same perceived playback loudness of audio files. It defines an algorithm to measure the &#039;&#039;&#039;perceived&#039;&#039;&#039; loudness of audio data.&lt;br /&gt;
&lt;br /&gt;
ReplayGain allows the loudness of each song within a collection of songs to be consistent. This is called &#039;Track Gain&#039; (or &#039;Radio Gain&#039; in earlier parlance). It also allows the loudness of a specific sub-collection (an &amp;quot;album&amp;quot;) to be consistent with the rest of the collection, while allowing the dynamics from song to song on the album to remain intact. This is called &#039;Album Gain&#039; (or &#039;Audiophile Gain&#039; in earlier parlance). This is especially important when listening to classical music albums, because quiet tracks need to remain a certain degree quieter than the louder ones.&lt;br /&gt;
&lt;br /&gt;
ReplayGain is different from [[Normalization|peak normalization]]. Peak normalization merely ensures that the peak amplitude reaches a certain level. This does not ensure equal loudness. The ReplayGain technique measures the &#039;&#039;effective power&#039;&#039; of the waveform (i.e. the RMS power after applying an &amp;quot;equal loudness contour&amp;quot;), and then adjusts the amplitude of the waveform accordingly. The result is that Replay Gained waveforms are usually more uniformly amplified than peak-normalized waveforms.&lt;br /&gt;
&lt;br /&gt;
==Target loudness==&lt;br /&gt;
The target loudness of almost all ReplayGain utilities is 89&amp;amp;nbsp;dB SPL when replayed in an SMPTE RP 200 calibrated system (an early departure from the proposal, endorsed by its author&amp;lt;ref&amp;gt;[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=83397&amp;amp;view=findpost&amp;amp;p=721854 Does Replay gain work differtly in Media monkey]&amp;lt;/ref&amp;gt;) &amp;amp;mdash; the ReplayGain proposal and SMPTE recommendation are 6&amp;amp;nbsp;dB lower.&amp;lt;ref&amp;gt;[http://www.mars.org/mailman/public/mad-dev/2004-February/000993.html ReplayGain discussion at mad-dev]&amp;lt;/ref&amp;gt; The target loudness may be more commonly known and understood as &#039;&#039;&#039;-18&#039;&#039;&#039;&amp;amp;nbsp;&#039;&#039;&#039;[https://en.wikipedia.org/wiki/LUFS LUFS]&#039;&#039;&#039; (&#039;&#039;Loudness Units relative to Full Scale&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Some utilities have realized the inadequacies of the classic ReplayGain loudness calculation, switching to a more modern algorithm ([https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en ITU-R BS.1770]). However, the way it was integrated was extremely &#039;&#039;ad hoc&#039;&#039;, at least until a draft of a [[ReplayGain 2.0 specification|revised specification]] started being written.&lt;br /&gt;
&lt;br /&gt;
==Clipping==&lt;br /&gt;
Audio is generally recorded such that the loudest sounds don&#039;t clip, but the use of ReplayGain can cause clipping if the average volume of a song is below the target level. That is, upon playback, the volume of a quiet song is increased, so the parts of the song with above-average loudness, especially in the bass frequencies, will exceed the limits of the format and will be distorted. Whether this distortion is audible depends on the sounds in question, and the listener&#039;s sensitivity.&lt;br /&gt;
&lt;br /&gt;
Implementations deal with the risk of clipping in different ways. Some have a &amp;quot;pre-amp&amp;quot; feature which reduces (or boosts) the original audio&#039;s level by a certain amount before doing whatever is needed for ReplayGain. Some have a &amp;quot;prevent clipping&amp;quot; feature to reduce the amount of ReplayGain adjustment to whatever amount would keep clipping from occurring, based on peak info stored in the file&#039;s metadata (thus reducing the effectiveness of ReplayGain). Some recommend using a compressor/limiter DSP to prevent or reduce clipping, regardless of whether it was caused by ReplayGain.&lt;br /&gt;
&lt;br /&gt;
An alternative that may reduce the risk of clipping is the [https://tech.ebu.ch/docs/r/r128.pdf EBU R 128] recommendation of a &#039;&#039;&#039;-23&#039;&#039;&#039;&amp;amp;nbsp;&#039;&#039;&#039;LUFS&#039;&#039;&#039; target, although some may find the additional reduction in volume excessive, particularly if it leads to maxing out volume on user hardware. [[Opus]] in particular has adopted that recommendation.&lt;br /&gt;
&lt;br /&gt;
== Implementations ==&lt;br /&gt;
There are different ReplayGain implementations, each with its own uses and strength. Most use [[metadata]] to indicate the level of the volume change that the player should make. Some modify the audio data itself, and optionally use metadata as well. There are advantages and disadvantages to both methods.&lt;br /&gt;
&lt;br /&gt;
In the metadata method, information on both types of ReplayGain (Track Gain and Album Gain) can be stored. The volume-change information can be very precise. If audio data was also changed, the metadata can contain &amp;quot;undo&amp;quot; info. Not all audio players/decoders know how to read and use ReplayGain information stored in metadata. And there&#039;s no standard for where and how ReplayGain info is stored; each implementation uses different formats and puts the info in different locations.&lt;br /&gt;
&lt;br /&gt;
In the audio data method, the file&#039;s actual audio data is modified so that its natural/default playback volume is at the target level. In this scenario, only one type of ReplayGain (Track Gain or Album Gain) can be applied. If no &amp;quot;undo&amp;quot; info is saved somewhere, it may not be possible to restore the original audio data. Limitations of the audio file format may prevent precise (finely tuned) gain adjustments with this method. For example, MP3 and AAC files can only be losslessly modified in 1.5 dB steps. Depending on the audio file format, the process may also be lossy in the sense that it could irreversibly push a signal above the format&#039;s maximum amplitude (resulting in clipping) or below the minimum (resulting in silence).&lt;br /&gt;
&lt;br /&gt;
=== MP3Gain ===&lt;br /&gt;
[[MP3Gain]] is an implementation of ReplayGain. It can be used to just analyze files &amp;amp; recommend changes or to also modify the gain. If modifying the gain, it always modifies the global gain fields in the MP3 audio data. It can add somewhat precise metadata, including undo info. The gain can be modified to any target dB, or it can be changed by a specified amount. For balance correction, user-specified changes can even be made on just one channel in simple L/R stereo-mode files (not joint stereo).&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]]&lt;br /&gt;
* Method: Audio + Meta (in APE tag), or Audio only&lt;br /&gt;
* APE tag fields (ASCII bytes):&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values for this file. 3 digits, zero-padded if necessary.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_ALBUM_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values across a set of files scanned as an album. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_UNDO +###,+###,N&amp;lt;/code&amp;gt; - the global gain adjustment to restore the original values in the left and right channels, respectively, followed by an indicator of whether to wrap at the extremes (&amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; means no, &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; means yes). The adjustment values are 3 digits, zero-padded, preceded by a sign (&amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;).&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Examples: &amp;lt;code&amp;gt;+0.424046&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-10.38500&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Example: &amp;lt;code&amp;gt;0.149923&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Optional.&lt;br /&gt;
* Limitations: Although the metadata, if written, contains precise adjustment &amp;amp; peak values, the audio data modifications are limited to 1.5dB steps and may become irreversible (however, that&#039;s a very rare condition; see the [https://hydrogenaud.io/index.php/topic,34154.0.html &amp;quot;mp3gain is NOT lossless&amp;quot; forum thread])&lt;br /&gt;
* http://mp3gain.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== AACGain ===&lt;br /&gt;
[[AACGain]] is a modified version of MP3Gain that works on both MP3 and AAC files.&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]], [[AAC]] (with or without MP4 container)&lt;br /&gt;
* Method: Audio + Meta, or Audio only&lt;br /&gt;
* Limitations: Limited to 1.5dB steps mode, may become irreversible (same caveat as for MP3Gain)&lt;br /&gt;
* http://aacgain.altosdesign.com/&lt;br /&gt;
&lt;br /&gt;
=== [[LAME]] ===&lt;br /&gt;
* Method: Header ([http://gabriel.mp3-tech.org/mp3infotag.html mp3infotag])&lt;br /&gt;
* Notes:&lt;br /&gt;
** Tags added during encoding; not supported by any player yet; Track Gain only&lt;br /&gt;
** Replay Gaining MP3&#039;s is usually done using MP3Gain (see [[ReplayGain#MP3Gain|above]]) or [[ReplayGain#foobar2000 ReplayGain scanner|foobar2000]]&lt;br /&gt;
* http://lame.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== [[Musepack]] ReplayGain ===&lt;br /&gt;
* Method: Header (similar to Meta data method)&lt;br /&gt;
* Notes: ReplayGain values are stored in the header and ReplayGain is part of the Musepack specifications; therefore any Musepack decoder that does not support ReplayGain can be considered broken.&lt;br /&gt;
* http://www.musepack.net/&lt;br /&gt;
&lt;br /&gt;
=== VorbisGain ===&lt;br /&gt;
* Format: (Ogg) [[Vorbis]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* http://www.sjeng.org/vorbisgain.html&lt;br /&gt;
** new compiles of VorbisGain at [http://www.rarewares.org/ogg.html www.rarewares.org]&lt;br /&gt;
:&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Andavari has provided a very useful script to integrate VorbisGain, which is a CLI tool, into Windows Explorer. Please (Ogg) [[Vorbis#ReplayGain|check this section]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== FLAC / METAFLAC ===&lt;br /&gt;
* Format: [[Free Lossless Audio Codec|FLAC]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* http://flac.sf.net&lt;br /&gt;
&lt;br /&gt;
=== WavPack / WVGAIN ===&lt;br /&gt;
* Format: [[WavPack]]&lt;br /&gt;
* Method: Meta (in [[APEv2]] tag)&lt;br /&gt;
* http://www.wavpack.com&lt;br /&gt;
&lt;br /&gt;
=== Wavegain ===&lt;br /&gt;
* Format: waveform&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Limitations: Irreversible&lt;br /&gt;
* http://www.rarewares.org/others.php#wavegain&lt;br /&gt;
&lt;br /&gt;
=== MusicPlayer ===&lt;br /&gt;
* Custom implementation, not derived from the original MP3Gain one (but inspired from). As far as I know, all other implementations are directly derived from the MP3Gain (gain_analysis.c, which is GPL) source.&lt;br /&gt;
* Format: any that FFmpeg supports&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Limitations: Doesn&#039;t modify the files at all. Stores the value in own database. Used only for playback.&lt;br /&gt;
* https://github.com/albertz/music-player&lt;br /&gt;
&lt;br /&gt;
=== [[foobar2000]] ReplayGain scanner ===&lt;br /&gt;
* Since v1.1.6, defaults to ITU-R BS.1770 analysis (although it labels it EBU R128), but can be configured to use the &amp;quot;Classic ReplayGain&amp;quot; algorithm instead. The ITU-R BS.1770 implementation uses a reference level of -18&amp;amp;nbsp;LUFS instead of -23, in order to retain compatibility with the ReplayGain standard.&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] (default) or [[APEv2]] tags. A separate function can be invoked to apply the tagged Track or Album Gain to the MP3 global gain fields (as MP3Gain does), and rewrite any existing tags to account for the peak change and compensate for the difference from 89&amp;amp;nbsp;dB. The 89&amp;amp;nbsp;dB reference level for tags isn&#039;t configurable, but the reference level applied to the global gain fields is (it&#039;s under Preferences &amp;gt; Advanced &amp;gt; Tools &amp;gt; ReplayGain Scanner &amp;gt; Target MP3 alteration volume level).&lt;br /&gt;
** [[Musepack]]: Values written to header.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags. As with MP3, it is also an option to apply gain via a separate function.&lt;br /&gt;
** [[MP4]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain).&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** Modules ([[MOD]] etc.): Optionally saved into [[APEv2]] tags.&lt;br /&gt;
* https://foobar2000.org/&lt;br /&gt;
&lt;br /&gt;
=== [[MediaMonkey]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[APEv2]] or [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[WAV]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[MPC]]: Internal gain Structure.&lt;br /&gt;
* In addition to tags, all ReplayGain values are also stored in MediaMonkey&#039;s MDB database&lt;br /&gt;
* Album/Audiophile ReplayGain not supported until v3.0 (Dec 2007); support during burning &amp;amp; ripping added in 3.1 (Jun 2009)&lt;br /&gt;
* Also capable of (irreversibly) changing the volume of MP3 tracks, similar to [[MP3Gain]]&lt;br /&gt;
* http://www.mediamonkey.com/&lt;br /&gt;
&lt;br /&gt;
=== [[Winamp]] ReplayGain scanner===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in Windows Media Audio tags.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[MP4]]&lt;br /&gt;
** [[TAK]]: Values written to [[APEv2]] tags.&lt;br /&gt;
* Support Album/Track Gain&lt;br /&gt;
&lt;br /&gt;
=== [[loudgain]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** MP2, [[MP3]]: Values written to [[ID3v2]] tags (ID3v2.3/ID3v2.4 selectable).&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Speex]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[Opus]]: Values written to [[Vorbis comment]], based on -23&amp;amp;nbsp;LUFS Opus standard. Only &amp;lt;code&amp;gt;R128_TRACK_GAIN&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;R128_ALBUM_GAIN&amp;lt;/code&amp;gt; are written, but the calculated &#039;&#039;true peak&#039;&#039; value can still be used to reduce the gain values ([[Clipping]] prevention).&lt;br /&gt;
** [[MP4]], [[M4A]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain). ReplayGain values are stored under &amp;lt;code&amp;gt;----:com.apple.iTunes:…&amp;lt;/code&amp;gt;. This is for [[AAC]] and [[ALAC]] in [[MPEG-4]] containers.&lt;br /&gt;
** [[ASF]], [[Windows Media Audio|WMA]]: Values written to WMA tags, no prefix.&lt;br /&gt;
** [[WAV]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] (ID3v2.3/ID3v2.4 selectable) format. Using the &amp;lt;code&amp;gt;bext&amp;lt;/code&amp;gt; chunk (for BWF v2) isn’t (yet) supported, but won’t be destroyed on writing.&lt;br /&gt;
** [[Audio Interchange File Format|AIFF]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] format.&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[Monkey&#039;s Audio]] (APE): Values written to [[APEv2]] tags.&lt;br /&gt;
* Follows EBU R128, ITU BS.1770 and the [[ReplayGain 2.0 specification|revised ReplayGain specification]].&lt;br /&gt;
* &#039;&#039;Never&#039;&#039; touches the actual audio data but &#039;&#039;only writes RG2 tags&#039;&#039;.&lt;br /&gt;
* Uses &#039;&#039;true peak&#039;&#039; values calculated by oversampling to 192&amp;amp;nbsp;kHz, using a custom polyphase FIR interpolator that will oversample 4x for sample rates &amp;lt; 96&amp;amp;nbsp;kHz, 2x for sample rates &amp;lt; 192&amp;amp;nbsp;kHz and leave the signal unchanged for 192&amp;amp;nbsp;kHz.&lt;br /&gt;
* &#039;&#039;Clipping prevention&#039;&#039; can be used to lower the ReplayGain values to a safe margin (default -1&amp;amp;nbsp;dBTP, can be changed).&lt;br /&gt;
* Many options for special cases: force RG tags upper-/lowercase, add extra tags (LRA, Reference loudness), strip unwanted tag types (APEv2 from MP2/MP3, ID3 from WavPack), tab-delimited table output for analysis with CSV file.&lt;br /&gt;
* &#039;&#039;Linux&#039;&#039; Free and Open Source software, can be installed on &#039;&#039;MacOS&#039;&#039; using &#039;&#039;HomeBrew&#039;&#039;, on &#039;&#039;Windows 10&#039;&#039; using the Linux &#039;&#039;bash&#039;&#039;.&lt;br /&gt;
* Also installs a &amp;lt;code&amp;gt;rgbpm&amp;lt;/code&amp;gt; bash script for mass-tagging, which can be adapted to the user’s needs.&lt;br /&gt;
* &#039;&#039;&#039;Warning:&#039;&#039;&#039; Loudgain relies on standard libraries like &#039;&#039;TagLib&#039;&#039;. Linux distros (except rolling releases) sometimes deliver outdated libraries, so be sure you use the latest version of &#039;&#039;TagLib&#039;&#039;. Version 1.11.1 had a nasty bug for a while that [https://hydrogenaud.io/index.php/topic,118085.msg974957.html#msg974957 could corrupt Ogg Vorbis files]. This has been fixed in the meantime but the TagLib version not updated. Loudgain comes with a (slower) static version called &amp;lt;code&amp;gt;loudgain.static&amp;lt;/code&amp;gt; in the repo’s &amp;lt;code&amp;gt;/bin&amp;lt;/code&amp;gt; folder that doesn’t expose the bug and can also be used on older Linux versions (like Ubuntu 14.04, Linux Mint 17).&lt;br /&gt;
* https://github.com/Moonbase59/loudgain&lt;br /&gt;
* Bug tracker: https://github.com/Moonbase59/loudgain/issues&lt;br /&gt;
&lt;br /&gt;
=== [[rsgain]] ===&lt;br /&gt;
rsgain is a newer ReplayGain command line utility designed with a &amp;quot;batteries included&amp;quot; philosophy.&lt;br /&gt;
&lt;br /&gt;
Features:&lt;br /&gt;
* Cross-platform Windows&amp;amp;nbsp;/&amp;amp;nbsp;macOS&amp;amp;nbsp;/&amp;amp;nbsp;Linux&lt;br /&gt;
* Supports all popular audio formats&lt;br /&gt;
* Simplified &amp;quot;Easy Mode&amp;quot; command line syntax supports recursive, directory-based scanning&lt;br /&gt;
* Multithreaded scanning option that provides significant speed improvement with full library scans&lt;br /&gt;
* Option to skip files with existing ReplayGain metadata&lt;br /&gt;
* Scan presets allow the user to save advanced settings for consistent use&lt;br /&gt;
&lt;br /&gt;
== Players support ==&lt;br /&gt;
ReplayGain being present in the specs of the FLAC, Musepack, and APE formats, any player that support those formats usually supports ReplayGain.&lt;br /&gt;
&lt;br /&gt;
The situation with MP3 is rather different, as it was not part of the MP3 specs. The APEv2 tags metadata implementation is somewhat becoming the de-facto standard.&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
* [[foobar2000]] supports ReplayGain in all possible aspects.&lt;br /&gt;
* [[Winamp]] supports ReplayGain in album or track mode.&lt;br /&gt;
* [[MediaMonkey]] supports ReplayGain, with many configuration options.&lt;br /&gt;
* [[XMPlay]] recently implemented ReplayGain&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;...and probably others.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
* [[XMMS]]. Reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], [[Musepack]], (Ogg) [[Vorbis]] ..&lt;br /&gt;
:For [[MP3]], use the CVS version of the [http://xmms-mad.sourceforge.net/ xmms-mad] mp3 plugin (it&#039;s not yet released as binary, furthermore not available in distribs&#039; versions for now. Meanwhile binaries are available here: [http://perso.crans.org/~krempp/xmms-mad/ custom binaries])&lt;br /&gt;
* [[amarok]]. By using the amarok-script [http://kde-apps.org/content/show.php?content=26073 ReplayGain]&lt;br /&gt;
:And possibly others, since [http://developer.kde.org/~wheeler/taglib.html TagLib] added support for [[APEv2]] tags in [[MP3]] files, players using this library (like [[amaroK]] and [[JuK]]) might support that kind of ReplayGain tags in the near future.&lt;br /&gt;
* [http://www.sacredchao.net/quodlibet Quod Libet] reads ReplayGain from (Ogg) [[Vorbis]], [[MP3]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:Requires support to be enabled (via the appropriate python bindings and libraries) for the above formats. Does not support ReplayGain values stored in [[APEv2]] tags in [[MP3]]s. ReplayGain values are stored in RVA2 id3v2.4 frames. See the [http://www.sacredchao.net/quodlibet/wiki/Development/ID3Notes Quod Libet RVA2 / ReplayGain notes].&lt;br /&gt;
* [http://www.musicpd.org/ Music Player Daemon] (MPD) reads ReplayGain from (Ogg) [[Vorbis]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:foobar2000-style TXXX frames in [[MP3]]s are also supported in the latest development releases.&lt;br /&gt;
* [http://www.mplayerhq.hu/ MPlayer]. Mplayer support for ReplayGain is codec dependent.&lt;br /&gt;
:Codecs that are known to support ReplayGain: vorbis&lt;br /&gt;
:Because of this, you need to prioritize the codecs that support it, or choose it individually on the command line.  To add it to the command line, add an -ac [codec] option after each file that you want to choose the codec for, or at the beginning to make it apply to all files listed.  To prioritize the codecs by default, list them in a line in mplayer.conf:&lt;br /&gt;
 ac=[codec],[othercodec],vorbis,mad,&lt;br /&gt;
* [http://idjc.sourceforge.net/ IDJC] (Internet DJ Console) reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], (Ogg) FLAC, (Ogg) [[Vorbis]], MP2 (audio), [[MP3]], [[Opus]], but only the &#039;&#039;lowercase&#039;&#039; tags. There is a [https://sourceforge.net/p/idjc/bugs/100/ ticket] open to handle tags case-insensitively.&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
* [https://www.videolan.org/vlc/ VLC] supports ReplayGain in many file formats, but usually only the &#039;&#039;uppercase&#039;&#039; variant of the tags.&lt;br /&gt;
* [https://kodi.tv/ KODI] reads ReplayGain from nearly all formats, but usually only the &#039;&#039;lowercase&#039;&#039; variant of the tags.&lt;br /&gt;
&lt;br /&gt;
=== Portable devices ===&lt;br /&gt;
[http://www.rockbox.org/ Rockbox] supports ReplayGain (in album or track mode) for most formats, including  WMA, MP1/2/3, AAC, ALAC, Musepack, Monkey&#039;s Audio, Wavpack, FLAC and Vorbis.  &amp;lt;br&amp;gt;Note that ReplayGain is only supported when using the respective codec&#039;s native tagging format.  For example:  ReplayGain stored in APEv2 tags is not supported for MP3, rather ID3v2.x tags are expected.&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Fuze with firmware 1.02.26 and 2.02.26&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Clip+&lt;br /&gt;
&lt;br /&gt;
The iPod features &#039;&#039;Soundcheck&#039;&#039;, which seems to produce roughly the same normalization gains as ReplayGain, but doesn&#039;t provide an Album Gain.&lt;br /&gt;
&lt;br /&gt;
=== Hi-Fi ===&lt;br /&gt;
Slim Devices, a company owned by Logitech Inc, supports ReplayGain on both of their hi-end audiophile players, known as the [[Slim Devices Transporter|Transporter]] and the [[Slim Devices Squeezebox|Squeezebox]].&lt;br /&gt;
&lt;br /&gt;
BluOS also supports ReplayGain with the selection of album- or track-gain and a so called Smart option that decides between the two by itself.&lt;br /&gt;
NAD devices that use BluOS consequently also support ReplayGain.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;references/&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[ReplayGain specification]]&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Replay_Gain ReplayGain] at Wikipedia&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain.html ReplayGain using foobar2000] (how to use ReplayGain in Windows using foobar2000).&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain-in-Linux.html ReplayGain in Linux] (how to use ReplayGain in Linux using foobar2000 and Wine, or using metaflac or vorbisgain).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Technical]]&lt;br /&gt;
[[index.php?title=Category:Metadata]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38783</id>
		<title>ReplayGain</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=ReplayGain&amp;diff=38783"/>
		<updated>2026-01-22T19:01:38Z</updated>

		<summary type="html">&lt;p&gt;Skamp: Clarified the differences between the new ITU-R BS.1770 algorithm and the EBU R 128 recommendations. Addition of non breakable spaces between numbers and units.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;ReplayGain&#039;&#039;&#039; is the name of a technique invented to achieve the same perceived playback loudness of audio files. It defines an algorithm to measure the &#039;&#039;&#039;perceived&#039;&#039;&#039; loudness of audio data.&lt;br /&gt;
&lt;br /&gt;
ReplayGain allows the loudness of each song within a collection of songs to be consistent. This is called &#039;Track Gain&#039; (or &#039;Radio Gain&#039; in earlier parlance). It also allows the loudness of a specific sub-collection (an &amp;quot;album&amp;quot;) to be consistent with the rest of the collection, while allowing the dynamics from song to song on the album to remain intact. This is called &#039;Album Gain&#039; (or &#039;Audiophile Gain&#039; in earlier parlance). This is especially important when listening to classical music albums, because quiet tracks need to remain a certain degree quieter than the louder ones.&lt;br /&gt;
&lt;br /&gt;
ReplayGain is different from [[Normalization|peak normalization]]. Peak normalization merely ensures that the peak amplitude reaches a certain level. This does not ensure equal loudness. The ReplayGain technique measures the &#039;&#039;effective power&#039;&#039; of the waveform (i.e. the RMS power after applying an &amp;quot;equal loudness contour&amp;quot;), and then adjusts the amplitude of the waveform accordingly. The result is that Replay Gained waveforms are usually more uniformly amplified than peak-normalized waveforms.&lt;br /&gt;
&lt;br /&gt;
==Target loudness==&lt;br /&gt;
The target loudness of almost all ReplayGain utilities is 89&amp;amp;nbsp;dB SPL when replayed in an SMPTE RP 200 calibrated system (an early departure from the proposal, endorsed by its author&amp;lt;ref&amp;gt;[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=83397&amp;amp;view=findpost&amp;amp;p=721854 Does Replay gain work differtly in Media monkey]&amp;lt;/ref&amp;gt;) &amp;amp;mdash; the ReplayGain proposal and SMPTE recommendation are 6&amp;amp;nbsp;dB lower.&amp;lt;ref&amp;gt;[http://www.mars.org/mailman/public/mad-dev/2004-February/000993.html ReplayGain discussion at mad-dev]&amp;lt;/ref&amp;gt; The target loudness may be more commonly known and understood as &#039;&#039;&#039;-18&#039;&#039;&#039;&amp;amp;nbsp;&#039;&#039;&#039;[https://en.wikipedia.org/wiki/LUFS LUFS]&#039;&#039;&#039; (&#039;&#039;Loudness Units relative to Full Scale&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Some utilities have realized the inadequacies of the classic ReplayGain loudness calculation, switching to a more modern algorithm ([https://www.itu.int/rec/R-REC-BS.1770-5-202311-I/en ITU-R BS.1770]). However, the way it was integrated was extremely &#039;&#039;ad hoc&#039;&#039;, at least until a draft of a [[ReplayGain 2.0 specification|revised specification]] started being written.&lt;br /&gt;
&lt;br /&gt;
==Clipping==&lt;br /&gt;
Audio is generally recorded such that the loudest sounds don&#039;t clip, but the use of ReplayGain can cause clipping if the average volume of a song is below the target level. That is, upon playback, the volume of a quiet song is increased, so the parts of the song with above-average loudness, especially in the bass frequencies, will exceed the limits of the format and will be distorted. Whether this distortion is audible depends on the sounds in question, and the listener&#039;s sensitivity.&lt;br /&gt;
&lt;br /&gt;
Implementations deal with the risk of clipping in different ways. Some have a &amp;quot;pre-amp&amp;quot; feature which reduces (or boosts) the original audio&#039;s level by a certain amount before doing whatever is needed for ReplayGain. Some have a &amp;quot;prevent clipping&amp;quot; feature to reduce the amount of ReplayGain adjustment to whatever amount would keep clipping from occurring, based on peak info stored in the file&#039;s metadata (thus reducing the effectiveness of ReplayGain). Some recommend using a compressor/limiter DSP to prevent or reduce clipping, regardless of whether it was caused by ReplayGain.&lt;br /&gt;
&lt;br /&gt;
An alternative that may reduce the risk of clipping is the [https://tech.ebu.ch/docs/r/r128.pdf EBU R 128] recommendation of a &#039;&#039;&#039;-23&#039;&#039;&#039;&amp;amp;nbsp;&#039;&#039;&#039;LUFS&#039;&#039;&#039; target, although some may find the additional reduction in volume excessive, particularly if it leads to maxing out volume on user hardware. [[Opus]] in particular has adopted that recommendation.&lt;br /&gt;
&lt;br /&gt;
== Implementations ==&lt;br /&gt;
There are different ReplayGain implementations, each with its own uses and strength. Most use [[metadata]] to indicate the level of the volume change that the player should make. Some modify the audio data itself, and optionally use metadata as well. There are advantages and disadvantages to both methods.&lt;br /&gt;
&lt;br /&gt;
In the metadata method, information on both types of ReplayGain (Track Gain and Album Gain) can be stored. The volume-change information can be very precise. If audio data was also changed, the metadata can contain &amp;quot;undo&amp;quot; info. Not all audio players/decoders know how to read and use ReplayGain information stored in metadata. And there&#039;s no standard for where and how ReplayGain info is stored; each implementation uses different formats and puts the info in different locations.&lt;br /&gt;
&lt;br /&gt;
In the audio data method, the file&#039;s actual audio data is modified so that its natural/default playback volume is at the target level. In this scenario, only one type of ReplayGain (Track Gain or Album Gain) can be applied. If no &amp;quot;undo&amp;quot; info is saved somewhere, it may not be possible to restore the original audio data. Limitations of the audio file format may prevent precise (finely tuned) gain adjustments with this method. For example, MP3 and AAC files can only be losslessly modified in 1.5 dB steps. Depending on the audio file format, the process may also be lossy in the sense that it could irreversibly push a signal above the format&#039;s maximum amplitude (resulting in clipping) or below the minimum (resulting in silence).&lt;br /&gt;
&lt;br /&gt;
=== MP3Gain ===&lt;br /&gt;
[[MP3Gain]] is an implementation of ReplayGain. It can be used to just analyze files &amp;amp; recommend changes or to also modify the gain. If modifying the gain, it always modifies the global gain fields in the MP3 audio data. It can add somewhat precise metadata, including undo info. The gain can be modified to any target dB, or it can be changed by a specified amount. For balance correction, user-specified changes can even be made on just one channel in simple L/R stereo-mode files (not joint stereo).&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]]&lt;br /&gt;
* Method: Audio + Meta (in APE tag), or Audio only&lt;br /&gt;
* APE tag fields (ASCII bytes):&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values for this file. 3 digits, zero-padded if necessary.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_ALBUM_MINMAX ###,###&amp;lt;/code&amp;gt; - minimum &amp;amp; maximum global gain values across a set of files scanned as an album. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;MP3GAIN_UNDO +###,+###,N&amp;lt;/code&amp;gt; - the global gain adjustment to restore the original values in the left and right channels, respectively, followed by an indicator of whether to wrap at the extremes (&amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; means no, &amp;lt;code&amp;gt;W&amp;lt;/code&amp;gt; means yes). The adjustment values are 3 digits, zero-padded, preceded by a sign (&amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt;).&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Examples: &amp;lt;code&amp;gt;+0.424046&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-10.38500&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_TRACK_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Example: &amp;lt;code&amp;gt;0.149923&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_GAIN +#.###### dB&amp;lt;/code&amp;gt; - The value is always 9 characters including the sign and decimal point. Optional.&lt;br /&gt;
** &amp;lt;code&amp;gt;REPLAYGAIN_ALBUM_PEAK #.###### dB&amp;lt;/code&amp;gt; - The value is always 8 characters including the decimal point. Optional.&lt;br /&gt;
* Limitations: Although the metadata, if written, contains precise adjustment &amp;amp; peak values, the audio data modifications are limited to 1.5dB steps and may become irreversible (however, that&#039;s a very rare condition; see the [https://hydrogenaud.io/index.php/topic,34154.0.html &amp;quot;mp3gain is NOT lossless&amp;quot; forum thread])&lt;br /&gt;
* http://mp3gain.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== AACGain ===&lt;br /&gt;
[[AACGain]] is a modified version of MP3Gain that works on both MP3 and AAC files.&lt;br /&gt;
&lt;br /&gt;
* Format: [[MP3]], [[AAC]] (with or without MP4 container)&lt;br /&gt;
* Method: Audio + Meta, or Audio only&lt;br /&gt;
* Limitations: Limited to 1.5dB steps mode, may become irreversible (same caveat as for MP3Gain)&lt;br /&gt;
* http://aacgain.altosdesign.com/&lt;br /&gt;
&lt;br /&gt;
=== [[LAME]] ===&lt;br /&gt;
* Method: Header ([http://gabriel.mp3-tech.org/mp3infotag.html mp3infotag])&lt;br /&gt;
* Notes:&lt;br /&gt;
** Tags added during encoding; not supported by any player yet; Track Gain only&lt;br /&gt;
** Replay Gaining MP3&#039;s is usually done using MP3Gain (see [[ReplayGain#MP3Gain|above]]) or [[ReplayGain#foobar2000 ReplayGain scanner|foobar2000]]&lt;br /&gt;
* http://lame.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
=== [[Musepack]] ReplayGain ===&lt;br /&gt;
* Method: Header (similar to Meta data method)&lt;br /&gt;
* Notes: ReplayGain values are stored in the header and ReplayGain is part of the Musepack specifications; therefore any Musepack decoder that does not support ReplayGain can be considered broken.&lt;br /&gt;
* http://www.musepack.net/&lt;br /&gt;
&lt;br /&gt;
=== VorbisGain ===&lt;br /&gt;
* Format: (Ogg) [[Vorbis]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* http://www.sjeng.org/vorbisgain.html&lt;br /&gt;
** new compiles of VorbisGain at [http://www.rarewares.org/ogg.html www.rarewares.org]&lt;br /&gt;
:&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Andavari has provided a very useful script to integrate VorbisGain, which is a CLI tool, into Windows Explorer. Please (Ogg) [[Vorbis#ReplayGain|check this section]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== FLAC / METAFLAC ===&lt;br /&gt;
* Format: [[Free Lossless Audio Codec|FLAC]]&lt;br /&gt;
* Method: Meta (in [[Vorbis comment]])&lt;br /&gt;
* http://flac.sf.net&lt;br /&gt;
&lt;br /&gt;
=== WavPack / WVGAIN ===&lt;br /&gt;
* Format: [[WavPack]]&lt;br /&gt;
* Method: Meta (in [[APEv2]] tag)&lt;br /&gt;
* http://www.wavpack.com&lt;br /&gt;
&lt;br /&gt;
=== Wavegain ===&lt;br /&gt;
* Format: waveform&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Limitations: Irreversible&lt;br /&gt;
* http://www.rarewares.org/others.php#wavegain&lt;br /&gt;
&lt;br /&gt;
=== MusicPlayer ===&lt;br /&gt;
* Custom implementation, not derived from the original MP3Gain one (but inspired from). As far as I know, all other implementations are directly derived from the MP3Gain (gain_analysis.c, which is GPL) source.&lt;br /&gt;
* Format: any that FFmpeg supports&lt;br /&gt;
* Method: Audio&lt;br /&gt;
* Limitations: Doesn&#039;t modify the files at all. Stores the value in own database. Used only for playback.&lt;br /&gt;
* https://github.com/albertz/music-player&lt;br /&gt;
&lt;br /&gt;
=== [[foobar2000]] ReplayGain scanner ===&lt;br /&gt;
* Since v1.1.6, defaults to ITU-R BS.1770 analysis (although it labels is EBU R128), but can be configured to use the &amp;quot;Classic ReplayGain&amp;quot; algorithm instead. The ITU-R BS.1770 implementation uses a reference level of -18&amp;amp;nbsp;LUFS instead of -23, in order to retain compatibility with the ReplayGain standard.&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] (default) or [[APEv2]] tags. A separate function can be invoked to apply the tagged Track or Album Gain to the MP3 global gain fields (as MP3Gain does), and rewrite any existing tags to account for the peak change and compensate for the difference from 89&amp;amp;nbsp;dB. The 89&amp;amp;nbsp;dB reference level for tags isn&#039;t configurable, but the reference level applied to the global gain fields is (it&#039;s under Preferences &amp;gt; Advanced &amp;gt; Tools &amp;gt; ReplayGain Scanner &amp;gt; Target MP3 alteration volume level).&lt;br /&gt;
** [[Musepack]]: Values written to header.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags. As with MP3, it is also an option to apply gain via a separate function.&lt;br /&gt;
** [[MP4]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain).&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** Modules ([[MOD]] etc.): Optionally saved into [[APEv2]] tags.&lt;br /&gt;
* https://foobar2000.org/&lt;br /&gt;
&lt;br /&gt;
=== [[MediaMonkey]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[APEv2]] or [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[WAV]]: Values stored in MediaMonkey&#039;s MDB database.&lt;br /&gt;
** [[MPC]]: Internal gain Structure.&lt;br /&gt;
* In addition to tags, all ReplayGain values are also stored in MediaMonkey&#039;s MDB database&lt;br /&gt;
* Album/Audiophile ReplayGain not supported until v3.0 (Dec 2007); support during burning &amp;amp; ripping added in 3.1 (Jun 2009)&lt;br /&gt;
* Also capable of (irreversibly) changing the volume of MP3 tracks, similar to [[MP3Gain]]&lt;br /&gt;
* http://www.mediamonkey.com/&lt;br /&gt;
&lt;br /&gt;
=== [[Winamp]] ReplayGain scanner===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[MP3]]: Values written to [[ID3v2]] tags.&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[WMA]]: Values stored in Windows Media Audio tags.&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[APE]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[AAC]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[MP4]]&lt;br /&gt;
** [[TAK]]: Values written to [[APEv2]] tags.&lt;br /&gt;
* Support Album/Track Gain&lt;br /&gt;
&lt;br /&gt;
=== [[loudgain]] ===&lt;br /&gt;
* Format:&lt;br /&gt;
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** MP2, [[MP3]]: Values written to [[ID3v2]] tags (ID3v2.3/ID3v2.4 selectable).&lt;br /&gt;
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** (Ogg) [[Speex]]: Values written to [[Vorbis comment]].&lt;br /&gt;
** [[Opus]]: Values written to [[Vorbis comment]], based on -23&amp;amp;nbsp;LUFS Opus standard. Only &amp;lt;code&amp;gt;R128_TRACK_GAIN&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;R128_ALBUM_GAIN&amp;lt;/code&amp;gt; are written, but the calculated &#039;&#039;true peak&#039;&#039; value can still be used to reduce the gain values ([[Clipping]] prevention).&lt;br /&gt;
** [[MP4]], [[M4A]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain). ReplayGain values are stored under &amp;lt;code&amp;gt;----:com.apple.iTunes:…&amp;lt;/code&amp;gt;. This is for [[AAC]] and [[ALAC]] in [[MPEG-4]] containers.&lt;br /&gt;
** [[ASF]], [[Windows Media Audio|WMA]]: Values written to WMA tags, no prefix.&lt;br /&gt;
** [[WAV]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] (ID3v2.3/ID3v2.4 selectable) format. Using the &amp;lt;code&amp;gt;bext&amp;lt;/code&amp;gt; chunk (for BWF v2) isn’t (yet) supported, but won’t be destroyed on writing.&lt;br /&gt;
** [[Audio Interchange File Format|AIFF]]: Values written to the &amp;lt;code&amp;gt;ID3 &amp;lt;/code&amp;gt; chunk, in [[ID3v2]] format.&lt;br /&gt;
** [[WavPack]]: Values written to [[APEv2]] tags.&lt;br /&gt;
** [[Monkey&#039;s Audio]] (APE): Values written to [[APEv2]] tags.&lt;br /&gt;
* Follows EBU R128, ITU BS.1770 and the [[ReplayGain 2.0 specification|revised ReplayGain specification]].&lt;br /&gt;
* &#039;&#039;Never&#039;&#039; touches the actual audio data but &#039;&#039;only writes RG2 tags&#039;&#039;.&lt;br /&gt;
* Uses &#039;&#039;true peak&#039;&#039; values calculated by oversampling to 192&amp;amp;nbsp;kHz, using a custom polyphase FIR interpolator that will oversample 4x for sample rates &amp;lt; 96&amp;amp;nbsp;kHz, 2x for sample rates &amp;lt; 192&amp;amp;nbsp;kHz and leave the signal unchanged for 192&amp;amp;nbsp;kHz.&lt;br /&gt;
* &#039;&#039;Clipping prevention&#039;&#039; can be used to lower the ReplayGain values to a safe margin (default -1&amp;amp;nbsp;dBTP, can be changed).&lt;br /&gt;
* Many options for special cases: force RG tags upper-/lowercase, add extra tags (LRA, Reference loudness), strip unwanted tag types (APEv2 from MP2/MP3, ID3 from WavPack), tab-delimited table output for analysis with CSV file.&lt;br /&gt;
* &#039;&#039;Linux&#039;&#039; Free and Open Source software, can be installed on &#039;&#039;MacOS&#039;&#039; using &#039;&#039;HomeBrew&#039;&#039;, on &#039;&#039;Windows 10&#039;&#039; using the Linux &#039;&#039;bash&#039;&#039;.&lt;br /&gt;
* Also installs a &amp;lt;code&amp;gt;rgbpm&amp;lt;/code&amp;gt; bash script for mass-tagging, which can be adapted to the user’s needs.&lt;br /&gt;
* &#039;&#039;&#039;Warning:&#039;&#039;&#039; Loudgain relies on standard libraries like &#039;&#039;TagLib&#039;&#039;. Linux distros (except rolling releases) sometimes deliver outdated libraries, so be sure you use the latest version of &#039;&#039;TagLib&#039;&#039;. Version 1.11.1 had a nasty bug for a while that [https://hydrogenaud.io/index.php/topic,118085.msg974957.html#msg974957 could corrupt Ogg Vorbis files]. This has been fixed in the meantime but the TagLib version not updated. Loudgain comes with a (slower) static version called &amp;lt;code&amp;gt;loudgain.static&amp;lt;/code&amp;gt; in the repo’s &amp;lt;code&amp;gt;/bin&amp;lt;/code&amp;gt; folder that doesn’t expose the bug and can also be used on older Linux versions (like Ubuntu 14.04, Linux Mint 17).&lt;br /&gt;
* https://github.com/Moonbase59/loudgain&lt;br /&gt;
* Bug tracker: https://github.com/Moonbase59/loudgain/issues&lt;br /&gt;
&lt;br /&gt;
=== [[rsgain]] ===&lt;br /&gt;
rsgain is a newer ReplayGain command line utility designed with a &amp;quot;batteries included&amp;quot; philosophy.&lt;br /&gt;
&lt;br /&gt;
Features:&lt;br /&gt;
* Cross-platform Windows&amp;amp;nbsp;/&amp;amp;nbsp;macOS&amp;amp;nbsp;/&amp;amp;nbsp;Linux&lt;br /&gt;
* Supports all popular audio formats&lt;br /&gt;
* Simplified &amp;quot;Easy Mode&amp;quot; command line syntax supports recursive, directory-based scanning&lt;br /&gt;
* Multithreaded scanning option that provides significant speed improvement with full library scans&lt;br /&gt;
* Option to skip files with existing ReplayGain metadata&lt;br /&gt;
* Scan presets allow the user to save advanced settings for consistent use&lt;br /&gt;
&lt;br /&gt;
== Players support ==&lt;br /&gt;
ReplayGain being present in the specs of the FLAC, Musepack, and APE formats, any player that support those formats usually supports ReplayGain.&lt;br /&gt;
&lt;br /&gt;
The situation with MP3 is rather different, as it was not part of the MP3 specs. The APEv2 tags metadata implementation is somewhat becoming the de-facto standard.&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
* [[foobar2000]] supports ReplayGain in all possible aspects.&lt;br /&gt;
* [[Winamp]] supports ReplayGain in album or track mode.&lt;br /&gt;
* [[MediaMonkey]] supports ReplayGain, with many configuration options.&lt;br /&gt;
* [[XMPlay]] recently implemented ReplayGain&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;...and probably others.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
* [[XMMS]]. Reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], [[Musepack]], (Ogg) [[Vorbis]] ..&lt;br /&gt;
:For [[MP3]], use the CVS version of the [http://xmms-mad.sourceforge.net/ xmms-mad] mp3 plugin (it&#039;s not yet released as binary, furthermore not available in distribs&#039; versions for now. Meanwhile binaries are available here: [http://perso.crans.org/~krempp/xmms-mad/ custom binaries])&lt;br /&gt;
* [[amarok]]. By using the amarok-script [http://kde-apps.org/content/show.php?content=26073 ReplayGain]&lt;br /&gt;
:And possibly others, since [http://developer.kde.org/~wheeler/taglib.html TagLib] added support for [[APEv2]] tags in [[MP3]] files, players using this library (like [[amaroK]] and [[JuK]]) might support that kind of ReplayGain tags in the near future.&lt;br /&gt;
* [http://www.sacredchao.net/quodlibet Quod Libet] reads ReplayGain from (Ogg) [[Vorbis]], [[MP3]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:Requires support to be enabled (via the appropriate python bindings and libraries) for the above formats. Does not support ReplayGain values stored in [[APEv2]] tags in [[MP3]]s. ReplayGain values are stored in RVA2 id3v2.4 frames. See the [http://www.sacredchao.net/quodlibet/wiki/Development/ID3Notes Quod Libet RVA2 / ReplayGain notes].&lt;br /&gt;
* [http://www.musicpd.org/ Music Player Daemon] (MPD) reads ReplayGain from (Ogg) [[Vorbis]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].&lt;br /&gt;
:foobar2000-style TXXX frames in [[MP3]]s are also supported in the latest development releases.&lt;br /&gt;
* [http://www.mplayerhq.hu/ MPlayer]. Mplayer support for ReplayGain is codec dependent.&lt;br /&gt;
:Codecs that are known to support ReplayGain: vorbis&lt;br /&gt;
:Because of this, you need to prioritize the codecs that support it, or choose it individually on the command line.  To add it to the command line, add an -ac [codec] option after each file that you want to choose the codec for, or at the beginning to make it apply to all files listed.  To prioritize the codecs by default, list them in a line in mplayer.conf:&lt;br /&gt;
 ac=[codec],[othercodec],vorbis,mad,&lt;br /&gt;
* [http://idjc.sourceforge.net/ IDJC] (Internet DJ Console) reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], (Ogg) FLAC, (Ogg) [[Vorbis]], MP2 (audio), [[MP3]], [[Opus]], but only the &#039;&#039;lowercase&#039;&#039; tags. There is a [https://sourceforge.net/p/idjc/bugs/100/ ticket] open to handle tags case-insensitively.&lt;br /&gt;
* [https://picard.musicbrainz.org/ MusicBrainz Picard] is a tagger (and player) that tags using metadata from the MusicBrainz.org database. Picard supports ReplayGain tags for files tagged with APE, ASF, ID3, MP4 and Vorbis tags. There is a ReplayGain plugin that can be used to calculate the ReplayGain values for both Albums and Tracks.&lt;br /&gt;
* [https://www.videolan.org/vlc/ VLC] supports ReplayGain in many file formats, but usually only the &#039;&#039;uppercase&#039;&#039; variant of the tags.&lt;br /&gt;
* [https://kodi.tv/ KODI] reads ReplayGain from nearly all formats, but usually only the &#039;&#039;lowercase&#039;&#039; variant of the tags.&lt;br /&gt;
&lt;br /&gt;
=== Portable devices ===&lt;br /&gt;
[http://www.rockbox.org/ Rockbox] supports ReplayGain (in album or track mode) for most formats, including  WMA, MP1/2/3, AAC, ALAC, Musepack, Monkey&#039;s Audio, Wavpack, FLAC and Vorbis.  &amp;lt;br&amp;gt;Note that ReplayGain is only supported when using the respective codec&#039;s native tagging format.  For example:  ReplayGain stored in APEv2 tags is not supported for MP3, rather ID3v2.x tags are expected.&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Fuze with firmware 1.02.26 and 2.02.26&lt;br /&gt;
&lt;br /&gt;
Sandisk Sansa Clip+&lt;br /&gt;
&lt;br /&gt;
The iPod features &#039;&#039;Soundcheck&#039;&#039;, which seems to produce roughly the same normalization gains as ReplayGain, but doesn&#039;t provide an Album Gain.&lt;br /&gt;
&lt;br /&gt;
=== Hi-Fi ===&lt;br /&gt;
Slim Devices, a company owned by Logitech Inc, supports ReplayGain on both of their hi-end audiophile players, known as the [[Slim Devices Transporter|Transporter]] and the [[Slim Devices Squeezebox|Squeezebox]].&lt;br /&gt;
&lt;br /&gt;
BluOS also supports ReplayGain with the selection of album- or track-gain and a so called Smart option that decides between the two by itself.&lt;br /&gt;
NAD devices that use BluOS consequently also support ReplayGain.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;references/&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[ReplayGain specification]]&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Replay_Gain ReplayGain] at Wikipedia&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain.html ReplayGain using foobar2000] (how to use ReplayGain in Windows using foobar2000).&lt;br /&gt;
* [http://www.bobulous.org.uk/misc/Replay-Gain-in-Linux.html ReplayGain in Linux] (how to use ReplayGain in Linux using foobar2000 and Wine, or using metaflac or vorbisgain).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Technical]]&lt;br /&gt;
[[index.php?title=Category:Metadata]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=LossyWAV&amp;diff=25523</id>
		<title>LossyWAV</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=LossyWAV&amp;diff=25523"/>
		<updated>2013-10-22T10:13:57Z</updated>

		<summary type="html">&lt;p&gt;Skamp: /* Linux / OS X support: lossyWAV and WINE */ updated caudec URL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Software Infobox&lt;br /&gt;
| name = lossyWAV&lt;br /&gt;
| logo =&lt;br /&gt;
| screenshot = &lt;br /&gt;
| caption = &lt;br /&gt;
| maintainer = [http://www.hydrogenaudio.org/forums/index.php?showuser=42400 Nick.C]&lt;br /&gt;
| stable_release = 1.3.0&lt;br /&gt;
| preview_release = &amp;lt;none&amp;gt;&lt;br /&gt;
| operating_system = [[Wikipedia:Microsoft Windows|Windows]]&lt;br /&gt;
| use = [[Wikipedia:Digital signal processing|Digital signal processing]]&lt;br /&gt;
| license = [[Wikipedia:GNU General Public License|GNU GPL]]&lt;br /&gt;
| website = [http://www.hydrogenaudio.org/forums/index.php?showtopic=90104 1.3.0 release thread]&amp;lt;br /&amp;gt;[http://www.hydrogenaudio.org/forums/index.php?showtopic=81002 1.3.0 development thread]&lt;br /&gt;
}}&lt;br /&gt;
lossyWAV is a [[Wikipedia:Free software|free]], [[lossy]] pre-processor for [[PCM]] audio contained in the [[RIFF_WAVE|WAV]] file format. Proposed by [http://www.hydrogenaudio.org/forums/index.php?showuser=409 David Robinson], it reduces [[Wikipedia:Audio bit depth|bit depth]] of the input signal, which, when used in conjunction with certain lossless codecs, reduces the bitrate of the encoded file significantly compared to unpreprocessed compression.&lt;br /&gt;
lossyWAV&#039;s primary goal is to maintain [[transparency]] with a high degree of confidence when processing any audio data.&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
lossyWAV is based on the lossyFLAC idea proposed by [http://www.hydrogenaudio.org/forums/index.php?showuser=409 David Robinson] at Hydrogenaudio, which is a method of carefully reducing the bitdepth of (blocks of) samples which will then allow the FLAC lossless encoder to make use of its wasted bits feature. The aim is to transparently reduce audio bit depth (by making some lower significant bits ([[Wikipedia:Least_significant_bit|lsb]]&#039;s) zero), consequently taking advantage of FLAC&#039;s detection of consistently-zeroed lower significant bits within each single frame and significantly increasing coding efficiency.[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=55522&amp;amp;view=findpost&amp;amp;p=498179] In this way the user can enjoy audio encoded using the same codec (which may be all important from a hardware compatibility perspective) at a reduced bitrate compared to the lossless version.&lt;br /&gt;
&lt;br /&gt;
[http://www.hydrogenaudio.org/forums/index.php?showuser=42400 Nick Currie] ported the original [[Wikipedia:MATLAB|MATLAB]] implementation to [[Wikipedia:Borland Delphi|Delphi]] (Many thanks [[Wikipedia:CodeGear|CodeGear]] for Turbo Explorer!) with a liberal sprinkling of [[Wikipedia:IA-32|IA-32]] and [[Wikipedia:x87|x87]] Assembly Language for speed.&lt;br /&gt;
&lt;br /&gt;
Subsequently, lossyFLAC proved itself to work with other lossless codecs, so the application name was changed to lossyWAV. &lt;br /&gt;
&lt;br /&gt;
Since then, Nick has heavily developed and built upon lossyWAV, with valuable tuning performed by [http://www.hydrogenaudio.org/forums/index.php?showuser=25015 Horst Albrecht] at Hydrogenaudio. Although the current lossyWAV implementation has built on David&#039;s original method, the method itself still very much belongs to its author.&lt;br /&gt;
&lt;br /&gt;
==Indicative bitrate reduction==&lt;br /&gt;
It must be stressed that lossyWAV is a pure variable bit-depth pre-processor in that the overall sample size remains the same after processing but the number of significant bits used for the samples in a codec-block can change on a block-by-block basis. Bits-to-remove from the audio data are calculated on a block-by-block basis (codec-block length = 512 samples, 11.6msec @ 44.1kHz) using overlapping [[Wikipedia:fast Fourier transform|fast Fourier Transform]] (FFT) analyses of at least two lengths (default quality preset (-q 5) = 32, 64 &amp;amp; 1024 [[Wikipedia:Sampling %28signal processing%29|samples]]). After some manipulation, the results of each FFT analysis for a specific codec-block are then grouped and the minimum value used to determine bits-to-remove for the whole codec-block. Bit removal adds noise to the output, however the level of the added noise associated with the removal of a number of bits has been pre-calculated and the number of bits to remove will depend on the level of the noise floor of the codec-block in question. The added noise is adaptively shaped by default, however the user can select parameters to make the added noise fixed shaped or simply [[Wikipedia:white noise|white noise]]. Each sample in the codec-block is then rounded such that the first &amp;lt;bits-to-remove&amp;gt; lsb&#039;s are zero. In this way the wasted bits feature of [[FLAC]] et al. is exploited.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!lossyWAV Test Set (16 bit / 44.1kHz)&lt;br /&gt;
!Codec&lt;br /&gt;
!lossless&lt;br /&gt;
!--insane&lt;br /&gt;
!--extreme&lt;br /&gt;
!--high&lt;br /&gt;
!--standard&lt;br /&gt;
!--economic&lt;br /&gt;
!--portable&lt;br /&gt;
!--extraportable&lt;br /&gt;
|-&lt;br /&gt;
!10 Album Test Set&lt;br /&gt;
| FLAC&lt;br /&gt;
| 854 kbit/s&lt;br /&gt;
| 627 kbit/s&lt;br /&gt;
| 548 kbit/s&lt;br /&gt;
| 477 kbit/s&lt;br /&gt;
| 442 kbit/s&lt;br /&gt;
| 407 kbit/s&lt;br /&gt;
| 353 kbit/s&lt;br /&gt;
| 311 kbit/s&lt;br /&gt;
|-&lt;br /&gt;
!Nick.C&#039;s Full Collection&lt;br /&gt;
| FLAC&lt;br /&gt;
| 882 kbit/s&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 307 kbit/s&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==File identification==&lt;br /&gt;
lossyWAV-processed WAV files are named with a double filename extension, .lossy.wav, to make them instantly identifiable. e.g. &amp;quot;.lossy.flac&amp;quot; would indicate an audio file which was processed using lossyWAV, and subsequently encoded using FLAC.[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=55522&amp;amp;view=findpost&amp;amp;p=498559]&lt;br /&gt;
&lt;br /&gt;
The --correction parameter is used when processing to create a correction file which is named with the .lwcdf.wav double filename extension. When &amp;quot;added&amp;quot; to the corresponding .lossy.wav, using the --merge parameter, the original file will be reconstituted.&lt;br /&gt;
&lt;br /&gt;
Combinations of lossyWAV with each specific encoder are referred to as lossy&#039;&#039;&#039;X&#039;&#039;&#039;, where &#039;&#039;&#039;X&#039;&#039;&#039; is an abbreviation of the lossless codec name. Combination names are listed in the &amp;quot;[[LossyWAV#Known supported codecs|known supported codecs]]&amp;quot; section below.&lt;br /&gt;
&lt;br /&gt;
lossyWAV inserts a variable-length &#039;fact&#039; chunk into the WAV file immediately after the &#039;fmt &#039; chunk. This takes the form:&amp;lt;pre&amp;gt;fact/&amp;lt;size&amp;gt;/lossyWAV x.y.z @ dd/mm/yyyy hh:mm:ss, -q 5&amp;lt;/pre&amp;gt;Where the version, date &amp;amp; time and user settings are copied. Additionally, if a lossyWAV &#039;fact&#039; chunk is found in a file, the processing will be halted (exit code = 16) to prevent re-processing of an already processed file.&lt;br /&gt;
&lt;br /&gt;
The --check parameter can be used to determine whether a file has previously been processed without trying to process it, exit code = 16 if already processed; exit code = 0 if not.&lt;br /&gt;
&lt;br /&gt;
==Quality presets==&lt;br /&gt;
*--quality insane: (-q I or -q 10) Highest quality preset, generally considered to be excessive;&lt;br /&gt;
*--quality extreme: (-q E or -q 7.5) Higher quality preset, disc space-saving alternative to lossless archiving for large audio collections, considered to be suitable for transcoding to other lossy codecs;&lt;br /&gt;
*--quality high: (-q H or -q 5.0) High quality preset, midway between extreme and standard;&lt;br /&gt;
*--quality standard: (-q S or -q 2.5) Default preset, generally accepted to be transparent;&lt;br /&gt;
*--quality economic: (-q C or -q 0.0) Intermediate preset midway between standard and portable;&lt;br /&gt;
*--quality portable: (-q P or -q -2.5) DAP quality preset for use on a compatible [[Wikipedia:Digital audio player|DAP]].[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=56129&amp;amp;view=findpost&amp;amp;p=531316]&lt;br /&gt;
*--quality extraportable: (-q X or -q -5.0) Lowest quality preset for use on a compatible [[Wikipedia:Digital audio player|DAP]].[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=56129&amp;amp;view=findpost&amp;amp;p=531316]&lt;br /&gt;
&lt;br /&gt;
All tuning for version 1.0.0 was performed on quality preset --standard with higher presets being more conservative. For versions 1.1.0, 1.2.0 and 1.3.0, tuning effort has been focused on the lowest quality preset in an effort to achieve an effective compromise between resultant bitrate and perceived quality. Quality preset --standard is generally accepted to be (and from testing so far is) transparent. If you find a track which --standard fails to achieve transparency after processing, please post a sample (no more than 30 seconds) in the development thread.&lt;br /&gt;
&lt;br /&gt;
The upper frequency limit used in the calculation of minimum signal power varies, dependent on quality preset, in the range 15.159kHz to 16.682kHz&lt;br /&gt;
&lt;br /&gt;
==Supported input formats==&lt;br /&gt;
*[[WAV]]: 9-bit to 32-bit integer; 1 to 8 channels; sample rate &amp;amp;ge; 32kHz [[Pulse Code Modulation|PCM]]. Very high sample rates (&amp;amp;gt;48kHz) have not been extensively tested. Tunings have been focussed on 16-bit, 44.1kHz samples (i.e. [[Wikipedia:Red Book (audio CD standard)|CD]] PCM).&lt;br /&gt;
&lt;br /&gt;
==Codec compatibility==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Codec&lt;br /&gt;
!Supported&lt;br /&gt;
!Encoder parameters&lt;br /&gt;
!Combination name&lt;br /&gt;
|-&lt;br /&gt;
! [[Free Lossless Audio Codec|FLAC]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;5&#039;&#039;&#039; -&#039;&#039;&#039;b&#039;&#039;&#039; 512 --&#039;&#039;&#039;keep-foreign-metadata&#039;&#039;&#039;&lt;br /&gt;
| lossy&#039;&#039;&#039;FLAC&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Lossless Predictive Audio Compression|LPAC]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;b&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;LPAC&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Wikipedia:Audio Lossless Coding|MPEG-4 ALS]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;l&#039;&#039;&#039; -&#039;&#039;&#039;n&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;ALS&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[TAK]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;fsl&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;TAK&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[WavPack]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| --&#039;&#039;&#039;blocksize&#039;&#039;&#039;=512 --&#039;&#039;&#039;merge-blocks&#039;&#039;&#039;&lt;br /&gt;
| lossy&#039;&#039;&#039;WV&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Windows Media Audio#Windows Media Audio Lossless|WMA Lossless]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| lossy&#039;&#039;&#039;WMALSL&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Apple Lossless]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Lossless Audio|LA]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Monkey&#039;s Audio]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[OptimFROG]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Wikipedia:TTA (codec)|TTA]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* Combinations of lossyWAV with each specific encoder are referred to as lossy&#039;&#039;&#039;X&#039;&#039;&#039;, where &#039;&#039;&#039;X&#039;&#039;&#039; is an abbreviation of the lossless codec name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is also [http://www.hometheaterhifi.com/volume_8_4/dvd-benchmark-part-6-dvd-audio-11-2001.html#Meridian%20Lossless%20Packing%20(MLP)%20in%20a%20Nutshell evidence] &amp;amp;mdash; so-called &amp;quot;Bit Shifting&amp;quot; &amp;amp;mdash; to suggest that lossyWAV may work with [[Wikipedia:Meridian Lossless Packing|MLP]], but this remains untested due to prohibitive prices of encoders. At least one [http://www.hydrogenaudio.org/forums/index.php?showtopic=98609&amp;amp;hl= commercial DVD-A] uses constant bit-depth reduction with lower bit-depth on rear channels.&lt;br /&gt;
&lt;br /&gt;
A comparison of portable media players is [[Wikipedia:Comparison of portable media players#Audio Formats|here]], which shows FLAC and WMA Lossless compatibility among listed players.&lt;br /&gt;
Any player supported by [http://www.rockbox.org Rockbox] can use FLAC or WavPack files after installing Rockbox.&lt;br /&gt;
===Important note===&lt;br /&gt;
&#039;&#039;&#039;NB: when encoding using a lossless codec, please ensure that the block size of the lossless codec matches that of lossyWAV (default = 512 samples). If this is not done then the lossless encoding of the processed WAV file will (almost certainly) be larger than it would otherwise have been. This is achieved by adding the &amp;quot;Encoder Parameters&amp;quot; in the table above to the command line of the lossless codec in question.&#039;&#039;&#039;&lt;br /&gt;
===Bonus feature===&lt;br /&gt;
Another, possibly not obvious, feature of lossyWAV is that the processed output can be &amp;quot;transcoded&amp;quot; from one lossless codec to another lossless codec with absolutely no loss of quality whatsoever. This is solely due to the fact that lossyWAV output is designed to be losslessly encoded - something that lossless codecs do very well indeed.&lt;br /&gt;
&lt;br /&gt;
==Using lossyWAV==&lt;br /&gt;
===Application settings===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lossyWAV 1.3.0, Copyright (C) 2007-2011 Nick Currie. Copyleft.&lt;br /&gt;
&lt;br /&gt;
This program is free software: you can redistribute it and/or modify it under&lt;br /&gt;
the terms of the GNU General Public License as published by the Free Software&lt;br /&gt;
Foundation, either version 3 of the License, or (at your option) any later&lt;br /&gt;
version.&lt;br /&gt;
&lt;br /&gt;
This program is distributed in the hope that it will be useful,but WITHOUT ANY&lt;br /&gt;
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A&lt;br /&gt;
PARTICULAR PURPOSE.  See the GNU General Public License for more details.&lt;br /&gt;
&lt;br /&gt;
You should have received a copy of the GNU General Public License along with&lt;br /&gt;
this program.  If not, see &amp;lt;http://www.gnu.org/licenses/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Process Description:&lt;br /&gt;
&lt;br /&gt;
lossyWAV is a near lossless audio processor which dynamically reduces the &lt;br /&gt;
bitdepth of the signal on a block-by-block basis. Bitdepth reduction adds noise&lt;br /&gt;
to the processed output. The amount of permissible added noise is based on&lt;br /&gt;
analysis of the signal levels in the default frequency range 20Hz to 16kHz.&lt;br /&gt;
&lt;br /&gt;
If signals above the upper limiting frequency are at an even lower level, they&lt;br /&gt;
can be swamped by the added noise. This is usually inaudible, but the behaviour&lt;br /&gt;
can be changed by specifying a different --limit (in the range 10kHz to 20kHz).&lt;br /&gt;
&lt;br /&gt;
For many audio signals there is little content at very high frequencies and&lt;br /&gt;
forcing lossyWAV to keep the added noise level lower than the content at these&lt;br /&gt;
frequencies can increase the bitrate dramatically for no perceptible benefit.&lt;br /&gt;
&lt;br /&gt;
The noise added by the process is shaped using an adaptive method provided by&lt;br /&gt;
Sebastian Gesemann. This method, as implemented in lossyWAV, aims to use the&lt;br /&gt;
signal itself as the basis of the filter used for noise shaping. Adaptive noise&lt;br /&gt;
shaping is enabled by default.&lt;br /&gt;
&lt;br /&gt;
Usage   : lossyWAV &amp;lt;input wav file&amp;gt; &amp;lt;options&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example : lossyWAV musicfile.wav&lt;br /&gt;
&lt;br /&gt;
Quality Options:&lt;br /&gt;
&lt;br /&gt;
-q, --quality &amp;lt;t&amp;gt;    where t is one of the following (default = standard):&lt;br /&gt;
    I, insane        highest quality output, suitable for transcoding;&lt;br /&gt;
    E, extreme       higher quality output, suitable for transcoding;&lt;br /&gt;
    H, high          high quality output, suitable for transcoding;&lt;br /&gt;
    S, standard      default quality output, considered to be transparent;&lt;br /&gt;
    C, economic      intermediate quality output, likely to be transparent;&lt;br /&gt;
    P, portable      good quality output for DAP use, may not be transparent;&lt;br /&gt;
    X, extraportable lowest quality output, not fully transparent.&lt;br /&gt;
&lt;br /&gt;
Standard Options:&lt;br /&gt;
&lt;br /&gt;
-C, --correction     write correction file for processed WAV file; default=off.&lt;br /&gt;
-f, --force          forcibly over-write output file if it exists; default=off.&lt;br /&gt;
-h, --help           display help.&lt;br /&gt;
-L, --longhelp       display extended help.&lt;br /&gt;
-M, --merge          merge existing lossy.wav and lwcdf.wav files.&lt;br /&gt;
-o, --outdir &amp;lt;t&amp;gt;     destination directory for the output file(s).&lt;br /&gt;
-v, --version        display the lossyWAV version number.&lt;br /&gt;
-w, --writetolog     create (or add to) lossyWAV.log in the output directory.&lt;br /&gt;
&lt;br /&gt;
Advanced Options:&lt;br /&gt;
&lt;br /&gt;
-                    take WAV input from STDIN.&lt;br /&gt;
-c, --check          check if WAV file has already been processed; default=off.&lt;br /&gt;
                     errorlevel=16 if already processed, 0 if not.&lt;br /&gt;
-q, --quality &amp;lt;n&amp;gt;    quality preset (-5.0&amp;lt;=n&amp;lt;=10.0); (-5=lowest, 10=highest;&lt;br /&gt;
                     default=2.5; I=10; E=7.5; H=5; S=2.5; C=0; P=-2.5; X=-5).&lt;br /&gt;
--, --stdout         write WAV output to STDOUT.&lt;br /&gt;
    --stdinname &amp;lt;t&amp;gt;  pseudo filename to use when input from STDIN.&lt;br /&gt;
&lt;br /&gt;
Advanced Quality Options:&lt;br /&gt;
&lt;br /&gt;
-A, --adaptive &amp;lt;n/t&amp;gt; modify settings for Sebastian Gesemann&#039;s adaptive noise&lt;br /&gt;
                     shaping method. takes a parameter to set the order of the&lt;br /&gt;
                     FIR filter, (32&amp;lt;=n&amp;lt;=96; default=64; multiple of 8 only);&lt;br /&gt;
                     &amp;quot;OFF&amp;quot; to disable adaptive shaping; &amp;quot;NOWARP&amp;quot; to disable &lt;br /&gt;
                     default frequency warping;&lt;br /&gt;
-a, --analyses &amp;lt;n&amp;gt;   set number of FFT analysis lengths, (2&amp;lt;=n&amp;lt;=6; default=3,&lt;br /&gt;
                     i.e. 32, 64 &amp;amp; 1024 samples. n=2, remove 32 sample FFT;&lt;br /&gt;
                     n&amp;gt;3 add 512; n&amp;gt;4, add 256; n&amp;gt;6, add 128) nb. FFT lengths.&lt;br /&gt;
                     stated are for 44.1/48kHz audio, higher sample rates will&lt;br /&gt;
                     automatically increase all FFT lengths as required.&lt;br /&gt;
-l, --limit &amp;lt;n&amp;gt;      set upper frequency limit to be used in analyses to n Hz;&lt;br /&gt;
                     (10000&amp;lt;=n&amp;lt;=20000; default=16000).&lt;br /&gt;
    --linkchannels   revert to original single bits-to-remove value for all&lt;br /&gt;
                     channels rather than channel dependent bits-to-remove.&lt;br /&gt;
    --maxclips &amp;lt;n&amp;gt;   set max. number of acceptable clips per channel per block;&lt;br /&gt;
                     (0&amp;lt;=n&amp;lt;=16; default=3,3,3,3,3,2,2,2,2,2,1,1,1,0,0,0).&lt;br /&gt;
-m, --midside        analyse 2 channel audio for mid/side content.&lt;br /&gt;
    --nodccorrect    disable DC correction of audio data prior to FFT analysis,&lt;br /&gt;
                     default=on; (DC offset calculated per FFT data set).&lt;br /&gt;
    --scale &amp;lt;n&amp;gt;      factor to scale audio by; (0.0625&amp;lt;n&amp;lt;=8.0; default=1).&lt;br /&gt;
-s, --shaping [n]    enable fixed noise shaping, takes optional parameter [n]&lt;br /&gt;
                     to allow user defined shaping proportion (0.0&amp;lt;=n&amp;lt;=1.0),&lt;br /&gt;
                     otherwise default to quality setting dependent value.&lt;br /&gt;
                     Disables adaptive noise shaping.&lt;br /&gt;
    --static &amp;lt;n&amp;gt;     set minimum-bits-to-keep-static to n bits (default=6;&lt;br /&gt;
                     7&amp;lt;=n&amp;lt;=28, limited to bits-per-sample - 4).&lt;br /&gt;
-U, --underlap &amp;lt;n&amp;gt;   enable underlap mode to increase number of FFT analyses&lt;br /&gt;
                     performed at each FFT length, (n = 2, 4 or 8, default=2).&lt;br /&gt;
&lt;br /&gt;
Output Options:&lt;br /&gt;
&lt;br /&gt;
    --bitdist        show distrubution of bits to remove.&lt;br /&gt;
    --blockdist      show distribution of lowest / highest significant bit of&lt;br /&gt;
                     input codec-blocks and bit-removed codec-blocks.&lt;br /&gt;
-d, --detail         enable per block per channel bits-to-remove data display.&lt;br /&gt;
-F, --freqdist       enable frequency analysis display of input data.&lt;br /&gt;
-H, --histogram      show sample value histogram (input, lossy and correction).&lt;br /&gt;
    --longdist       show long frequency distribution data (input/lossy/lwcdf).&lt;br /&gt;
    --perchannel     show selected distribution data per channel.&lt;br /&gt;
-p, --postanalyse    enable frequency analysis display of output and&lt;br /&gt;
                     correction data in addition to input data.&lt;br /&gt;
    --sampledist     show distribution of lowest / highest significant bit of&lt;br /&gt;
                     input samples and bit-removed samples.&lt;br /&gt;
    --spread [full]  show detailed [more detailed] results from the spreading/&lt;br /&gt;
                     averaging algorithm.&lt;br /&gt;
-W, --width &amp;lt;n&amp;gt;      select width of output options (79&amp;lt;=n&amp;lt;=255).&lt;br /&gt;
&lt;br /&gt;
System Options:&lt;br /&gt;
&lt;br /&gt;
-B, --below          set process priority to below normal.&lt;br /&gt;
    --low            set process priority to low.&lt;br /&gt;
-N, --nowarnings     suppress lossyWAV warnings.&lt;br /&gt;
-Q, --quiet          significantly reduce screen output.&lt;br /&gt;
-S, --silent         no screen output.&lt;br /&gt;
&lt;br /&gt;
Special thanks go to:&lt;br /&gt;
&lt;br /&gt;
David Robinson       for the publication of his lossyFLAC method, guidance, and&lt;br /&gt;
                     the motivation to implement his method as lossyWAV.&lt;br /&gt;
&lt;br /&gt;
Horst Albrecht       for ABX testing, valuable support in tuning the internal&lt;br /&gt;
                     presets, constructive criticism and all the feedback.&lt;br /&gt;
&lt;br /&gt;
Sebastian Gesemann   for the adaptive noise shaping method and the amount of&lt;br /&gt;
                     help received in implementing it and also for the basis of&lt;br /&gt;
                     the fixed noise shaping method.&lt;br /&gt;
&lt;br /&gt;
Matteo Frigo and     for libfftw3-3.dll contained in the FFTW distribution&lt;br /&gt;
Steven G Johnson     (v3.2.1 or v3.2.2).&lt;br /&gt;
&lt;br /&gt;
Mark G Beckett       for the Delphi unit that provides an interface to the&lt;br /&gt;
(Univ. of Edinburgh) relevant fftw routines in libfftw3-3.dll.&lt;br /&gt;
&lt;br /&gt;
Don Cross            for the Complex-FFT algorithm originally used.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example drag &#039;n&#039; drop batch file===&lt;br /&gt;
Simply drag the FLAC files onto this batch file and it will process, recode in FLAC and copy ALL of the tags from the input FLAC file, placing the output lossyFLAC file in the same directory as the input FLAC file. Requires flac.exe and [http://www.synthetic-soul.co.uk/tag/ tag.exe] to be somewhere on the path. &lt;br /&gt;
&amp;lt;pre&amp;gt;@echo off&lt;br /&gt;
:repeat&lt;br /&gt;
if %1.==. goto end&lt;br /&gt;
if exist &amp;quot;%1&amp;quot; flac -d &amp;quot;%1&amp;quot; --stdout --silent|lossywav - --stdout --standard --stdinname &amp;quot;%1&amp;quot;|flac - -b 512 -o &amp;quot;%~dpn1.lossy.flac&amp;quot; --silent &amp;amp;&amp;amp; tag --fromfile &amp;quot;%1&amp;quot; &amp;quot;%~dpn1.lossy.flac&amp;quot;&lt;br /&gt;
shift&lt;br /&gt;
goto repeat&lt;br /&gt;
:end&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and FFTW===&lt;br /&gt;
Since version 1.2.0, lossyWAV has been compatible with [[Wikipedia:FFTW|FFTW]] although not dependent on it. Should the user wish to take advantage of the increased processing speed available when using FFTW (from superior FFT implementations), libfftw3-3.dll should be placed in a directory on the host computer which features on the path.&lt;br /&gt;
&lt;br /&gt;
===Linux / OS X support: lossyWAV and WINE===&lt;br /&gt;
The cause of lossyWAV&#039;s WINE incompatibility was found and removed during the development of 1.2.0 and retrospectively amended for 1.1.0b in a maintenance release (1.1.0c). The latest stable version (1.3.0 at the time of writing) is fully supported.&lt;br /&gt;
&lt;br /&gt;
[http://caudec.net/ caudec] is a command-line tool that can encode and decode lossyWAV files (lossyFLAC, lossyWV, lossyTAK), using the official binary (lossyWAV.exe) with Wine (see: [http://caudec.net/documentation/windowscodecs/ installation instructions]). Caudec can also test file integrity and compute (and tag) Replaygain data. While it hasn&#039;t been tested at the time of writing, it is possible that lossyWAV support in caudec works on OS X as well.&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and [[foobar2000]]===&lt;br /&gt;
Example [[foobar2000]] converter settings:&lt;br /&gt;
&lt;br /&gt;
lossyFLAC settings:&amp;lt;pre&amp;gt;Encoder: C:\Windows\System32\cmd.exe&lt;br /&gt;
Extension : lossy.flac&lt;br /&gt;
Parameters: /d /c C:\&amp;quot;Program Files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|&lt;br /&gt;
            C:\&amp;quot;Program Files&amp;quot;\bin\flac - -b 512 -5 -f -o%d --ignore-chunk-sizes&lt;br /&gt;
Format is : lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyTAK settings:&amp;lt;pre&amp;gt;Encoder: C:\Windows\System32\cmd.exe&lt;br /&gt;
Extension  : lossy.tak&lt;br /&gt;
Parameters : /d /c C:\&amp;quot;Program Files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|&lt;br /&gt;
             C:\&amp;quot;Program Files&amp;quot;\bin\takc -e -p2m -fsl512 -ihs - %d&lt;br /&gt;
Format is: lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyWV settings:&amp;lt;pre&amp;gt;Encoder: C:\Windows\System32\cmd.exe&lt;br /&gt;
Extension : lossy.wv&lt;br /&gt;
Parameters: /d /c C:\&amp;quot;Program Files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|&lt;br /&gt;
            C:\&amp;quot;Program Files&amp;quot;\bin\wavpack -hm --blocksize=512 --merge-blocks -i - %d&lt;br /&gt;
Format is : lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyWMALSL* settings:&amp;lt;pre&amp;gt;Encoder: C:\Windows\System32\cmd.exe&lt;br /&gt;
Extension : lossy.wma&lt;br /&gt;
Parameters : /d /c c:\&amp;quot;program files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|&lt;br /&gt;
             c:\&amp;quot;program files&amp;quot;\bin\wmaencode - %d --codec lsl --ignorelength&lt;br /&gt;
Format is : lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enclose the element of the path containing spaces within double quotation marks (&amp;quot;), e.g. C:\&amp;quot;Program Files&amp;quot;\directory_where_executable_is\executable_name. This is a Windows limitation.&lt;br /&gt;
&lt;br /&gt;
lossyWMALSL conversion uses WMAEncode.exe by lvqcl found [http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=90519&amp;amp;view=findpost&amp;amp;p=767754 here].&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and EAC===&lt;br /&gt;
:&#039;&#039;For example settings, see [[EAC and LossyWAV]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Frequently asked questions==&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why is the &amp;quot;.wav&amp;quot; file extension used?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039; The &amp;quot;.wav&amp;quot; file extension is used because lossyWAV is a digital signal processor and not a codec. No decoding is required for any program to play a WAV file which has been processed with lossyWAV as it remains compliant with the RIFF WAVE format.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why create a processor which means that I cannot be sure that a lossless file is truly lossless?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039; Unless one creates the lossless file personally, one can &#039;&#039;&#039;never&#039;&#039;&#039; be completely sure that the file is indeed lossless. E.g. a lossless file you receive could be transcoded from [[MP3]] without your knowledge. To distinguish a lossyWAV file from lossless files it is recommended to use the extension .lossy.EXT where EXT is the original extension e.g. .lossy.flac&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[Variable Bitrate|VBR]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; Yes.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Do I need to re-process to change lossless codecs?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[transparency|transparent]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; At preset --standard, almost certainly.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[lossless]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Will it ever have a [[Constant Bitrate|CBR]] mode?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Will it low-pass filter my audio?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No. The frequency limit is for the analysis only. LossyWAV cannot low-pass filter your audio.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why should I use this?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039;&lt;br /&gt;
:*high quality&lt;br /&gt;
:*extremely low chance of audible [[artifact]]s&lt;br /&gt;
:*reasonable [[bitrate]]s&lt;br /&gt;
:*usable with unmodified, established lossless formats.&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=55522 Original lossyFLAC thread] - Introduction of the concept by David Robinson (Replay Gain developer) and initial development&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=96635 lossyWAV 1.3.1 Delphi to C++ translation thread]&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=81002 lossyWAV 1.3.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=90104 lossyWAV 1.3.0 release thread] - Release of version 1.3.0 on 06 August 2011&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=65499 lossyWAV 1.2.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=77042 lossyWAV 1.2.0 release thread] - Release of version 1.2.0 on 16 December 2009&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=63254 lossyWAV 1.1.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=64617 lossyWAV 1.1.0 release thread] - Release of version 1.1.0 on 12 July 2008&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=56129 lossyWAV Development thread] - Conversion of the original MATLAB script to Delphi and evolution of the method&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=63225 lossyWAV 1.0.0 release thread] - Release of version 1.0.0b on 12 May 2008&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=TAK&amp;diff=25522</id>
		<title>TAK</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=TAK&amp;diff=25522"/>
		<updated>2013-10-22T10:13:11Z</updated>

		<summary type="html">&lt;p&gt;Skamp: /* Linux */ updated caudec URL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Codec Infobox&lt;br /&gt;
| name = Tom&#039;s lossless Audio Kompressor&lt;br /&gt;
| logo =&lt;br /&gt;
| type = lossless&lt;br /&gt;
| purpose = lossless audio compression.&lt;br /&gt;
| maintainer = Thomas Becker&lt;br /&gt;
| recommended_encoder = TAK encoder&lt;br /&gt;
| recommended_text = TAK v2.3.0&lt;br /&gt;
| website = [http://thbeck.de/Tak/Tak.html ThBeck.de/Tak/Tak.html] &#039;&#039;(german)&#039;&#039;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&#039;&#039;&#039;Tom&#039;s lossless Audio Kompressor&#039;&#039;&#039; (&#039;&#039;&#039;TAK&#039;&#039;&#039;) is a lossless audio compressor which promises compression performance similar to [[Monkey&#039;s Audio]] “High” and decompression speed similar to [[Free Lossless Audio Codec|FLAC]].&lt;br /&gt;
&lt;br /&gt;
=== Features ===&lt;br /&gt;
* High compression&lt;br /&gt;
* Fast compression and decompression speed&lt;br /&gt;
* Streaming support (necessary headers for decompressing the audio are written to the stream every 2 seconds)&lt;br /&gt;
* Piping support for encoding&lt;br /&gt;
* Error tolerance (single bit error will never affect more than 250 ms)&lt;br /&gt;
* Error detection (each frame protected by a 24-bit checksum (CRC))&lt;br /&gt;
* High-resolution (up to 24-bit/channel) audio support&lt;br /&gt;
* Support for up to 192 Khz Audio&lt;br /&gt;
* Seeking without seek table&lt;br /&gt;
* APEv2 tags supported at end of file&lt;br /&gt;
&lt;br /&gt;
=== Pros ===&lt;br /&gt;
* Fast encoding speed (while providing better compression TAK encodes as fast as [[Free Lossless Audio Codec|FLAC]] -8 in TAK&#039;s “Insane” and several times faster in “Turbo” mode)&lt;br /&gt;
* Fast decompression speed (on par with FLAC / [[WavPack]])&lt;br /&gt;
* Good compression levels (on par with [[Monkey&#039;s Audio]] High)&lt;br /&gt;
* Error Robustness&lt;br /&gt;
* Fast Seeking&lt;br /&gt;
&lt;br /&gt;
=== Cons ===&lt;br /&gt;
* Closed Source&lt;br /&gt;
* No hardware support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software support ==&lt;br /&gt;
=== Windows ===&lt;br /&gt;
* [http://thbeck.de/Download/TAK_2.3.0.zip TAK 2.3.0] - Official release which consists of a CLI, a GUI, a [[Winamp]] plugin, the SDK, and the decoding library.&lt;br /&gt;
* [http://www.foobar2000.org/components/view/foo_input_tak TAK Decoder 0.4.7] - Plugin for [[foobar2000]] (supports tagging and [[ReplayGain]]).&lt;br /&gt;
* [http://www.liviocavallo.altervista.org/ dsfTAKSource 0.0.1.6] - DirectShow source filter which uses the official decoding library to play TAK-files in Windows Media Player, Media Player Classic - Home Cinema, Zoom Player and alike.&lt;br /&gt;
* [http://reino.degeelebosch.nl/ DC-Bass Source Mod 1.5.2.0] - DirectShow source filter which uses the official decoding library to play TAK-files, amongst many others, in any DirectShow media player (as mentioned above).&lt;br /&gt;
* [http://code.google.com/p/lavfilters/ LAV Filters] - Set of open-source DirectShow filters which uses [http://www.hydrogenaudio.org/forums/index.php?showtopic=96976&amp;amp;view=findpost&amp;amp;p=810355 FFMpeg&#039;s reverse-engineered decoder] to play TAK-files in any DirectShow media player.&lt;br /&gt;
* [http://sourceforge.net/projects/mpcbe/ Media Player Classic - BE] - DirectShow media player with an internal TAK source filter which uses FFMpeg&#039;s reverse-engineered decoder to play TAK-files. The internal TAK source filter also supports embedded cue-sheets.&lt;br /&gt;
* [[Mp3tag]] – universal tag editor with support for TAK&lt;br /&gt;
* [http://etree.org/shnutils/shntool/ shntool] (since version 3.0.6)&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
* ffmpeg can demux, decode and parse TAK since commit d7a473926504e2acfa6ae3bead0938e1f4e03441:[http://git.videolan.org/?p=ffmpeg.git;a=commit;h=d7a473926504e2acfa6ae3bead0938e1f4e03441]. First official release that supports TAK decoding is 1.1.&lt;br /&gt;
* The GUI program (Tak.exe) and the command-line program (Takc.exe) work with [http://www.winehq.org/ Wine].&lt;br /&gt;
* [http://caudec.net/ caudec] is a command-line tool that can encode and decode TAK files, using the official binary (Takc.exe) with Wine (see: [http://caudec.net/documentation/windowscodecs/ installation instructions]). Caudec can also test file integrity and compute (and tag) Replaygain data. While it hasn&#039;t been tested at the time of writing, it is possible that TAK support in caudec works on OS X as well.&lt;br /&gt;
&lt;br /&gt;
== Hardware support ==&lt;br /&gt;
* None&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended Settings ==&lt;br /&gt;
* Default compression: “-p2” (formerly &#039;&#039;Normal&#039;&#039;) is the most attractive setting, providing an excellent compromise between compression and encoding speed. (At compression levels close to [[Monkey&#039;s Audio]] High (&amp;lt;0.4% difference), it is able to encode more quickly.)&lt;br /&gt;
 takc -e [input file]&lt;br /&gt;
* Highest compression: “-pMax” (same as -p4m) (This will create files which are comparable in size to file created using [[Monkey&#039;s Audio]] High. Decompression speed is comparable to [[WavPack]] Normal.)&lt;br /&gt;
 takc -e -pMax [input file]&lt;br /&gt;
* Fastest compression: “-p0” (This will create files which are comparable in size to [[Monkey&#039;s Audio]] Fast or [[WavPack]] High. Decompression speed is comparable to [[Free Lossless Audio Codec|FLAC]] 0.)&lt;br /&gt;
 takc -e -p0 [input file]&lt;br /&gt;
&lt;br /&gt;
=== TAK Performance Graph ===&lt;br /&gt;
[[Image:TAK_performance_graph_1-0-4.png|frame|center|Graph showing encoding and decoding rate against compression, using data from Synthetic Soul&#039;s test on TAK 1.0.4&amp;lt;br /&amp;gt;(see [[TAK#External Links|External Links]])]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using TAK ==&lt;br /&gt;
=== TAK with [[foobar2000]] ===&lt;br /&gt;
* Copy the takc.exe to your [[foobar2000]] directory&lt;br /&gt;
* Go to File → Preferences → Tools → Converter&lt;br /&gt;
* Set it up as shown:&lt;br /&gt;
[[Image:Tak_foobar_converter.png|frame|center|Screenshot of foobar 0.9.5 Converter settings for TAK 1.0.3]]&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; replace -p2 with the desired compression level.&lt;br /&gt;
&lt;br /&gt;
* TAK introduced encoding from STDIN in version 1.0.3, eliminating the need for a temporary file and greatly improving overall compression time. If you are using an earlier version of TAK use the following command line instead:&lt;br /&gt;
 -e -p2 %s %d&lt;br /&gt;
* Use [[APEv2 specification|APEv2]] tagging (will be used as internal tagging)&lt;br /&gt;
&lt;br /&gt;
=== TAK with EAC ===&lt;br /&gt;
Please read the [[EAC and TAK|wiki guide]], which details how to create TAK files with [[Exact Audio Copy|EAC]].&lt;br /&gt;
&lt;br /&gt;
=== Converting TAK using pipe ===&lt;br /&gt;
 Takc.exe -d input.tak - | lame.exe -V 6 - output.mp3&lt;br /&gt;
 Takc.exe -d input.tak - | opusenc.exe --bitrate 64 - output.opus&lt;br /&gt;
 Takc.exe -d input.tak - | flac.exe -8 - -o output.flac&lt;br /&gt;
 Takc.exe -d input.tak - | wavpack.exe -hhx - output.wv&lt;br /&gt;
&lt;br /&gt;
 flac.exe -dc input.flac | Takc.exe -e -pMax - output.tak&lt;br /&gt;
 wvunpack.exe input.wv - | Takc.exe -e -pMax - output.tak&lt;br /&gt;
 ffmpeg.exe -i input.xxx -f wav - | Takc.exe -e -pMax &#039;&#039;&#039;-ihs&#039;&#039;&#039; - output.tak&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Future Features ==&lt;br /&gt;
* Unicode support&lt;br /&gt;
* MD5 audio checksums for verification and identification&lt;br /&gt;
* A German version&lt;br /&gt;
* Embedded cue sheets&lt;br /&gt;
* Embedded cover art&lt;br /&gt;
* Multichannel audio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
; Is the codec safe for use/definitely lossless?&lt;br /&gt;
: Yes, TAK is verified as being lossless, as determined through rigorous testing by the author and satisfied users. To check, convert a WAV to TAK and back and compare the two, for instance using [[Foobar2000:Foobar2000|foobar2000]]&#039;s [[Foobar2000:Components/Binary Comparator (foo_bitcompare)|Binary Comparator]].&lt;br /&gt;
; Why should I use TAK?&lt;br /&gt;
: TAK offers high ratios of compression but also great decoding speeds.&lt;br /&gt;
; What can I compress with TAK?&lt;br /&gt;
: TAK 1.0 can compress any integer-format (up to 24 bits per channel) PCM RIFF WAVE file (.WAV). Piping support is implemented as of v1.0.3, so converting lossless files to WAV first is not necessary: users can simply pipe the decompressed output from their decoder of choice directly into TAK&#039;s encoder.&lt;br /&gt;
; What about hardware support?&lt;br /&gt;
: There is none at the moment. However, &#039;&#039;-p0&#039;&#039;, &#039;&#039;-p1&#039;&#039; and &#039;&#039;-p2&#039;&#039; are the candidates for most suitable settings for hardware.&lt;br /&gt;
; Will the source be opened?&lt;br /&gt;
: The official encoder and decoder are currently closed-source. Thomas has expressed an intention to open the source of the decoder at some point in time, stipulating preconditions of its first being further refined, ported to C or C++, and documented. This may or may not lead to releases of other code. However, as of June of 2013, he feels that “a lot of (not very exciting) work is required” until the decoding source would be ready to be published, and that may or may not happen in the foreseeable future. Such questions generally generate more noise than fruitful discussion, so it is best to wait and see what happens. In any case, there is an independently implemented open source decoder available, bundled with ffmpeg.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://thbeck.de/Tak/Tak.html thbeck.de/Tak/Tak.html] – Official Website &#039;&#039;(german)&#039;&#039;&lt;br /&gt;
* [http://www.hydrogenaudio.org/forums/index.php?showtopic=101386 TAK 2.3.0 Discussion Thread on HA] &#039;&#039;(english)&#039;&#039;&lt;br /&gt;
* [http://www.hydrogenaudio.org/forums/index.php?showtopic=89610 TAK 2.2.0 Discussion Thread on HA] &#039;&#039;(english)&#039;&#039;&lt;br /&gt;
* [http://synthetic-soul.co.uk/comparison/lossless/ synthetic-soul.co.uk/comparison/lossless] – Comparison with Other Codecs (by Synthetic Soul)&lt;br /&gt;
* [http://flac.sourceforge.net/comparison.html flac.sourceforge.net/comparison.html] – An Updated Comparison (from FLAC Homepage)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Lossless]]&lt;br /&gt;
[[Category:Encoder/Decoder]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=LossyWAV&amp;diff=25163</id>
		<title>LossyWAV</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=LossyWAV&amp;diff=25163"/>
		<updated>2013-06-04T17:47:09Z</updated>

		<summary type="html">&lt;p&gt;Skamp: added caudec to the list of Linux software that supports lossyWAV&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Software Infobox&lt;br /&gt;
| name = lossyWAV&lt;br /&gt;
| logo =&lt;br /&gt;
| screenshot = &lt;br /&gt;
| caption = &lt;br /&gt;
| maintainer = [http://www.hydrogenaudio.org/forums/index.php?showuser=42400 Nick.C]&lt;br /&gt;
| stable_release = 1.3.0&lt;br /&gt;
| preview_release = &amp;lt;none&amp;gt;&lt;br /&gt;
| operating_system = [[Wikipedia:Microsoft Windows|Windows]]&lt;br /&gt;
| use = [[Wikipedia:Digital signal processing|Digital signal processing]]&lt;br /&gt;
| license = [[Wikipedia:GNU General Public License|GNU GPL]]&lt;br /&gt;
| website = [http://www.hydrogenaudio.org/forums/index.php?showtopic=90104 1.3.0 release thread]&amp;lt;br /&amp;gt;[http://www.hydrogenaudio.org/forums/index.php?showtopic=81002 1.3.0 development thread]&lt;br /&gt;
}}&lt;br /&gt;
lossyWAV is a [[Wikipedia:Free software|free]], [[lossy]] pre-processor for [[PCM]] audio contained in the [[RIFF_WAVE|WAV]] file format. Proposed by [http://www.hydrogenaudio.org/forums/index.php?showuser=409 David Robinson], it reduces [[Wikipedia:Audio bit depth|bit depth]] of the input signal, which, when used in conjunction with certain lossless codecs, reduces the bitrate of the encoded file significantly compared to unpreprocessed compression.&lt;br /&gt;
lossyWAV&#039;s primary goal is to maintain [[transparency]] with a high degree of confidence when processing any audio data.&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
lossyWAV is based on the lossyFLAC idea proposed by [http://www.hydrogenaudio.org/forums/index.php?showuser=409 David Robinson] at Hydrogenaudio, which is a method of carefully reducing the bitdepth of (blocks of) samples which will then allow the FLAC lossless encoder to make use of its wasted bits feature. The aim is to transparently reduce audio bit depth (by making some lower significant bits ([[Wikipedia:Least_significant_bit|lsb]]&#039;s) zero), consequently taking advantage of FLAC&#039;s detection of consistently-zeroed lower significant bits within each single frame and significantly increasing coding efficiency.[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=55522&amp;amp;view=findpost&amp;amp;p=498179] In this way the user can enjoy audio encoded using the same codec (which may be all important from a hardware compatibility perspective) at a reduced bitrate compared to the lossless version.&lt;br /&gt;
&lt;br /&gt;
[http://www.hydrogenaudio.org/forums/index.php?showuser=42400 Nick Currie] ported the original [[Wikipedia:MATLAB|MATLAB]] implementation to [[Wikipedia:Borland Delphi|Delphi]] (Many thanks [[Wikipedia:CodeGear|CodeGear]] for Turbo Explorer!!) with a liberal sprinkling of [[Wikipedia:IA-32|IA-32]] and [[Wikipedia:x87|x87]] Assembly Language for speed.&lt;br /&gt;
&lt;br /&gt;
Subsequently, lossyFLAC proved itself to work with other lossless codecs, so the application name was changed to lossyWAV. &lt;br /&gt;
&lt;br /&gt;
Since then, Nick has heavily developed and built upon lossyWAV, with valuable tuning performed by [http://www.hydrogenaudio.org/forums/index.php?showuser=25015 Horst Albrecht] at Hydrogenaudio. Although the current lossyWAV implementation has built on David&#039;s original method, the method itself still very much belongs to its author.&lt;br /&gt;
&lt;br /&gt;
==Indicative bitrate reduction==&lt;br /&gt;
It must be stressed that lossyWAV is a pure variable bit-depth pre-processor in that the overall sample size remains the same after processing but the number of significant bits used for the samples in a codec-block can change on a block-by-block basis. Bits-to-remove from the audio data are calculated on a block-by-block basis (codec-block length = 512 samples, 11.6msec @ 44.1kHz) using overlapping [[Wikipedia:fast Fourier transform|fast Fourier Transform]] (FFT) analyses of at least two lengths (default quality preset (-q 5) = 32, 64 &amp;amp; 1024 [[Wikipedia:Sampling %28signal processing%29|samples]]). After some manipulation, the results of each FFT analysis for a specific codec-block are then grouped and the minimum value used to determine bits-to-remove for the whole codec-block. Bit removal adds noise to the output, however the level of the added noise associated with the removal of a number of bits has been pre-calculated and the number of bits to remove will depend on the level of the noise floor of the codec-block in question. The added noise is adaptively shaped by default, however the user can select parameters to make the added noise fixed shaped or simply [[Wikipedia:white noise|white noise]]. Each sample in the codec-block is then rounded such that the first &amp;lt;bits-to-remove&amp;gt; lsb&#039;s are zero. In this way the wasted bits feature of [[FLAC]] et al. is exploited.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!lossyWAV Test Set (16 bit / 44.1kHz)&lt;br /&gt;
!Codec&lt;br /&gt;
!lossless&lt;br /&gt;
!--insane&lt;br /&gt;
!--extreme&lt;br /&gt;
!--high&lt;br /&gt;
!--standard&lt;br /&gt;
!--economic&lt;br /&gt;
!--portable&lt;br /&gt;
!--extraportable&lt;br /&gt;
|-&lt;br /&gt;
!10 Album Test Set&lt;br /&gt;
| FLAC&lt;br /&gt;
| 854 kbit/s&lt;br /&gt;
| 627 kbit/s&lt;br /&gt;
| 548 kbit/s&lt;br /&gt;
| 477 kbit/s&lt;br /&gt;
| 442 kbit/s&lt;br /&gt;
| 407 kbit/s&lt;br /&gt;
| 353 kbit/s&lt;br /&gt;
| 311 kbit/s&lt;br /&gt;
|-&lt;br /&gt;
!Nick.C&#039;s Full Collection&lt;br /&gt;
| FLAC&lt;br /&gt;
| 882 kbit/s&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| -&lt;br /&gt;
| 307 kbit/s&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==File identification==&lt;br /&gt;
lossyWAV-processed WAV files are named with a double filename extension, .lossy.wav, to make them instantly identifiable. e.g. &amp;quot;.lossy.flac&amp;quot; would indicate an audio file which was processed using lossyWAV, and subsequently encoded using FLAC.[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=55522&amp;amp;view=findpost&amp;amp;p=498559]&lt;br /&gt;
&lt;br /&gt;
The --correction parameter is used when processing to create a correction file which is named with the .lwcdf.wav double filename extension. When &amp;quot;added&amp;quot; to the corresponding .lossy.wav, using the --merge parameter, the original file will be reconstituted.&lt;br /&gt;
&lt;br /&gt;
Combinations of lossyWAV with each specific encoder are referred to as lossy&#039;&#039;&#039;X&#039;&#039;&#039;, where &#039;&#039;&#039;X&#039;&#039;&#039; is an abbreviation of the lossless codec name. Combination names are listed in the &amp;quot;[[LossyWAV#Known supported codecs|known supported codecs]]&amp;quot; section below.&lt;br /&gt;
&lt;br /&gt;
lossyWAV inserts a variable-length &#039;fact&#039; chunk into the WAV file immediately after the &#039;fmt &#039; chunk. This takes the form:&amp;lt;pre&amp;gt;fact/&amp;lt;size&amp;gt;/lossyWAV x.y.z @ dd/mm/yyyy hh:mm:ss, -q 5&amp;lt;/pre&amp;gt;Where the version, date &amp;amp; time and user settings are copied. Additionally, if a lossyWAV &#039;fact&#039; chunk is found in a file, the processing will be halted (exit code = 16) to prevent re-processing of an already processed file.&lt;br /&gt;
&lt;br /&gt;
The --check parameter can be used to determine whether a file has previously been processed without trying to process it, exit code = 16 if already processed; exit code = 0 if not.&lt;br /&gt;
&lt;br /&gt;
==Quality presets==&lt;br /&gt;
*--quality insane: (-q I or -q 10) Highest quality preset, generally considered to be excessive;&lt;br /&gt;
*--quality extreme: (-q E or -q 7.5) Higher quality preset, disc space-saving alternative to lossless archiving for large audio collections, considered to be suitable for transcoding to other lossy codecs;&lt;br /&gt;
*--quality high: (-q H or -q 5.0) High quality preset, midway between extreme and standard;&lt;br /&gt;
*--quality standard: (-q S or -q 2.5) Default preset, generally accepted to be transparent;&lt;br /&gt;
*--quality economic: (-q C or -q 0.0) Intermediate preset midway between standard and portable;&lt;br /&gt;
*--quality portable: (-q P or -q -2.5) DAP quality preset for use on a compatible [[Wikipedia:Digital audio player|DAP]].[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=56129&amp;amp;view=findpost&amp;amp;p=531316]&lt;br /&gt;
*--quality extraportable: (-q X or -q -5.0) Lowest quality preset for use on a compatible [[Wikipedia:Digital audio player|DAP]].[http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=56129&amp;amp;view=findpost&amp;amp;p=531316]&lt;br /&gt;
&lt;br /&gt;
All tuning for version 1.0.0 was performed on quality preset --standard with higher presets being more conservative. For versions 1.1.0, 1.2.0 and 1.3.0, tuning effort has been focused on the lowest quality preset in an effort to achieve an effective compromise between resultant bitrate and perceived quality. Quality preset --standard is generally accepted to be (and from testing so far is) transparent. If you find a track which --standard fails to achieve transparency after processing, please post a sample (no more than 30 seconds) in the development thread.&lt;br /&gt;
&lt;br /&gt;
The upper frequency limit used in the calculation of minimum signal power varies, dependent on quality preset, in the range 15.159kHz to 16.682kHz&lt;br /&gt;
&lt;br /&gt;
==Supported input formats==&lt;br /&gt;
*[[WAV]]: 9-bit to 32-bit integer; 1 to 8 channels; sample rate &amp;amp;ge; 32kHz [[Pulse Code Modulation|PCM]]. Very high sample rates (&amp;amp;gt;48kHz) have not been extensively tested. Tunings have been focussed on 16-bit, 44.1kHz samples (i.e. [[Wikipedia:Red Book (audio CD standard)|CD]] PCM).&lt;br /&gt;
&lt;br /&gt;
==Codec compatibility==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Codec&lt;br /&gt;
!Supported&lt;br /&gt;
!Encoder parameters&lt;br /&gt;
!Combination name&lt;br /&gt;
|-&lt;br /&gt;
! [[Free Lossless Audio Codec|FLAC]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;5&#039;&#039;&#039; -&#039;&#039;&#039;b&#039;&#039;&#039; 512 --&#039;&#039;&#039;keep-foreign-metadata&#039;&#039;&#039;&lt;br /&gt;
| lossy&#039;&#039;&#039;FLAC&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Lossless Predictive Audio Compression|LPAC]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;b&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;LPAC&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Wikipedia:Audio Lossless Coding|MPEG-4 ALS]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;l&#039;&#039;&#039; -&#039;&#039;&#039;n&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;ALS&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[TAK]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| -&#039;&#039;&#039;fsl&#039;&#039;&#039;512&lt;br /&gt;
| lossy&#039;&#039;&#039;TAK&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[WavPack]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| --&#039;&#039;&#039;blocksize&#039;&#039;&#039;=512 --&#039;&#039;&#039;merge-blocks&#039;&#039;&#039;&lt;br /&gt;
| lossy&#039;&#039;&#039;WV&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Windows Media Audio#Windows Media Audio Lossless|WMA Lossless]]&lt;br /&gt;
| &#039;&#039;&#039;Yes&#039;&#039;&#039;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| lossy&#039;&#039;&#039;WMALSL&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! [[Apple Lossless]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Lossless Audio|LA]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Monkey&#039;s Audio]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[OptimFROG]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|-&lt;br /&gt;
! [[Wikipedia:TTA (codec)|TTA]]&lt;br /&gt;
| No&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
| &amp;amp;mdash;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* Combinations of lossyWAV with each specific encoder are referred to as lossy&#039;&#039;&#039;X&#039;&#039;&#039;, where &#039;&#039;&#039;X&#039;&#039;&#039; is an abbreviation of the lossless codec name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is also [http://www.hometheaterhifi.com/volume_8_4/dvd-benchmark-part-6-dvd-audio-11-2001.html#Meridian%20Lossless%20Packing%20(MLP)%20in%20a%20Nutshell evidence] &amp;amp;mdash; so-called &amp;quot;Bit Shifting&amp;quot; &amp;amp;mdash; to suggest that lossyWAV may work with [[Wikipedia:Meridian Lossless Packing|MLP]], but this remains untested due to prohibitive prices of encoders. At least one [http://www.hydrogenaudio.org/forums/index.php?showtopic=98609&amp;amp;hl= commercial DVD-A] uses constant bit-depth reduction with lower bit-depth on rear channels.&lt;br /&gt;
&lt;br /&gt;
A comparison of portable media players is [[Wikipedia:Comparison of portable media players#Audio Formats|here]], which shows FLAC and WMA Lossless compatibility among listed players.&lt;br /&gt;
Any player supported by [http://www.rockbox.org Rockbox] can use FLAC or WavPack files after installing Rockbox.&lt;br /&gt;
===Important note===&lt;br /&gt;
&#039;&#039;&#039;NB: when encoding using a lossless codec, please ensure that the block size of the lossless codec matches that of lossyWAV (default = 512 samples). If this is not done then the lossless encoding of the processed WAV file will (almost certainly) be larger than it would otherwise have been. This is achieved by adding the &amp;quot;Encoder Parameters&amp;quot; in the table above to the command line of the lossless codec in question.&#039;&#039;&#039;&lt;br /&gt;
===Bonus feature===&lt;br /&gt;
Another, possibly not obvious, feature of lossyWAV is that the processed output can be &amp;quot;transcoded&amp;quot; from one lossless codec to another lossless codec with absolutely no loss of quality whatsoever. This is solely due to the fact that lossyWAV output is designed to be losslessly encoded - something that lossless codecs do very well indeed.&lt;br /&gt;
&lt;br /&gt;
==Using lossyWAV==&lt;br /&gt;
===Application settings===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lossyWAV 1.3.0, Copyright (C) 2007-2011 Nick Currie. Copyleft.&lt;br /&gt;
&lt;br /&gt;
This program is free software: you can redistribute it and/or modify it under&lt;br /&gt;
the terms of the GNU General Public License as published by the Free Software&lt;br /&gt;
Foundation, either version 3 of the License, or (at your option) any later&lt;br /&gt;
version.&lt;br /&gt;
&lt;br /&gt;
This program is distributed in the hope that it will be useful,but WITHOUT ANY&lt;br /&gt;
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A&lt;br /&gt;
PARTICULAR PURPOSE.  See the GNU General Public License for more details.&lt;br /&gt;
&lt;br /&gt;
You should have received a copy of the GNU General Public License along with&lt;br /&gt;
this program.  If not, see &amp;lt;http://www.gnu.org/licenses/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Process Description:&lt;br /&gt;
&lt;br /&gt;
lossyWAV is a near lossless audio processor which dynamically reduces the &lt;br /&gt;
bitdepth of the signal on a block-by-block basis. Bitdepth reduction adds noise&lt;br /&gt;
to the processed output. The amount of permissible added noise is based on&lt;br /&gt;
analysis of the signal levels in the default frequency range 20Hz to 16kHz.&lt;br /&gt;
&lt;br /&gt;
If signals above the upper limiting frequency are at an even lower level, they&lt;br /&gt;
can be swamped by the added noise. This is usually inaudible, but the behaviour&lt;br /&gt;
can be changed by specifying a different --limit (in the range 10kHz to 20kHz).&lt;br /&gt;
&lt;br /&gt;
For many audio signals there is little content at very high frequencies and&lt;br /&gt;
forcing lossyWAV to keep the added noise level lower than the content at these&lt;br /&gt;
frequencies can increase the bitrate dramatically for no perceptible benefit.&lt;br /&gt;
&lt;br /&gt;
The noise added by the process is shaped using an adaptive method provided by&lt;br /&gt;
Sebastian Gesemann. This method, as implemented in lossyWAV, aims to use the&lt;br /&gt;
signal itself as the basis of the filter used for noise shaping. Adaptive noise&lt;br /&gt;
shaping is enabled by default.&lt;br /&gt;
&lt;br /&gt;
Usage   : lossyWAV &amp;lt;input wav file&amp;gt; &amp;lt;options&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example : lossyWAV musicfile.wav&lt;br /&gt;
&lt;br /&gt;
Quality Options:&lt;br /&gt;
&lt;br /&gt;
-q, --quality &amp;lt;t&amp;gt;    where t is one of the following (default = standard):&lt;br /&gt;
    I, insane        highest quality output, suitable for transcoding;&lt;br /&gt;
    E, extreme       higher quality output, suitable for transcoding;&lt;br /&gt;
    H, high          high quality output, suitable for transcoding;&lt;br /&gt;
    S, standard      default quality output, considered to be transparent;&lt;br /&gt;
    C, economic      intermediate quality output, likely to be transparent;&lt;br /&gt;
    P, portable      good quality output for DAP use, may not be transparent;&lt;br /&gt;
    X, extraportable lowest quality output, not fully transparent.&lt;br /&gt;
&lt;br /&gt;
Standard Options:&lt;br /&gt;
&lt;br /&gt;
-C, --correction     write correction file for processed WAV file; default=off.&lt;br /&gt;
-f, --force          forcibly over-write output file if it exists; default=off.&lt;br /&gt;
-h, --help           display help.&lt;br /&gt;
-L, --longhelp       display extended help.&lt;br /&gt;
-M, --merge          merge existing lossy.wav and lwcdf.wav files.&lt;br /&gt;
-o, --outdir &amp;lt;t&amp;gt;     destination directory for the output file(s).&lt;br /&gt;
-v, --version        display the lossyWAV version number.&lt;br /&gt;
-w, --writetolog     create (or add to) lossyWAV.log in the output directory.&lt;br /&gt;
&lt;br /&gt;
Advanced Options:&lt;br /&gt;
&lt;br /&gt;
-                    take WAV input from STDIN.&lt;br /&gt;
-c, --check          check if WAV file has already been processed; default=off.&lt;br /&gt;
                     errorlevel=16 if already processed, 0 if not.&lt;br /&gt;
-q, --quality &amp;lt;n&amp;gt;    quality preset (-5.0&amp;lt;=n&amp;lt;=10.0); (-5=lowest, 10=highest;&lt;br /&gt;
                     default=2.5; I=10; E=7.5; H=5; S=2.5; C=0; P=-2.5; X=-5).&lt;br /&gt;
--, --stdout         write WAV output to STDOUT.&lt;br /&gt;
    --stdinname &amp;lt;t&amp;gt;  pseudo filename to use when input from STDIN.&lt;br /&gt;
&lt;br /&gt;
Advanced Quality Options:&lt;br /&gt;
&lt;br /&gt;
-A, --adaptive &amp;lt;n/t&amp;gt; modify settings for Sebastian Gesemann&#039;s adaptive noise&lt;br /&gt;
                     shaping method. takes a parameter to set the order of the&lt;br /&gt;
                     FIR filter, (32&amp;lt;=n&amp;lt;=96; default=64; multiple of 8 only);&lt;br /&gt;
                     &amp;quot;OFF&amp;quot; to disable adaptive shaping; &amp;quot;NOWARP&amp;quot; to disable &lt;br /&gt;
                     default frequency warping;&lt;br /&gt;
-a, --analyses &amp;lt;n&amp;gt;   set number of FFT analysis lengths, (2&amp;lt;=n&amp;lt;=6; default=3,&lt;br /&gt;
                     i.e. 32, 64 &amp;amp; 1024 samples. n=2, remove 32 sample FFT;&lt;br /&gt;
                     n&amp;gt;3 add 512; n&amp;gt;4, add 256; n&amp;gt;6, add 128) nb. FFT lengths.&lt;br /&gt;
                     stated are for 44.1/48kHz audio, higher sample rates will&lt;br /&gt;
                     automatically increase all FFT lengths as required.&lt;br /&gt;
-l, --limit &amp;lt;n&amp;gt;      set upper frequency limit to be used in analyses to n Hz;&lt;br /&gt;
                     (10000&amp;lt;=n&amp;lt;=20000; default=16000).&lt;br /&gt;
    --linkchannels   revert to original single bits-to-remove value for all&lt;br /&gt;
                     channels rather than channel dependent bits-to-remove.&lt;br /&gt;
    --maxclips &amp;lt;n&amp;gt;   set max. number of acceptable clips per channel per block;&lt;br /&gt;
                     (0&amp;lt;=n&amp;lt;=16; default=3,3,3,3,3,2,2,2,2,2,1,1,1,0,0,0).&lt;br /&gt;
-m, --midside        analyse 2 channel audio for mid/side content.&lt;br /&gt;
    --nodccorrect    disable DC correction of audio data prior to FFT analysis,&lt;br /&gt;
                     default=on; (DC offset calculated per FFT data set).&lt;br /&gt;
    --scale &amp;lt;n&amp;gt;      factor to scale audio by; (0.0625&amp;lt;n&amp;lt;=8.0; default=1).&lt;br /&gt;
-s, --shaping [n]    enable fixed noise shaping, takes optional parameter [n]&lt;br /&gt;
                     to allow user defined shaping proportion (0.0&amp;lt;=n&amp;lt;=1.0),&lt;br /&gt;
                     otherwise default to quality setting dependent value.&lt;br /&gt;
                     Disables adaptive noise shaping.&lt;br /&gt;
    --static &amp;lt;n&amp;gt;     set minimum-bits-to-keep-static to n bits (default=6;&lt;br /&gt;
                     7&amp;lt;=n&amp;lt;=28, limited to bits-per-sample - 4).&lt;br /&gt;
-U, --underlap &amp;lt;n&amp;gt;   enable underlap mode to increase number of FFT analyses&lt;br /&gt;
                     performed at each FFT length, (n = 2, 4 or 8, default=2).&lt;br /&gt;
&lt;br /&gt;
Output Options:&lt;br /&gt;
&lt;br /&gt;
    --bitdist        show distrubution of bits to remove.&lt;br /&gt;
    --blockdist      show distribution of lowest / highest significant bit of&lt;br /&gt;
                     input codec-blocks and bit-removed codec-blocks.&lt;br /&gt;
-d, --detail         enable per block per channel bits-to-remove data display.&lt;br /&gt;
-F, --freqdist       enable frequency analysis display of input data.&lt;br /&gt;
-H, --histogram      show sample value histogram (input, lossy and correction).&lt;br /&gt;
    --longdist       show long frequency distribution data (input/lossy/lwcdf).&lt;br /&gt;
    --perchannel     show selected distribution data per channel.&lt;br /&gt;
-p, --postanalyse    enable frequency analysis display of output and&lt;br /&gt;
                     correction data in addition to input data.&lt;br /&gt;
    --sampledist     show distribution of lowest / highest significant bit of&lt;br /&gt;
                     input samples and bit-removed samples.&lt;br /&gt;
    --spread [full]  show detailed [more detailed] results from the spreading/&lt;br /&gt;
                     averaging algorithm.&lt;br /&gt;
-W, --width &amp;lt;n&amp;gt;      select width of output options (79&amp;lt;=n&amp;lt;=255).&lt;br /&gt;
&lt;br /&gt;
System Options:&lt;br /&gt;
&lt;br /&gt;
-B, --below          set process priority to below normal.&lt;br /&gt;
    --low            set process priority to low.&lt;br /&gt;
-N, --nowarnings     suppress lossyWAV warnings.&lt;br /&gt;
-Q, --quiet          significantly reduce screen output.&lt;br /&gt;
-S, --silent         no screen output.&lt;br /&gt;
&lt;br /&gt;
Special thanks go to:&lt;br /&gt;
&lt;br /&gt;
David Robinson       for the publication of his lossyFLAC method, guidance, and&lt;br /&gt;
                     the motivation to implement his method as lossyWAV.&lt;br /&gt;
&lt;br /&gt;
Horst Albrecht       for ABX testing, valuable support in tuning the internal&lt;br /&gt;
                     presets, constructive criticism and all the feedback.&lt;br /&gt;
&lt;br /&gt;
Sebastian Gesemann   for the adaptive noise shaping method and the amount of&lt;br /&gt;
                     help received in implementing it and also for the basis of&lt;br /&gt;
                     the fixed noise shaping method.&lt;br /&gt;
&lt;br /&gt;
Matteo Frigo and     for libfftw3-3.dll contained in the FFTW distribution&lt;br /&gt;
Steven G Johnson     (v3.2.1 or v3.2.2).&lt;br /&gt;
&lt;br /&gt;
Mark G Beckett       for the Delphi unit that provides an interface to the&lt;br /&gt;
(Univ. of Edinburgh) relevant fftw routines in libfftw3-3.dll.&lt;br /&gt;
&lt;br /&gt;
Don Cross            for the Complex-FFT algorithm originally used.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example drag &#039;n&#039; drop batch file===&lt;br /&gt;
Simply drag the FLAC files onto this batch file and it will process, recode in FLAC and copy ALL of the tags from the input FLAC file, placing the output lossyFLAC file in the same directory as the input FLAC file. Requires flac.exe and [http://www.synthetic-soul.co.uk/tag/ tag.exe] to be somewhere on the path. &lt;br /&gt;
&amp;lt;pre&amp;gt;@echo off&lt;br /&gt;
:repeat&lt;br /&gt;
if %1.==. goto end&lt;br /&gt;
if exist &amp;quot;%1&amp;quot; flac -d &amp;quot;%1&amp;quot; --stdout --silent|lossywav - --stdout --standard --stdinname &amp;quot;%1&amp;quot;|flac - -b 512 -o &amp;quot;%~dpn1.lossy.flac&amp;quot; --silent &amp;amp;&amp;amp; tag --fromfile &amp;quot;%1&amp;quot; &amp;quot;%~dpn1.lossy.flac&amp;quot;&lt;br /&gt;
shift&lt;br /&gt;
goto repeat&lt;br /&gt;
:end&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and FFTW===&lt;br /&gt;
Since version 1.2.0, lossyWAV has been compatible with [[Wikipedia:FFTW|FFTW]] although not dependent on it. Should the user wish to take advantage of the increased processing speed available when using FFTW (from superior FFT implementations), libfftw3-3.dll should be placed in a directory on the host computer which features on the path.&lt;br /&gt;
&lt;br /&gt;
===Linux / OS X support: lossyWAV and WINE===&lt;br /&gt;
The cause of lossyWAV&#039;s WINE incompatibility was found and removed during the development of 1.2.0 and retrospectively amended for 1.1.0b in a maintenance release (1.1.0c). The latest stable version (1.3.0 at the time of writing) is fully supported.&lt;br /&gt;
&lt;br /&gt;
[http://caudec.outpost.fr/ caudec] is a command-line tool that can encode and decode lossyWAV files (lossyFLAC, lossyWV, lossyTAK), using the official binary (lossyWAV.exe) with Wine (see: [http://caudec.outpost.fr/documentation/windowscodecs/ installation instructions]). Caudec can also test file integrity and compute (and tag) Replaygain data. While it hasn&#039;t been tested at the time of writing, it is possible that lossyWAV support in caudec works on OS X as well.&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and [[foobar2000]]===&lt;br /&gt;
Example [[foobar2000]] converter settings:&lt;br /&gt;
&lt;br /&gt;
lossyFLAC settings:&amp;lt;pre&amp;gt;Encoder: C:\Windows\System32\cmd.exe&lt;br /&gt;
Extension : lossy.flac&lt;br /&gt;
Parameters: /d /c C:\&amp;quot;Program Files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|&lt;br /&gt;
            C:\&amp;quot;Program Files&amp;quot;\bin\flac - -b 512 -5 -f -o%d --ignore-chunk-sizes&lt;br /&gt;
Format is : lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyTAK settings:&amp;lt;pre&amp;gt;Encoder: C:\Windows\System32\cmd.exe&lt;br /&gt;
Extension  : lossy.tak&lt;br /&gt;
Parameters : /d /c C:\&amp;quot;Program Files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|&lt;br /&gt;
             C:\&amp;quot;Program Files&amp;quot;\bin\takc -e -p2m -fsl512 -ihs - %d&lt;br /&gt;
Format is: lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyWV settings:&amp;lt;pre&amp;gt;Encoder: C:\Windows\System32\cmd.exe&lt;br /&gt;
Extension : lossy.wv&lt;br /&gt;
Parameters: /d /c C:\&amp;quot;Program Files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|&lt;br /&gt;
            C:\&amp;quot;Program Files&amp;quot;\bin\wavpack -hm --blocksize=512 --merge-blocks -i - %d&lt;br /&gt;
Format is : lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
lossyWMALSL* settings:&amp;lt;pre&amp;gt;Encoder: C:\Windows\System32\cmd.exe&lt;br /&gt;
Extension : lossy.wma&lt;br /&gt;
Parameters : /d /c c:\&amp;quot;program files&amp;quot;\bin\lossywav - --quality standard --silent --stdout|&lt;br /&gt;
             c:\&amp;quot;program files&amp;quot;\bin\wmaencode - %d --codec lsl --ignorelength&lt;br /&gt;
Format is : lossless or hybrid&lt;br /&gt;
Highest BPS mode supported: 24&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enclose the element of the path containing spaces within double quotation marks (&amp;quot;), e.g. C:\&amp;quot;Program Files&amp;quot;\directory_where_executable_is\executable_name. This is a Windows limitation.&lt;br /&gt;
&lt;br /&gt;
lossyWMALSL conversion uses WMAEncode.exe by lvqcl found [http://www.hydrogenaudio.org/forums/index.php?s=&amp;amp;showtopic=90519&amp;amp;view=findpost&amp;amp;p=767754 here].&lt;br /&gt;
&lt;br /&gt;
===lossyWAV and EAC===&lt;br /&gt;
:&#039;&#039;For example settings, see [[EAC and LossyWAV]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Frequently asked questions==&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why is the &amp;quot;.wav&amp;quot; file extension used?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039; The &amp;quot;.wav&amp;quot; file extension is used because lossyWAV is a digital signal processor and not a codec. No decoding is required for any program to play a WAV file which has been processed with lossyWAV as it remains compliant with the RIFF WAVE format.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why create a processor which means that I cannot be sure that a lossless file is truly lossless?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039; Unless one creates the lossless file personally, one can &#039;&#039;&#039;never&#039;&#039;&#039; be completely sure that the file is indeed lossless. E.g. a lossless file you receive could be transcoded from [[MP3]] without your knowledge. To distinguish a lossyWAV file from lossless files it is recommended to use the extension .lossy.EXT where EXT is the original extension e.g. .lossy.flac&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[Variable Bitrate|VBR]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; Yes.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Do I need to re-process to change lossless codecs?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[transparency|transparent]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; At preset --standard, almost certainly.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Is it [[lossless]]?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Will it ever have a [[Constant Bitrate|CBR]] mode?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Will it low-pass filter my audio?&lt;br /&gt;
*&#039;&#039;&#039;Short answer:&#039;&#039;&#039; No. The frequency limit is for the analysis only. LossyWAV cannot low-pass filter your audio.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Question:&#039;&#039;&#039; Why should I use this?&lt;br /&gt;
*&#039;&#039;&#039;Answer:&#039;&#039;&#039;&lt;br /&gt;
:*high quality&lt;br /&gt;
:*extremely low chance of audible [[artifact]]s&lt;br /&gt;
:*reasonable [[bitrate]]s&lt;br /&gt;
:*usable with unmodified, established lossless formats.&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=55522 Original lossyFLAC thread] - Introduction of the concept by David Robinson (Replay Gain developer) and initial development&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=96635 lossyWAV 1.3.1 Delphi to C++ translation thread]&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=81002 lossyWAV 1.3.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=90104 lossyWAV 1.3.0 release thread] - Release of version 1.3.0 on 06 August 2011&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=65499 lossyWAV 1.2.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=77042 lossyWAV 1.2.0 release thread] - Release of version 1.2.0 on 16 December 2009&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=63254 lossyWAV 1.1.0 development thread]&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=64617 lossyWAV 1.1.0 release thread] - Release of version 1.1.0 on 12 July 2008&lt;br /&gt;
----&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=56129 lossyWAV Development thread] - Conversion of the original MATLAB script to Delphi and evolution of the method&lt;br /&gt;
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=63225 lossyWAV 1.0.0 release thread] - Release of version 1.0.0b on 12 May 2008&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
	<entry>
		<id>https://wiki.hydrogenaudio.org/index.php?title=TAK&amp;diff=25162</id>
		<title>TAK</title>
		<link rel="alternate" type="text/html" href="https://wiki.hydrogenaudio.org/index.php?title=TAK&amp;diff=25162"/>
		<updated>2013-06-04T17:38:50Z</updated>

		<summary type="html">&lt;p&gt;Skamp: added caudec to the list of Linux software that supports TAK&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Codec Infobox&lt;br /&gt;
| name = Tom&#039;s lossless Audio Kompressor&lt;br /&gt;
| logo =&lt;br /&gt;
| type = lossless&lt;br /&gt;
| purpose = lossless audio compression.&lt;br /&gt;
| maintainer = Thomas Becker&lt;br /&gt;
| recommended_encoder = TAK encoder&lt;br /&gt;
| recommended_text = TAK v2.2.0&lt;br /&gt;
| website = [http://thbeck.de/Tak/Tak.html ThBeck.de/Tak/Tak.html] &#039;&#039;(german)&#039;&#039;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&#039;&#039;&#039;Tom&#039;s lossless Audio Kompressor&#039;&#039;&#039; (&#039;&#039;&#039;TAK&#039;&#039;&#039;) is a lossless audio compressor which promises compression performance similar to [[Monkey&#039;s Audio]] “High” and decompression speed similar to [[Free Lossless Audio Codec|FLAC]].&lt;br /&gt;
&lt;br /&gt;
=== Features ===&lt;br /&gt;
* High compression&lt;br /&gt;
* Fast compression and decompression speed&lt;br /&gt;
* Streaming support (necessary headers for decompressing the audio are written to the stream every 2 seconds)&lt;br /&gt;
* Piping support for encoding&lt;br /&gt;
* Error tolerance (single bit error will never affect more than 250 ms)&lt;br /&gt;
* Error detection (each frame protected by a 24-bit checksum (CRC))&lt;br /&gt;
* High-resolution (up to 24-bit/channel) audio support&lt;br /&gt;
* Support for up to 192 Khz Audio&lt;br /&gt;
* Seeking without seek table&lt;br /&gt;
* APEv2 tags supported at end of file&lt;br /&gt;
&lt;br /&gt;
=== Pros ===&lt;br /&gt;
* Fast encoding speed (while providing better compression TAK encodes as fast as [[Free Lossless Audio Codec|FLAC]] -8 in TAK&#039;s “Insane” and several times faster in “Turbo” mode)&lt;br /&gt;
* Fast decompression speed (on par with FLAC / [[WavPack]])&lt;br /&gt;
* Good compression levels (on par with [[Monkey&#039;s Audio]] High)&lt;br /&gt;
* Error Robustness&lt;br /&gt;
* Fast Seeking&lt;br /&gt;
&lt;br /&gt;
=== Cons ===&lt;br /&gt;
* Closed Source&lt;br /&gt;
* No hardware support&lt;br /&gt;
* Limited software support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software support ==&lt;br /&gt;
=== Windows ===&lt;br /&gt;
* [http://www.hydrogenaudio.org/forums/index.php?showtopic=89610 TAK 2.2.0] (official release which consists of a CLI, a GUI, a [[Winamp]] plugin, the SDK, and the decoding library)&lt;br /&gt;
* [http://foosion.foobar2000.org/components/ TAK Decoder 0.4.4] - plugin for [[foobar2000]] (supports tagging and [[ReplayGain]])&lt;br /&gt;
* [http://www.liviocavallo.altervista.org/ dsfTAKSource 0.0.1.6] - DirectShow source filter to play TAK-files in Windows Media Player, Media Player Classic - Home Cinema, Zoom Player and alike&lt;br /&gt;
* [http://reino.degeelebosch.nl/ DC-Bass Source Mod 1.5.0.0] - DirectShow source filter to play TAK-files, amongst many others, in any DirectShow media player (as mentioned above)&lt;br /&gt;
* [[Mp3tag]] – universal tag editor with support for TAK&lt;br /&gt;
* [http://etree.org/shnutils/shntool/ shntool] (since version 3.0.6)&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
* ffmpeg can demux, decode and parse TAK since commit d7a473926504e2acfa6ae3bead0938e1f4e03441:[http://git.videolan.org/?p=ffmpeg.git;a=commit;h=d7a473926504e2acfa6ae3bead0938e1f4e03441]. First official release that supports TAK decoding is 1.1.&lt;br /&gt;
* The GUI program (Tak.exe) and the command-line program (Takc.exe) work with [http://www.winehq.org/ Wine].&lt;br /&gt;
* [http://caudec.outpost.fr caudec] is a command-line tool that can encode and decode TAK files, using the official binary (Takc.exe) with Wine (see: [http://caudec.outpost.fr/documentation/windowscodecs/ installation instructions]). Caudec can also test file integrity and compute (and tag) Replaygain data. While it hasn&#039;t been tested at the time of writing, it is possible that TAK support in caudec works on OS X as well.&lt;br /&gt;
&lt;br /&gt;
== Hardware support ==&lt;br /&gt;
* None&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended Settings ==&lt;br /&gt;
* Default compression: “-p2” (formerly &#039;&#039;Normal&#039;&#039;) is the most attractive setting, providing an excellent compromise between compression and encoding speed. (At compression levels close to [[Monkey&#039;s Audio]] High (&amp;lt;0.4% difference), it is able to encode more quickly.)&lt;br /&gt;
 takc -e [input file]&lt;br /&gt;
* Highest compression: “-pMax” (same as -p4m) (This will create files which are comparable in size to file created using [[Monkey&#039;s Audio]] High. Decompression speed is comparable to [[WavPack]] Normal.)&lt;br /&gt;
 takc -e -pMax [input file]&lt;br /&gt;
* Fastest compression: “-p0” (This will create files which are comparable in size to [[Monkey&#039;s Audio]] Fast or [[WavPack]] High. Decompression speed is comparable to [[Free Lossless Audio Codec|FLAC]] 0.)&lt;br /&gt;
 takc -e -p0 [input file]&lt;br /&gt;
&lt;br /&gt;
=== TAK Performance Graph ===&lt;br /&gt;
[[Image:TAK_performance_graph_1-0-4.png|frame|center|Graph showing encoding and decoding rate against compression, using data from Synthetic Soul&#039;s test on TAK 1.0.4&amp;lt;br /&amp;gt;(see [[TAK#External Links|External Links]])]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using TAK ==&lt;br /&gt;
=== TAK with [[foobar2000]] ===&lt;br /&gt;
* Copy the takc.exe to your [[foobar2000]] directory&lt;br /&gt;
* Go to File → Preferences → Tools → Converter&lt;br /&gt;
* Set it up as shown:&lt;br /&gt;
[[Image:Tak_foobar_converter.png|frame|center|Screenshot of foobar 0.9.5 Converter settings for TAK 1.0.3]]&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; replace -p2 with the desired compression level.&lt;br /&gt;
&lt;br /&gt;
* TAK introduced encoding from STDIN in version 1.0.3, eliminating the need for a temporary file and greatly improving overall compression time. If you are using an earlier version of TAK use the following command line instead:&lt;br /&gt;
 -e -p2 %s %d&lt;br /&gt;
* Use [[APEv2 specification|APEv2]] tagging (will be used as internal tagging)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== TAK with EAC ===&lt;br /&gt;
Please read the [[EAC and TAK|wiki guide]], which details how to create TAK files with [[Exact Audio Copy|EAC]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Future Features ==&lt;br /&gt;
* Unicode support&lt;br /&gt;
* MD5 audio checksums for verification and identification&lt;br /&gt;
* A German version&lt;br /&gt;
* Embedded cue sheets&lt;br /&gt;
* Embedded cover art&lt;br /&gt;
* Multichannel audio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
; Is the codec safe for use?&lt;br /&gt;
: Yes. To check, convert a WAVE to TAK and back and compare the two (or use foobar&#039;s bitcompare tool).&lt;br /&gt;
; Why should I use TAK?&lt;br /&gt;
: TAK offers high compression ratios with great decoding rates.&lt;br /&gt;
; What can I compress with TAK?&lt;br /&gt;
: TAK 1.0 can compress any integer-format (up to 24 bits per channel) PCM RIFF WAVE file (.wav). Piping support as of v1.0.3 is implemented, so converting lossless files to WAV first is not necessary.&lt;br /&gt;
; What about hardware support?&lt;br /&gt;
: None at the moment. Although, &#039;&#039;-p0&#039;&#039;, &#039;&#039;-p1&#039;&#039; and &#039;&#039;-p2&#039;&#039; are the candidates for hardware playback.&lt;br /&gt;
; Will the source be opened?&lt;br /&gt;
: Yes, TAK will be open-source, as soon as the code is ported to C or C++ and documented. However, Thomas has mentioned that he would like to improve the codec before opening the source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://thbeck.de/Tak/Tak.html thbeck.de/Tak/Tak.html] – Official Website &#039;&#039;(german)&#039;&#039;&lt;br /&gt;
* [http://www.hydrogenaudio.org/forums/index.php?showtopic=89610 TAK 2.2.0 Discussion Thread on HA] &#039;&#039;(english)&#039;&#039;&lt;br /&gt;
* [http://synthetic-soul.co.uk/comparison/lossless/ synthetic-soul.co.uk/comparison/lossless] – Comparison with Other Codecs (by Synthetic Soul)&lt;br /&gt;
* [http://flac.sourceforge.net/comparison.html flac.sourceforge.net/comparison.html] – An Updated Comparison (from FLAC Homepage)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Lossless]]&lt;br /&gt;
[[Category:Encoder/Decoder]]&lt;/div&gt;</summary>
		<author><name>Skamp</name></author>
	</entry>
</feed>