I'm currently working on making a game inspired by Guitar Hero and Frets on Fire, so far everything's been going well - I've written a script that can parse .chart files generated by the FeedBack Editor into usable data.
My concern is how would I go about to make sure the timing is correct_(I'm gonna have to convert these beat values into ms instead)_? The files I'm parsing hold values such as these;
0 = N 1 120
120 = N 2 120
240 = N 3 576
Where the first integer is at what beat the note should occur, N is whether or not the note is a hammer-on, then the Fret ID_(Green or Red etc)_ and the length of the note, again in beats.
I'm worried that songs will easily go out of sync if there's sudden FPS lag spikes, what would be a way to prevent it from going out of sync?
I've tried to find sources to figure out how they make sure that the timing on the notes is correct, but I can't seem to find anything useful.
This is a hard problem, because it depends on your audio player API. To make it work correctly, you'd need to have a function in your player that returns the current playing position. Let's say your player API has a method to get the position in milliseconds.
I would do the synchronization in native code, because if you use the value within lua, GC could kick in and throw you out of sync. Just use lua to parse the timings and set up arrays of structs (or something similar) for the native code.