Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Apply Gain to File Contents - Lower adjustment to prevent clipping according to (Read 2099 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Apply Gain to File Contents - Lower adjustment to prevent clipping according to

"Apply Gain to File Contents - Lower adjustment to prevent clipping according to peak information"

What does this option really do?
Does it just lower the "target" dB value for only those songs that would clip?
Or does it do anything smarter to prevent the clipping (without lowering target dB)?
And do you need to do a normal gain scan first on all files to find the peak values?

Is there any way to see what files that have been "lowered" to prevent clipping?
Lars-Erik Østerud

Re: Apply Gain to File Contents - Lower adjustment to prevent clipping according to

Reply #1
Any file where the gain adjustment value still leaves the file peak over ±1.0.

Re: Apply Gain to File Contents - Lower adjustment to prevent clipping according to

Reply #2
So what does this options do then?
Lars-Erik Østerud

Re: Apply Gain to File Contents - Lower adjustment to prevent clipping according to

Reply #3
Let's say that you have three MP3 files. You want them to be equally loud. You are targeting 93 dB. (Just an example...)
You can adjust loudness in 1.5 dB steps.

First file is 88 dB loud.
Second file is 95 dB loud.
Third file is 80 dB loud.

First file will be normalized to 92.5 dB.
Second file will be normalized to 92 dB.
Third will will be normalized to 86 dB.

As you can see, third file is far from targeted 93 dB. foobar2000 has prevented the clipping.
If you decide not to use "... lower adjustment ..." your file will be normalized to 92 dB but it will cause clipping.
You can read more about clipping online.
This is mostly happening with music with lots of dynamic range.

The easiest way to understand how this works is to do some experiments by yourself.
Download Audacity and ReplayGain plugin. Grab some modern loud music and grab some old classical music.
Do some experiments there and you will see what exactly we are talking about.

Edit: This is for experienced people only
Why is foobar still using dB for both classic RG and new R128? Why not LUFS?
We are only confusing people + there are some examples where difference is pretty big, most notably on bass heavy music.
gold plated toslink fan

Re: Apply Gain to File Contents - Lower adjustment to prevent clipping according to

Reply #4
What I don't like in foobar2000 is that there is no way to sse if a file clips easy.
In mp3gain thee is a col that indicates if a file clips (now or after a given change).
And you can do some "try and fail" (change the target dB and see if it will clip or not).
foobar2000 use a better algorithm to normalize (especially on bass heavy songs, that is why I am reanalyzing my files in foobar2000 now).
But the whole thing happens without any visual monitoring.
If I reanalyze with mp3gain I can see if that thinks the file will clip now.
But I'm not sure if that info is correct as they don're use the same algorithm.
Is there a way in foobar2000 to rescan files and display if they clip, and how much (how much less dB is needed).
I wish there where a tool (like a waveform editor) that could show exacly where the file clips (is it one time, several times etc).
Lars-Erik Østerud

Re: Apply Gain to File Contents - Lower adjustment to prevent clipping according to

Reply #5
I posted syntax in your other thread for displaying a track's volume, Track/Album gain, and peak level in playlist columns.
https://hydrogenaud.io/index.php?topic=121273.msg1000424#msg1000424
After you scan and save the ReplayGain info, any tracks with a peak greater than 0dB are already clipping.

Logically, if you adjust the volume of an MP3 with the "apply gain but prevent clipping according to the peak" option, and you adjust to a target volume of 89dB (or any other target volume) after you adjust the volume, any tracks that couldn't be adjusted to the target volume without clipping will have a lower volume. By default, fb2k doesn't make it easy to see the volume or track/album gain for more than one track at a time, which is why I posted the syntax for creating custom playlist columns that display that info much like MP3Gain does.

The main difference is, Mp3Gain lets you set the target volume and tells you in advance whether adjusting to that volume will result in clipping. Foobar2000 doesn't, but if you use the "apply gain but prevent clipping according to the peak" option and you've created playlist columns for displaying the volume etc, it's easy enough to check whether there's tracks that are lower than the target volume after an adjustment.

By default, MP3Gain and fb2k check for peaks the same way, regardless of the scanning method. They both just check the "sample peak". If you enable "true peak" scanning in fb2k (in preferences), it checks for the true peak level, not just the sample peak, so it's more accurate but it'll also slow the scanning speed.

This is the difference between "sample peak" (the dots representing samples) and "true peak" after the the waveform  is reconstructed.

Re: Apply Gain to File Contents - Lower adjustment to prevent clipping according to

Reply #6
Have enabled the tru peak scanner. But since I don't use the tags (all my devices don't support that) but add the gain to the file (multipier for each block like Mp3Gain does) I won't get all accurate (and with the R128 alorithm it differs slightly from Mp3Gain in about 50% of the songs - for the rest they agree :-)  Have manualle gone though songs with clipping in Audacity and adjustet the few that had bad clipping (most that where shown has clipping just touched the 0 dB, and some where high drum/cymbal hits in music where that doesnæt affect the sound anyway). For new music the compression is so high that it newer get over 50% so there will never be any clipping (must be the only advantage of compression :-)
Lars-Erik Østerud

Re: Apply Gain to File Contents - Lower adjustment to prevent clipping according to

Reply #7
I don't use the tags as such either, as my portable MP3 player doesn't support ReplayGain, but from memory, when you physically adjust the volume with fb2k (as you would with MP3Gain) if no ReplayGain info exists, it'll adjust the volume without writing the volume to tags. If there's ReplayGain info before the volume adjustment, fb2k will adjust the volume and update the tags.

It makes sense to me to use the tags to check for clipping after the volume adjustment, and creating a playlist column to show the peak levels makes it easier.

I generally adjust the volume to 89dB so I rarely have to worry about clipping, but I adjust to a slightly higher volume before transferring tracks to my mother's tablet for her, so for MP3/AAC I adjust the volume without using the option to prevent clipping, and ignore peaks of only +1dB or so (because the only way to reduce the peaks is to re-encode), but for lossless sources or peaks that are too much above 0dB, I re-encode while applying fb2k's Advanced Limiter DSP. It saves having to import into something like Audacity, check peaks and adjust, then export.

Usually I enable the ReplayGain option in fb2k's converter configuration under precessing, and in your case you'd set the "with ReplayGain" preamp slider to +3dB so fb2k will adjust the volume to 92dB while converting, then I'd add the Advanced Limiter as a DSP to limit the peaks.

Or to make the Advanced Limiter kick in a little earlier (I don't think it limits until the peaks are at 0dB) you could enable ReplayGain in the converter, set the preamp slider to +4 dB so the volume is adjusted to 93dB, then add the Advanced Limiter to the DSP chain followed by the Amplify or Scale DSP to reduce the volume by 1dB so you're back at the target volume of 92dB. You can save the whole thing as a converter preset.

All that's pretty easy when you've got a column at least displaying the peaks. If you're going to re-encode anyway it's definitely better than having to import into Audacity. Here's an example.

# 1 is an MP3 that happened to be right on 89dB with a peak that's clipping a fraction.
# 2 is a copy of the MP3 adjusted to 92dB using the multiplier method. Obviously there's clipping so it has to be fixed.
# 3 is the MP3 converted to FLAC with the ReplayGain configuration in the converter set to 93dB, the Advanced Limiter is applied and the Amplify DSP is reducing the volume by 1dB for 92dB. Doing it that way effectively limits at -1dB.
# 4 is the same as 3 but the output is MP3 rather than FLAC. Lossy encoding can effect the peak levels (by about 0.3dB in this case, but it can often be a fair bit more) so it's a good idea to limit the peaks a little lower than 0dB.

Re: Apply Gain to File Contents - Lower adjustment to prevent clipping according to

Reply #8
I have compaered foobar2000 and mp3gain algorithms now (scanned them again in mp3gain after).
About 50% of my tracks end up with the same result (was not changed by foobar2000).
The R128 alorithm in foobar2000 adjusts a lots of tracks down in volume (and a few up).
Usually it "hits" quite good, but some are adjusted very wrong.
Usually easy to find as they have 3.0 +/- compared to mp3gain (usually it's only 1.5 +/-).
So I do some manual checks and listening and adjust those I feel wrong manually.
I don't use the tags at all (remove them from the files).

What programs are the screenshots from. The left overview looked nice.
Lars-Erik Østerud

 

Re: Apply Gain to File Contents - Lower adjustment to prevent clipping according to

Reply #9
What programs are the screenshots from. The left overview looked nice.

They're screenshots of my Foobar2000 setup.

Even though my portable player doesn't support ReplayGain I don't delete the tags after adjusting the volume. Or after scanning etc. My portable player doesn't understand them but I keep the tags as a reference.

Because I use ReplayGain quite a bit, and I use fb2k for converting files a lot, and because it's easier when the volumes and peaks are easy to see, I created custom playlist columns for those. I already had some tabs below the playlist area in the GUI, so I added a couple more.

There's two types of tab elements that can be added to the fb2k GUI. "Playlist tabs" and "Normal tabs". Both can contain the "Playlist View" UI element. "Playlist tabs" give you a tab for each playlist you create, and you'd use those tabs to switch between playlists. When a "Normal tab" contains the "Playlist View" UI element, it displays the contents of the active/selected playlist.

The upshot of that is my fb2k setup has "Playlist tabs" at the top, and "Normal tabs" below, a couple of which are dedicated to displaying volume. For me, it was a way to get to the volume information easily, not have it there when I don't need it, and it doesn't clutter the Playlists tabs with too many columns.

It looks a bit "old" as I'm running fb2k on XP, and I've never had the desire to display album art or visualisations etc, but it's convenient for me.
FYI. The columns on the left are for viewing the contents of a media library with Facets. That's worth checking out at some stage, Facets is the main reason I switched to fb2k many years ago.
https://www.foobar2000.org/components/view/foo_facets