Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | malachi |
- I made some sliders to adjust the volume of the various BGM and sound effects, but realized that they’re set to a linear scale, while audio works off of the logarithmic decibel scale.
Is there a way to set the audio scale to be logarithmic, or do I need to do that in the code?
- Every time I enter the scene with the sliders, they reset their value to what they’re set to in the Inspector menu. I want them to retain the values used when the screen was last open. I tried to pull the values from the audio buses in the _ready() function, but they get reset before entering that function.
Is there a way to either not trigger the value_changed() function when entering the tree, or to otherwise not overwrite the previous values?
Code:
func _ready():
$SoundVolumeSlider.value = AudioServer.get_bus_volume_db((AudioServer.get_bus_index("SoundEffects")))
func _on_SoundVolumeSlider_value_changed(value):
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("SoundEffects"), $SoundVolumeSlider.value)