Audio Tracks in Timeline
Objective: To help you understand what an Audio Track is in Unity’s Timeline.
We have looked at Activation and Animation Tracks so far, so now let’s take a look at the Audio Track in Timeline. Compared to the other two, Audio Tracks take in Audio Clips which come with a format of .wav, .mp3 or .ogg. Similar to the other tracks you can have multiple of the same, building out a very complex cutscene with overlapping audio clips and animations.
How to Add an Audio Track
Similar to the other tracks, this is as simple as right clicking in the Timeline editor → Audio Track, or alternatively, dragging a game object into the Timeline editor → Add Audio Track.
Once added, you will see that it is now looking for an Audio Source. There is also a few options available now in the Inspector window which let’s you adjust the volume, left and right stereo pan and the spatial blend between 2D and 3D:
Adding an Audio Source or Audio Clip to Audio Track
We now have 2 options here, we could simply drag and drop in an Audio Clip to the Audio Track which would work fine, or the alternative is to have a game object with the Audio Source component and Audio Clip attached to it.
Adding an Audio Clip to the Audio Track
Right clicking on the Audio Track within the Timeline will then allow us to ‘Add from Audio Clip’ which is the attached Audio Clip located in the Audio Source component.
My Audio Clip is far too long, so I have gone ahead and split the track to a much smaller piece by highlighting it in the Timeline editor, dragging the white keyframe line to the desired position and pressing the ‘S’ key. I then deleted the second clip as we don’t need it, and now we are left with this:
Audio Clip Properties
We now also have a bunch of Audio Clip properties that allow us to make adjustments within the Inspector, including Speed Multiplier, Blend Curves, Looping and Volume Control.
Issue Between Activation Track and Audio Track
However, now I have an issue between the Audio Track and Activation Track with the same game object. As the sphere is constantly being switched on and off with the Activation Track, it is also doing the same for the Audio Track, so the music is constantly cutting in and out. The easiest solution for this is just creating a new empty game object and attaching the Audio to this.
Fading in and Out
We also have the ability to make an Audio Clip fade in and out by simply dragging the ends of the Audio Clip inwards while holding down the ‘Ctrl’ key.
This will allow our music to gradually introduce itself into the cutscene (and fade out) instead of instantly being switched on and off.