HydrogenAudio

Hydrogenaudio Forum => Scientific Discussion => Topic started by: Kyopaxa on 2012-01-18 22:09:38

Title: ReplayGain and dB calculations
Post by: Kyopaxa on 2012-01-18 22:09:38
Hi,

I've been trying to create my own implementation of ReplayGain to gather some personalized statistics over thousands of OGG files.
For that I used the source code of VorbisGain 0.37, just doing some small modifications to get the numbers I need, but now I'm totally confused about how ReplayGain calculates the audio levels. I read the wiki documentation, read a lot of articles about dBFS, dB SPL and RMS, but I am still lost with what's currently implemented in the C code of ReplayGain...

In the wiki, it states that RG tries to normalize the tracks to SMPTE-sanctioned 89 dB SPL, but in the code, the reference number used is actually 64.82:

Code: [Select]
#define PINK_REF                64.82 //298640883795                              // calibration value


Now, this is where I'm totally lost. What does this 64.82 stands for? Maybe is because ReplayGain C implementation calculates the values in a different dB scale? What scale is that?
Title: ReplayGain and dB calculations
Post by: Notat on 2012-01-18 23:18:10
The 89 dB SPL is a bit difficult to explain without unspooling the whole ball of yarn. ReplayGain operates by comparing the measured loudness of an audio file with the measured loudness of a reference signal. The reference signal is pink noise at -14 dB RMS (http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_specification#Reference_level). The constant in the code represents the measured loudness of this reference. If a measured file is found to be louder than this, ReplayGain will attenuate it.
Title: ReplayGain and dB calculations
Post by: Kyopaxa on 2012-01-19 00:01:12
Wow, I think I finally understood the whole thing! Thanks a lot.

So, to put this with other words:

The calibration value of 64.82 is the result of processing a -14dbFS pink noise signal with ReplayGain loudness algorithm.

I only have a question left.

Is this 64.82 still measured in dbSPL (According to SMPTE)? After all, the loudness value is the RMS value of a particular 0.05 sec chunk selected after cropping the first 5% higher level 0.05 sec chunks of the processed file, isn't it?