-
The Audio Listener component is the equivalent
-
of your ears in the game.
-
It receives, or listens, to audio sources
-
that are in the game world.
-
The control of the audio's behaviour is done on
-
the audio source component
-
and therefore the listener itself has no settings.
-
This is attached to a camera in your scene by default
-
but can be placed on any object.
-
Often this is attached to a character
-
and crucially there can be only one listener
-
per scene in order for it to function correctly.
-
You can test an audio listener from any position in the world
-
by moving the scene camera around
-
with the audio preview toggle enabled.
-
This gives you live testing of audio sources
-
in your environment without having to move
-
the real listener or play test the game.
-
Audio sources are components that playback audio.
-
Think of them as speakers in the game world.
-
In this example our turbine has an audio source attached
-
with the turbine audio clip that's been applied to it.
-
We can assign a clip by dragging and dropping,
-
or by using code to select a clip to play.
-
We can mute, bypass any filters,
-
choose whether to play this audio source on awake,
-
as in - when the game begins
-
and whether to loop the clip.
-
Priority varies between 0 and 255,
-
0 being the highest priority.
-
It's advisable to have music set as the highest priority
-
to avoid other clips from overriding
-
when many clips are being played at once.
-
Volume determines how loud the clip is played
-
based on it's original waveform.
-
Pitch controls the pitch of a clip.
-
If you're working with 3D sounds
-
the settings are more detailed.
-
Doppler level defines how much the Doppler Effect
-
will be used.
-
This is a perceived shift in frequency as the listener
-
or the ear in real terms
-
is moving past the sound source.
-
It will seem higher approaching it
-
and lower as it moves away.
-
Think of an emergency vehicle's siren as it passes you
-
for example.
-
Volume roll-off determines the type of roll-off
-
to be used by the sound
-
as the listener moves away from it.
-
This can be logarithmic, linear,
-
or customised manually using a curve
-
and adding keys as shown.
-
The minimum distance defines how close
-
to play the sound at full volume.
-
So if you are designing 3D sound
-
use this value to make the sound source louder.
-
This can be adjusted using the spherical Gizmo
-
in the scene view.
-
And it works in the conjunction with the
-
maximum distance setting below,
-
which by default is set to 500 metres
-
and is a distance after which
-
the sound rolls off.
-
Pan level defines how truly 3D the sound is.
-
This defaults to 1 for 3D sound
-
making it fully panned when the stereo listener
-
is moved past it.
-
Spread is the control of the angle of spread
-
from 3D stereo to multichannel sound.
-
Finally for 2D sound pan can be controlled
-
at the bottom of the component.
-
As a rule elements such as music
-
should be set to 2D sound,
-
whilst diegetic sound that should be
-
fading realistically should be set up
-
as 3D and positioned accordingly.
-
The 2D and 3D values of a sound
-
are controlled by an audio clip's import settings.
-
When selecting a clip in the project
-
you will be able to see the import settings
-
in the inspector.
-
You can choose the audio format to use,
-
whether it should be 3D or 2D sound,
-
whether you want to force your stereo sound to mono,
-
how to load it and what compression to use.
-
You can also preview sound at the bottom,
-
choose whether to loop whilst previewing
-
and set the inspector to auto-play
-
whilst browsing through clips.