Hello! I know this is a small piece of code out of a larger script, but I'm positive my issue lies in the chunk in the picture and I'll try my best to explain. This function is intended to fade individual instruments (AudioStreamPlayer, here called player) using a tween. Normally when this function is triggered, it works as I expect it to, but sometimes it causes all audio in the game to cut out for about a second before starting back up again. I have tried removing the tween and setting the volume directly and this issue no longer occurs. I also have a system in place to check if a tween is currently occurring with the given player and to wait til that tween is finished to start a new one. Does anybody have a clue why the audio is cutting out? I can give more details if needed, thank you!
#Audio Completely Cutting Out When Tweening Volume
1 messages · Page 1 of 1 (latest)
Can you try using tween_method instead? I thought I remembered that working better
And just create a method that sets the volume_db?
This is code I'd written that should work for tweening volume using tween_method, adapted to your variables
tween.tween_method(func(v): player.volume_db = linear_to_db(v), db_to_linear(player.volume_db), intensity, time)
also shameless plug for my PR to add a volume_linear property that would make volume tweening much easier
That works like a charm, thank you so much! I guess it makes sense that decibels don't fade very well linearly. I had no idea that you could declare functions in-line like that either