Skip to main content
Topic: RG and adjusting preamp to prevent clipping (Read 6452 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

RG and adjusting preamp to prevent clipping

So I've been reading about Replaygain and preamp, and my question is how do you use them together to prevent clipping the "purist way" without compression?

http://replaygain.hydrogenaudio.org/player_clipping.html
Quote
The audiophile user will not want any compression or limiting on the signal. In this case the only option is to reduce the pre-amp gain (so that the scaling of the digital signal is lower than that suggested by the replay level). In order to maintain the consistency of level between tracks, the pre-amp gain should remain at this reduced level for subsequent tracks.


How do I know what to set the preamp value to? Do I check out of all my files which one has the highest rg track gain? For example my highest is +0.05 and the lowest is -9.92. So should I set my preamp to -0.05? To me it makes sense but I'm probably missing something I don't know...

preamp filter -> rg filter
Correct?

So for that 0.05 song
-0.05 -> +0.05 = 0.0 dB output change

And for that 9.92 song
-0.05 -> -9.92 = -9.97 dB output change

And for some other -5 song
-0.05 -> -5 = -5.05 dB output change

From what I've read you generally do not want the preamp to be + since it increases chance for clipping.

Quote
If the Peak Level is stored in the header of the file, it is trivial to calculate if (following the Replay Gain adjustment and Pre-amp gain) the signal will clip at some point. If it won't, then no further action is necessary. If it will, then either the hard limiter should be enabled, or the pre-amp gain should be reduced accordingly before playing the track.


http://www.hydrogenaudio.org/forums/index....showtopic=20369
Quote
rg-peak as far as i know is the highest "spike" in an album or track. It is used by fb2k to avoid clipping(if this highest peak exceeds max. volume after applying replaygain, then the volume of the track/albums is scaled down just enough to avoid clipping)


Quote
What does the Replaygain Peak numbers measure?

eg.
replaygain_album_peak = 1.133234

Does a value of 1 = 0 db (100%)?

Is it possible to display it in +- db?
[a href="index.php?act=findpost&pid=234007"][{POST_SNAPBACK}][/a]


It's easy to calculate:

20*log10(1.133234)=+1.09 dB FS


In dB FS (i.e. decibels above digital full scale) positive numbers indicate clipping.

Cheers,
David.


Or should I use the largest peak level for preamp? Calculate how much to lower dB as so:
So for example the highest track peak is 3.57 (old recording):

20 * log~3.57 = ~11.05 dB

So I would then adjust preamp to -11.05 dB

The latter option (track peak) seems to make more sense but...

RG and adjusting preamp to prevent clipping

Reply #1
Set the ReplayGain processing mode to "apply gain and prevent clipping according to peak."
This will automatically lower the volume of tracks or albums with peaks greater than 1.0.

Leave the preamp at ±0.0 dB. You might want to reduce the one for tracks without replaygain info to, say, -6.0 dB, to avoid abrupt volume changes between scanned and unscanned files.

RG and adjusting preamp to prevent clipping

Reply #2
I saw that option but won't that make tracks kind of jump in volume? I'd rather just make everything the same volume to prevent it from clipping in the first place. What I'm not sure about is what to set the preamp in order to do that.

I haven't thought about non-rg-scanned sources...

 

RG and adjusting preamp to prevent clipping

Reply #3
I saw that option but won't that make tracks kind of jump in volume?


As a purist, I guess you'll be more likely to use Album Gain, so it would be the whole album that's scaled down to ensure the Album Peak doesn't exceed 1.000, so my answer is...

...Yes, but only those few that would have clipped AFTER applying the Replay Gain (which is usually negative and will bring the resulting peak below 1.000 most of the time. For old recordings and dynamic recordings such as classical, you may find zero or positive Replay Gain that would cause this. For most rock & pop, I'd think it unlikely.

The calculation is simplest in decibels (addition rather than multiplication of gain factors):
Convert Album Peak (e.g. 1.234567) into dB:
20*log(1.234567) = +1.83dB

Add this to Album Gain (e.g. -8.90 dB):
+1.83 + (-8.90) = -7.07 dBFS = peak value relative to full scale after applying gain

Add RG Pre-amp setting (e.g. -6.02 dB to approximate the original 83 dB SPL calibration) and Volume Control setting (usually 0.00 dB):
+1.83 - 8.90 - 6.02 - 0.00 = -13.09 dBFS = peak value relative to full scale after all RG is applied in FB2K's playback chain unless you turn on clipping prevention, which would limit positive results to 0 dBFS.

So, if the sum of Album Gain and Album Peak (converted to dBFS) is positive, FB2K will apply the negative of that gain to prevent clipping if you've turned on clipping prevention.

I'd suggest that a negative pre-amp might be best for the true purist. 83 dB SPL, or preamp of -6 dB or so, isn't a bad target, though it will be much quieter than Windows' own sounds and sounds on many websites unless you find a way of applying a negative gain to all other sounds.

Quote
I'd rather just make everything the same volume to prevent it from clipping in the first place. What I'm not sure about is what to set the preamp in order to do that.

I haven't thought about non-rg-scanned sources...


Well, you now have the formula for each album, but I don't know how to collect the values for a whole collection into a spreadsheet to find the maximum peak after apply Album Gain.

I usually set my non-RG pre-amp to somewhere in the range of -7.0 dB to -9.0 dB.

I've moved away from purism, and I don't bother with clipping prevention now. I'm happy to set only a modest target volume (89 dB is fine for me) and use Advanced Limiter, which looks ahead in the buffer (hence 'Advanced') and won't touch my sound unless an upcoming peak would actually exceed full scale, where it will apply soft limiting around the area to rein it in without any very unpleasant distortion. In most circumstances when Album Gain clips at 89 dB target (zero pre-amp), there's something like the culmination of a crashing orchestral crescendo which is quite noise-like and will mask the harmonic distortions so that they're not annoying (probably the case whether peaks are clipped or limited). Advanced Limiter actually sounds pretty good with a bit of positive pre-amp and positive gain applied, so I'm not too worried about audio quality during the rare and brief occasions when it will be called upon in normal use.
Dynamic – the artist formerly known as DickD

RG and adjusting preamp to prevent clipping

Reply #4
Thanks for the explanation.

Too bad foorbar doesn't have more advanced math functions.

One more thing, does replaygain take into consideration peak amplitude level in its calculation? Why does it store peak value then?

Quote
First, the player needs to determine if the user requires "Radio" style level equalisation (all tracks same loudness), or "Audiophile" style level equalisation (all tracks "ideal" loudness). This option should be selectable in the Replay Gain control panel, and should default to "Radio".

Then the player reads the appropriate Replay Gain adjustment value from the file header, and converts it back to its original dB value. See the Replay Gain Data Format for more details. Please remember to divide it by ten!

The player also needs to read (or calculate) the Peak amplitude. This is required for Clipping prevention.


EDIT:
Found a way to get the rg info (and all metainfo) into excel using dbpoweramp:
http://www.dbpoweramp.com/codec-central-utility.htm

So from there I just copied to OOCalc and then did the calculations for track gain+(20*log(peak)) and found the maximum.

RG and adjusting preamp to prevent clipping

Reply #5
You've obviously done a lot of research on this - I'd forgotten there was quite so much information available on-line.

Remember that the RG web pages were written explain how to implement RG before there were any implementations. They're not required reading for people who just want to use it, though if you find it interesting, go ahead.


Assuming you want to use ReplayGain (i.e. you're not just wanting clipping prevention without ReplayGain) then Frank Bicking and Dynamic have already given you the perfect answer: album mode, clipping prevention. pre-amp=0 if you have a typical collection, -6 if you have a very dynamic (e.g. mostly classical) one.

There's a little benefit, and a huge amount of pain/effort, to setting the pre-amp to some other carefully calculated number - mainly because whatever rational you'd used to come up with it could be broken by new tracks in your collection. You can try other random pre-amp values if you want.

So, no need to hit excel - fb2k will just "do the right thing" as described in the ReplayGain "standard" with very little effort on your part.

Cheers,
David.

RG and adjusting preamp to prevent clipping

Reply #6
Ah thanks, always good to know from the source.

My perfectionism gets the best of me. lol Maybe I'll create a plugin for this...

 
SimplePortal 1.0.0 RC1 © 2008-2019