Dynamic Audio in UE5 with FMOD


When we started designing Wire our initial idea was to make a game with a large focus on the audio component. For this our sound designer decided that we would use FMOD and its integration into Unreal Engine 5 to adjust the music and sound effects depending on what is happening in the game.  

Custom TickableWorldSubsystem 

After implementing some of the audio events that needed to be adjusted by parameters, I started on a custom variation of the TickableWorldSubsystem that UE5 uses. I used a TickableWorldSubsystem because it is a static class that can be called from all other classes, either C++ or blueprint, with an overridable Tick Function to adjust some parameters that require it on every tick.  

In this subsystem class that I named AudioParameterSubsystem I had multiple functions that calculated and returned parameters relevant to the specific FMOD event instances but also some functions that were only called after corresponding game events. These additionally called relevant functions in the classes with FMOD Event Instances, so the parameters on the Instance could be adjusted depending on the event that triggered the original subsystem function. 

FMOD Snapshots 

One of the events the AudioParameterSubsystem used to adjust the game music is the switch between the Main Menu, the game and the Pause Menu.  
Each time the game switches between these an event is broadcast from the subsystem to the Music Player to adjust the music with a snapshot in FMOD.  
To call the snapshot on the music in FMOD the music player in UE5 calls the corresponding FMOD Event in the music player class, when the subsystem notifies it of the change. 

Parameters for FMOD Events 

One of the events with multiple parameters to adjust it is the music that plays throughout the whole game. Some of these parameters are something such as how many enemies are still alive within the current room, the distance to the closest music box from the player character or whether the player is going to die with the next hit.  
For both the distance and how many enemies are still alive parameters I calculate a percentage between 0 and 100, though the parameter I send to FMOD for the attached event is a float value with decimal numbers between 0 and 1.  
For the distance I decided on a maximal value which would be relevant since it should simulate that the music gets louder or quieter when the player character either moves closer or further away from the boxes that play the music in the game world. And with that maximum value and the actual distance between the closest box, which I find by going through a list of all boxes in the room which is adjusted each time the player enters a new room, and the player I calculate the float value that sets the FMOD event parameter each tick. 
The parameter for the number of enemies left alive is similar to the distance parameter. It also uses a float as a percentage between 0 and 1, with the maximal number of enemies being set on each room change of the player and the current number of enemies adjusted on each enemy death. As such the parameter does not need to be adjusted each game tick and instead only gets changed on the room change event or whenever an enemy gets killed. 
And last but not least, the parameter with some of the larger changes to the music and the sound environment in general is the player health, specifically the parameters that are set whenever the player would die in the next hit. Each time the player loses or gains health, this parameter gets switched, and the changed state sent to the FMOD event. 

Another subtle change to sounds and not the music are the material parameters that is used for many different sound events. This parameter changes depending on the tags on the relevant components. Some of the sounds that get influenced by the tags are the steps and the punch of the player, the impact of the bullets and the bounces of the grenade. When each of the relevant sounds plays, I check the tags of the component of the impacted object and set the parameter for the sound in the same function.


Conclusion 

I'm happy that we managed to reach one of our goals for Wire, designing and implementing a dynamic soundscape with FMOD and the UE5 integration using many different parameters for all the audio events.  
That's it for this devlog. Thanks for your time! 

-Kröll Barbara 

Get W|re

Leave a comment

Log in with itch.io to leave a comment.