Low FPS causes inaccurate playing
By setting target_fps or force_fps to 30 or below, the MIDI player becomes increasingly inaccurate in when it plays notes, as notes get locked to the frame. For example, at 20FPS, notes are tied to one of the 20 frames, which is sometimes off by a lot.
I assume it’s related to https://bitbucket.org/arlez80/godot-midi-player/issues/51/timebase-1ms and the fixes introduced there to get notes to be more accurate, and I assume it’s the limitations of Godot at the moment which make it hard to get things timed properly. It seems that adjusting how frequently _sequence is called doesn’t help the problem at all.
If I had to guess, the amount of silence added to the front of audio samples to get them to line up correctly would need to be increased, so that there’s a larger gap available to line them up. However, I’m not sure if this is possible, and I haven’t had any luck in my own attempts.
Comments (6)
-
reporter -
repo owner I think it can be fixed by using thread. https://docs.godotengine.org/en/stable/classes/class_thread.html
and I added silence to head for adjust Godot's audio mixer has latency about 30ms.
in other words, Godot can’t playAudioStreamPlayer
at intervals shorter than 30ms. -
repo owner I fixed it at e501d96.
-
reporter Just tested it; sounds great, even at low FPS. Thank you.
It produces this error:
E 0:00:01.677 wait_to_finish: Thread must have been started to wait for its completion.<C++ Error> Condition "!is_active()" is true. Returned: Variant()<C++ Source> core/bind/core_bind.cpp:2725 @ wait_to_finish()<Stack Trace> MidiPlayer.gd:602 @ _process()
-
repo owner yeah, I noticed it and fixed it e501d96171308af129f8e55f7bc516ec90b8cdc5.
-
repo owner - changed status to resolved
- Log in to comment
An addendum: I found a way to control the rendering rate separately from the processing rate, so running the MIDI player at high frequencies without incurring a rendering cost isn’t a problem anymore.
For anyone curious:
That said, I believe the root of this issue also produces discrepancies even when the game is running at 60FPS.