From the morning wake up call of a buzzing alarm, to the silent rumble of an air conditioner, sound surrounds us. Audio can make or break a video game and can provide a fully immersive experience for the player when done correctly.
I'm using the Unity 5 Audio mixer for the first time in a project, and since I'm not an audio expert, I'm trying to make sure I'm setting off in the right direction before I get too committed! Would be very grateful if anybody could offer any advice or comments on my approach. I currently have a single Audio Mixer, with following groups:-Master. Luckily, the Unity Audio Mixer is here to save the day! To create an Audio Mixer, first make sure the Audio Mixer window is open. You will find it located under Window Audio Mixer or Ctrl + 8: In the Audio Mixer window, create an Audio Mixer named MasterMixer by clicking the + located at the top right of the window.
The Audio Mixer is a great aid in helping you achieve that.In this tutorial, you’ll learn how to do the following:. Create an audio mixer. Create groups, views, and snapshots for the audio mixer. Route audio source signals to groups. Send and receive audio from one group to another. Add effects to groups. Expose parameters for scripting in C#.
Note: This tutorial assumes you know your way around the Unity editor, and that you have a basic knowledge of Unity Audio Sources. Check out some of our other first if you need to sharpen your skills in Unity.
Getting StartedBefore you dive into the world of Audio Mixers, Groups, and Sound Effects, it’s best to understand the basic types of that you’ll see in games:. Music. Sound effects or SFX. Dialogue. Environment or AmbianceEach of these categories can be broken down into several sub-categories. For this tutorial, you will focus on the above four categories.Download the and extract it to a location of your choosing.Open up the Starter Project in Unity.
The assets are sorted inside several folders:. Audio: Holds anything relating to Audio. Audio Manager: Holds assets needed to manage your audio in-game.
Environment: Contains environmental audio clips. Music: Contains musical audio clips. SFX: Contains various sound clips. StarterAssets: Contains various assets that will help make this tutorial easy and fun! You will not have to go into this folder for this tutorial.Open the MixerMayhem scene in the StarterAssets/Scenes folder.Run the starter project. If everything went okay, you should be able to hover over each object, and they should each produce a unique sound when clicked on.Creating an Audio MixerRight now, the audio in the scene is being played by Audio Sources on each of the objects. Jumping back and forth between all these individual Audio Sources to make changes or add effects to them can become quite a tedious process.
Luckily, the Unity Audio Mixer is here to save the day!To create an Audio Mixer, first make sure the Audio Mixer window is open. You will find it located under Window Audio Mixer or Ctrl + 8:In the Audio Mixer window, create an Audio Mixer named MasterMixer by clicking the + located at the top right of the window.Alternatively, you can create an Audio Mixer under Project WindowCreateAudio Mixer:You should now have a blank Audio Mixer opened in your Audio Mixer window.Here’s some explanation:. Audio Mixers can be routed into an Audio Group of another Audio Mixer. All of your Audio Mixers are listed here. Snapshots contain the parameters of a specific state within the Audio Mixer.
Groups are how the Audio Mixer knows to work its way up the hierarchy. Note: This section assumes you know how to edit code in a code editor and that you have a basic knowledge of C#. Check out some of our other first if you need to sharpen your programming skills in Unity.With the Audio Mixer complete, it’s time to give the player some options in game that will let them make their own changes to the Audio Mixer.In the Hierarchy window, there is a game object named AudioManager that has a child canvas object named AudioManagerCanvas. Under that, you should see another object that is currently inactive named SliderPanel. Enable this game object.Exposing ParametersIn the Game window you should see some sliders and buttons. These will be the sliders to adjust the Music and SFX volumes.In order to access the volume levels of your Music and SFX group, you need to expose those parameters.
To do this, first select the Music group, then in the Inspector window, right click the Volume field and select the Expose ‘Volume (of Music)’ to script option. Note: In order for the Snapshots to transition correctly, they must be appropriately aligned on start. If you made adjustments to the volume sliders, make sure the Starting Snapshot is at the same volume as it's corresponding volume slider — otherwise the new Snapshot values will be ignored during the transition. Where to Go From Here?In case you missed anything, you can download the final project for this tutorial.That wraps up this introduction to the Unity Audio Mixer, and all of its major components.I'd love to see the neat effects you come up with, so I encourage you to try out the other effects not covered by this tutorial!
Also, have a go at using multiple Audio Mixers by routing one into another, for organizational and layering benefits.If you have any questions or comments, please join in the forum discussion below!