Difference between revisions of "ReplayGain"

From Hydrogenaudio Knowledgebase
Jump to: navigation, search
 
(rename)
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
'''ReplayGain''' is the name of a technique invented to achieve the same perceived playback loudness of audio files. It defines an algorithm to measure the '''perceived''' loudness of audio data.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
+
  <head>
+
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
    <meta name="robots" content="noindex,nofollow" />
+
<link rel="shortcut icon" href="/favicon.ico" />
+
<link title="Creative Commons" type="application/rdf+xml" href="/index.php?title=ReplayGain&amp;action=creativecommons" rel="meta" />
+
<link rel="copyright" href="http://www.gnu.org/copyleft/fdl.html" />
+
    <title>Editing ReplayGain - Edit - Hydrogenaudio Knowledgebase</title>
+
    <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "/skins/monobook/main.css"; /*]]>*/</style>
+
  
    <link rel="stylesheet" type="text/css" media="print" href="/skins/common/commonPrint.css" />
+
ReplayGain allows the loudness of each song within a collection of songs to be consistent. This is called 'Track Gain' (or 'Radio Gain' in earlier parlance). It also allows the loudness of a specific sub-collection (an "album") 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 'Album Gain' (or 'Audiophile Gain' 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.
    <!--[if IE 5]><style type="text/css" media="all">@import "/skins/monobook/IEFixes.css";</style><![endif]-->
+
    <!--[if IE 6]><style type="text/css" media="all">@import "/skins/monobook/IE60Fixes.css";</style><![endif]-->
+
    <!--[if IE]><script type="text/javascript" src="/skins/common/IEFixes.js"></script>
+
    <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
+
    <script type="text/javascript" src="/index.php?title=-&amp;action=raw&amp;gen=js"></script>    <script type="text/javascript" src="/skins/common/wikibits.js"></script>
+
    <style type="text/css">/*<![CDATA[*/
+
@import "/index.php?title=MediaWiki:Monobook.css&action=raw&ctype=text/css&smaxage=18000";
+
@import "/index.php?title=-&action=raw&gen=css";
+
/*]]>*/</style>          </head>
+
  
  <body        class="ns-0">
+
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 ''effective power'' of the waveform (i.e. the RMS power after applying an "equal loudness contour"), and then adjusts the amplitude of the waveform accordingly. The result is that Replay Gained waveforms are usually more uniformly amplified then peak-normalized waveforms.
    <div id="globalWrapper">
+
      <div id="column-content">
+
<div id="content">
+
  <a name="top" id="contentTop"></a>
+
    <h1 class="firstHeading">Editing ReplayGain</h1>
+
  <div id="bodyContent">
+
    <h3 id="siteSub">From Hydrogenaudio Knowledgebase</h3>
+
  
    <div id="contentSub"></div>
+
==Target loudness==
            <!-- start content -->
+
The target loudness of almost all ReplayGain utilities is 89 dB SPL (an early departure from the proposal, endorsed by its author<ref>[http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=83397&view=findpost&p=721854 Does Replay gain work differtly in Media monkey]</ref>) &mdash; the ReplayGain proposal and SMPTE recommendation are 6dB lower.<ref>[http://www.mars.org/mailman/public/mad-dev/2004-February/000993.html ReplayGain discussion at mad-dev]</ref>
    <p>You've followed a link to a page that doesn't exist yet.
+
To create the page, start typing in the box below
+
(see the <a href="/index.php?title=Hydrogenaudio_Knowledgebase:Help&amp;action=edit" class="new" title="Hydrogenaudio Knowledgebase:Help">help page</a> for more info).
+
If you are here by mistake, just click your browser's <b>back</b> button.
+
</p>
+
<script type='text/javascript'>
+
/*<![CDATA[*/
+
document.writeln("<div id='toolbar'>");
+
addButton('/skins/common/images/button_bold.png','Bold text','\'\'\'','\'\'\'','Bold text');
+
addButton('/skins/common/images/button_italic.png','Italic text','\'\'','\'\'','Italic text');
+
addButton('/skins/common/images/button_link.png','Internal link','[[',']]','Link title');
+
addButton('/skins/common/images/button_extlink.png','External link (remember http:// prefix)','[',']','http://www.example.com link title');
+
addButton('/skins/common/images/button_headline.png','Level 2 headline','\n== ',' ==\n','Headline text');
+
addButton('/skins/common/images/button_image.png','Embedded image','[[Image:',']]','Example.jpg');
+
addButton('/skins/common/images/button_media.png','Media file link','[[Media:',']]','Example.mp3');
+
addButton('/skins/common/images/button_math.png','Mathematical formula (LaTeX)','\<math\>','\</math\>','Insert formula here');
+
addButton('/skins/common/images/button_nowiki.png','Ignore wiki formatting','\<nowiki\>','\</nowiki\>','Insert non-formatted text here');
+
addButton('/skins/common/images/button_sig.png','Your signature with timestamp','--[[User:81.173.252.115|81.173.252.115]] 20:26, 22 Feb 2005 (CST)','','');
+
addButton('/skins/common/images/button_hr.png','Horizontal line (use sparingly)','\n----\n','','');
+
addInfobox('Click a button to get an example text','Please enter the text you want to be formatted.\\n It will be shown in the infobox for copy and pasting.\\nExample:\\n$1\\nwill become:\\n$2');
+
document.writeln("</div>");
+
/*]]>*/
+
</script>
+
<form id="editform" name="editform" method="post" action="/index.php?title=ReplayGain&amp;action=submit"
+
enctype="multipart/form-data">
+
  
<textarea tabindex='1' accesskey="," name="wpTextbox1" rows='25'
+
==Clipping==
cols='80'>
+
Audio is generally recorded such that the loudest sounds don'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's sensitivity.
</textarea>
+
<br />Summary: <input tabindex='3' type='text' value="" name="wpSummary" maxlength='200' size='60' /><br />
+
<br />
+
<input tabindex='5' id='wpSave' type='submit' value="Save page" name="wpSave" accesskey="s" title="Save your changes [alt-s]"/>
+
<input tabindex='6' id='wpPreview' type='submit' value="Show preview" name="wpPreview" accesskey="p" title="Preview your changes, please use this before saving! [alt-p]"/>
+
<em><a href="/index.php?title=ReplayGain" title="ReplayGain">Cancel</a></em> | <em><a target="helpwindow" href="/index.php?title=Help:Editing">Editing help</a> (opens in new window)</em><div id="editpage-copywarn">
+
<p>Please note that all contributions to Hydrogenaudio Knowledgebase are
+
considered to be released under the GNU Free Documentation License 1.2 (see <a href="/index.php?title=Hydrogenaudio_Knowledgebase:Copyrights" title="Hydrogenaudio Knowledgebase:Copyrights">Project:Copyrights</a> for details).
+
If you don't want your writing to be edited mercilessly and redistributed
+
at will, then don't submit it here.<br />
+
  
You are also promising us that you wrote this yourself, or copied it from a
+
Implementations deal with the risk of clipping in different ways. Some have a "pre-amp" feature which reduces (or boosts) the original audio's level by a certain amount before doing whatever is needed for ReplayGain. Some have a "prevent clipping" feature to reduce the amount of ReplayGain adjustment to whatever amount would keep clipping from occurring, based on peak info stored in the file'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.
public domain or similar free resource.
+
<strong >DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION!</strong >
+
</p>
+
</div >
+
  
<input type='hidden' value="" name="wpSection" />
+
== Implementations ==
<input type='hidden' value="" name="wpEdittime" />
+
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.
</form>
+
<div class="printfooter">
+
Retrieved from "<a href="http://wiki.hydrogenaudio.org/index.php?title=ReplayGain">http://wiki.hydrogenaudio.org/index.php?title=ReplayGain</a>"</div>
+
        <!-- end content -->
+
    <div class="visualClear"></div>
+
  
  </div>
+
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 "undo" info. Not all audio players/decoders know how to read and use ReplayGain information stored in metadata. And there's no standard for where and how ReplayGain info is stored; each implementation uses different formats and puts the info in different locations.
</div>
+
      </div>
+
      <div id="column-one">
+
<div id="p-cactions" class="portlet">
+
  <h5>Views</h5>
+
  <ul>
+
    <li id="ca-nstab-main"
+
      class="selected"       ><a href="/index.php?title=ReplayGain">Article</a></li><li id="ca-talk"
+
      class="new"       ><a href="/index.php?title=Talk:ReplayGain&amp;action=edit">Discussion</a></li><li id="ca-edit"
+
      class="selected"       ><a href="/index.php?title=ReplayGain&amp;action=edit">Edit</a></li>   </ul>
+
  
</div>
+
In the audio data method, the file'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 "undo" 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's maximum amplitude (resulting in clipping) or below the minimum (resulting in silence).
<div class="portlet" id="p-personal">
+
  <h5>Personal tools</h5>
+
  <div class="pBody">
+
    <ul>
+
    <li id="pt-login"><a href="/index.php?title=Special:Userlogin&amp;returnto=ReplayGain">Create an account or log in</a></li>     </ul>
+
  </div>
+
  
</div>
+
=== MP3Gain ===
<div class="portlet" id="p-logo">
+
[[MP3Gain]] is an implementation of ReplayGain. It can be used to just analyze files & 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).
  <a style="background-image: url(/skins/common/images/ha_logo.png);"
+
    href="/index.php?title=Main_Page"
+
    title="Main Page"></a>
+
</div>
+
<script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
+
<div class="portlet" id="p-nav">
+
  <h5>Navigation</h5>
+
  <div class="pBody">
+
  
    <ul>
+
* Format: [[MP3]]
            <li id="n-mainpage"><a href="/index.php?title=Main_Page">Main Page</a></li>       <li id="n-topicindex"><a href="/index.php?title=Topic_Index">Topic Index</a></li>       <li id="n-portal"><a href="/index.php?title=Hydrogenaudio_Knowledgebase:Community_Portal">HAK Community</a></li>       <li id="n-currentevents"><a href="/index.php?title=Current_events">Current events</a></li>       <li id="n-recentchanges"><a href="/index.php?title=Special:Recentchanges">Recent changes</a></li>       <li id="n-randompage"><a href="/index.php?title=Special:Randompage">Random page</a></li>       <li id="n-help"><a href="/index.php?title=Help:Contents">Help</a></li>     </ul>
+
* Method: Audio + Meta (in APE tag), or Audio only
 +
* APE tag fields (ASCII bytes):
 +
** <code>MP3GAIN_MINMAX ###,###</code> - minimum & maximum global gain values for this file. 3 digits, zero-padded if necessary.
 +
** <code>MP3GAIN_ALBUM_MINMAX ###,###</code> - minimum & maximum global gain values across a set of files scanned as an album. Optional.
 +
** <code>MP3GAIN_UNDO +###,+###,N</code> - 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 (<code>N</code> means no, <code>W</code> means yes). The adjustment values are 3 digits, zero-padded, preceded by a sign (<code>+</code> or <code>-</code>).
 +
** <code>REPLAYGAIN_TRACK_GAIN +#.###### dB</code> - The value is always 9 characters including the sign and decimal point. Examples: <code>+0.424046</code> and <code>-10.38500</code>
 +
** <code>REPLAYGAIN_TRACK_PEAK #.###### dB</code> - The value is always 8 characters including the decimal point. Example: <code>0.149923</code>
 +
** <code>REPLAYGAIN_ALBUM_GAIN +#.###### dB</code> - The value is always 9 characters including the sign and decimal point. Optional.
 +
** <code>REPLAYGAIN_ALBUM_PEAK #.###### dB</code> - The value is always 8 characters including the decimal point. Optional.
 +
* Limitations: Although the metadata, if written, contains precise adjustment & peak values, the audio data modifications are limited to 1.5dB steps and may become irreversible (however, that's a very rare condition; see the [http://www.hydrogenaudio.org/forums/lofiversion/index.php/t34154.html "mp3gain is NOT lossless" forum thread])
 +
* http://mp3gain.sourceforge.net/
  
  </div>
+
=== AACGain ===
</div>
+
[[AACGain]] is a modified version of MP3Gain that works on both MP3 and AAC files.
<div id="p-search" class="portlet">
+
  <h5>Search</h5>
+
  <div class="pBody">
+
    <form name="searchform" action="/index.php?title=Special:Search" id="searchform">
+
      <input id="searchInput" name="search" type="text"
+
        accesskey="f" value="" />
+
      <input type='submit' name="go" class="searchButton" id="searchGoButton"
+
        value="Go"
+
        />&nbsp;<input type='submit' name="fulltext"
+
        class="searchButton"
+
        value="Search" />
+
  
    </form>
+
* Format: [[MP3]], [[AAC]] (with or without MP4 container)
  </div>
+
* Method: Audio + Meta, or Audio only
</div>
+
* Limitations: Limited to 1.5dB steps mode, may become irreversible (same caveat as for MP3Gain)
<div class="portlet" id="p-tb">
+
* http://altosdesign.com/aacgain/
  <h5>Toolbox</h5>
+
  <div class="pBody">
+
    <ul>
+
    <li id="t-whatlinkshere"><a href="/index.php?title=Special:Whatlinkshere&amp;target=ReplayGain">What links here</a></li>
+
  
    <li id="t-recentchangeslinked"><a href="/index.php?title=Special:Recentchangeslinked&amp;target=ReplayGain">Related changes</a></li>
+
=== [[LAME]] ===
                                                        <li id="t-specialpages"><a href="/index.php?title=Special:Specialpages">Special pages</a></li>           </ul>
+
* Method: Header ([http://gabriel.mp3-tech.org/mp3infotag.html mp3infotag])
  </div>
+
* Notes:
</div>
+
** Tags added during encoding; not supported by any player yet; Track Gain only
      </div><!-- end of the left (by default at least) column -->
+
** Replay Gaining MP3's are usually done using MP3Gain (see [[ReplayGain#MP3Gain|above]]) or [[ReplayGain#foobar2000 ReplayGain scanner|foobar2000]]
      <div class="visualClear"></div>
+
* http://lame.sourceforge.net/
      <div id="footer">
+
  
    <div id="f-poweredbyico"><a href="http://www.mediawiki.org/"><img src="/skins/common/images/poweredby_mediawiki_88x31.png" alt="MediaWiki" /></a></div> <div id="f-copyrightico"><a href="http://www.gnu.org/copyleft/fdl.html"><img src="/skins/common/images/gnu-fdl.png" alt='GNU Free Documentation License 1.2' /></a></div> <ul id="f-list">
+
=== [[Musepack]] ReplayGain ===
          <li id="f-about"><a href="/index.php?title=Hydrogenaudio_Knowledgebase:About" title="Hydrogenaudio Knowledgebase:About">About Hydrogenaudio Knowledgebase</a></li>   <li id="f-disclaimer"><a href="/index.php?title=Hydrogenaudio_Knowledgebase:General_disclaimer" title="Hydrogenaudio Knowledgebase:General disclaimer">Disclaimers</a></li> </ul>
+
* Method: Header (similar to Meta data method)
      </div>
+
* 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.
    </div>
+
* http://www.musepack.net/
    <!-- Served by morbo.morbo.org in 0.08 secs. -->  </body>
+
  
</html>
+
=== VorbisGain ===
 +
* Format: (Ogg) [[Vorbis]]
 +
* Method: Meta (in [[Vorbis comment]])
 +
* http://www.sjeng.org/vorbisgain.html
 +
** new compiles of VorbisGain at [http://www.rarewares.org/ogg.html www.rarewares.org]
 +
:'''''Note:''' Andavari has provided a very useful script to integrate VorbisGain, which is a CLI tool, into Windows Explorer. Please (Ogg) [[Vorbis#Replay Gain|check this section]].
 +
 
 +
=== FLAC / METAFLAC ===
 +
* Format: [[Free Lossless Audio Codec|FLAC]]
 +
* Method: Meta (in [[Vorbis comment]])
 +
* http://flac.sf.net
 +
 
 +
=== WavPack / WVGAIN ===
 +
* Format: [[WavPack]]
 +
* Method: Meta (in [[APEv2]] tag)
 +
* http://www.wavpack.com
 +
 
 +
=== Wavegain ===
 +
* Format: waveform
 +
* Method: Audio
 +
* Limitations: Irreversible
 +
* http://www.rarewares.org/files/others/wavegain.zip
 +
 
 +
=== [[foobar2000]] ReplayGain scanner ===
 +
* Format:
 +
** [[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, but requiring tags first), and to rewrite the tags to account for the peak change and compensate for the difference from 89&nbsp;dB. The 89&nbsp;dB reference level for tags isn't configurable, but the reference level applied to the global gain fields is (it's under Preferences > Advanced > Tools > ReplayGain Scanner > Target MP3 alteration volume level).
 +
** [[Musepack]]: Values written to header.
 +
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].
 +
** [[WavPack]]: Values written to [[APEv2]] tags.
 +
** [[AAC]]: Values written to [[APEv2]] tags.
 +
** [[MP4]]: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain).
 +
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].
 +
** [[APE]]: Values written to [[APEv2]] tags.
 +
** Modules ([[MOD]] etc.): Optionally saved into [[APEv2]] tags.
 +
* http://foobar2000.org
 +
 
 +
=== [[MediaMonkey]] ===
 +
* Format:
 +
** [[MP3]]: Values written to [[APEv2]] or [[ID3v2]] tags.
 +
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].
 +
** [[WMA]]: Values stored in MediaMonkey's MDB database.
 +
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].
 +
** [[APE]]: Values written to [[APEv2]] tags.
 +
** [[WAV]]: Values stored in MediaMonkey's MDB database.
 +
** [[MPC]]: Internal gain Structure.
 +
* In addition to tags, all ReplayGain values are also stored in MediaMonkey's MDB database
 +
* Album/Audiophile ReplayGain not supported until v3.0 (Dec 2007); support during burning & ripping added in 3.1 (Jun 2009)
 +
* Also capable of (irreversibly) changing the volume of MP3 tracks, similar to [[MP3Gain]]
 +
* http://www.mediamonkey.com/
 +
 
 +
=== [[Winamp]] ReplayGain scanner===
 +
* Format:
 +
** [[MP3]]: Values written to [[ID3v2]] tags.
 +
** (Ogg) [[Vorbis]]: Values written to [[Vorbis comment]].
 +
** [[WMA]]: Values stored in Windows Media Audio tags.
 +
** [[Free Lossless Audio Codec|FLAC]]: Values written to [[Vorbis comment]].
 +
** [[APE]]: Values written to [[APEv2]] tags.
 +
** [[AAC]]: Values written to [[APEv2]] tags.
 +
** [[MP4]]
 +
** [[TAK]]: Values written to [[APEv2]] tags.
 +
* Support Album/Track Gain
 +
 
 +
== Players support ==
 +
ReplayGain being present in the specs of FLAC, Musepack, and APE formats, any player that support those formats usually support ReplayGain.
 +
 
 +
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.
 +
 
 +
=== Windows ===
 +
* [[foobar2000]] supports ReplayGain in all possible aspects.
 +
* [[Winamp]] supports ReplayGain in album or track mode.
 +
* [[MediaMonkey]] supports track ReplayGain only
 +
* [[XMPlay]] recently implemented ReplayGain
 +
 
 +
''...and probably others.''
 +
 
 +
=== Linux ===
 +
* [[XMMS]]. Reads ReplayGain from [[Free Lossless Audio Codec|FLAC]], [[Musepack]], (Ogg) [[Vorbis]] ..
 +
:For [[MP3]], use the CVS version of the [http://xmms-mad.sourceforge.net/ xmms-mad] mp3 plugin (it's not yet released as binary, furthermore not available in distribs' versions for now. Meanwhile binaries are available here: [http://perso.crans.org/~krempp/xmms-mad/ custom binaries])
 +
* [[amarok]]. By using the amarok-script [http://kde-apps.org/content/show.php?content=26073 ReplayGain]
 +
: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.
 +
* [http://www.sacredchao.net/quodlibet Quod Libet] reads ReplayGain from (Ogg) [[Vorbis]], [[MP3]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].
 +
: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].
 +
* [http://www.musicpd.org/ Music Player Daemon] (MPD) reads ReplayGain from (Ogg) [[Vorbis]], [[Free Lossless Audio Codec|FLAC]], and [[Musepack]].
 +
:foobar2000-style TXXX frames in [[MP3]]s are also supported in the latest development releases.
 +
* [http://www.mplayerhq.hu/ MPlayer]. Mplayer support for ReplayGain is codec dependent.
 +
:Codecs that are known to support ReplayGain: vorbis
 +
: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:
 +
ac=[codec],[othercodec],vorbis,mad,
 +
 
 +
=== Portable devices ===
 +
[http://www.rockbox.org/ Rockbox] supports ReplayGain (in album or track mode) for most formats, including  WMA, MP1/2/3, AAC, ALAC, Musepack, Monkey's Audio, Wavpack, FLAC and Vorbis.  <br>Note that ReplayGain is only supported when using the respective codec's native tagging format.  For example:  ReplayGain stored in APEv2 tags is not supported for MP3, rather ID3v2.x tags are expected.
 +
 
 +
Sandisk Sansa Fuze with firmware 1.02.26 and 2.02.26
 +
 
 +
Sandisk Sansa Clip+
 +
 
 +
The iPod features ''Soundcheck'', which seems to produce roughly the same normalization gains as ReplayGain, but doesn't provide an Album Gain.
 +
 
 +
=== Hi-Fi ===
 +
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]].
 +
 
 +
==Notes==
 +
<small><references/></small>
 +
 
 +
== See also ==
 +
* [[ReplayGain specification]]
 +
 
 +
== External links ==
 +
* [http://en.wikipedia.org/wiki/Replay_Gain ReplayGain] at Wikipedia
 +
* [http://www.replaygain.org/ ReplayGain - A Proposed Standard], the original proposal, now out of date with respect to current practice
 +
* [http://www.bobulous.org.uk/misc/Replay-Gain.html ReplayGain using foobar2000] (how to use ReplayGain in Windows using foobar2000).
 +
* [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).
 +
 
 +
 
 +
[[Category:Technical]]
 +
[[Category:Metadata]]

Revision as of 18:20, 27 July 2011

ReplayGain is the name of a technique invented to achieve the same perceived playback loudness of audio files. It defines an algorithm to measure the perceived loudness of audio data.

ReplayGain allows the loudness of each song within a collection of songs to be consistent. This is called 'Track Gain' (or 'Radio Gain' in earlier parlance). It also allows the loudness of a specific sub-collection (an "album") 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 'Album Gain' (or 'Audiophile Gain' 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.

ReplayGain is different from 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 effective power of the waveform (i.e. the RMS power after applying an "equal loudness contour"), and then adjusts the amplitude of the waveform accordingly. The result is that Replay Gained waveforms are usually more uniformly amplified then peak-normalized waveforms.

Target loudness

The target loudness of almost all ReplayGain utilities is 89 dB SPL (an early departure from the proposal, endorsed by its author[1]) — the ReplayGain proposal and SMPTE recommendation are 6dB lower.[2]

Clipping

Audio is generally recorded such that the loudest sounds don'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's sensitivity.

Implementations deal with the risk of clipping in different ways. Some have a "pre-amp" feature which reduces (or boosts) the original audio's level by a certain amount before doing whatever is needed for ReplayGain. Some have a "prevent clipping" feature to reduce the amount of ReplayGain adjustment to whatever amount would keep clipping from occurring, based on peak info stored in the file'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.

Implementations

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.

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 "undo" info. Not all audio players/decoders know how to read and use ReplayGain information stored in metadata. And there's no standard for where and how ReplayGain info is stored; each implementation uses different formats and puts the info in different locations.

In the audio data method, the file'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 "undo" 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's maximum amplitude (resulting in clipping) or below the minimum (resulting in silence).

MP3Gain

MP3Gain is an implementation of ReplayGain. It can be used to just analyze files & 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).

  • Format: MP3
  • Method: Audio + Meta (in APE tag), or Audio only
  • APE tag fields (ASCII bytes):
    • MP3GAIN_MINMAX ###,### - minimum & maximum global gain values for this file. 3 digits, zero-padded if necessary.
    • MP3GAIN_ALBUM_MINMAX ###,### - minimum & maximum global gain values across a set of files scanned as an album. Optional.
    • MP3GAIN_UNDO +###,+###,N - 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 (N means no, W means yes). The adjustment values are 3 digits, zero-padded, preceded by a sign (+ or -).
    • REPLAYGAIN_TRACK_GAIN +#.###### dB - The value is always 9 characters including the sign and decimal point. Examples: +0.424046 and -10.38500
    • REPLAYGAIN_TRACK_PEAK #.###### dB - The value is always 8 characters including the decimal point. Example: 0.149923
    • REPLAYGAIN_ALBUM_GAIN +#.###### dB - The value is always 9 characters including the sign and decimal point. Optional.
    • REPLAYGAIN_ALBUM_PEAK #.###### dB - The value is always 8 characters including the decimal point. Optional.
  • Limitations: Although the metadata, if written, contains precise adjustment & peak values, the audio data modifications are limited to 1.5dB steps and may become irreversible (however, that's a very rare condition; see the "mp3gain is NOT lossless" forum thread)
  • http://mp3gain.sourceforge.net/

AACGain

AACGain is a modified version of MP3Gain that works on both MP3 and AAC files.

  • Format: MP3, AAC (with or without MP4 container)
  • Method: Audio + Meta, or Audio only
  • Limitations: Limited to 1.5dB steps mode, may become irreversible (same caveat as for MP3Gain)
  • http://altosdesign.com/aacgain/

LAME

Musepack ReplayGain

  • Method: Header (similar to Meta data method)
  • 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.
  • http://www.musepack.net/

VorbisGain

Note: Andavari has provided a very useful script to integrate VorbisGain, which is a CLI tool, into Windows Explorer. Please (Ogg) check this section.

FLAC / METAFLAC

WavPack / WVGAIN

Wavegain

foobar2000 ReplayGain scanner

  • Format:
    • 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, but requiring tags first), and to rewrite the tags to account for the peak change and compensate for the difference from 89 dB. The 89 dB reference level for tags isn't configurable, but the reference level applied to the global gain fields is (it's under Preferences > Advanced > Tools > ReplayGain Scanner > Target MP3 alteration volume level).
    • Musepack: Values written to header.
    • (Ogg) Vorbis: Values written to Vorbis comment.
    • WavPack: Values written to APEv2 tags.
    • AAC: Values written to APEv2 tags.
    • MP4: Uses its own iTunes-compatible tagging system (though iTunes does not support ReplayGain).
    • FLAC: Values written to Vorbis comment.
    • APE: Values written to APEv2 tags.
    • Modules (MOD etc.): Optionally saved into APEv2 tags.
  • http://foobar2000.org

MediaMonkey

  • Format:
  • In addition to tags, all ReplayGain values are also stored in MediaMonkey's MDB database
  • Album/Audiophile ReplayGain not supported until v3.0 (Dec 2007); support during burning & ripping added in 3.1 (Jun 2009)
  • Also capable of (irreversibly) changing the volume of MP3 tracks, similar to MP3Gain
  • http://www.mediamonkey.com/

Winamp ReplayGain scanner

Players support

ReplayGain being present in the specs of FLAC, Musepack, and APE formats, any player that support those formats usually support ReplayGain.

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.

Windows

  • foobar2000 supports ReplayGain in all possible aspects.
  • Winamp supports ReplayGain in album or track mode.
  • MediaMonkey supports track ReplayGain only
  • XMPlay recently implemented ReplayGain

...and probably others.

Linux

For MP3, use the CVS version of the xmms-mad mp3 plugin (it's not yet released as binary, furthermore not available in distribs' versions for now. Meanwhile binaries are available here: custom binaries)
And possibly others, since 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.
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 MP3s. ReplayGain values are stored in RVA2 id3v2.4 frames. See the Quod Libet RVA2 / ReplayGain notes.
foobar2000-style TXXX frames in MP3s are also supported in the latest development releases.
  • MPlayer. Mplayer support for ReplayGain is codec dependent.
Codecs that are known to support ReplayGain: vorbis
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:
ac=[codec],[othercodec],vorbis,mad,

Portable devices

Rockbox supports ReplayGain (in album or track mode) for most formats, including WMA, MP1/2/3, AAC, ALAC, Musepack, Monkey's Audio, Wavpack, FLAC and Vorbis.
Note that ReplayGain is only supported when using the respective codec's native tagging format. For example: ReplayGain stored in APEv2 tags is not supported for MP3, rather ID3v2.x tags are expected.

Sandisk Sansa Fuze with firmware 1.02.26 and 2.02.26

Sandisk Sansa Clip+

The iPod features Soundcheck, which seems to produce roughly the same normalization gains as ReplayGain, but doesn't provide an Album Gain.

Hi-Fi

Slim Devices a company owned by Logitech Inc, supports ReplayGain on both of their hi-end audiophile players, known as the Transporter and the Squeezebox.

Notes

  1. Does Replay gain work differtly in Media monkey
  2. ReplayGain discussion at mad-dev

See also

External links