0 votes

i want to know how to control the music and the sounds volum

asked Aug 8, 2019 in Engine by abdolilah (57 points)

1 Answer

0 votes

First of all, have a look at the documentation, it explains how audio works in Godot: http://docs.godotengine.org/en/3.1/tutorials/audio/index.html

Then, in code you can either modify individual AudioStreamPlayers: https://docs.godotengine.org/en/3.1/classes/class_audiostreamplayer.html

Or use the AudioServer API to change global volumes: https://docs.godotengine.org/en/3.1/classes/class_audioserver.html

Using the latter, for example, if you have two buses, one for "Music" and one for "Sounds", you can change their volume like this:

var music_bus = AudioServer.get_bus_index("Music")
var sounds_bus = AudioServer.get_bus_index("Sounds")

AudioServer.set_bus_volume_db(music_bus, -10.0)
AudioServer.set_bus_volume_db(sounds_bus, -3.0)

Note: by default Godot only has a "Master" bus (the main one), but you can create new ones specifically for music, sounds and other things.

answered Aug 8, 2019 by Zylann (26,143 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.