Legacy GM [SOLVED] Rhythm beat, local time


Definitely not a Sith Lord
I don't really understand that tutorial, but based on your question, is:
time = 0; //Initialize variable
audio_play_sound(snd_song,0,false); //Play song


if (time == someTime) {
good enough for you?


OH wait, I understand it now. I didn't quite understand when he said to minus 10 from 14 and that it would be equal to 4. 14 being the elapsed time since the beginning of the game time (I took this as the literal initialization of the game but in fact it's rather the time since the beginning of the level or when you've initialized the song) and 10 being the elapsed time since the beginning of the "LOOP" song. It didn't click for me when he said loop but 4 seconds is the current time of the loop.

But yeah you're right. I'll have to create a variable that checks for the time. Luckily I won't be using loops so I won't need another variable to minus from the other, since the initial variable will be the time of the song anyway.

Also I'll have to divide that time variable by 60 to get seconds seeing as my room speed is 60 frames per second
Last edited:


Tim Robb put it pretty clear in the comments

int current_seconds = 1.5f;

int beats_per_minute = 50;
int beats_per_second = beats_per_minute/60; // 60 seconds in a minute
int notes_per_beat = 4; // Sixteenth Notes
int notes_per_second = beats_per_second * notes_per_beat;

int current_note = notes_per_second * current_seconds;

This breaks it down a little further to explain what each value means and is for.

Also, a potentially better way to do it would be to run a timer that ticks at the frequency of notes_per_second and increments a value each time, rather than recording the seconds of playback and calculating it from that.
1.5 being the elapsed time since the start of the level.