Razorhanny
Mar 15 2008, 22:33
I used to be an avid ReplayGain fan for years. The main reason was because of the loud discs of today making my ears bleed wheen listening with headphones, right after a quiet classical album.
Well, recently I've been really into soundtrack CDs, because I'm always amazed by the rich dynamic range these releases show! And as usual I've been ripping all my discs with EAC/FLAC... And aplying "gain and prevent clipping according to peak" on foobar, with the preamp setting set to zero (89.0db). That said I though I would never hear a clip while playing those files, especially because the original waveforms have amazing headrooms!
To my surprise, when playing "Kimble Returns", from "The Fugitive" soundtrack, everything was quiet until the song was coming to it's end, and then the volume goes really up to a climax, and then horrible clipping occurs on the right channel! This was a big surprise to me, since I though that replaygain would never alow that to happen, but then I started to think it was the CD fault... Then I converted the song to WAV, to take a look at the waveforms with soundforge, and it surprised me even more, there was no clipping whatsoever! The original WAV file don't clip! It just almost reach the maximum 16bit volume, at -0,4db at the climax! That said, replaygain was the one to blame, replaygain caused the clip.
Then with those new infos on my mind I started a trial, to find out how to properly use ReplayGain, and created some simple sine waves with a synthesis tool. When at regular volume, those sine waves where masterfully treated with my replaygain settings, but when I started to make files with varied volume thing started to go wrong! The bigger the dynamic range, more clipping replaygain introduced to the Flacs. Then to finalize the test I created a 30 seconds sine wave that have an average volume of -39.0db, and then about 5 seconds to end it goes up to -1.0db for 2 seconds and come back to -39.0db until it ends.
When I ReplayGained this track, ReplayGain added a +23.20db trackgain to it, and as anyone could imagine, the part where the volume were already loud clipped as hell! Even when I played it with foobar ReplayGain preamp set to -12.0db... So, I was thinking, maybe that's why ReplayGain Is not a standard, because it is not that universally compatible as I though for years, because when using it with a song that have enormous dynamic range, the higher volume parts will probably clip, and I found no way to prevent that.
Razorhanny
Mar 15 2008, 22:55
That said, it's sad to see there's no lossless way of replaygaining "The Fugitive" soundtrack CD (and many others, I'm preety sure), unless I set the preamp to something like -8.0db, wich will make all the other CDs sound terribly quiet. Maybe I'll just have to go back using the volume knob.
What player do you use? Foobar2000 has an option to "apply replay gain and prevent clipping according to peak".
Razorhanny
Mar 16 2008, 00:52
QUOTE (Mark7 @ Mar 15 2008, 20:48)

What player do you use? Foobar2000 has an option to "apply replay gain and prevent clipping according to peak".
And as I said, that's the option I use... And even with that, the clip only stopped ocurring after applying -8.0db preamp setting.
Many people recommend using Advanced Limiter for precisely this reason. That said, that's not exactly a "hi-fi" solution, but it would certainly reduce the audibility of the distortion.
Beyond that... you have only two options. You can crank down the preamp to -25db. Or you can add dynamic range compression. And I think most people here would agree that a -25db preamp setting is quite reasonable for the situation you are describing. (Note, because foobar's processing chain is floating point, this does not entail any quality reduction unless you start bumping against your sound card's noise floor.)
Razorhanny
Mar 16 2008, 01:15
Axon, nice to see someone who really read what I wrote before fast fingering words! Actually, Advanced Limiter is preety much the only DSP I use, and as you said, on a situation like this the results are not very good. Back to the subject, I really don't think using -25db would be very produtive, as some of the loud CDs have extremely high and constant volume levels, leading ReplayGain to add around -7db to them, wich, together with the -21db preamp would lead to super quiet -28db! For now, I just stopped using ReplayGain, cleaned the dust out of the volume knob, and the music sounds great!.
Yirkha
Mar 16 2008, 02:00
It's a flaw in the scanning process that it didn't find the loud passage important enough to reflect in the overall gain, not the technology itself. You can easily edit the track gain of this piece manually.
It sounds like the passage is so short that RG tosses it out entirely - remember, RG uses the 95th percentile of estimated loudness to arrive at the gain value.
In that situation, what the hell does "program loudness" even mean? If you're really aiming for an average loudness of 89db, and the peak loudness is 40db above that, you're toast anyway. Either you correctly estimate the average loudness, which results in attempting to reproduce a 129db crescendo (ka-boom!), or you vastly overestimate it, at which point you're talking about more of a 60-70db average loudness. In other words, it doesn't matter if RG is "correctly" estimating the loudness or not. The whole notion of "average loudness" here is sorta meaningless.
If you don't have an easily identifiable program loudness, RG probably can't make a reasonable gain correction. That said, Razorhanny... if you can boost your gain later in your amplification, and it does not reduce the SNR too much, that could be your best solution. Especially when you combine that with Advanced Limiter, to minimize its impact.
QUOTE
And as I said, that's the option I use... And even with that, the clip only stopped ocurring after applying -8.0db preamp setting.
Sorry, i missed that.
QUOTE
Axon, nice to see someone who really read what I wrote before fast fingering words!
yeah, rub it in.

Anyway, this sounds like a real flaw to me. This isn't about the average RMS. It's about the peak information in the replaygain tag that seems to be completely ignored, even though you're using "gain and prevent clipping according to peak". Maybe this options does not work properly or maybe the peak is not detected accurately.
So how does replaygain get the peak level? i would assume it checks all samples to get the peak, but now i'm not so sure. This peak value would be useless if it's not accurate.
Razorhanny
Mar 16 2008, 17:22
QUOTE (Mark7 @ Mar 16 2008, 11:11)

Anyway, this sounds like a real flaw to me. This isn't about the average RMS. It's about the peak information in the replaygain tag that seems to be completely ignored, even though you're using "gain and prevent clipping according to peak". Maybe this options does not work properly or maybe the peak is not detected accurately.
So how does replaygain get the peak level? i would assume it checks all samples to get the peak, but now i'm not so sure. This peak value would be useless if it's not accurate.
Mark7, that's exactly what I think, this event was a real surprise, because I always though one of the main advantages of using replaygain was to prevent clipping on loud discs! Never though I would see it causing the clips.
Is this issue really a Replay Gain issue, or is it an issue with Foobar's implementation of Replay Gain?
Razorhanny
Mar 16 2008, 17:48
QUOTE (bilbo @ Mar 16 2008, 13:34)

Is this issue really a Replay Gain issue, or is it an issue with Foobar's implementation of Replay Gain?
I think it's really ReplayGain, because of the gain it's applying to the song generating the clip, foobar just use that information to play the music. And foobar can even "correct" that, if I use a negative preamp gain, wich should not be necessary, since the file had been scanned and adjusted to have a normalized unclipped volume level!
john33
Mar 16 2008, 18:14
QUOTE (Mark7 @ Mar 16 2008, 14:11)

So how does replaygain get the peak level? i would assume it checks all samples to get the peak, but now i'm not so sure. This peak value would be useless if it's not accurate.
Yes, it checks each and every sample. It is entirely feasible to introduce clipping if the RG routines are not correctly implemented, but I'd be amazed if that is the case in foobar.
cliveb
Mar 16 2008, 19:08
Has anybody actually reproduced the problem reported by Razorhanny? I certainly can't.
I just prepared a test file which replaygained as follows:
GAIN = +24.81dB
PEAK = 0.620574 (which is -4.14dB)
Playing it in Foobar v0.8.3 without the "use peak info to scale down tracks that still clip after applying replaygain" results in the expected clipping. But playing it with the "use peak info" option switched on resulted in no clipping. These are precisely the results we would expect.
Just to double-check, I then normalised the loud section to 0dB. This resulted in these replaygain settings:
GAIN = +24.13dB
PEAK = 0.999969 (wich is -0.00027dB, if we're going to nitpick)
Again, there was no clipping on playback with the "use peak info" option switched on. Note also that the change in GAIN value demonstrates that the new louder section must be being taken note of during the replaygain scan.
I had the playback preamp set to 0dB at all times.
The only slightly unusual thing about my test setup is that I'm using Foobar v0.8.3. I know a lot of people use one of the 0.9 releases. Could that be significant?
Razorhanny
Mar 16 2008, 20:21
Just so that everyone can se what I'm talking about, the waveforms of the song I first noticed this issue on, "Kimble Returns" from "The Fugitive" soundtrack:
Normal WAV without any processing:

ReplayGained file, with "Apply Gain And Prevent Clipping According To Peak" and 0db preamp:

As everyone can see, ReplayGain caused severe clipping on the right channel.
greynol
Mar 16 2008, 20:44
QUOTE (Razorhanny @ Mar 16 2008, 12:21)

As everyone can see, ReplayGain caused severe clipping on the right channel.
This is not readily obvious from your screenshots. It appears to me that the track has been normalized based on the peak which is what is done in this type of situation.
Anyhow, it's not possible to see clipped samples unless you
zoom-in!!!!!!!!!!!!
Razorhanny
Mar 16 2008, 21:02
QUOTE (greynol @ Mar 16 2008, 16:44)

QUOTE (Razorhanny @ Mar 16 2008, 12:21)

As everyone can see, ReplayGain caused severe clipping on the right channel.
This is not readily obvious from your screenshots. It appears to me that the track has been normalized based on the peak which is what is done in this type of situation.
Anyhow, it's not possible to see clipped samples unless you
zoom-in!!!!!!!!!!!!
greynol
Mar 16 2008, 21:05
This reveals nothing definitive either, except to reinforce what I stated in my previous post.

You need to zoom-in
vertically as well!!!!!!!!!!!!
Razorhanny
Mar 16 2008, 21:17
Well, there's no more room, the waveform is visually touching the limit. And it is sure clipping a lot, this in not the only spot, it's happenning on about 1,5seconds of the song.
greynol
Mar 16 2008, 21:21
You cannot demonstrate clipping unless you provide the sample values or zoom in. Maybe this is a limitation with your software?
Razorhanny
Mar 16 2008, 21:27
From what I know, anything that loud tends to clip.


And it's exactly what was happenning, but now I just don't ReplayGain my music anymore.
greynol
Mar 16 2008, 21:31
You really need to zoom in more, but it's fairly obvious that both versions indicate clipping, lol.
RG is in no way responsible!
Razorhanny
Mar 16 2008, 21:33
No problem, I just came here to tell what happened, because it was a real surprise, I just have no need to prove anything. I did what I planned.
greynol
Mar 16 2008, 21:38
Your assumption that the original source is not clipped is false. A flat-top is a flat-top. It does not matter that it occurs 0.4 dB down.
Razorhanny
Mar 16 2008, 21:41
Well, just to clarify, I just rechecked the waveforms for the testones and it is really still round at the top, even seeing that it reaches the limit. But still, it clips, and the original don't. Maybe the problem is somewhere else, then.
greynol
Mar 16 2008, 21:45
QUOTE (Razorhanny @ Mar 16 2008, 13:41)

Maybe the problem is somewhere else, then.
There's no question.
Teknojnky
Mar 16 2008, 21:46
sounds to me like its clipping at playback, not necessarily whether the source is clipped or not, but because the gain values is too high for the peak.
Simply edit the RG value to where it does not clip playback.
greynol
Mar 16 2008, 21:51
QUOTE (Teknojnky @ Mar 16 2008, 13:46)

sounds to me like its clipping at playback, not necessarily whether the source is clipped or not, but because the gain values is too high for the peak.
He said foobar was configured to prevent clipping according to the peak value.
QUOTE (Teknojnky @ Mar 16 2008, 13:46)

Simply edit the RG value to where it does not clip playback.
This won't un-flatten the waveform.
Razorhanny
Mar 16 2008, 21:54
Yes, maybe I over reacted too soon, good to know I can go back and ReplayGain my collection

I can definitely hear the clip on the right channel, no matter what negative gain I apply, maybe it was just that since ReplayGain made it louder the clipping was easier to notice. Thanks, Greynol!
greynol
Mar 16 2008, 22:01
You're welcome.
I've read that many CD players have a difficult time reproducing samples at full-scale. I suppose this is the reason why the level on the disc has been reduced.
QUOTE (Razorhanny @ Mar 16 2008, 23:54)

Yes, maybe I over reacted too soon, good to know I can go back and ReplayGain my collection

I can definitely hear the clip on the right channel, no matter what negative gain I apply, maybe it was just that since ReplayGain made it louder the clipping was easier to notice. Thanks, Greynol!
BTW, do you hear artifacts when playing 'udial' test signal?
(
Test your soundcard for clipping)
Razorhanny
Mar 17 2008, 01:24
QUOTE (lvqcl @ Mar 16 2008, 19:29)

BTW, do you hear artifacts when playing 'udial' test signal?
(
Test your soundcard for clipping)
I played it, and it gets really clean when I use the resampler DSP set to 48000hz, does it mean I should always use this resampler setting on foobar?
QUOTE (Razorhanny @ Mar 17 2008, 03:24)

QUOTE (lvqcl @ Mar 16 2008, 19:29)

BTW, do you hear artifacts when playing 'udial' test signal?
(
Test your soundcard for clipping)
I played it, and it gets really clean when I use the resampler DSP set to 48000hz, does it mean I should always use this resampler setting on foobar?
I think software resampling cam improve sound quality.
And, what about clipping artifacts if you use resampler -- do they remain the same or become lower?
Razorhanny
Mar 17 2008, 18:10
Finally I found out what was happenning... Dolby Headphone Wrapper was adding almost 0,5db to the music, then, on this song, where replaygain left no more headroom to work from, it just clipped. Now I readjusted the Dolby Headphone amplification to 100% (It was 120% before), and the clipping stopped. Thanks!
QUOTE (greynol @ Mar 16 2008, 17:45)

QUOTE (Razorhanny @ Mar 16 2008, 13:41)

Maybe the problem is somewhere else, then.
There's no question.

For sure
greynol
Mar 17 2008, 18:19
Nothing's ever simple, that's for sure.
So the original clipping was made worse because of the overload? I guess the 0.4 dB increase due to RG makes a noticeable difference in this situation.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.