In Unity it's possible to process
our audio signals with audio effects
and shape their timbre, frequency content,
or the dynamics of their volume.
We can do this by adding audio effects
to a group in an audio mixer.
In our scene we have 4 game objects,
each with an audio source which contains a loop
of a different element of a musical track.
All of these are routed in to audio mixer 1.
Audio mixer 1 currently has an
attenuation effect which is there by default
on the master channel.
If we play our scene
activate Edit In Play Mode
we can adjust the volume
of the attenuation effect
and thereby control the volume of the master group.
Notice that as we adjust the volume
the changes in volume are reflected
in the volume parameter in the inspector.
It's important to note that when we make
changes in play mode those changes will be saved
to the audio mixer asset.
Unlike changes made to the scene hierarchy
for example which will be reset
when we exit play mode.
In order to apply effects processors
to the audio signal passing through the master we can
add them from the drop down menu.
We're going to add a low pass simple effect.
The low pass simple effect is a low pass
filter which allows us to attenuate
frequencies above the cut off frequency.
The default is 5000hz.
If we play our project.
Edit in play mode
and adjust the cut-off frequency
We can hear that the high frequencies are attenuated.
Audio effects are applied sequentially.
So in this cast the attenuation effect
is going to be applied first followed by
the low pass simple effect.
We'll add a distortion effect
and listen to the resulting signal.
We can hear that the distortion
adds high and mid-range harmonics
which were not previously present in the signal.
In this case the distortion is sequenced
after the low pass simple so
the high frequencies are attenuated
and then new mid and high frequencies are added.
If we want to change this order we can click
on the low pass simple and drag it down
so that it now occurs after
the distortion in the signal chain and we can listen to the effect.
What we can hear is that as we
attenuate the high frequencies using the low pass
it's cancelling out the effect of the distortion effect
because the distorted signal is being run sequentially
through the low pass simple effect.
Let's check out another example.
Here we have the Nightmares project,
which you can download from the assets store.
And what we've done is we've
routed our background music to an audio mixer,
to this music group here, and we've
added a low pass filter effect.
We've also created two
audio mixer snapshots.
Audio mixer snapshots allow us to
save and recall the settings in the mixer.
In the Unpaused snapshot the cut-off
frequency for the low pass filter is
all the way up at 22000hz.
In the Paused snapshot we've pulled it down to 365hz.
This is going to attenuate the high frequencies
and give the music a muffled sound
when the paused snapshot is called.
The script which controls our paused menu
also controls the transition to these snapshots.
For more about snapshots and controlling them via script
see the information linked below.
Let's check this out and hear how it sounds.
Press escape.
And then press escape again to resume.
This is an example of how we can use
audio effects processing to convey information to
the player about the game state.
Subtitles by the Amara.org community