+3 votes

Apparently this can be accomplished using an AudioEffectDelay because it says " Delay effects range from a subtle echo effect to a pronounced blending of previous sounds with new sounds."

Obviously, I need to add the effect using the AudioServer. But how do I set it up so it works like intended?

asked Apr 30, 2018 in Engine by paradigmo (27 points)

1 Answer

+5 votes
Best answer

I don't know anything about AudioEffectDelay or AudioServer, so this may not be what you're looking for.

In my current projects, I achieve fade outs and fade ins of StreamPlayers using Tweens.

Basically, I have functions which tween up or down the volume.

An example:

onready var tween_out = get_node("Tween")

export var transition_duration = 1.00
export var transition_type = 1 # TRANS_SINE

func fade_out(stream_player):
    # tween music volume down to 0
    tween_out.interpolate_property(stream_player, "volume_db", 0, -80, transition_duration, transition_type, Tween.EASE_IN, 0)
    tween_out.start()
    # when the tween ends, the music will be stopped

func _on_TweenOut_tween_completed(object, key):
    # stop the music -- otherwise it continues to run at silent volume
    object.stop()
answered Apr 30, 2018 by Diet Estus (1,494 points)
selected May 1, 2018 by paradigmo

Thanks, I guess using Tween works just as well.

Thanks. Was incredibly helpful for me too.

Remember at the function _on_TweenOut_tween_completed it's important to reset the volume unless you will use a fade in effect

func _on_Tween_tween_completed(object, key):
# stop the music -- otherwise it continues to run at silent volume
object.stop()
object.volume_db = 0 # reset volume
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.