ReplayGain plug-in

This plug-in is an implementation of ReplayGain that calculates the Track Gain of the selected audio track.

Note: This plug-in does not change the audio in any way and does not write metadata. It just calculates the Track Gain level for the selected audio and displays it. [UPDATE: The new version includes a “Normalize” option that does change the audio]

The gain level indicated by this plug-in may be slightly different to other implementations of ReplayGain due to minor differences between the Loudness Filter used in this plug-in and that specified in the ReplayGain 1.0 specification. However it should be sufficiently accurate to be useful.

How to install:
Installation is the same as for any other Nyquist plug-in.
Place the ReplayGain.ny file in the Plug-Ins folder inside the Audacity installation folder. On Windows computers, this is usually under “Program Files”. On Mac OS X, it is usually under “Applications”. On Linux it is often easiest to create a plug-ins folder ~/.audacity-files/plug-ins/
Restart Audacity, then the ReplayGain Plug-ins will appear underneath the divider in the “Analyze” menu.

Purpose of this plug-in:
When making compilation CDs is is often beneficial to adjust the volume level of individual tracks so that each track will play at a similar volume on the CD. The ReplayGain level that is calculated by this plug-in can act as a guide to how much amplification needs to be applied to each track so that they will have (approximately) equal loudness.

How to use:

  1. Import all of the tracks for the compilation into Audacity.
  2. Select the first track and apply the ReplayGain effect.
  3. Open the Amplify effect and enter the ReplayGain amount in the “Amplification (dB)” control, then apply to the selected track.
  4. Repeat steps 2 and 3 to each track.
  5. Review each track to ensure that the relative loudness is roughly equal for each track and adjust if necessary.
  6. Select all of the tracks (Ctrl+A) and apply the Amplification effect with the default settings.

Limitations of this plug-in:
The way that human hearing detects loudness is subjective, extremely complex and context sensitive, so as with all current algorithms for equal volume playback, ReplayGain can only offer a reasonable guess as to the required gain to achieve equal loudness. Because of this limitation it is advisable to listen to the tracks before exporting the files and committing to CD.

The track sample rate must be at least 44100. This is the minimum sample rate to support the full audio frequency range.

Not all tracks are supposed to be the same loudness. If your compilation includes a Thrash Metal track followed by a gentle lullaby, the second track should probably be quieter than the first. The plug-in is unaware of the emotive connotation of the music, so this decision must be made manually and appropriate action taken.

ReplayGain should be reasonably accurate at achieving equal loudness within a specific genre of music, but is less accurate when comparing music of different genres.

Released under terms of the GNU General Public License version 2:
GNU General Public License v2.0 - GNU Project - Free Software Foundation .

Request from the author:
Please give feedback!
If you find this plug-in useful, please let me know.
If you have questions about how to use it, please ask.
If you have suggestions for improvements, please make them here.
Any other comments, please post.

Analyze plug-in (OLD VERSION):
ReplayGain.ny (2.41 KB)
NEW VERSION This includes “Equal Loudness Normalizing” and will show up in the Effect menu as “ReplayGain”.

Hi Steve,

does this interesting new plug-in address (at least part of) Koz’ feature request on “Normalize a multi-channel show”

or am I missing the point??


No it addresses a different issue.

As you are aware, even within a specific genre of music, some records (vinyl) can be much louder/quieter than others. When you throw in recordings from other sources (cassette recordings, MP3 downloads etc.) the variation in track loudness can be very significant. Normalizing the tracks so that they have the same peak level will frequently fail to make the tracks sound the same loudness because peak level is a poor indicator of loudness.

The problem is particularly evident when making compilation CDs (“My Favourite Rock n Roll Songs”, or “Background Music for the Wedding Reception”, or whatever).
If the tracks are just burned to CD without any editing there is a good chance that you’ll be diving for the volume control every couple of tracks. Even if all of the tracks are Normalised the same problem is quite likely (it only takes one loud peak to throw the overall loudness way out). In particular, modern recordings tend to be a lot louder than old recordings (thanks to the Loudness War)

RMS level is generally a better guide to the loudness of a track than peak level, so in terms of achieving the same loudness in tracks, Normalizing to the same RMS level is a better than the standard peak level Normalizing.

Although RMS normalizing is an improvement, it is still not a particularly good indicator of loudness, so ReplayGain was invented as a better indicator.

The way that ReplayGain is most commonly used is by scanning each track and embedding the ReplayGain value in the track metadata. Players that support ReplayGain can then adjust the playback volume automatically so, in effect, the player does the “dive for the volume control” to save you from needing to do it. Many software MP3 players and some hardware players support ReplayGain, but audio CDs don’t have metadata. When making an audio CD the track volume needs to be adjusted before burning the tracks.

The best way to adjust the track level is to listen carefully to the tracks and adjust the levels manually before Export Multiple. However, many people want some sort of automatic way to determine the level. That’s where this plug-in comes in…

This plug-in calculates a “track gain” level to achieve a standard loudness level.
Once the track gain level has been calculated, the Amplify effect can be used to apply the gain.

By running this plug-in on each track in turn and applying the calculated amount of amplification to each track, the tracks should all then have similar loudness.

In most cases, the calculated level will produce a peak level substantially below 0 dB. With a few exceptional tracks the peak level may be above 0 dB.
Once all tracks for the compilation have been adjusted so that they are all the same loudness (relative to the other tracks in the compilation), the overall level may be adjusted up or down, provided that all tracks are adjusted by the same number of dB. The easy way to do this is to select all tracks at once and apply the Amplify effect with the default settings (step 6 in my previous post). This will bring the level of all tracks up (or down) by the same amount, so they will still have the same relative loudness. The default settings in the Amplify effect will bring the highest peak in the compilation to 0dB.

As a side note, the reason that the plug-in only analyses the tracks and does not actually normalize the track is because normalizing with Nyquist plug-ins can consume all available RAM if long tracks are selected. Analyzing (without normalizing) is done in this plug-in without loading all of the selection into RAM at the same time, so although processing very long tracks may be quite slow it should be memory safe.

OIC - thanks for the explanation Steve, most illuminating


Next time you are making a compilation CD, give it a go and see if it works :wink:

Today I needed to make a compilation CD which gave me the opportunity to try this plug-in out “for real”.

Considering that my tracks were all under 4 minutes and the computer had plenty of RAM, I found it a bit irritating that the plug-in only analysed , requiring me to manually apply the necessary gain with Audacity’s Amplify effect. I therefore changed the plug-in into a “process” type plug-in and added the ability to actually apply the calculated gain. In other words, this effect is now an “Equal Loudness Normalize” effect.

“Process” type Nyquist plug-ins appear in the Audacity “Effect” menu (below the divider line).

The other advantage of it being a process type plug-in is that the effect can be repeated using Ctr+R (command+R on Mac). This is much more convenient when processing multiple tracks, particularly as this effect must only be applied to one track at a time.

The reason that it must only be applied to one track at a time is that Nyquist can not tell the difference between “silence” and “white space” (empty track).

The ReplayGain algorithm tends to set the volume quite low, particularly on tracks that have a lot of dynamic compression. I have therefore added a slider that allows manual adjustment of the Normalized output level. Obviously, when making a compilation it is essential to have this manual adjustment set to the same value for all tracks, otherwise there is no point using the effect.

Overall I was quite pleased with the result. The processed tracks were all quite close to the same loudness.
In the worst case, one track differed from the value calculated by foobar2000 v.1.1.5 (the last version of foobar2000 to use the ReplayGain specification) by 1.6 dB, but considering that test have shown that ReplayGain can be out by 6 dB or more, I think the results are quite reasonable.

If anyone wants to try and tweak this plug-in to get results that are closer to the ReplayGain specification, I think the part that needs tweaking is the equal loudness filter.
Here is the current code for the filter:

;;; equal loudness curve
(defun eqloud (s-in)
                (lowpass2 s-in 4000 0.9) 
              140 0.5)
            2200 -6 2)
          1400 -4 1)
        10000 -10 1)
      12000 14 0.7)

And the new version of the plug-in:
ReplayGain.ny (2.89 KB)

Steve, you’re a star! This is exactly what I was looking for in Audacity and it works brilliantly. I admit, I don’t know how you do it. Since the effect is applied to individual tracks, how does it calculate levels for the respective tracks which make all tracks sound equally loud? Well, how ever you do it, it works. I tested it on several Rory Gallagher tracks from vinyl, original CD and remastered CD which differed considerably. The result is perfect equal loudness. I’m delighted!
There is one slight improvement I would like to suggest. I understand the “adjust” slider to be an “adjust by”, rather than an “adjust to” option. However it’s difficult to tell how many dB to adjust by, if you don’t know the dB Full Scale level which the adjustment will result in. DBfs is after all what we digital sound editors have to go by.
My suggestion is to change it into an “adjust to dBSF” slider. I think it’s more straight forward to enter a target level, than having to work out the amount to adjust by to get to that level. What do you think?

Thanks again for this wonderful effect.

That would be nice, but the plug-in does not know what the dBFS level will be. The plug-in is attempting to work out how “loud” the track is, but some tracks will need to have a different dBFS level than others if they are to “sound the same loudness”. So what the plug-in does is to work out how much to amplify the track so that it sounds a as loud as a “standard” sound. The “standard” sound is defined by the ReplayGain specification here: ReplayGain 1.0 specification - Hydrogenaudio Knowledgebase

Hi Steve!
Thanks for the link. I read up on it and have come up with another idea.
Apparently ReplayGain uses a reference level of -14 dBSF of pink noise. Would it be possible to have a slider to adjust the reference level? The reason I’m so interested in such an option is that it would simplify the process of achieving a certain target level. If for instance I’m producing a radio show for a station broadcasting at -6 dBSF, that value could be entered as a reference level. Is that doable?
Sorry for asking for more and more adjustments. In fact I’m really glad of this plug-in.


That is essentially what the slider does.
You can look at it two ways (at least), but it’s still doing the same thing:

  1. The audio is Normalized to a “standard loudness”, then the “Adjust Normalized Output” control amplifies the output up or down.

  2. The slider control adjusts the reference level.
    When at zero the reference level is (roughly) the same as the ReplayGain standard.
    If the slider is increased to +5 then the reference level is 5 dB higher than the ReplayGain standard.
    If the slider is lowered to -5 then the reference level is 5 dB lower than the ReplayGain standard.

Probably the easiest way to achieve a target level is to apply the effect to each track (one track at a time) with the slider set to zero (default).
It’s likely that after doing this, all of your tracks will be a bit quiet.
The important thing is that they will all be quiet by about the same amount.

If we then amplify all of the tracks by the same amount, then they will still sound about the same loudness as each other.

So what we can do is to select all of the track and apply the Amplify effect with the target level set to the required peak level (dBFS).
I would recommend using 0 dB as the target level. This means that one track will just touch 0 dB at its highest peak and all other tracks will be a bit below 0 dB, but all of the tracks should sound about the same loudness (which is what we want).

Meanwhile I produced a whole radio show using ReplayGain. The result is most satisfying. Of 70 tracks there were two I didn’t quite agree with and which I boosted by 1 and 2 dB respectively.
It’s worth noting that ReplayGain does not reset Gain levels set in the Track Panel, so they should be set to 0 for all tracks when applying ReplayGain.
A brilliant tool. Thanks very much.


Thanks very much for the feedback Whistler. Feedback from “testing in the wild” (real world testing) is invaluable.
I intend to come back to this “Equal Loudness Normalizing” at some point - in particular, looking at the EBU R128 algorithm.

If you’re interested in this from an academic viewpoint, there’s an interesting thread on the Hydrogenaudio forum:

ReplayGain and EBU R128 generally agree to within about +/- 3 dB, though there are occasional tracks that can be out by much more (the most extreme difference quoted in that topic was a massive 12.23 dB difference - I wonder which was closer to “humanly perceived loudness”).

If the plug-in posted here is mostly getting to within a couple of dB of humanly perceived loudness then that’s a pretty good result.
I think it’s unfortunate that both ReplayGain and EBU R128 quote levels to two decimal places, as that suggests much greater accuracy than they actually achieve.

After a couple of attempts I have managed to downloaded the plugin and and get it into the Audacity plugin folder (something was blocking my ability to load the plugin directly to the Audacity plugin folder)…

I have tried it on two files and so far so good, I think it works :slight_smile:

I am now going to try your plugin on a large number number of files (from record, cd etc etc) and will let you know how I get on, but so far so good…

If a computer and Audacity novice can install this and make it work then it must be user friendly :slight_smile:

So from a complete Audacity novice, Danke!

Thank you for the feedback.
I’d be very interested to hear about your results from a large number of file.

I have worked through a folder of about 40 tracks from various sources (kinda compilation sort of thing).
All appears to be good, the folder had some tracks which were significantly quieter than others and after applying your plugin, my initial impression (on the computer speakers) is that the “loudness” is much more equal.
I have now loaded the modified folder on the trusty mp3 so I will be able to give a better report on the loudness balance soon.
I found that when compared to modern tracks, my modified tracks seemed slightly quieter when I converted them with the “Adjust Normalized Output” slider set at 0dB, a 1dB increase resolved that (subjective) issue.

On a different note, I found the the process of individually importing and modifying each track rather slow, is it possible to give your plugin the option of being attached to the Audacity toolbar(s)? This would make life a bit easier for those of us intending to work through a larger number of tracks.

As it is a “plug-in” and not a built-in effect it is not possible to put it into a toolbar. However, if you’re using the most recent version (appears in the “Effect” menu rather than the Analyze menu) then as long as it is the last effect that has been used you can apply the effect again with Ctrl+R (Repeat last effect)

Newbie to Audacity.

  1. I can’t work out where to download the file from.

  2. I presume that as it is a plugin that one can’t use batch processing.

Click where it says “NEW VERSION” in huge letters near the bottom of the first post.

Audacity does not currently support plug-ins in Chains.

So far so good :slight_smile: .
There is only one thing I would say to anyone reading these posts…
Spend some time fiddling with the "Adjust Normalized output:"slider and then listening to what you have modified so you can establish a base “loudness” setting that matches the bulk of your music library. I am suggesting this because the age and source of a particular music file will have an impact on the musics perceived loudness.
Simply, because it is difficult to apply the ReplayGain plugin to a whole library, if you want to avoid having noticeable differences between groups of files it may help to try and match the “loudness” to the bulk of a library.

For me, I think I may have created a monster…
We have a lot of records, CD’s etc of various ages loaded to the computer and are in the habit of periodically mixing tracks in “this weeks” playlist. I now have to either go back and reconvert all the tracks I have modified (and there are lots) or continue adjusting the loudness of the entire library.

So If you are contemplating trying the ReplayGain plugin then I can tell you that it does work and it is easy to use…
Just plan ahead because there doesn’t appear to be (that I have found) a quick way of importing the contents of a file, applying the plugin to the imported files tracks while maintaining each tracks original labels.

Thanks again for the plugin.