The audio mixer asset in Unity allows us
a great deal of control over the signal flow
of audio in our projects.
By default our main camera
is assigned an audio listener component.
The audio listener component is where audio
is output from the scene
to the headphones or the speakers of the listener
In Unity all audio starts at an audio source.
Here we have a game object called Base
and it's got an audio source on it which has a clip
of a baseline loaded,
which is also set to play on awake and loop.
There are 3 other objects
which contain other musical parts including
an arpeggio kick and percussion.
When we play the scene we're going to hear these
first 3 parts play directly through
the audio listener component.
If we want to get more control over how
our audio is processed we can create an
audio mixer asset, so choose Create
Audio Mixer
and then we can either double click on it
to make it visible
or we can go to Window - Audio Mixer
or choose command-8
on Mac or control-8 on PC.
The audio mixer can be docked
like many of the other windows,
I'm going to dock it down here on the bottom of my screen
and I'm going to expand
to give myself a little bit more real estate.
The default state for an audio mixer
is that it's created only
with a master group here.
In Unity's audio system we refer to channels
as groups because they provide a little
bit of additional audio functionality
that a normal mixer channel would not.
Now, we've got our master
and currently nothing is assigned to it.
If we play we'll see
no movement in the meters.
If we choose our
game objects here we can edit
for all of them the output parameter here
and we can assign it by clicking on it
to the master channel of audio mixer 1.
Now when we play
we've setup some signal flow,
our signal is now passing from
our audio sources through the master
to the audio listener on the main camera.
By default the master group
is created with an attenuation effect applied to it.
The attenuation effect is what allows
us to control the volume of the signal
passing through the master group.
If we want to adjust that while we're playing
we're going to need to click Edit In Play Mode.
Now we can adjust the volume
and we can see in the inspector on the right
that the change is being reflected.
Changes made while editing
during play mode will be saved
to the audio mixer asset.
Unlike scene changes, which will revert
when exiting play mode.
Currently audio mixer 1 has only 1 group
the master.
To create a more flexible signal flow
we're going to go over here to the Groups area
and click the + button twice.
When we click the + button a new group
will be created that is the child
of the currently selected group.
Notice that in the channel strip view
group A and group B have appeared.
With multiple groups in our mixer we can
now assign some of our parts to different groups
Let's assign the kick drum
by clicking on the output parameter
to group A.
Now if we play
activate Edit In Play Mode.
You'll notice that when we turn down group A
we can turn down the kick drum independently because
it's now on it's own group.
And when we turn down the master we can
turn down everything.
This is because group A is routed
through the master so the master controls
everything which is routed through it..
That's because of the way
that the groups are arranged in the groups
area down here.
We can see that group A is a child
of the master group and group B is in turn
a child of group A.
So if we assign our arpeggio
using it's output to group B
we can now test again
and we'll see that turning down group A
now turns down
both the kick and the arpeggio
because group B is a child of group A.
So here we have what's called a
serial signal flow routing,
meaning group B passes through group A
and then passes through the master.
We can also create a parallel signal flow
by changing the routing of group B.
If we click on group B in the groups area
and drag it's name on to the master
we can now make group B
a child of the master and pass it's signal
directly to the master, and we can test that out.
So now we have the kick in group A.
The arpeggio in group B.
And everything being run through the master.
While we're working in the mixer we may want to check
parts of our mix individually.
We can do this using the solo, mute and bypass
buttons on each of the groups.
When we click solo
all the other tracks are temporarily muted
so that we can hear that track by itself
and make any changes we need to make.
When we click mute the opposite happens.
The one track we've muted becomes silent
and we can hear anything else that we need to hear.
Bypass allows us to bypass any
audio effects that we've applied to the channel.
Let's go down and click Add
Low Pass Simple.
This is a low pass filter which will remove
high frequencies from our arpeggio sound.
Here's the arpeggio soloed.
Here's the bypass.
So if we're having problems with one of our effects
or we want to check something we can bypass.
It's worth noting that solo, mute and bypass
are not intended to be used at runtime
they're supposed to be used in
setting up your mix and designing your sounds.
But not to be controlled by the
engine while the game is playing.
Additionally each group has it's own pitch control.
If we look in the inspector we'll see
that the pitch is currently set
to 100 for this group,
our arpeggio,
let's set it to 50%.
So we can adjust the pitch not just
at the individual sound level using
audio source pitch control but also
at the group level.
In addition to controlling signal flow
with groups we can also control
signal flow with multiple mixers.
By using multiple mixers for each
category of sounds in our mix
we can then route those mixers
to groups in audio mixer 1
to control the overall balance of the mix.
If we create another mixer by
clicking the + button,
we'll call this one
Drum Mixer.
We can now create two groups within this.
We'll configure this in a
parallel routing
and we will assign our kick
to the drum mixer kick channel
and we'll activate our percussion source here
and assign that to the percussion channel.
In order to be able to control the volume balance
between those two sets of elements let's
create a third group
and route it to the master output.
Now if we grab our drum mixer
and drop it on to audio mixer 1
we can choose drum group as an input.
When we play the scene
We can see that our entire drum mixer
is now being routed through drum group
to the master output.
As you're working in the mixer and your project's
grow more complex you may find
that you want to manage the view of the mixer.
This can be done using the visibility
controls down here, let's say we want to make
groups A and B invisible and just view the
drum group and the master,
we can do that by clicking these eye icons
beside the group names.
Once we've made them visible we can save that in a view.
Here we currently only have one view,
let's click the + button to make another.
Now in view View Simple we have
these two groups turned off
and in our main view
we could have them turned back on
by clicking on the view name we can toggle
between different views of the mixer.
Snapshots allow us to store
and recall the state of the mixer.
We'll cover snapshots in their own dedicated lesson.
Please see the link below for more information.
So far we've taken a look at
controlling our signal flow for our game music.
Let's take a look at an example which includes
some sound effects as well.
Here we have the Nightmares project
which is available for download on the asset store.
What we've done is we've setup two mixers.
One is the master mixer and another
is a sound effects mixer.
In the master mixer we have two groups,
one for music and one for our sound effects.
We've also got our vocal effects
for when the player gets hurt routed
to a vocal effects group also on
the sound effects mixer.
Our background music is routed directly
to the music channel of the master mixer
since there's only one channel for the
music in this case.
If we play our scene we can see this in action.
Using this approach we can then
balance each separate set of effects,
gun shots, vocal effects
against our music easily
using one overall volume for sound effects
and one overall volume for music.
Subtitles by the Amara.org community