Audio mixing
Tutorial
·
Beginner
·
+10XP
·
30 mins
·
(151)
Unity Technologies

Add background music and configure an Audio Mixer to balance the sounds in your game.
Languages available:
1. Overview
Audio plays a critical role in shaping the player's experience, making gameplay more immersive and responsive. Professional game audio designers spend years perfecting soundscapes, and Unity’s Audio Mixer provides powerful tools to achieve a polished mix. By routing different sounds into categories, you can apply effects and volume adjustments globally rather than adjusting individual audio sources manually.
In this tutorial, you’ll add some background music. Then you’ll configure an Audio Mixer to efficiently manage and balance the sounds of your tanks’ engines, effects, and explosions.
2. Add background music
Background music enhances the atmosphere of a game, but it must be balanced properly so it doesn’t overpower key sound effects like engine sounds, the charging effect, or the explosions. In this step, you'll add a looping background music track and test it in the scene. Later, you’ll use an Audio Mixer to manage its volume.
1. Add an Audio Source GameObject for the background music
- In the Hierarchy window, open the Add (+) dropdown and select Audio > Audio Source.
- Rename the new Audio Source “Background Music” for better organization.
Note: An Audio Source GameObject is just an empty GameObject with an Audio Source component added to it.
2. Assign a background music clip
- In the Inspector window, use the foldout (triangle) to expand the Audio Source component.
- Select the Audio Resource property picker (⊙) and select one of the Music_[style] files.
Tip: In the Select Audio Resource window, you can select each of the soundwaves to preview the track before selecting it (you might have to expand the Preview window to see the soundwave).
3. Enable looping and test playback
- Enable the Loop property in the Audio Source component so the music plays continuously.
- Enter Play mode to test the background music and ensure it plays as expected.
Your game now has a background music track that loops continuously, but it probably sounds too loud at the moment. In the next steps, you'll use an Audio Mixer to better manage volume levels for a more balanced mix.
3. Create and set up a new Audio Mixer
Manually adjusting audio levels for each Audio Source component can become inefficient, especially as a game grows in complexity.
Unity’s Audio Mixer provides a structured way to manage all sound levels globally, rather than tweaking individual audio sources. By organizing sounds into categories, an Audio Mixer allows for centralized volume control, effects processing, and dynamic balancing during gameplay.
1. Create an Audio Mixer
- In the Project window, inside the Assets > _Tanks folder, create a new folder named “Audio Mixers” to keep things organized.
- Right-click the empty Audio Mixers folder and select Create > Audio > Audio Mixer.
- Rename the new Audio Mixer “MainMix”.
2. Open and dock the Audio Mixer window
- Double-click MainMix to open the Audio Mixer window.
- Dock the Audio Mixer window next to the Scene view for a more efficient workflow. This allows you to tweak audio settings while keeping an eye on the game environment.
3. Create three Audio Mixer groups for different audio categories
- In the Audio Mixer window, under the Groups section, select the Add (+) button three times to create three Audio Mixer groups and name them as follows:
- Music (for background music)
- Driving (for engine sounds)
- SFX (for sound effects like explosions and firing)
Important: All new groups must be child groups of the Master group, and on the same level as each other. To ensure this, you can right-click the Master group and select Add child group.
Your Audio Mixer is now set up as a global audio management tool, allowing you to route sounds through categorized groups for better control and balance.
4. Route audio sources to Audio Mixer groups
With your Audio Mixer groups set up, you’re ready to route all the Audio Sources in your project through the appropriate groups.
Then, you’ll be able to control the volume and add effects to entire groups of audio, rather than to individual audio sources.
1. Assign background music to the Music group
- In the Hierarchy window, select the Background Music GameObject, then, in the Inspector window, use the foldout to expand its Audio Source component.
- Select the Output picker (⊙) and select the Music group from the MainMix.
2. Assign tank engine sounds to the Driving group
- Select the original root Tank prefab in the _Tanks > Prefabs > Tanks folder, then locate the Audio Source component that plays the EngineIdle sound.
- Select the Output picker (⊙) and select the Driving group from the MainMix.
Important: Make sure to apply this change to your original Tank prefab (rather than any one variant). When you apply a change to the source prefab, all Tank variants will automatically inherit this setting.
3. Assign tank firing sounds to the SFX group
- Select the other Audio Source component in the original root Tank prefab that handles the firing sound effects.
- Select the Output picker (⊙) and select the SFX group from the MainMix.
4. Assign explosion sounds to the SFX group
- Open the _Tanks > Prefabs > Explosives folder.
- Select the CompleteShellExplosion prefab. In the Inspector window, use the foldout (triangle) to expand the Audio Source component, then select the Output picker (⊙) and select the SFX group from the MainMix.
- Select the TankExplosion prefab. In the Inspector window, use the foldout (triangle) to expand the Audio source component, then select the Output picker (⊙) and select SFX group from the MainMix.
5. Confirm that prefab variants inherited the changes
- To confirm that the changes to your original prefab propagated the changes to the Tank prefab variants, select the tank variants and confirm that their Audio Source components are all routed correctly.
6. Test and visualize the audio levels
- Enter Play mode and watch the Audio Mixer groups’ volume meters go up and down as various types of sounds play.
All game sounds are now routed through the appropriate Audio Mixer groups, ready for mixing.
5. Adjust audio levels
Now it’s time to balance the audio levels to ensure that background music remains audible without overpowering key sound effects that are crucial for gameplay. If you’re not familiar with these sound level meters — sometimes called volume unit (VU) meters or peak meters — they measure volume in negative decibels (dB), where 0 dB is full volume, and lower negative values are quieter. This process of reducing volume is known as attenuation.
It’s helpful to be aware of the following target volume ranges for different types of game audio:
- Background music: Typically mixed between -30 dB to -20 dB to create an immersive atmosphere without overpowering the sound effects.
- Sound effects (SFX): Usually fall between -10 dB to -5 dB, ensuring they remain clear and impactful.
- Dialogue (if applicable): Often mixed around -6 dB to -3 dB, as speech needs to be easily heard over background elements.
Keep those numbers in mind when you’re mixing your audio.
1. Temporarily disable AI-controlled tanks to simplify audio testing
- In the Hierarchy window, select all AI-controlled Tank GameObjects.
Tip: You can mutli-select GameObjects in the Hierarchy window by holding the Ctrl key (macOS: Cmd).
- At the top of the Inspector window, disable the Is Active checkbox next to each GameObject’s name to disable them.
This ensures that AI-controlled tanks will not be distracting you while you’re trying to test audio levels.
2. Enable Edit in Play mode
- Enter Play mode and select the Edit in Play Mode button at the top of the Audio Mixer window.
This allows you to edit and actually save the changes you make while in Play mode.
3. Lower the background music volume
- In the Audio Mixer window, select the Music group in MainMix.
- Adjust the Attenuation slider down and notice where the volume tends to peak now — it should be between the recommended -30 dB to -20 range.
Note: The attenuation level you choose will vary depending on which music track you chose. Adjust the attenuation until the volume is an appropriate level.
4. Adjust the engine sound levels
- Select the Driving group in MainMix.
- Adjust the Attenuation slider so that the average volume levels are similar to the levels of the background music (between -30 dB and -20 dB).
Note: Depending on how much you lowered the volume of the engine sounds Audio Source component earlier, your attenuation level may be different.
Your game’s audio levels are now fairly balanced, with background music and engine sounds at lower, but still audible, levels.
6. Add a ducking audio effect
Ducking is a key technique in game audio that helps ensure important sound effects are always audible over background audio.
You’ll use the Duck Volume effect to detect loud sounds in the SFX group and temporarily lower the volume of the Music group in response.
1. Apply a Duck Volume effect to the Music group
- In the Audio Mixer window, select the Music group. Then, in the Inspector window, select Add Effect > Duck Volume.
Note: A warning will appear stating No Send sources connected — this will be resolved in the next step.
2. Set up the SFX group to control the Duck Volume effect
- In the Audio Mixer window, select the SFX group. Then, in the Inspector window, select Add Effect > Send.
- In the Inspector window, open the Receive property dropdown and select Music\Duck Volume.
This links the effect so that the SFX group triggers the ducking behavior in the Music group.
- Adjust the Send Level property to 0 dB to ensure the full signal is sent from the SFX group to the Duck Volume effect. There’s no reason to reduce this signal.
3. Prepare to configure the ducking effect
- With the Music group still selected, enter Play mode and select the Edit in Play Mode button at the top of the Audio Mixer window.
Note: The white line is the threshold for applying the effect, and the change in the curve after the threshold line is how the volume of the music will be adjusted after the volume threshold is reached.
4. Refine the ducking effect in real time
- Lower the Threshold property to around -45 dB, ensuring quieter sound effects still trigger the effect.
- Increase the Ratio property to 250% so the music dips more significantly when SFX sounds play.
- Reduce the Attack Time property and the Release Time property to 0, ensuring the volume drop happens instantly and restores quickly when the sound from the SFX group stops.
Your game’s background music now lowers when sound effects occur, ensuring important sound effects remain clear.
7. Optional: More things to try
Try these optional activities to challenge yourself, build your skills, and improve your project.
Each challenge is tagged as Easy, Medium, or Expert difficulty so that you know what to expect. You can complete one, all, or none of them — it’s totally up to you. If you’re not interested in doing these challenges, mark this step as complete and proceed to the next tutorial.
Easy: Experiment with other audio effects
Now that you know how to apply a Duck Volume effect, try adding different effects to your Music, Driving, or SFX groups to enhance your game’s audio.
Here are some effects you might want to experiment with:
- Music group:
- SFX Reverb: Adds a sense of space and depth to your background music.
- Chorus: Slightly modulates the pitch and time of the music, creating a fuller sound.
- Driving group:
- Lowpass: Reduces high frequencies, simulating a muffled effect (for example, hearing the engine from inside the tank).
- Flange: Creates a sweeping, jet-engine-like effect for futuristic or unique vehicle sounds.
- SFX group:
- Distortion: Adds grit and power to explosions or tanks firing.
- Echo: Creates a subtle doubling effect for your firing sounds.
Test these effects in Play mode and tweak their parameters to see how they impact your game’s sound.
Medium: Source new background music

Personalize your game by finding new background music unique to your project that fits your desired mood or theme.
1. Search for music with the right license
- Look for royalty-free music with a Creative Commons (CC) license that allows use in games.
- Some licenses require attribution (CC-BY), while others (CC-0) are free to use with no restrictions.
- Learn more about Creative Commons licenses.
2. Explore these sites for free game-ready music
- FreeSound: A vast library of user-submitted sounds and music, many with CC licenses for reuse.
- OpenGameArt: A great resource for game-specific audio and music.
- Pixabay Music: Free commercial-use music, including CC-0 licensed tracks.
3. Implement your new music in Unity
- Import the audio file into your Assets > _Tanks > Audio > Music folder.
- Assign it to the BackgroundMusic GameObject’s Audio Source component in the Hierarchy window.
Test your new soundtrack and adjust the Audio Mixer settings if needed.
8. Next steps
You’ve added background music and configured an Audio Mixer to balance the sounds in your game.
In the next tutorial, you’ll create a Title screen, set up a Game Manager, and add a Player Selection screen.