Lesson 9: Audio Pipeline and Mix Pass
Silent prototypes teach mechanics. Sound teaches weight, danger, and success. This lesson gives you a small but shippable audio stack that matches the game you already built in Lessons 3–8, without turning you into a full-time sound designer.
Lesson Objective
By the end of this lesson you will have:
- Import defaults you can reuse for SFX and music (compression, load type, streaming where it helps)
- At least one Audio Mixer with separate groups for SFX, Music, and UI
- A simple play API (static helper or small
AudioService) so gameplay code does not scatterAudioSourcesetup everywhere - A 10-minute mix pass checklist you can repeat before every milestone build
Why This Matters
Bad audio is not only ugly—it masks bugs. If footsteps, hits, and UI clicks share one flat volume, players cannot tell what matters. A minimal mixer graph plus routing discipline fixes most “why does this feel cheap?” feedback before you touch particles.
For extra library ideas later, bookmark our Top 20 Free SFX and Music Libraries for Game Developers (2026 Edition).
Step-by-Step
Step 1 - Normalize import settings
Create folders such as Audio/SFX, Audio/Music, Audio/UI.
SFX clips (short, many):
- Select a batch of
.wav/.oggclips. - In the Inspector, set Force To Mono for mono-friendly sounds (footsteps, UI) when you do not need stereo width.
- Load Type: Decompress On Load for tiny UI ticks; Compressed In Memory for longer one-shots if memory is tight.
- Compression Format: Vorbis or ADPCM depending on platform targets—prefer what your platform module recommends for your build.
Music (long loops):
- Use Streaming load type for longer tracks when appropriate.
- Enable Load In Background if you fade music in after scene load.
- Loop music clips explicitly in the clip import settings when the file is authored to loop cleanly.
Pro tip: Pick one reference SFX (a punchy UI click) and tune import settings until that clip feels crisp on headphones and cheap laptop speakers.
Step 2 - Create an Audio Mixer
- Assets → Create → Audio Mixer. Name it
MainMix. - Open the Audio Mixer window. Add groups:
SFX,Music,UI, all under Master. - Expose volume parameters (right-click volume → Expose). Rename exposed parameters to
sfx_vol,music_vol,ui_volin the Exposed Parameters dropdown.
Route everything through these groups instead of the default master-only chain.
Step 3 - Place listeners and sources correctly
- Keep one active Audio Listener on your main camera (or player rig)—never two at once.
- For 3D sounds (world pickups, enemy shots), use Spatial Blend = 1 on
AudioSourceand tune Min/Max Distance. - For UI and music, use 2D sources (
Spatial Blend = 0) parented under a persistent object.
Step 4 - Add a tiny AudioService
Create AudioService.cs on a DontDestroyOnLoad object:
using UnityEngine;
using UnityEngine.Audio;
public class AudioService : MonoBehaviour
{
public static AudioService Instance { get; private set; }
[SerializeField] private AudioMixer mainMix;
[SerializeField] private AudioSource sfxSource;
[SerializeField] private AudioSource uiSource;
[SerializeField] private AudioSource musicSource;
void Awake()
{
if (Instance != null) { Destroy(gameObject); return; }
Instance = this;
DontDestroyOnLoad(gameObject);
}
public void PlaySfx(AudioClip clip, float volume = 1f)
{
sfxSource.PlayOneShot(clip, volume);
}
public void PlayUi(AudioClip clip, float volume = 1f)
{
uiSource.PlayOneShot(clip, volume);
}
public void PlayMusic(AudioClip clip, bool loop = true)
{
musicSource.clip = clip;
musicSource.loop = loop;
musicSource.Play();
}
public void SetSfxDb(float db) => mainMix.SetFloat("sfx_vol", db);
public void SetMusicDb(float db) => mainMix.SetFloat("music_vol", db);
public void SetUiDb(float db) => mainMix.SetFloat("ui_vol", db);
}
Assign three AudioSource components: hook SFX and UI outputs to their mixer groups; assign Music output to Music. This keeps one-shots from fighting the music channel.
Step 5 - Hook gameplay events
From Lesson 6 UI buttons, call AudioService.Instance.PlayUi(clickClip).
From combat in Lessons 4–5, call PlaySfx on hit, death, and wave start.
Avoid Play() on a shared source for overlapping SFX—PlayOneShot is fine until you need pooling for rapid-fire weapons.
Step 6 - Run the 10-minute mix pass
- Silence check: Mute Music; confirm SFX/UI still read clearly.
- Masking check: Restore music; lower Music group until hits pop (often around -8 dB to -14 dB relative to peaks—ears beat numbers).
- Peak hunt: Watch for clipping on Master; pull SFX down before Master if you hear distortion stacks.
- Loop seam: If music loops click, fix the file or add a short crossfade in code later—note it in your backlog instead of shipping a glitchy loop.
- Platform sanity: Build once to device; Bluetooth latency is real—do not over-tune purely in-editor.
Mini Challenge
Add a pause menu slider that adjusts music_vol and sfx_vol exposed parameters. Store the player’s dB choices with your Lesson 8 save model as two floats.
Common Mistakes
- Multiple listeners after scene loads or duplicate cameras.
- Music on PlayOneShot—loops belong on a dedicated looping source.
- 3D spatialization on UI clicks—keep UI 2D.
- Ignoring voice chat / platform mix—console SDKs sometimes require specific categories; note that before console ports.
Troubleshooting
No sound at all
Confirm the Audio Listener is enabled, mute flags are off, and mixer attenuation is not -80 dB from a bad default.
Sounds cut out when many play
Introduce a small pool of AudioSource components for rapid SFX, or limit simultaneous instances per clip.
Mixer changes do nothing
Verify each AudioSource Output field points to the correct Mixer Group, not Master directly unless intentional.
Recap
You set sane import defaults, created a three-bus mixer, centralized playback in a persistent service, and ran a short mix checklist so audio supports the core loop instead of fighting it.
Next Lesson Teaser
Lesson 10 focuses on VFX and game feel polish—particles, trails, and hit-stop style feedback that reads on top of your new mix.
FAQ
FMOD/Wwise for this course?
Out of scope for the slice; upgrade when you hire audio or ship on platforms that demand middleware.
Adaptive music?
Start with layers (intro loop + combat stem) toggled by code; full adaptive scores come after vertical slice sign-off.
Voice-over?
Treat VO like music for routing—dedicate a VO mixer group when you add it.
Related Links
- Lesson 8: Save, Load, and Progression Systems
- Top 20 Free SFX and Music Libraries for Game Developers (2026 Edition)
- Unity guide
If it sounds good with music half as loud as you think, players can still reach for the volume slider—and that is a win.