TExcelTAD
Home › Assets, Tools & Shipping › Audio Formats & Compression

Audio Formats & Compression

Audio is easy to get wrong in two opposite directions: music loaded fully into memory as uncompressed PCM eats hundreds of megabytes, while footsteps decoded from a compressed stream every time they play cost CPU and add latency. The right choice depends on how long the sound is, how often it plays, and how quickly it must start.

Formats you'll meet

Format Type Use
WAV (PCM) uncompressed source files from the audio designer; very short, latency-critical effects
Ogg Vorbis lossy, open music and long sounds in Unity and Godot; good quality per byte
Opus lossy, open voice and music at low bitrates; used by some engines and platforms
MP3 lossy supported by Godot and Unity; fine for music; patents have expired
ADPCM lightly compressed (about 3.5:1) many short effects; cheap to decode
FLAC lossless archiving sources (not usually shipped)

Always keep uncompressed sources (WAV, 48 kHz or 44.1 kHz, 24-bit) in version control and let the engine compress per platform. Re-compressing an already-lossy MP3 into Vorbis loses quality twice.

Size of uncompressed audio

PCM size is simply sample rate × channels × bytes per sample × seconds:

python · try it yourself
def pcm_bytes(seconds, rate=48_000, channels=2, bits=16):
    return seconds * rate * channels * bits // 8

def mib(n):
    return n / (1024 * 1024)

sounds = [("footstep", 0.4, 1), ("explosion", 2.5, 2), ("dialogue line", 6.0, 1), ("level music", 180.0, 2)]
for name, sec, ch in sounds:
    print(f"{name:<14} {sec:6.1f} s {'stereo' if ch == 2 else 'mono  '} {mib(pcm_bytes(sec, channels=ch)):8.2f} MiB")
print()
print(f"1 hour of stereo music as 16-bit PCM: {mib(pcm_bytes(3600)):.0f} MiB")
for kbps in (96, 128, 192):
    print(f"   ... as {kbps} kbit/s Vorbis/Opus: {kbps * 1000 / 8 * 3600 / 1024 / 1024:6.1f} MiB")
footstep          0.4 s mono       0.04 MiB
explosion         2.5 s stereo     0.46 MiB
dialogue line     6.0 s mono       0.55 MiB
level music     180.0 s stereo    32.96 MiB

1 hour of stereo music as 16-bit PCM: 659 MiB
   ... as 96 kbit/s Vorbis/Opus:   41.2 MiB
   ... as 128 kbit/s Vorbis/Opus:   54.9 MiB
   ... as 192 kbit/s Vorbis/Opus:   82.4 MiB

Two things jump out: sound effects are small even uncompressed, and music is where compression matters, by a factor of about ten.

How the engine holds a sound

Engines let you choose per clip how it lives in memory. In Unity's Audio Clip importer:

Load Type In memory CPU when playing Use for
Decompress On Load full PCM lowest short, frequent effects
Compressed In Memory compressed data, decoded as it plays some medium-length, less frequent sounds
Streaming a small buffer, read from disk as it plays some, plus disk I/O music, ambience, long dialogue

Unity's Compression Format (PCM, ADPCM, Vorbis) and Quality are set per platform in the same importer. Godot imports WAV (with optional compression; recent versions offer QOA) for effects, and Ogg Vorbis / MP3 for music, which are kept compressed and decoded while they play. Unreal imports WAV sources and compresses them per platform in the Sound Wave's settings; it can also stream long waves. The choice logic is the same everywhere:

python · try it yourself
def choose(seconds, plays_per_minute, channels=2):
    if seconds >= 30:
        return "stream, Vorbis/Opus ~128-160 kbit/s"
    if seconds <= 2 and plays_per_minute >= 10:
        return "decompress on load (ADPCM or PCM)"
    return "compressed in memory (Vorbis/ADPCM)"

clips = [("footstep", 0.4, 120), ("ui_click", 0.1, 30), ("explosion", 2.5, 3),
         ("dialogue_017", 6.0, 0.2), ("ambience_forest", 95.0, 1), ("music_boss", 210.0, 0.5)]
for name, sec, ppm in clips:
    print(f"{name:<16} {sec:6.1f} s, {ppm:5} plays/min -> {choose(sec, ppm)}")
footstep            0.4 s,   120 plays/min -> decompress on load (ADPCM or PCM)
ui_click            0.1 s,    30 plays/min -> decompress on load (ADPCM or PCM)
explosion           2.5 s,     3 plays/min -> compressed in memory (Vorbis/ADPCM)
dialogue_017        6.0 s,   0.2 plays/min -> compressed in memory (Vorbis/ADPCM)
ambience_forest    95.0 s,     1 plays/min -> stream, Vorbis/Opus ~128-160 kbit/s
music_boss        210.0 s,   0.5 plays/min -> stream, Vorbis/Opus ~128-160 kbit/s

The thresholds are a starting point, not a rule; profile memory and CPU on the target device.

Sample rate, channels and the 3D question

  • Mono for positional sounds. A 3D sound is panned by the engine; a stereo source either ignores positioning or gets downmixed. Footsteps, gunshots and voices in the world should be mono, which also halves their size.
  • Stereo for music, UI and ambience beds.
  • Sample rate: 48 kHz or 44.1 kHz for most things. Downsampling quiet ambient loops to 22.05 kHz is a common mobile saving (Unity's Sample Rate Setting → Override).
  • Loop points: loops must be cut at zero crossings and the format must loop seamlessly. MP3 and some encoders add silence at the start (encoder delay), which causes a gap; Ogg Vorbis and WAV loop cleanly.

Test yourself

Which load type suits a 3-minute music track?

  1. Decompress on load
  2. Streaming
  3. PCM in memory
  4. ADPCM in memory

Why should a footstep that plays in 3D space be mono?

  1. Stereo is not supported
  2. The engine positions it; a stereo source can't be panned properly and doubles the size
  3. Mono is louder
  4. To loop it

What should be kept in version control as the audio source?

  1. The compressed Ogg files
  2. Uncompressed WAV masters, letting the engine compress per platform
  3. MP3 at 128 kbit/s
  4. Nothing, audio is generated