Rhythm System not working properly

So i started making a Rhythm Game on GDevelop, everything was working fine, but then i realized that the longer i waited in the game, the more the notes/bpm would desync with the music.

I am 100% sure this is the right bpm that i set, because in FL Studio it is, so that can’t be the problem.

I’ve been wondering if this was because of lag or freeze frames, even though my game works completely fine, at 60 fps, since i’ve made it so the game is forced to run at 60 fps, not more, not less.

Here’s the code i am using, since well that’s probably helpful :

Hope i can get some help with this, thanks! If you need more infos, just ask me!

I’m not clear on your goal but you can get the offest (progress) of a sound being played on a channel.

This moves a sprite 50 pixels every second. (trunc() is truncate, it removes the decimals. It’s basically rounding down) You can use any formula you need.

Hi!

I made a small test, and noticed that when the timer is reset, it seems that it has a tiny (a few milliseconds?) delay before it starts again. Normally this doesn’t cause any trouble and the user is not able to even notice it, but in your case the delay starts to accumulate and eventually the sync fails.

However, there seems to be a solution. Instead of resetting the timer, make a variable which is always “one click ahead” of the timer. When the timer achieves the variable value, the value is increased and again the timer has to achieve the variable value.

Here is the example, where I compared these two techniques. Timer2 keeps the sync, whereas Timer1 doesn’t. The sound file has 120bpm click sound (this: Freesound - Audacity click track 01 - 120 bmp - 10 min - 3.2 Mb.mp3 by Leo9geo)

Hope this helps. :slight_smile:

3 Likes