This post is not a question, but rather a mini tutorial on how to change the game audio volume.
Thought it was worth sharing it for anyone struggling with it (like myself) since there doesn’t seem to be a solution posted on answerhub or the forum, aside doing it in C++ or using Rama’s plugin.
It’s actually rather simple
Create a new Sound Mix asset (leave the default settings)
In your Game Instance Blueprint (should work in any BP, but since the GameInstance is persistent, it’s the best candidate for the job), do the following script :
Set base sound mix : select the newly create Sound Mix Asset to activate it for the entire session.
Set Sound Mix Class Override : Set the Sound Mix and the Sound Class (there are multiple ones, Master is the parent of the other classes). Set the Fade in Time to 0 if you want the change to be immediate.
Some notes :
The delay after the Event Init is a bit dirty but mandatory as it won’t work otherwise. I suspect it happens too quickly and some audio components have yet to be fully loaded.
In the Set Sound Mix Class Override, if the volume is set to zero, any active sounds will be stopped, hence the clamp min 0.01 (there might be a way to prevent this behavior, but I haven’t thoroughly looked at it yet)
Now, every time you want to change the volume, just execute the event Change Volume with the new value.
At the moment there is no virtualisation, so any sound that is not played is ignored. You can work around that limitation by keeping track of the elapsed time, and when unmuting the sound you actually start it again and seek to this time point (using the “StartTime” parameter of the Play() method).
I wanted to do sliders witth setting sound for sound classes using sound mixer - the problem is later how I can read current sound classes values (sound classes has default values after level load and I can find a way to read value out of sound mix)?
any idea on how to later retrieve the master submix from the project settings in c++ (also BP would work)? i need to get the master submix without having a reference to the class. the only thing i get is the “Audio::FMixerSubmix” class for the master submix but not the USoundSubmix instance.