Building a Modular Ducking System
Using Unity and Wwise
With our Ambient System complete — read more here — we had a slight problem, entering a cutscene, we would still hear our ambient noise playing underneath. While this would be realistically heard, we want to shift all focus on the ‘story elements’ as such. Rather than Stopping and Restarting our Events, I wanted to create a system to pull specific volumes down, as this could potentially be used in a variety of ways to draw focus elsewhere. Pulling the volume down indefinitely, results in ‘muting’ the audio, which is exactly what needs to be done in this example.
To do this, we can set up a number of different busses in Wwise. At a simple level, we can create one tier of busses underneath our Master, one for Music, SFX, and VO. With a larger scale session we could additionally break these busses up further also for more control.
For now we simply want to lower the volume for any of these busses. By default, all sound objects will be routing to the Master bus, so remember to set these appropriately!
To control the volumes we can create Game Parameters and set up RTPCs for each Bus. These parameters allow values to be passed through from the game engine, and in this case we simply want to have a volume range of 0–100.
In Unity, we can now manipulate the RTPC values of our Audio Busses. While we could simply create a script to duck our SFX Bus during cutscenes, we can go a step further and make things modular. Creating a script that can access any bus, manipulating it by any volume.
To start, we need to create a reference to the RTPC we want to alter. We can also pass through a value in which we wish to decrease the volume by.
Our previous scripts from the other articles in this series, allow for bool variables to dictate when to call our Audio Manager. In this instance, we only need OnEnable and OnDisable, as the script will be turned on and off with each cutscene it’s added to. But this could very easily be modified to add different triggers.
To pass through information to the AudioManager Script, we simply pass through our two variables.
By passing through the RTPC to the Audio Manager, we can simply use the SetGlobalValue function. To calculate the volume we want to set. We can use Mathf.Clamp to lock the value between 0 and 100. Then if we use GetGlobalValue to receive the current volume information, and subtract our target value variable, we can set our bus volume appropriately. When we want to revert the ducking, we simply add this same value back to the current value.
Attaching this script to each cutscene, allows us to target an audio bus, and decrease it by a certain volume.
Now, as we enter a cutscene, using Wwise’s remote connection, we can track our RTPC value decrease by the defined amount during our cutscene, then increase to its original value when it ends.