In this assignment we're going to look at taking
a project created in Unity 4, in this case
the Nightmares project which is available
as a free download in the asset store
and upgrading it to Unity 5.
We're going to focus on the audio capability
of Unity 5, including using audio mixers
and audio effects.
To upgrade the project we're going to focus
on three areas.
We're going to create two audio mixers
and route all of our audio sources
to groups in those mixers.
We're going to setup some effects processing
to shape the mix at run time
and we're also going to look at how to control our
mixer at run time using scripting.
We're going to cover this in two videos.
In this video we'll look at signal flow
with the audio mixer and using audio effects
in your mix.
Let's begin by creating some new
audio mixer assets which we'll use
to manage the audio signal flow
in our project.
We'll highlight our Audio folder,
go to the Create menu and choose
Audio Mixer.
We'll call this first mixer Master Mixer
and we're going to make a second mixer
called Sound Effects.
Next we'll open our audio mixer window
under Window - Audio Mixer.
You can also choose command-8 on mac
or control-8 on PC.
I've docked my audio mixer at the bottom of the screen.
Let's give it a little bit more screen real estate.
We're currently looking at the sound effects mixer.
To look at the master mixer we can click
it's name in the mixers list below.
Master mixer has only one group,
the master.
We're going to add some groups so that we can
route in our sound effects mixer
and our music.
Let's create some new groups in master mixer.
We'll highlight the master group,
click the + button,
and then highlight it again so that the
second group is created as a child
of the master.
We can click on these names to rename them.
Now our music group is only going to
contain a single signal, the output from
the audio source on our background music
object which loops our background music.
Our sound effects group is going to contain
multiple audio signals coming from
different game objects and we may want to control
the levels of those independently.
This is why we're created the sound effects mixer.
and what we want to do now is
route the output of the entire
sound effects mixer in to the
sound effects group of master mixer.
We'll do this by dragging the sound effects
mixer on to master mixer
and then selecting the group that we want to route
that mixer's output in to,
in this case Sound Effects.
Now we can see that sound effects has become
a child of master mixer
and we'll route it's output
in to the sound effects group of master mixer.
In sound effects we're going to create some new groups as well.
We'll call these Player,
Enemies and Gun Shots.
Notice that since gun shots was created with the enemies
group highlighted it's been made a child of enemies.
We're going to want to make that a child of the
master so that it's signal will flow
directly in to the master group
and then in to the sound effects group of master mixer.
With our groups created it's time to
route the outputs of our audio sources
to the groups that we've made.
Let's start with the player.
The player has an audio source
on Gun Barrel End
which is currently routed directly
to the audio listener in the scene.
We're going to go ahead and choose
a new output for that, in this case
the gun shots group of our sound effects mixer.
On the parent player game object
we have another audio source
which plays the player vocalisation sound effects.
We're going to go ahead and select the output for that
and route that to the player group
of our sound effects mixer.
After making those changes to the player object
let's make sure that we hit Apply
to save them to the player prefab.
We're also going to configure the output routing
for our enemy prefabs.
To do this we're going to go to the
Completed Assets folder
Prefabs
and we'll start with our Helephant prefab.
We'll scroll down,
select the output of the Helephant audio source
and choose the Enemies group of our
sound effects mixer.
We'll do the same for our Zombear,
and our Zombunnie
prefabs.
The only remaining audio source that we need
to assign is our background music.
Select the background music game object in the scene
and on the audio source we'll choose the output
and assign it directly to the music group
of master mixer.
With our audio sources now routed
in to our new audio mixers
we're going to add some effects processing.
Let's open the audio mixer
and we're going to select master mixer
and on the Music group we're going to
choose Add
low pass simple.
Low pass simple is a low pass filter
which attenuates frequencies
above the cutoff frequency,
making them quieter.
Let's test our scene and hear how the low
pass filter sounds.
So as we pull the cutoff down we can hear the high
frequencies are attenuated.
As you can hear, the music is still a little
loud over the sound effects.
The first thing that we're going to do is that we're going to
pull the volume down, I think to about -10 decibels.
The next thing that we're going to do is we're going to
add a little bit of dynamic volume
control using the the duck
volume audio effect.
We're going to go ahead and click Add on the music group.
select Duck Volume.
And now what we need to do is we need to
route some signal from the group
that we want to cause our
music to duck in volume.
We're going to use the sound effects group so
that when the sound effects play the music
will automatically get quieter.
In order for the duck volume effect to be able to
receive signal from the sound effects
group we're going to need to use a send audio effect.
On the sound effects group we're going to click Add
and choose Send.
The send effect allows us to duplicate
our audio signal and route it elsewhere
in the audio mixer.
In this case we're going to route it to our
duck volume effect by choosing
Music - Duck Volume
from the Bus menu of the send.
With the bus selected we're going to turn up
the send level all the way.
This is how loud the duplicate
signal is going to be, which is being
routed to the duck volume effect.
In this case this won't add
any audible level to our project
because we're using the side chain input
of the duck volume
only as a control signal.
With our send and our duck volume effects
setup let's play the scene and test again.
We can see that the volume that's being received
is not exceeding the threshold
of the duck volume effect..
The duck volume effect will not actually
begin to lower the volume of the music until the
threshold is exceeded.
Let's play the scene and experiment with
the threshold value.
What we want is for the threshold to be
low enough that the sound effects will
cause the duck volume to begin turning
down the music when the sound effects play.
Edit In Play Mode.
So we've arrived at the sort of -34 value
which sounds pretty good because when
our sound effects are playing we could hear
that the music is getting reduced
and then that effect is that our
sound effects feel a little bit louder
and more present but we haven't had to
sacrifice music volume overall
in order to do that.
For detailed information about duck volume
and send effects see the information linked below.
With our two mixers and our audio effects
setup it's time to prepare them
for script control at run time.
The first thing that we're going to do is to create
two audio mixer snapshots
which are going to control the state
of the mixer and allow us to recall
different mixer states, including levels
and effects settings.
We're going to start by creating
a new audio mixer snapshot
by clicking the + button
in the snapshots area.
We'll call that one Paused and we'll
name our first snapshot
Unpaused.
Both of these snapshots will be saved to the
master mixer because that's where they were created.
In the Unpaused snapshot we'll keep out
mixer settings the same.
In the Paused snapshot we're going to change the
value of the low pass simple effect
and pull the filter cutoff down.
Let's say to 365hz.
We can test quickly how that sounds.
Edit In Play Mode.
And recall the Paused snapshot by clicking on it.
Now that we've got our project setup
we're going to end part 1.
In part 2 we'll look at controlling the mix via scripting.
Subtitles by the Amara.org community