How to change sound volumes globally in Godot 3.0

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Diet Estus

I am trying to make a menu in my game from which users can change the volumes of all sounds in the game at once. Most games have a feature like this.

I am working in Godot 3.0.

Currently, I have a Sound singleton which consists of AudioStreamPlayer2Ds, one per sound effect. Many of my nodes use this singleton to play their sound effects.

I also have some special nodes which have their own Sound nodes built in. These special sound nodes also consist of AudioStreamPlayer2Ds.

My question is: How can I write a function to change all the volumes of my AudioStreamPlayer2Ds at once?

Should I simply iterate over game objects looking for the nodes and increase their volume_db? Is there a better way?

I searched around for an answer but there’s a lot of noise from Godot 2.0, which treats audio differently from Godot 3.0.

:bust_in_silhouette: Reply From: SleepyTom

Have a look at the master bus which is the global object which all sounds are ultimately played through. It has a volume property - in terms of decibels - which you can use to adjust the volume across all channels.

In my game I use that to turn on/off all sounds when I need to.

Just noticed that you asked this in February, so you probably already know the answer I gave above…The original answer given to your question then works perfectly… https://forum.godotengine.org/24377/change-global-volume-in-3-0

That question was actually posted by someone else. Guess that makes my question a duplicate. Thanks for the help anyway! It’s spot on.

Diet Estus | 2018-04-03 06:47

Yep just change the dB of the bus that you’re using. Can put sfx, bgm into their own buses to control them that way also.

jobax | 2018-04-03 08:45

Sorry my bad :slight_smile:

SleepyTom | 2018-04-03 08:52