sound control

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

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

:bust_in_silhouette: Reply From: Zylann

First of all, have a look at the documentation, it explains how audio works in Godot:

Then, in code you can either modify individual AudioStreamPlayers: AudioStreamPlayer — Godot Engine (3.1) documentation in English

Or use the AudioServer API to change global volumes: AudioServer — Godot Engine (3.1) documentation in English

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.