Replay Gain / iTunesNORM / Compression

Discuss Decibel, a high quality audio player.
Post Reply
krofa
Posts: 4
Joined: Fri Sep 14, 2012 10:02 am

Replay Gain / iTunesNORM / Compression

Post by krofa » Sun Sep 30, 2012 12:10 am

Hello!

I've just purchased Decibel - I'm looking forward to using it…

ATM I am researching the Replay Gain thing a bit. I'm a musician, so the lingo surrounding this is not foreign to me.

The Wikipedia article explains that this tool basically calculates a per song or per album volume level that is derived through an RMS analysis. The reference level is set at -14 dB FS leaving headroom for dynamics. This level should translate to 89 dB SPL in the "acoustic domain". (What this translates to in the analog domain (dBu / dBV) depends on your calibration!)

I'm also gathering that iTunes Sound Check purports to do the same thing based on Peak level analysis. I take it that they chose to go this way to be on the safe side. Peak analysis doesn't account for perceived loudness as reliably as RMS would, but it makes sure that there is no clipping at all. Bottom-line, if you adjust playback levels based on peak values, you will get no clipping period. Hence, you won't need compression... I don't know what the reference level for Sound Check is. I'm guessing that this approach would probably have more headroom than -14 dB FS.

In any case, I am planning to start using these features but I want to ensure two things; universal compatibility between media players and totally avoid any compression at all.

In a post here http://forums.sbooth.org/viewtopic.php? ... ain#p10928 you've mentioned that iTunesNORM support for Decibel is on your list.

Did you already implement it so that I could use something like iVolume and keep my ability to use both iTunes and Decibel with similar results? Or, does your "Tags" application write iTunesNORM data as well? That would be an elegant solution too.

Regarding compression. The fact that you've put a "Hard Limit" option under replay gain preferences tells me that using a limiter like algorithm does come into question with RG. Is that the case? If so, if I were to choose "preamplification" would I be avoiding the use of such limiting? Or would it depend on where I set the preamplification slider?

BTW, does your pre-amplification slider basically adjust digital headroom up or down? So if it is set to its default 6 (dB FS, I presume), it practically shaves those dBs off of the -14 dB FS headroom? I have my doubts about this though - seeing that you’ve set max preamplification at 15 dBs. So what is the unit for the preamplification slider, and how does it relate to your digital volume slider?

Thanks for bearing with me!

Best.

User avatar
sbooth
Site Admin
Posts: 2445
Joined: Fri Dec 23, 2005 7:45 am
Location: USA
Contact:

Re: Replay Gain / iTunesNORM / Compression

Post by sbooth » Sun Sep 30, 2012 1:10 am

Thank you for purchasing Decibel! There are a lot of questions in your post but I'll try to address them below.
krofa wrote:In a post here http://forums.sbooth.org/viewtopic.php? ... ain#p10928 you've mentioned that iTunesNORM support for Decibel is on your list.

Did you already implement it so that I could use something like iVolume and keep my ability to use both iTunes and Decibel with similar results? Or, does your "Tags" application write iTunesNORM data as well? That would be an elegant solution too.
I have not yet implemented iTunNORM support in Decibel. Tag will calculate ReplayGain values for any supported file format, but it does not handle iTunNORM either. There is actually a third method of estimating loudness published by ITU. It is ITU-R BS.1770-3. I don't believe there is wide support in software players, but I have also considered adding volume adjustment using this algorithm as well.
Regarding compression. The fact that you've put a "Hard Limit" option under replay gain preferences tells me that using a limiter like algorithm does come into question with RG. Is that the case? If so, if I were to choose "preamplification" would I be avoiding the use of such limiting? Or would it depend on where I set the preamplification slider?
It really depends on the particular situation. If computed correctly, the RG information will contain an adjustment (in dB) for the track to normalize to 89 dB SPL and the track's peak value. When starting playback, Decibel sums the RG adjustment and the preamplification to determine an overall gain for the track. Then, the theoretical maximum sample value is calculated using this gain. If the sample is >=1 or < -1 then depending the settings the gain for the track may be adjusted downward so the peak sample will be in range. If this isn't done, the sample is hard limited to prevent clipping later after digital volume is applied.
BTW, does your pre-amplification slider basically adjust digital headroom up or down? So if it is set to its default 6 (dB FS, I presume), it practically shaves those dBs off of the -14 dB FS headroom? I have my doubts about this though - seeing that you’ve set max preamplification at 15 dBs. So what is the unit for the preamplification slider, and how does it relate to your digital volume slider?
The digital volume is applied in a separate step after the RG adjustment is performed. The RG gain application is performed immediately after audio is decoded and before it is buffered, and the volume is applied immediately before output. So, in the future when DSP is supported the RG will apply to the "native" signal and the volume will apply to the signal after DSP.

krofa
Posts: 4
Joined: Fri Sep 14, 2012 10:02 am

Re: Replay Gain / iTunesNORM / Compression

Post by krofa » Sun Sep 30, 2012 2:29 am

Hey man! Thanks for the detailed and quick reply!
smooth wrote: I have not yet implemented iTunNORM support in Decibel. Tag will calculate ReplayGain values for any supported file format, but it does not handle iTunNORM either. There is actually a third method of estimating loudness published by ITU. It is ITU-R BS.1770-3. I don't believe there is wide support in software players, but I have also considered adding volume adjustment using this algorithm as well.
Bottom line for me is, do you think that the new algorithm is more accurate in calculating perceived loudness so as to give you the option to further optimize playback fidelity. As an audiophile musician who has spent countless hours and days in the studio trying to optimize levels in mixes and masters without compressing the heck out of dynamics, my main concern is getting a playback device that just doesn't fiddle with compression and limiting at all during playback. We put tons of work into this in the studio and in the mastering house so from a musician (and musical) standpoint added compression means diminished fidelity. That said, I do appreciate the need for some such algorithm from a listener POV.

But the more I think about it, the iTunes method just seems safer, that is, if I'm understanding Sound Check correctly - esp. in the sense that it absolutely avoids compression by relying on peak level analyses. Even though this probably creates less homogenous playback loudness across tracks on a playlist, it still is more desirable in the musical sense - esp. if RG means added compression in certain cases no matter what. I would even suggest that giving us the option to use Sound Check might even make sense if it is the only method that steers clear from added compression and limiting.
smooth wrote: It really depends on the particular situation. If computed correctly, the RG information will contain an adjustment (in dB) for the track to normalize to 89 dB SPL and the track's peak value. When starting playback, Decibel sums the RG adjustment and the preamplification to determine an overall gain for the track. Then, the theoretical maximum sample value is calculated using this gain. If the sample is >=1 or < -1 then depending the settings the gain for the track may be adjusted downward so the peak sample will be in range. If this isn't done, the sample is hard limited to prevent clipping later after digital volume is applied.
(The bit about sample value being >=1 or <-1; these are the amplitude margins of the waveform, right?)

Now when you say "theoretical maximum sample value is calculated using this gain", does that happen in real time during playback? Or does that depend on whether I have chosen "Hard Limit" (HL) or "Reduce Preamplification" (RPA). My guess is, HL would happen in real time, whereas RPA would happen offline. Is that the case? If so, you're basically telling me that using RPA for "Clipping Prevention" would mean avoiding compression and limiting altogether. And there I'd have my answer.
smooth wrote: The digital volume is applied in a separate step after the RG adjustment is performed. The RG gain application is performed immediately after audio is decoded and before it is buffered, and the volume is applied immediately before output. So, in the future when DSP is supported the RG will apply to the "native" signal and the volume will apply to the signal after DSP.
Great to hear that you're planning to implement DSP. What fx platform are you planning to support? VST? That would give users a ton of options…

Best.

User avatar
sbooth
Site Admin
Posts: 2445
Joined: Fri Dec 23, 2005 7:45 am
Location: USA
Contact:

Re: Replay Gain / iTunesNORM / Compression

Post by sbooth » Sun Sep 30, 2012 1:11 pm

krofa wrote:Bottom line for me is, do you think that the new algorithm is more accurate in calculating perceived loudness so as to give you the option to further optimize playback fidelity. As an audiophile musician who has spent countless hours and days in the studio trying to optimize levels in mixes and masters without compressing the heck out of dynamics, my main concern is getting a playback device that just doesn't fiddle with compression and limiting at all during playback. We put tons of work into this in the studio and in the mastering house so from a musician (and musical) standpoint added compression means diminished fidelity. That said, I do appreciate the need for some such algorithm from a listener POV.
I really have no idea which is the most accurate algorithm for estimating loudness. I would assume that the new ITU method gives better results than RG (since it's newer), but as loudness can be somewhat perceptual I guess a 99% solution is the best that we can hope for.
But the more I think about it, the iTunes method just seems safer, that is, if I'm understanding Sound Check correctly - esp. in the sense that it absolutely avoids compression by relying on peak level analyses. Even though this probably creates less homogenous playback loudness across tracks on a playlist, it still is more desirable in the musical sense - esp. if RG means added compression in certain cases no matter what. I would even suggest that giving us the option to use Sound Check might even make sense if it is the only method that steers clear from added compression and limiting.
I don't know the details of how sound check works so I will have to do some research before I can respond.
(The bit about sample value being >=1 or <-1; these are the amplitude margins of the waveform, right?)
Yes, PCM audio when converted to floating point data will lie in the interval [-1, 1).
Now when you say "theoretical maximum sample value is calculated using this gain", does that happen in real time during playback? Or does that depend on whether I have chosen "Hard Limit" (HL) or "Reduce Preamplification" (RPA). My guess is, HL would happen in real time, whereas RPA would happen offline. Is that the case? If so, you're basically telling me that using RPA for "Clipping Prevention" would mean avoiding compression and limiting altogether. And there I'd have my answer.
The theoretical max sample (I say theoretical because it is based on the peak sample as recorded during the RG analysis) is calculated in advance if you have chosen RPA. The math is fairly simple, and in pseudocode looks like (with gain in dB):

Code: Select all

net_gain = pre_amp_gain + replay_gain_gain
if reduce_pre_amp_gain
  theoretical_max_sample = replay_gain_peak_sample_value * 10 ^ (net_gain / 20)
  if theoretical_max_sample >= 1 or theoretical_max_sample < -1
    reduced_gain = 20 * log10 (1 / abs(replay_gain_peak_sample_value))
So if you've chosen RPA you should never experience compression or limiting. I say should because it relies on an accurate max sample value recorded in the replay gain information.
Great to hear that you're planning to implement DSP. What fx platform are you planning to support? VST? That would give users a ton of options…
I plan on supporting Audio Units.

krofa
Posts: 4
Joined: Fri Sep 14, 2012 10:02 am

Re: Replay Gain / iTunesNORM / Compression

Post by krofa » Sun Sep 30, 2012 2:15 pm

Well, that answers most of my questions! - Thanks for that…

Please do keep us in the loop should you end up looking into Sound Check (SC).

I'd say, if implementing SC is not difficult; if it is as simple as taking into account the iTunesNROM field in your gain calculations instead of RPG data, then why not provide an option for its usage as well? That way, folks who had been relying on Sound Check for gain normalization, and weren't having (or perceiving) issues with it, they would have an easier time migrating to Decibel for their playback needs as well -- they wouldn't have to mess with calculating RPG values for their libraries and worry about whether their iOS devices would respond to the normalization data properly.

AU support is just as good as VST - most if not all professional effects developers will have AU versions of their plug-ins. An added bonus for AU is the fact that Mac OS ships with a basic set of AU effects so folks would have something to start working with from the get go. VST, I presume, would only come in handy if you were to port Decibel to Windows. You'd be ready in that department had you started with the VST platform to begin with. (Then again, I don't know if VST development under Mac OS and Windows have anything in common - if they don't then my presumption would be false…)

Best.

Post Reply