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: MP3Gain - getting overall library averages (Read 6028 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

MP3Gain - getting overall library averages

I have a quick MP3Gain question, for those familiar with the tool.
I know how to use Track Analysis, Album Analysis, etc. to get overall "sounds like" decibel levels for a given track or album.

But I'm interested in seeing what the overall "sounds like" level for my entire pre-ReplayGain library is.  The only way I know to do that is to copy my entire collection into a single folder, treat it as an album, and do an Album Analysis.  Is there a quicker way?

(I'm doing this because, rather than using the recommended dB levels of 83 or 89, I'd simply like to move everything to the "average" for my collection.)

MP3Gain - getting overall library averages

Reply #1
This won't give you a meaningful average anyway because the original Replay Gain method sets the measured loudness at the 95th-percentile of the sorted list of loudness measurements, not anywhere near the middle, which is going to be about the level of one of your loudest albums, ignoring entirely those albums that are very quiet and dynamic. That's very likely to cause severe clipping if you apply it to dynamic albums that haven't suffered from the Loudness War.

89 dB is a level that rarely causes any clipping in popular genres, and when it does it's usually very brief and difficult to hear. For those who have a loudness-limited audio player that's too quiet at 89 dB, a few people use 92 to 94 dB to get reasonably good loudness normalisation with occasional clipping (or if clipping is prevented, with modest variation in loudness).

If it's still too quiet and better-isolated headphones/earbuds or turning up the volume aren't an option (again this applies to some portable players and phones), then you really need to join the loudness war, sadly, though in a more subtle way than the latest hit factories do it. Running a DSP like a compressor-limiter in foobar2000's Converter DSP selection prior to sending it to the MP3 encoder may be the least bad option for bringing old material or quiet passages up to bearable loudness for a noisy listening environment. I've found ToneBoosters' TB_Compressor 2.4.0 DEMO VST plugin to do a decent job at its default settings (seems to suffer from very little pumping, for example), although my purpose was in making quiet background music of consistent lowish volume without losing the quiet intros on a number of tracks, so I varied the settings from default. I did try it occasionally to boost the loudness from my standard laptop speakers and found it did well for that too, near the default settings. I think there's a TB_Barricade processor that simulates radio-processing and works similarly, but I've not played much with it. (These both need foo_vst component to work in foobar2000, but fb2k gives a much simpler workflow for mass encoding after DSP is applied than using VST plugins in a sound editor like Audacity)
Dynamic – the artist formerly known as DickD

MP3Gain - getting overall library averages

Reply #2
Without wanting to detract attention from the rest of Dynamic’s very good explanation, I’d just like to emphasise its opening summary:
This won't give you a meaningful average
Can I ask why you thought it would?

 

MP3Gain - getting overall library averages

Reply #3
This won't give you a meaningful average
Can I ask why you thought it would?

The short answer is my lack of understanding on how MP3Gain calculates "perceived loudness"

The long answer: there's several different ways a "95th percentile" could be calculated--by mean or by mode, and probably other ways.  For example, if you have 9 tracks that are analyzed at 100dB and 1 that is analyzed at 40dB, the 95th percentile by average would be 97dB while the 95th percentile by mode would be 100dB.  For that reason, I thought the overall "album analysis" of my entire collection could change based on which tracks were included in the "album".  Obviously I was wrong.


MP3Gain - getting overall library averages

Reply #5
Quote
(I'm doing this because, rather than using the recommended dB levels of 83 or 89, I'd simply like to move everything to the "average" for my collection.)
Hear's another issue...

Many/most of your files are likely normalzed (0dB peaks), including many of your quieter-sounding files.  If you boost these files in order to bring them up to average, they will clip (distort). 

Since you can't boost all of your quiet-sounding files (without clipping), you can only match volumes by reducing the volume of most songs, and your average will (probably) be lower after applying MP3gain.  That's just the nature of loudness perception and digital files...

The 89dB level means that most songs can be volume-matched without clipping, but you may still have a few songs that can't be matched without clipping.  (MP3gain gives you the option of allowing clipping, or boosting as much as possible without clipping.)   

In theory, you could scan your collection and find the "ideal setting" for your files.  But, there is a good chance that your ideal level would be less than 89dB, and if you add a song everything might change and your ideal level might go lower.

MP3Gain - getting overall library averages

Reply #6
Hmm, good points DVDdoug.  I suspect the fact that avoiding clipping typically means reducing volume is the reason the most recent EBU recommendation is 80dB (-23 LUFS).  The issue I see is that, if you reduce volume enough to avoid all clipping, you'll destroy the dynamic range in the process.

I suppose the best thing to do would be for me just to listen to several songs and decide if 89dB works for me, or if I need to set it somewhere else.  Thanks.

MP3Gain - getting overall library averages

Reply #7
This won't give you a meaningful average
Can I ask why you thought it would?

The long answer: there's several different ways a "95th percentile" could be calculated--by mean or by mode, and probably other ways.

no, neither mean or mode are helpful in finding a percentile.

MP3Gain - getting overall library averages

Reply #8
The issue I see is that, if you reduce volume enough to avoid all clipping, you'll destroy the dynamic range in the process.

Not really, no.

What normally happens is that the loud files (which have little dynamic range) are matched to those that actually have dynamic range.

Also, bare in mind that mp3 is capable of greater dynamic range than what 16-bit audio can provide, which is already sufficient for just about any piece of music if not every piece of music ever tested under normal listening conditions.

MP3Gain - getting overall library averages

Reply #9
Completely agree with greynol that dynamic range is more than adequate for 16-bit audio and adjusting even as low as 83dB SPL gives more than enough dynamic range to reproduce a highly dynamic orchestral piece transparently and hiss-free - and indeed many orchestral CDs would be at around 83 dB SPL perceived loudness, giving about 20 dB of headroom for peaks (K-20 on Bob Katz's metering scale).

People often say that CDs have about 96dB of dynamic range and human ears need 120 dB from threshold of hearing to pain threshold.
This isn't strictly accurate.
There's about 96 dB of maximum signal-to-noise ratio over the whole 22 kHz bandwidth, but that's treating it like an oscilloscope, as if you needed to see the peaks and troughs on screen to hear them. (Being an electronics engineer of sorts, this is my instinct, and I had to learn that's not relevant to human hearing). Given that the human ear perceives audio in critical frequency bands like a spectrum analyser rather than as a waveform, a closer representation is something like a 1024-point FFT power spectrum of the signal, which many audio editors can display. A full scale sine wave is typically about 120 dB above the noise floor assuming straightforward flat dither, which could encompass a range from rooms about 20-30dB quieter than any real quiet listening room all the way up to noises as loud as chainsaws heard without ear protection. With noise-shaped dither, the possible range is even more extreme. This old post of mine shows you in pictures based on 16-bit 44.1kHz audio how the dynamic range of CD-audio is a good deal more than 102 dB, which itself is well beyond the oft-quoted 96 dB. If your volume control is set loud enough to discern the quietest -102dBFS sine wave, it's painfully/dangerously loud to discern the loudest one at 0dBFS!

We've also had mention of percentiles, which might need explaining:

The percentile measure is calculated like median. Median is the 50th percentile.

For example, if I have an array of just twenty-one numbers representing loudness measures at twenty-one moments in time:

Original array:
3 6 8 6 4 7 7 4 3 2 9 8 5 2 0 3 2 3 8 1 3

To find the mean average, you add them and divide by 21.
MEAN = 94/21 = 4.476 (rounded to 4 significant figures)

To find the MODE, you look for which number is most commonly seen in the array. In this case it's 3.

To find the MEDIAN, you sort the list into numerical order and look halfway along the list. If halfway falls between two samples, take the mean of the values to the left and to the right:

Sorted array:
0 1 2 2 2 3 3 3 3 3 4 4 5 6 6 7 7 8 8 8 9
MEDIAN is the value in 11th position (underlined) in the sorted array (there are 10 numbers less than or equal to the median on the left and also 10 numbers greater than or equal to the median on the right of the sorted array).

The n'th percentile corresponds to the number n% of the way along the array from left to right. To make this easier to work out, we'll number the array positions starting at zero, i.e. 0 to 20 (rather than 1st to 21st which is simply one greater)

Clearly the 100th percentile is the rightmost number, i.e. 9.
The 0th percentile is the leftmost number, i.e. 0.
The 50th percentile is in position 20*(50%/100%) = position 10 = the 11th position = the MEDIAN = the underlined 4.

If we look for the 55th percentile, starting from index 0, it's in position 20*(55/100) = 11, i.e. the 12th position. That's also 4.

The 57½th percentile would be position 20*(57.5/100) = 11.5. That's midway between the 12th and 13th values in the array, which are 4 and 5, so we can say the answer is 4.5
Try it in a spreadsheet of these numbers in a column, using the function =PERCENTILE(A1:A21, 0.575)
If you try 56.25 %-ile, =PERCENTILE(A1:A21, 0.5625) the position is 11.25 in the array, so making a straight line fit between 4 and 5, 0.25 of the way along the answer is 4.25

The 95th percentile in this case is the number in position 19, i.e. the 20th out of 21 numbers, which is 8.

In Replay Gain, a piece of music might have about 20 loudness measures per second and last 4 minutes (240 seconds), giving an array of about 4800 floating point loudness values. In this case the array is sorted into ascending order and the 95th percentile will have index 4799 * (95/100) = 4559.05 in the sorted list. For simplicity we can set Track Gain to be the value in position 4559 of the sorted list (in fact this is the 94.999th percentile). If we're pedantic about our percentile, we don't round off the 0.05 at the end and take 0.05*Array[4560] + (1-0.05)*Array[4559], which is very likely almost the same, so why bother being pedantic. There's nothing magic about the 95th percentile, it was just found to be a good match for human loudness perception in testing.

Album Gain does the same thing as if the album were a single track, so a 40 minute album would be 2400 seconds long, with 48000 floating point loudness values. The 95th percentle would have index 47999 * (95/100) = 47999 * 0.95 = 45599.05 in the sorted array. So we're likely to take index 45599 from the sorted array as our Album Gain value.

That's why you can't calculate Album Gain from a bunch of Track Gain values. All you can say is that Album Gain must be no greater than the highest Track Gain value but will be near the top end of the Track Gain values, and Album Peak will equal the highest Track Peak.

Some implementations of Replay Gain are using the newer EBU standard R-128 instead of this percentile method, which is different again, and copes well with both music and spoken dialogue in broadcast TV shows, for example, but broadly agrees with Replay Gain and human ears on music.
Dynamic – the artist formerly known as DickD