IPB

Welcome Guest ( Log In | Register )

level matching when comparing lossy to lossless
krabapple
post Feb 7 2013, 19:42
Post #1





Group: Members
Posts: 2241
Joined: 18-December 03
Member No.: 10538



I probably should have had this settled in my mind long ago, but -- how necessary is it to level match when you are comparing a lossless track, to its mp3 counterpart?

By way of investigation, I compared foobar2k's reported replaygain and track peak values for the same track encoded (LAME 3.98) as V2 (195kbps VBR) and at 320 kbps CBR

lossless:
Track gain -1.08
Track Peak 0.938171

195kbps VBR:
+0.11
0.954459

320kbps CBR:
+.10
0.934477

The track peak differences are negligable, but whence comes the >1db difference in RPG gain of lossless vs. lossy? Does this mean that one should level match according to those RPG values when doing an ABX?

This post has been edited by krabapple: Feb 7 2013, 19:42
Go to the top of the page
+Quote Post
 
Start new topic
Replies
2Bdecided
post Feb 8 2013, 13:06
Post #2


ReplayGain developer


Group: Developer
Posts: 5108
Joined: 5-November 01
From: Yorkshire, UK
Member No.: 409



If I understand it correctly, EBU R128 / ITU BS.1770 is calculated as follows.

Without gating, it's quite simple. Essentially you just apply a filter to each audio channel, calculate the mean square of all the samples, add the per-channel results together, convert to dB, and Bob's your uncle. There's a bit of scaling, and you don't call the result dB, but basically that's it.


However, without gating it doesn't work very well, so gating is included - actually it's included twice. Let me try to explain it properly (if I make a mistake, please jump in and correct me!). Take a deep breath...

Before you start, remember the loudness calculation is 10log10(value) minus 0.691. The result is in LUFS*, which is just a dB scale. Calling it LUFS* makes it clear that all the other stages have also been done. Remember this - you'll need to apply it several times below.

1) To the samples from each audio channel, apply a "K" filter which consists of
1a) a shelf filter at ~ 1.5kHz
1b) a high pass filter at ~40Hz
2) split the samples in each channel into 400ms long 75% overlapping blocks
3) calculate the mean square value of the samples in each block in each channel
4) add the results for each channel together; you now have one value for each block
5) save these values!
6) apply the loudness calculation to each block, and throw away the blocks which give a result less than -70LUFS. Keep a record of which blocks remain.
7) for each block that remains, recall the value from step 5, and calculate the mean value of all these blocks
8) to that mean value, apply the loudness calculation. Bingo! A gated loudness value! you've finished! No, not really...
9) Take that gated loudness value, subtract ten, call the result X, go back to the blocks that were left after step 6, and throw any away that have a value less than X.
10) For the blocks that remain, recall the value from step 5, and calculate the mean value of all these blocks.
11) to that mean value, apply the loudness calculation. This is the loudness, in LUFS, of your audio signal. Congratulations!

12) The target loudness is -23LUFS. To make your audio match this, scale the audio samples by the appropriate amount. e.g. if step 11 gave -17LUFS, you need to multiply each audio sample by 0.5 to make the audio half as loud.

That's it. You've really finished now.


Obviously there are implementation tweaks and tricks, but I think it's clever that people can create meters which display the EBU R128 gated LUFS loudness in real time on an audio signal that's been running for many hours (think about it - you need to create a new sum of those many hours of audio every time you add another 400ms block!)



ReplayGain, re-worded to enable a simple contrast with the above, is as follows.

Before you start, remember the loudness calculation is 10log10(value) minus a non specified value (it gets cancelled out during the match with pink noise in steps 7+8).

1) To the samples from each audio channel, apply a filter based on inverting an equal loudness curve, which consists of
1a) a shelf at about 2kHz, plus high frequency roll off above 4kHz and again above 10kHz
1b) a 2nd order high pass filter at ~100Hz
2) split the samples in each channel into 50ms long non-overlapping blocks
3) calculate the mean square value of the samples in each block in each channel
4) add the results for each channel together; you now have one value for each block
5) apply the loudness calculation to each block.
6) calculate the 95th percentile. Save this value
7) repeat all the above for a -20dB RMS pink noise signal.
8a) step 7 minus step 6 plus 83dB gives you the loudness, in dB SPL, of your audio signal in an SMPTE RP200 calibrated system.
8b) step 7 minus step 6 gives you the ReplayGain adjustment needed to make the audio match the reference.
9) Add 6dB to the result of step 8b - everyone else did wink.gif
10) scale the audio samples by the appropriate amount. e.g. if step 9 gave -6dB, you need to multiply each audio sample by 0.5 to make the audio half as loud.

Hope this helps.

Cheers,
David.

* - The EBU call it LUFS, and pronounce it as a single syllable; the ITU call it LKFS, and pronounce it by spelling out the four letters.

P.S. references:
EBU R128:
http://tech.ebu.ch/loudness
http://tech.ebu.ch/docs/r/r128.pdf
ITU BS.1770:
http://www.itu.int/rec/R-REC-BS.1770-3-201208-I/en
ReplayGain:
http://replaygain.hydrogenaudio.org/propos...ulating_rg.html

This post has been edited by 2Bdecided: Feb 8 2013, 17:38
Go to the top of the page
+Quote Post
DonP
post Feb 8 2013, 14:18
Post #3





Group: Members (Donating)
Posts: 1471
Joined: 11-February 03
From: Vermont
Member No.: 4955



QUOTE (2Bdecided @ Feb 8 2013, 07:06) *
Before you start, remember the loudness calculation is 10log10(value) minus 0.691. The result is in LUFS*, which is just a dB scale. Calling it LUFS* makes it clear that all the other stages have also been done. Remember this - you'll need to apply it several times below.


dB is 10*log10(value) if the value represents power. It it is voltage (the usual) then use 20*log10(value) because dB represents relative power, which is the square of relative voltage.
Go to the top of the page
+Quote Post

Posts in this topic
- krabapple   level matching when comparing lossy to lossless   Feb 7 2013, 19:42
- - lvqcl   The difference between lossless original and LAME...   Feb 7 2013, 20:01
- - Garf   If they're encoded from the same source I see ...   Feb 7 2013, 20:03
|- - krabapple   QUOTE (Garf @ Feb 7 2013, 14:03) If they...   Feb 7 2013, 20:28
- - Arnold B. Krueger   QUOTE (krabapple @ Feb 7 2013, 13:42) I p...   Feb 7 2013, 20:12
- - greynol   QUOTE (Arnold B. Krueger @ Feb 7 2013, 11...   Feb 7 2013, 20:32
|- - krabapple   QUOTE I find there is too great a tendency to trea...   Feb 7 2013, 20:46
|- - greynol   QUOTE (krabapple @ Feb 7 2013, 11:46) But...   Feb 7 2013, 20:59
- - krabapple   Here's what I get when I run the three tracks ...   Feb 7 2013, 20:37
|- - db1989   QUOTE (krabapple @ Feb 7 2013, 19:37) (So...   Feb 7 2013, 20:59
- - greynol   Thanks for the data. I believe those average RMS ...   Feb 7 2013, 20:41
- - lvqcl   Do you have foo_hdcd or use foo_dsp_effect for de-...   Feb 7 2013, 20:48
|- - krabapple   QUOTE (lvqcl @ Feb 7 2013, 14:48) Do you ...   Feb 7 2013, 20:51
- - lvqcl   foobar2000 always uses postprocessing plugins such...   Feb 7 2013, 20:56
|- - krabapple   QUOTE (lvqcl @ Feb 7 2013, 14:56) foobar2...   Feb 7 2013, 22:23
- - greynol   Without going into a prolonged discussion about it...   Feb 7 2013, 21:03
|- - [JAZ]   QUOTE (greynol @ Feb 7 2013, 21:03) Witho...   Feb 7 2013, 22:57
|- - greynol   QUOTE ([JAZ] @ Feb 7 2013, 13:57)...   Feb 7 2013, 23:11
|- - Kees de Visser   For critical work I still prefer to adjust for equ...   Feb 8 2013, 11:24
- - db1989   foobar2000 uses libebur128 since v1.1.7, so a diff...   Feb 7 2013, 21:15
- - 2Bdecided   If I understand it correctly, EBU R128 / ITU BS.17...   Feb 8 2013, 13:06
|- - DonP   QUOTE (2Bdecided @ Feb 8 2013, 07:06) Bef...   Feb 8 2013, 14:18
|- - 2Bdecided   QUOTE (DonP @ Feb 8 2013, 13:18) QUOTE (2...   Feb 8 2013, 14:56
- - 2Bdecided   I do not use automatic (RG/R128) loudness matching...   Feb 8 2013, 13:15
- - greynol   I'm glad that is all spelled out, though you c...   Feb 8 2013, 16:58
- - 2Bdecided   It's made me realise that I ought to do a tabl...   Feb 8 2013, 17:56
- - lvqcl   QUOTE (krabapple @ Feb 7 2013, 23:28) QUO...   Feb 8 2013, 23:19


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 1st September 2014 - 16:34