Uncommon type of timed events

I have a data table which is converted to an array of strings. The values represent milliseconds on which sound should be fired. My first approach was to compare in-game time with a row value. If it is equal then sound plays, if not - wait until next tick. The problem is that time between adjacent row values is less than a tick. My question is can i use an array of milliseconds to play sound in correct time?

Hey! I did a quick check and my suspicion to your method was proven correct. Using the code below: The Print String “Hello” does never executes when the Get Game Time in Seconds reaches 1. The Branch probably skips some of the game time, because it’s not possible to return data quickly enough using the Event Tick.

Increasing the span as such will yield a “Hello” 1-3 times:

You would probably need to find another method if you are required to execute on the precision of a millisecond.

I wonder if one could employ a timer - it’s quite happy to fire in between the frames, as many times needed, too. But the results are not distributed equally between the 2 frames, afaik.

The problem is that time between adjacent row values is less than a tick.

What is the end goal, though? What are you making that is so time sensitive? Let’s say you manage to pull it off and read the lines faster than Tick (with a timer). You still cannot start playing the sound between the frames (can you?). You can always up the frames, ofc, a sustainable 240Hz refresh is easily achievable these days. Modern computers reach several hundred frames per second, you could breach 1k fps. I’m ignoring the fact that 500Hz+ refresh screens are not available commercially, we’re talking sound, anyway.

And coming back to the actual application, can anyone tell if the sounds is played in the 1st or 2nd frame, even in a sluggish 30Hz scenario? If you add up all the input lag from the user devices, the 10ms delay seems insignificant. Someone corrects me here if I’m wrong, please.

For now i decided to fire event based on “less or equal” condition. It seems to work as expected.

I’m trying to make a rhythm game and i don’t want to use third party plugins. MIDI clock fires approximately every 0.005208333333 seconds at BPM 120. My time values are in MIDI clock and converted to milliseconds.
EDIT: Thanks for help everyone

So it does not really matter then. You’re not doing anything between the frames. You just need to check when something is ready to go on the current frame.

For rhythm games I’d suggest looking at the Quartz Sub-system. It’s specifically built with music and timing in mind (sound quantization events etc)

1 Like

44100 hz audio is still faster than 240 hz video. Think about it🤔

It does not matter. You cannot start / stop sound between the frames. The framerate is the execution frequency limiter. You’d need to go much deeper than BPs to achieve that.

I’ll look into it. Thanks

1 Like

Ah, i see. Now it is clear. Thank you

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.