Time Lagging in Quartz

I see. Well you are asking the right questions early!

There is no benefit in introducing the complexity of an “accurate clock” running on its own thread other than to satisfy the human desire to haves something be “real.” There is no spoon, my friend :slight_smile:

As soon as your accurate clock’s flag is processed by the game-thread, it is quantized, so its existence was futile. You can obtain do math (like you were doing to try to measure time delta’s w/ Quartz). See FGenericPlatformTime.

You can then do the math to determine the delta (as far as you can tell on game tick) between when you received the event and the “perfect” 128th note.

Since you know your BPM, you could calculate out what CPU cycle each 128th note should land on from here to eternity. You don’t need a running “async wall clock” to keep track of that.

The other issue you will probably run into is trying to schedule sounds w/ Quartz at the last second. Quartz lets you schedule ahead. If the sound is supposed to play right when you get user input (which is supposed happen right on the beat), that might be too late for Quartz to hit the deadline. Especially if you’re going to allow for players hitting behind the beat (i.e. after the sound should have technically started.)

1 Like