How to remove audio effect from bus?

Godot Version 4.3

Question

I need to make it so that when the game is paused, the music is under the filter effect (which I was able to implement):

	if isPaused:
		get_tree().paused = true
		self.show()
		AudioServer.add_bus_effect(Global.music_bus, AudioEffectFilter.new())

But now I need to do the opposite, namely, when the game is unpaused, the filter effect is removed. As I understand it, this can be done using the remove_bus_effect() function, but I did not understand how to work with it because of the effect index
Code:

		$Settings.hide()
		get_tree().paused = false
		self.hide()
		AudioServer.remove_bus_effect(Global.music_bus, AudioEffectFilter) <- doesn't work

You need to provide the index of the effect you want to remove. If this is the only effect you are applying, the index will probably be just “0”, so feed that into your function.

AudioServer.remove_bus_effect(Global.music_bus, 0)
2 Likes