Description
Describe the project you are working on:
A rhythm game where all events and animations are synced to MIDI data
Describe the problem or limitation you are having in your project:
I struggle to track and trigger events based on musical data (tempo). Since I can only execute logic in _process() and _physics_process(), I depend on the framerate while I need to trigger an event at exactly 2 seconds for example. But it's never 2s precisely and I constantly compensate the delay when the tempo (bar or beat) happens between 2 frames.
Other engines have APIs like dspTime (Unity) or TimeSynth (Unreal) to manage that and I'm wondering if it's achievable in Godot. I don't know about the complexity of implementation, from what I understand these precise timing methods seem to run on their own thread I guess ?
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
By having access to an API that can trigger events on precise timings like 2s (00:02:0000) which will allow easier programming for musical mechanics. Game logic will still run on main thread but at least we'll have another parallel logic that we can rely on to track the progression of the tempo for example.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
if get_absolute_time() == 2 print("Bar 2 reached")
If this enhancement will not be used often, can it be worked around with a few lines of script?:
There's no way to get absolute time and we need to check for approximations, which is ok for music playback and simplistic rhythm games but becomes hard when we want to deeply sync rhythm and game mechanics.
Is there a reason why this should be core and not an add-on in the asset library?:
I think this kind of implementation really depends on the engine low-level process and I guess it needs an alternative thread to run this implementation. Maybe a C++ plugin could do that ? I'm not advanced enough to know.