Using Audio Tracks in Unity and Timeline
Music and Sound FX are really important when it comes to setting the mood of your game or cinematic cut scenes. Let’s dig into using Audio Tracks in the Timeline editor.
For this example, I will be using a short sound clip, as well as music soundtrack.
In the Timeline editor, the + icon dropdown can be used to add various Tracks. Let’s select the Audio Track option.
Alternatively, an audio asset can be dragged into Timeline and a new Audio Track will be generated.
The S key can be pressed at any given point in the audio clip to Split it into two separate clips.
The Ease In and Ease Out option can be used fade the audio signal in and out.
Just like that, you have a nice fade in and out on your soundtrack!
If you select the audio clip, you can adjust the playback speed with the Speed Multiplier in the Inspector. Granted, this will also adjust the Pitch of the sound. The Pitch can be re-adjusted to taste in the Audio Source component.
The Inspector also features Blend In and Out curves for your Audio.
There is also a Loop option if you want to continuously loop your audio. The Volume slider is great for quick leveling of audio tracks.
Note that the Audio Tracks can take in an Audio Source assignment.
I create an empty Game Object to hold an Audio Source component.
Dragging the empty object into the Audio Source assignment box in the Audio Track, will prompt the user with an option to Create an Audio Source on that object.
The Audio Source component brings a lot of new options to the table.
Here is the Pitch option, should you want to play with the pitch of your audio.
Without an Audio Source, the Audio Track will play back in standard 2D stereo sound. The Spatial Blend setting changes the audio from 2D to 3D.
Moving the sider all the way to the right makes the audio fully 3D, meaning it will be louder or quieter depending on how close the Audio Source is to the Audio Listener. This can be very immersive when you want objects in motion to have world space sound playback.
The 3D Sound Settings offer some powerful adjustment options.
Selecting the Audio Source in the Hierarchy will show an area of affect sphere in the Scene view, barring you have Gizmos enabled.
This sphere represents the world space where the audio can be heard. Increasing the size of the sphere, increases the range of the Audio Source.
Gifs can’t record audio, but here I have the background music playing, and a sound clip triggering at the same moment the light burns out.
Have fun using Timeline to trigger all kinds of great sound FX and music, and thanks for reading!