INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Discussion of Replay Gain and Audio Level Meter proposal  (Read 3197 times)

negopus

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 295
  • Negopus: negotium, otium et opus
Discussion of Replay Gain and Audio Level Meter proposal
« on: June 29, 2006, 03:30:17 pm »

[Edit]

This post is rather technical (and long). Read it at your own risk. You might get some insight into Replay Gain, however.

After discovering Replay Gain, I have experimented a bit with it. I figured out how it works. Replay Gain changes the track volume in order to make all tracks sound at the same (apparent) loudness. I also have a proposal for a level meter to be implemented in Media Center.

I have started by figuring out how signal levels change using Replay Gain. It’s not difficult, but not so immediate either.
1) The source signal (the audio file) has a level that can be measured in dBFS (dB relative to Full Scale). It is usually normalized to peak at 0 dBFS (except for 0 dBFS+ signals, that I have described in another post). It clips at full scale, or 0 dBFS. So the dBFS level is usually negative. Each audio track has an average level AVG (A-weighted RMS) and a peak level PK, both of which are calculated by Analyze Audio. However the average level is translated to Replay Gain (using the formula RG=-20-AVG, with AVG<0), and Peak Level is expressed in percent, while it would be better to express it in dBFS (PK=20*log10([Peak Level]). PK is always negative (again, except for the case of 0 dBFS+ signals).
2) After processing with Replay Gain the resulting signal has a different level. Replay Gain aims at making all tracks play at the same (perceived) loudness. Let’s express its level just in dB, as there is no absolute reference here. Replay Gain adjusts the level so that the (A-weighted) RMS value (AVG) is 20 dB below full scale. The soundcard clips the signal when it reaches 0 dB (in the scale after Replay Gain).
3) At last the signal traverses the entire audio system. When it comes out of the speakers the signal is a physical sound and has a level that can be expressed in dB SPL (Sound Pressure Level). There is a calibration standard, that has been used in the movie industry for decades, and corresponds to both the Replay Gain standard and the K-20 standard by Bob Katz. A pink noise recorded at -20 dBFS RMS, played through a single speaker, should correspond to 83 dB SPL. I have tried to do this calibration, although with a non-professional sound level meter (a Nokia 5140i phone), and I found that 83 dB SPL is quite loud. I usually listen to music at a lower volume. (There is another standard where 89 dB SPL is used for calibration. It corresponds to the K-14 standard by Bob Katz.)

I have some confusion about the RMS reference level. The test signal mentioned above (Pink Noise -20 dBFS RMS) gives different results when using different programs:
•   Replay Gain (analyzed by MC) is -0.78 dB, that corresponds to a -19.22 dB (A-weighted?) RMS value.
•   CoolEdit calculates a RMS value of -19.91 dB using a 300 ms RMS window and the “0 dB = FS Sine Wave” setting (the “0 dB = FS Square Wave” setting gives a result 3 dB lower, RMS -22.91 dB).
•   Using InspectorXL the RMS value oscillates around -19.8 dB using a 50 ms RMS window (and -20.2 dB using a 300 ms RMS window) and the “Peak-RMS Parity” option set (that raises the RMS value by 3 dB – see later).
So I don’t know which one is the correct RMS value. I’m especially confused by the artificial 3 dB boost that some programs can introduce as an option.

I think this chart explains the situation better than one thousand words (I am not an ASCII artist, though). In this case Replay Gain is positive.


        PRE-RG =====================----------o dBFS
               |(noise)    |AVG    |PK        |Source Clip     

POST-RG ============================---] dB
               |(noise)    |AVG    |PK |Output Clip

    SPL -------------------------------] dB SPL
                           |83         |103



Logged

negopus

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 295
  • Negopus: negotium, otium et opus
Re: Discussion of Replay Gain and Audio Level Meter proposal
« Reply #1 on: June 29, 2006, 03:31:44 pm »

[Edit]

Now some maths.

According to Bob Katz’s terminology, let’s call headroom the dynamic range of the signal (AVG to PK). It is left unchanged by Replay Gain.

HR=PK-AVG

and cushion the spare part of the system’s dynamics (PK to the system’s full scale ]), that is actually never used in playback. The cushion is altered by Replay Gain.

CSH=0-PK-RG=-PK-(-20-AVG)=20+(AVG-PK)=20+HR

The output signal clips when there is no cushion.

CSH<0

That is, when

HR>20 and AVG<-20 (that is, the track dynamics is more than 20 dB and the average track level is below -20 dBFS)

The maths are not extremely difficult, but are somewhat boring and deserve some attention. When I found the correct formula and put it into a spreadsheet containing my entire audio library, I have found very few tracks that clip after Replay Gain (CSH<0). Most of them are demos of professional musical instruments:

•   “Flautando” by Herb Tucmandl, a demo of the Vienna Symphonic Library sample library, that shows its high dynamics.
•   “Adagio clean” , a classical piano track used to demonstrate Hybrid Piano 2 by Post Musical Instruments.
•   “Dark Side” by Dan Fisher, a demo of the Kurzweil K2600 synthesizer, that uses a lot of resonant analog filters.

Other tracks that clip (CSH<0) are from audiophile recordings and experimental tracks with high dynamics.

There are three different situations depending on the values of AVG and PK
•   A) AVG < -20  dBFS and CSH>0: Replay Gain is positive. There is still a cushion.
•   B) AVG < -20  dBFS and CSH>0: Replay Gain is positive and the source dynamics is greater than 20 dB. There is no cushion. This is a ClipsForSure situation. The track will clip during playback. This is the (rare) case when Replay Gain does not work well.
•   C) AVG > -20  dBFS: Replay Gain is negative. The source signal clipping at 0 dBFS won’t correspond to full scale after Replay Gain, so it won’t overload the output stage.

Here are the charts for the three situations described above.


A) AVG < -20 dBFS; RG > 0; CSH > 0

          PRE-RG |=======================--------o dBFS
                 |(noise)      |AVG    |PK      |Source Clip     

    POST-RG ============================---] dB
                 |(noise)      |AVG    |PK |Output Clip

        SPL -------------------------------] dB SPL
                               |83         |103

B) AVG < -20 dBFS; RG > 0; CSH < 0 (no cushion)

           PRE-RG ============================---o dBFS
                  |(noise)     |AVG          |PK |Source Clip     

    POST-RG ===============================* dB
                  |(noise)     |AVG        | |PK ClipsForSure (no cushion)
 
        SPL -------------------------------] dB SPL
                               |83         |103

C) AVG > -20 dBFS; RG < 0

 PRE-RG ============================---o dBFS
        |(noise)             |AVG  |PK |Source Clip     

    POST-RG ========================---o---] dB
        |(noise)             |AVG  |PK |   |Output Clip

        SPL -------------------------------] dB SPL
                             |83           |103


Logged

negopus

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 295
  • Negopus: negotium, otium et opus
Re: Discussion of Replay Gain and Audio Level Meter proposal
« Reply #2 on: June 29, 2006, 03:33:11 pm »

[Edit]

Now for the level meter. Having done these considerations, I have some suggestions to implement a level meter in Media Center.

First, the layout. It should be vertical and be located in the Action Window (that in the latest versions of MC is fixed, can’t be detached). It’s the only available place for a reasonably sized meter. Putting the meter in the position where spectrum analyzer currently is would make it too small. Also, I know that JRiver always keeps an eye on visual looks of audio meters inside Media Center. So I have looked at all the standard (but maybe boring) meters, but I found a more cool-looking, dynamic, meter.

The level meter should display the signal level at a selectable position: Pre-RG (or better, Pre-DSP Studio) and Post-RG (or Post-DSP Studio).

In both cases the meter should compensate for the delay introduced by the buffer (Tools > Options > Playback > Audio > Output Mode Setting > Buffering). If in Winamp (Media Center with DirectX host has a too slow refresh rate) I use a VST adapter and then a VST level meter, its display is in advance of one buffer size respect to the audio output. Probably the tap for the plug-in is placed before the buffer. I guess the same applies to Media Center.

The Pre-DSP Studio meter scale is in dBFS, from negative values up to 0. It displays the quality of the source file. Clips are displayed at full scale (0 dBFS). For clip detection there can be a choice between "digital over" (n consecutive samples at 0 dBFS level) or "upsampled" meter (detects 0 dBFS+ signals). The clip indicator lights up when a clip is detected, and can be reset by clicking on it. The coloring of the meter can be standard: green up to -12 dBFS, yellow from -12 dBFS to -6 dBFS, red from -6 dBFS to 0 dBFS.

The Post-DSP Studio meter displays what you are actually hearing through the speakers. It is the signal after the processing by DSP Studio, that is passing through the soundcard output. Its scale is in dB and, optionally, in dB SPL if you have a calibrated audio system. The calibration level, of course, is user-selectable. The coloring of the meter can be according to the K-20 standard: green up to 0 dB, yellow 0 to +4 dB, red more than +4 dB. Optionally the coloring of the meter can be taken from the Pre-DSP Studio section, and an additional clip indicator can be added at the level of the original “Source Clip” (only in the case RG<0 of course, where the dynamics range between “Source Clip” and “Output Clip” is unused).

For testing I have used InspectorXL, a VST plug-in, looped back the output of the sound card in an analog way. I haven’t experimented with digital loopback yet. InspectorXL was relatively cheap ($89) when I bought it from Elemental Audio. Now Roger Nichols Digital has acquired Elemental Audio, added iLok copy protection and boosted the price of InspectorXL to $299.

I found that the K-20 meter, based on the RMS value of the audio signal, is well suited to displaying the actual perceived loudness. InspectorXL has both a standard meter and a K-20 meter. I had to fiddle with the level meter parameters in order to make the standard meter behave like the K-20 meter. Time constants for decay should be rather slow. Also, you need to set the Peak-RMS parity option. A sine wave with a peak level of 1 (0 dB) has a RMS value of 0.707 (-3 dB). This option boosts the RMS value readout by 3 dB, in order to make the peak and RMS meters have the same value for a sine wave. It is not so polite, in my opinion. At least it is not mathematically correct. Bob Katz has used this standard in defining his K-20 level meter, however.

In the next post I will include some screenshots.


Logged

negopus

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 295
  • Negopus: negotium, otium et opus
Re: Discussion of Replay Gain and Audio Level Meter proposal
« Reply #3 on: June 30, 2006, 01:36:16 pm »

Screenshots

Screenshots were taken while playing a pink noise at -20 dBFS RMS. In this case Replay Gain is zero. The peak value of the signal is about 9 dB above the RMS value. The meter used is InspectorXL. Sorry for the poor quality, I’m not much into graphics.

All meters show both RMS and peak value, and both the instant value and a "hold" value. In total, 4 values are displayed.
•   The RMS value is the big colored bar
•   The RMS hold value is the thin horizontal green line
•   The peak value is the thick horizontal light blue line
•   The peak hold value is the thin horizontal light blue line
The key here is to display the RMS value as a big bar, and the peak value as a horizontal line only. The value of interest to the listener is the RMS value of the signal, which is related to the perceived loudness. The peak value could be of interest only to a mastering engineer, so it is better for the listener to focus on RMS value rather than the peak value.

•   Pre-DSP Studio – Linear scale


The meter is calibrated in dBFS, the amplitude of the source signal (the audio file being played).
Coloring of the big bar is: green up to -12 dBFS; yellow from -12 dBFS to -6 dBFS; red -6 dBFS to 0 dBFS.
The overflow light can be triggered either by a “digital over” or by upsampling and detecting 0 dBFS+ signals. The overflow light can be reset by clicking on it.

•   Post-DSP Studio - K-20 scale


The meter is calibrated in dB, after the Replay Gain (and the entire DSP Studio) stage.
This meter is calibrated according to the K-20 standard by Bob Katz. Please note that in the K-20 standard the RMS value is boosted +3 dB respect to the mathematically correct value. This is somewhat confusing (see the discussion in previous post). I applied the same boost in the other meters in order to be consistent.
Coloring of the big bar is: green up to 0 dB; yellow from 0 dB to +4 dB; red from +4 dB to +20 dB.

•   Post-DSP Studio – Logarithmic scale


The meter is calibrated in dB, after the Replay Gain (and the entire DSP Studio) stage.
The range is enhanced in the zone from 0 dB to +20 dB. This adds movement to the meter in the AVG-to-PK range, and is visually more interesting.
Coloring of the big bar is: green up to 0 dB; yellow from 0 dB to +4 dB; red from +4 dB to +20 dB. Alternatively the colouring of the big bar can be based on the signal amplitude (in dBFS) before Replay Gain (and DSP studio). This adds an indication of how Replay Gain (and DSP Studio) is working.
The overflow light actually lights up only in the rare cases when the Replay Gain is positive (average level below -20 dBFS) and the signal has a dynamic range of over 20 dB (there is no “cushion” after applying Replay Gain). So a second overflow light could be added where the source signal reaches the 0 dBFS level.

Logged

negopus

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 295
  • Negopus: negotium, otium et opus
Re: Discussion of Replay Gain and Audio Level Meter proposal
« Reply #4 on: June 30, 2006, 02:53:09 pm »

Layout

I think that the Audio Level Meter should be located in the Action Window, in the left pane. As it is closely related to DSP Studio, the Audio Level Meter should become a remote control for DSP Studio. The user should be able to check/uncheck all the modules in DSP Studio. (But, in order to change parameters, DSP Studio should be still open. I don't know if it makes sense to move the entire DSP Studio in the Action Window, because of size requirements. DSP Studio is too large to fit into the Action Window.
Logged

negopus

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 295
  • Negopus: negotium, otium et opus
Re: Discussion of Replay Gain and Audio Level Meter proposal
« Reply #5 on: June 30, 2006, 02:54:28 pm »

Signal Generator

Of course there should be a signal generator for calibration purposes. It should generate a pink noise at a -20 dbFS level, one channel at a time, so that one can calibrate the audio system to the reference 83 dB SPL.
Logged

negopus

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 295
  • Negopus: negotium, otium et opus
Re: Discussion of Replay Gain and Audio Level Meter proposal
« Reply #6 on: June 30, 2006, 02:56:47 pm »

Some open points

•   When Replay Gain is not used in plain mode (Track Based) another additional gain is involved. This needs to be taken into consideration in the scale of the Post-DSP Studio meter.
•   I haven't covered the case of multi-channel audio yet. Maybe the meter could just have more columns.
•   I don't know how MC handles files played by an external engine. Probably DSP Studio is not used, and the Audio Level Meter could be unusable.

Logged
Pages: [1]   Go Up