Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | MisterAcoustic |
Hello - I’m attempting to loop a sound when a key is pressed, and stop it when the key is released. Works well - with one exception. When the audio is looping, it doesn’t make a smooth transition to the next iteration of the loop. This is not a problem with the sound - it’s quite constant, and should loop smoothly.
I use code similar to what’s shown in the FPS Tutorial Part 6 in the docs. There is a function handling the ‘finished’
audio_node.connect("finished", self, "sound_finished")
and
func sound_finished():
if should_loop:
audio_node.play(0.3)
else:
audio_node.stop()
queue_free()
Note that I do use a value in the .play function - the sound does have a slight difference at the beginning that I want to avoid when it loops. I’ve changed the value, but there are always artifacts when the sound loops.
When the sound loops, sometimes it seems to work perfectly (the sound is two seconds long). Other times, I get slight hesitations, popping or crackling at the loop transition point.
How can I get a smooth loop?