TExcelTAD
Home › Assets, Tools & Shipping › Loudness & Normalization

Loudness & Normalization

Players notice inconsistent loudness long before they notice compression artefacts: a menu click that's louder than an explosion, music that drowns dialogue, a game that's much quieter than the video they just watched. Professional audio teams measure loudness and mix to a target. As a programmer you'll mostly need to understand the numbers, check them in a pipeline, and set up volume controls that behave.

Decibels in one table

Digital audio levels are measured in dBFS (decibels relative to full scale): 0 dBFS is the loudest value a sample can hold, everything else is negative. Decibels are logarithmic:

Change Amplitude factor
+6 dB ×2 (about)
−6 dB ×0.5
−20 dB ×0.1
−60 dB ×0.001 (almost silent)

dB = 20 × log10(amplitude) and amplitude = 10 ** (dB / 20). A volume slider should work in decibels (or with a curve), not linearly: a linear slider puts all the audible change in the bottom few percent.

Peak, RMS and LUFS

  • Peak is the largest absolute sample value. It tells you whether a sound will clip (exceed 0 dBFS), not how loud it sounds.
  • RMS (root mean square) is the average energy. It's closer to perceived loudness.
  • LUFS / LKFS (loudness units relative to full scale, defined in ITU-R BS.1770) is RMS with two improvements: a K-weighting filter that models the ear's sensitivity to frequencies, and gating that ignores silence. It's what loudness targets are written in.

This example measures a synthetic sound: a quiet tone, a loud burst, and silence. It computes peak and RMS, plus a gated loudness in the style of BS.1770 (400 ms blocks, an absolute gate at −70 and a relative gate 10 dB below the average), but without the K-weighting filter, so its number is only an approximation of LUFS:

python · try it yourself
import math

RATE = 8000
def tone(freq, amp, seconds):
    return [amp * math.sin(2 * math.pi * freq * i / RATE) for i in range(int(RATE * seconds))]

signal = tone(220, 0.10, 1.0) + tone(440, 0.60, 0.8) + [0.0] * RATE  # quiet, loud, silence

def db(x):
    return 20 * math.log10(x) if x > 0 else float("-inf")

def ms_db(mean_square):           # energy -> dB
    return 10 * math.log10(mean_square) if mean_square > 0 else float("-inf")

peak = max(abs(s) for s in signal)
rms_ms = sum(s * s for s in signal) / len(signal)

def gated_loudness(x, block=0.4, overlap=0.75):
    size, step = int(RATE * block), int(RATE * block * (1 - overlap))
    blocks = [sum(s * s for s in x[i:i + size]) / size for i in range(0, len(x) - size + 1, step)]
    loud = [b for b in blocks if ms_db(b) > -70]                       # absolute gate
    rel_gate = ms_db(sum(loud) / len(loud)) - 10
    kept = [b for b in loud if ms_db(b) > rel_gate]                    # relative gate
    return ms_db(sum(kept) / len(kept)), len(blocks), len(kept)

loudness, n_blocks, n_kept = gated_loudness(signal)
print(f"peak            : {db(peak):6.1f} dBFS")
print(f"RMS (whole file): {ms_db(rms_ms):6.1f} dBFS")
print(f"gated loudness  : {loudness:6.1f} (approx. LUFS, {n_kept} of {n_blocks} blocks kept)")
peak            :   -4.4 dBFS
RMS (whole file):  -12.7 dBFS
gated loudness  :   -8.8 (approx. LUFS, 11 of 25 blocks kept)

The RMS of the whole file is dragged down by the second of silence and the quiet part; the gated measurement mostly ignores them, which is why it matches what a listener perceives as "how loud this sound is". For real measurements use a meter that implements the full standard: Audacity's Loudness Normalization effect (it normalizes to a LUFS target), the loudness meters in Reaper, Adobe Audition, ffmpeg's ebur128 and loudnorm filters, or the meters inside FMOD and Wwise.

Normalization to a target

Normalization applies one gain so a sound hits a target loudness. The gain is just the difference in dB, but there's a catch: raising the level also raises the peak, and the peak must stay under a ceiling (often −1 dBTP, "true peak", to leave room for codec overshoot). If it doesn't fit, you need a limiter or a lower target:

python · try it yourself
def normalize_plan(name, loudness, peak_db, target=-16.0, ceiling=-1.0):
    gain = target - loudness
    new_peak = peak_db + gain
    if new_peak <= ceiling:
        return f"{name:<12} {loudness:6.1f} -> {target} LU: gain {gain:+5.1f} dB, peak {new_peak:5.1f} ok"
    return (f"{name:<12} {loudness:6.1f} -> {target} LU: gain {gain:+5.1f} dB would peak at {new_peak:+.1f}; "
            f"limit {new_peak - ceiling:.1f} dB or lower the target")

assets = [("music_menu", -19.4, -3.2), ("vo_intro", -24.8, -9.5), ("sfx_laser", -12.1, -0.4),
          ("ambience", -30.2, -18.0), ("sfx_drum", -22.0, -2.0)]
for a in assets:
    print(normalize_plan(*a))
music_menu    -19.4 -> -16.0 LU: gain  +3.4 dB would peak at +0.2; limit 1.2 dB or lower the target
vo_intro      -24.8 -> -16.0 LU: gain  +8.8 dB would peak at -0.7; limit 0.3 dB or lower the target
sfx_laser     -12.1 -> -16.0 LU: gain  -3.9 dB, peak  -4.3 ok
ambience      -30.2 -> -16.0 LU: gain +14.2 dB, peak  -3.8 ok
sfx_drum      -22.0 -> -16.0 LU: gain  +6.0 dB would peak at +4.0; limit 5.0 dB or lower the target

This plan normalizes each file to one target to show the arithmetic; the next section explains why a whole game shouldn't be treated that way.

Targets

There is no single industry-wide standard for games, but commonly cited targets are:

Context Integrated loudness, roughly
Broadcast TV (EBU R128) −23 LUFS
Console games (Sony's ASWG-R001 recommendation) about −24 LUFS for home consoles, louder for handhelds
Mobile games, web, streaming platforms often −16 to −14 LUFS

Measure the whole game mix over a representative play session (not individual files) against your target, and mix individual categories relative to each other. Normalizing every file to the same loudness is a common beginner mistake: a whisper and an explosion are supposed to differ. Normalise per category (all dialogue lines to one level, all UI clicks to another), then mix the categories with buses.

Buses and volume settings

Route every sound through a bus (mixer group) per category: Master → Music, SFX, Dialogue, UI. The settings menu then controls bus volumes, in dB:

csharp
// Unity: an exposed AudioMixer parameter driven by a 0..1 slider
float sliderValue = 0.5f;
float dB = sliderValue > 0.0001f ? Mathf.Log10(sliderValue) * 20f : -80f;
audioMixer.SetFloat("MusicVolume", dB);   // "MusicVolume" exposed on the Music group

Godot has the same concept as Audio Buses (AudioServer.set_bus_volume_db, plus linear_to_db()), and Unreal uses Sound Classes and Sound Mixes (or MetaSounds and submixes). FMOD & Wwise provide their own buses and loudness meters.

Test yourself

What does LUFS add on top of a plain RMS level?

  1. Nothing, it's the same
  2. A frequency weighting that models hearing, and gating that ignores silence
  3. Peak detection
  4. Stereo width

A sound measured at -20 LUFS with a peak of -2 dBFS is normalized to -16 LUFS. What happens to its peak?

  1. Stays at -2 dBFS
  2. Rises to +2 dBFS, so it would clip without a limiter
  3. Drops to -6 dBFS
  4. Becomes -16 dBFS

Why should a volume slider map to decibels instead of a linear gain?

  1. Decibels are faster to compute
  2. Loudness perception is logarithmic, so a linear slider puts all the audible change in a tiny range
  3. Engines only accept dB
  4. To avoid clipping