Hi, I'm trying to create a feature in Godot 3 that allows for switching between music segments on the beat.
My approach:
- In
_ready()
, use 60 / bpm
to get the time for each beat and store it in the _second_per_beat
variable.
- Play a continuously looping audio stream sample.
- Follow the instructions in the Godot documentation on Sync the gameplay with audio and music Introduction to calculate time using the two methods mentioned there.
- In
_process()
, calculate the current accumulated beat.
- Multiply the accumulated beat by _second_per_beat to get the current position in the song.
- If it's exactly at the specified time, stop the current looping segment and start playing the next specified looping segment.
I've almost completed all of these parts, but I found an issue where the timing isn't always stable during the transition. Sometimes segment 1 ends a bit slower, sometimes segment 2 starts a bit slower, and sometimes it transitions smoothly without any issues. Although the differences are small, you can still hear a sense of disruption in the sound. Is there a better way to handle this situation?
