✚ Game development

Game audio: sound effects, music and the in-game mixer

How to handle audio in a video game: sound effects with variations, voice limits, mixer buses, looping music, file formats and streamed loading.

Sound is often the last thing a solo developer thinks about, yet it is one of the first things players notice when it is missing. A jump without sound feels weightless, a hit without an audio impact feels as if it never landed. Handling audio well does not require expensive tools, but it does require some sensible technical and organisational choices.

Two categories of sound

Game audio falls roughly into two families with different needs:

Category Examples Characteristics
Sound effects Footsteps, jumps, gunshots, explosions, menu clicks Short, frequent, many at once
Music and ambience Background tracks, wind, rain, crowds Long, continuous, few at a time

This distinction drives how files are loaded and played.

Loading and formats

Sound effects are usually loaded fully into memory and decompressed in advance, because they must start without any delay. They are short, so the space they take up stays modest.

Music and long ambiences, on the other hand, are played by streaming: the file is read and decoded in chunks during playback. Keeping several minutes of uncompressed audio in memory would be wasteful.

As for formats, you work in uncompressed WAV during production and choose the distribution format according to platform and engine. Ogg Vorbis and Opus are open formats widely used for music and ambience; for short effects you can stay with WAV or use light compression. It is wise to use the same sample rate for all files to avoid constant resampling.

Voices and limits

Every sound being played occupies a voice. The number of simultaneous voices is limited, both for technical reasons and for clarity: twenty simultaneous explosions do not sound twenty times better; they produce a muddy and often distorted noise.

Some useful rules:

  • per-sound limit: for example no more than four instances of the same gunshot at once;
  • priority: the protagonist's voice or an important alert must never be cut off by a footstep;
  • stealing: when voices run out, stop the least important or quietest sound;
  • minimum interval: the same effect is not played twice within a few milliseconds, preventing sudden volume build-up.

Fighting repetition

Hearing exactly the same sound a hundred times in a row quickly becomes tiresome. Simple techniques to keep it lively:

  • variants: record three or four versions of the same footstep and pick one at random, avoiding repeating the last one;
  • pitch variation: randomly alter playback speed by a few percent;
  • volume variation: small random level differences;
  • layering: build an explosion from an initial crack, a body and a tail chosen separately.

With three variants and a small pitch variation, the ear stops noticing the repetition.

The mixer and buses

Instead of adjusting the volume of each sound individually, audio is organised into buses, channels that gather groups of sounds:

Master
 ├─ Music
 ├─ Effects
 │   ├─ Player
 │   ├─ Enemies
 │   └─ Ambience
 ├─ Dialogue
 └─ Interface

Each bus has its own volume and possibly effects, such as reverb for caves or a low-pass filter for underwater sounds. The volume sliders in the game's options act on the main buses: that is why players can turn down the music without losing the effects.

Ducking

When a character speaks, music and effects are automatically lowered to make room for the voice, and come back up when the dialogue ends. This technique, called ducking, is achieved by linking one bus's volume to another bus's level, and it greatly improves intelligibility.

Looping music

A background track must repeat without a noticeable jump. It needs a precise loop point, often not at the start of the file: an intro played only once, followed by a section that repeats. Many formats and engines let you specify loop start and end points in metadata.

When moving from one track to another, a crossfade of one or two seconds avoids abrupt cuts.

Volume and safe listening

A few points not to overlook:

  • normalise file levels, so that no sound is much louder than the others at the same volume setting;
  • start with a moderate master volume on first launch;
  • avoid sudden peaks, especially in menus and intro videos;
  • offer separate controls at least for music, effects and dialogue.

In short

  • Short sound effects are loaded into memory, music and ambience are streamed.
  • Voice limits, priorities and minimum intervals prevent clutter and distortion.
  • Variants and small random variations remove repetitiveness.
  • A bus-based mixer enables separate volume controls, effects and ducking.
  • Music needs precise loop points and crossfades between tracks.
MM
Marco Marzaduri

Marco Marzaduri works in cybersecurity, digital forensics and web development. A computer science graduate, he combines rigorous technical analysis with attention to the people who use technology.

Read also