Audio Loudness Filters

Advanced Audio Loudness and Normalization Topics

Loudness Measurement

Audio normalization adjusts the integrated loudness of a program to a specific target level. EBU R 128 recommends normalizing audio to a target level of -23 LUFS (levels between -24 and -14 LUFS are commonly used in the industry).

For the purposes of normalization dB and LU are equivalent in that a 1 dB change in sound pressure will produce a 1 LU difference in perceived audio loudness.

Audio normalization measures the integrated loudness in a first pass. A gain (or attentuation) in dB is then applied to the audio level in a second pass. The gain is limited such that the true peak does not exceed the full scale level. EBU R 128 recommends a true peak below -1 LUFS.

EBU 128 R analyzes the audio loudness over different timeframes:

  1. momentary uses a 400ms sliding window representing the instantaneous loudness
  2. short term averages the loudness over a 3 second sliding window
  3. integrated averages the loudness over the entire duration of the program

EBU R 128 Analyzer

The EBU R 128 analysis aaeb filter measures the loudness of an audio stream and supports the following configuration properties:

PropertyValueDescription
RelativeGateOffsetfloatSets the relative gate threshold in LU. By default the relative gate ignores loudness measurements more than 10 LU below the current gated loudness. This value increases or decreases the relative gate. The default value is 0.
TruePeakVersionintegerBT.1770 version number used to compute the true peak level. Default is BT.1770-3.
UseDolbyDIbooleanIndicates whether Dolby Dialog Intelligence should be used as the gating function. Default is false.

In compliance with BT.1770 the filter measures loudness on 100ms audio samples. The loudness measurements are added to each sample as an loud analysis element.

PropertyValueDescription
momentary_loudnessfloatMomentary (400ms) loudness in LUFS.
short_term_loudnessfloatShort term (3 s) loudness in LUFS.
ungated_loudnessfloatBT.1770-1 integrated ungated loudness in LUFS.
level_gated_loudnessfloatBT.1770-2/3/4 integrated level gated loudness in LUFS.
speech_gated_loudnessfloatIntegrated speech gated loudness in LUFS.
loudness_rangefloatLoudness range of of the program in LU.
sample_peakfloatPeak sample level in dBFS.
true_peakfloatTrue peak signal level in dBTP.
speech_percentagefloatPercentage of speech content detectd in the program.

Properties Writer

The properties prop container writer is used to write analyzer results to a JSON file. For example the following composition will measure the loudness of the input wav file and write the measurements to the json output:

---
input:
  container:
  - name: wav
    audio:
    - name: a1
      channels: 2
      label:
      - L
      - R
output:
  container:
  - name: json
    type: prop
    properties:
      Kind: data
    audio:
    - route:
        name: a1
      filter:
      - type: aaeb
        properties:
          RelativeGateOffset: 2
{
  "input": {
    "container": [
      {
        "name": "wav",
        "audio": [
          {
            "name": "a1",
            "channels": 2,
            "label": [
              "L",
              "R"
            ]
          }
        ]
      }
    ]
  },
  "output": {
    "container": [
      {
        "name": "json",
        "type": "prop",
        "properties": {
          "Kind": "data"
        },
        "audio": [
          {
            "route": {
              "name": "a1"
            },
            "filter": [
              {
                "type": "aaeb",
                "properties": {
                  "RelativeGateOffset": 2
                }
              }
            ]
          }
        ]
      }
    ]
  }
}

The properties writer will produce an output similar to the following:

{
  "audio": [
    {
      "format": "twos",
      "sample_rate": {
        "numerator": 48000,
        "denominator": 1
      },
      "channels": 2,
      "label": [
        "L",
        "R"
      ],
      "sample": [
        {
          "duration": 4800,
          "analysis": [
            {
              "type": "loud",
              "momentary_loudness": -10.0,
              "short_term_loudness": -12.0,
              "ungated_loudness": -21.0,
              "level_gated_loudness": -21.0,
              "speech_gated_loudness": -22.0,
              "loudness_range": 25.0,
              "sample_peak": -5.0,
              "true_peak": -4.0,
              "dialogue_percentage": 35.0
            }
          ]
        }
      ]
    }
  ]
}

Loudness Correction

Audio loudness is corrected using the volume operator. The volume is specified as a linear gain value where 1.0 represents 0 dB logarithmic gain. Use the following equations to convert between linear and logarithmic values:

linear = 10 ^ (dB / 20), dB = 20 * log10 (linear)

For example the following corrects the output loudness by -1 dB (0.891):

---
input:
  container:
  - name: wav
    audio:
    - name: a1
output:
  container:
  - name: aac
    type: audi
    audio:
    - route:
        name: a1
      volume: 0.891
      encode:
        type: mcac
        properties:
          BitRate: 128000
{
  "input": {
    "container": [
      {
        "name": "wav",
        "audio": [
          {
            "name": "a1"
          }
        ]
      }
    ]
  },
  "output": {
    "container": [
      {
        "name": "aac",
        "type": "audi",
        "audio": [
          {
            "route": {
              "name": "a1"
            },
            "volume": 0.891,
            "encode": {
              "type": "mcac",
              "properties": {
                "BitRate": 128000
              }
            }
          }
        ]
      }
    ]
  }
}