How to 'add' and/or 'subtract' db in buses?

Godot Version

4.3

Question

I am making a volume settings and I want to use buttons to increase and decrease the volume of the audio buses. Using a slider is easier since I can just set the slider’s value property as one of the parameters in the ‘set_bus_volume_db’ method. But using buttons was a design choice.

Since the ‘set_bus_volume_db’ method, as the name suggests, set the volume of the bus in decibels, I can’t add or subtract from the buses’ current value in db using that method. Is there a workaround for this?

You can use AudioServer.get_bus_volume_db to get the bus db and after that use AudioServer.set_bus_volume_db(bus, the_bus_db + or - the value you want to change). As a simple alternative i recommend you use AudioServer.set_bus_volume_db with linear_to_db/db_to_linear, will make your life much more easier.

2 Likes

That’s it! Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.