[TUTORIAL] Simple way to change Global Audio Volume

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

  1. Create a new Sound Mix asset (leave the default settings)
  2. 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.
9 Likes

Anybody know of a way to mute the volume without killing the sound instance so you can resume volume after muting it?

Atm, we need to clamp the volumes to .01 because 0 calls the Audio Component to be destroyed.

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 don’t think you can at the moment. But what I do for my own project is to set a float variable that I use in my menu.

In BP I believe you can only store graphic settings. Hence this little tut for audio.

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)?

And do you know how to store custom data in GameUserSettings?

Virtualisation is now supported, it can be set in audio wave settings.

The setting of the volume only worked for me if I went to ProjectSettings:Engine:Audio and set Default Base Sound Mix to my SoundMix asset directly there. But then everything is sweet.

1 Like

Doesn’t seem to work on editor window, but works fine in standalone

I had to explicitly set my Sound Cue/Sound Waves to Sound Class Master (not just leave the Sound Class as the default which is Master) to get this to work, very strange…

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.

Amazing. You have done a great job. I really liked it. I also want to employ it on my audio website.