I am working on an open-source midi synth and whenever I play back a song that hits multiple notes at the same time, the music is slowing down.
I know I have a pretty wonky implementation (lines 140 and below in the code) because kivy hangs whenever there is a loop inside the update function. I wrote a workaround by splitting the midi file into a list that gets drained on every update. I suspect the issue is either kivy being slow, or the time.sleep() messing up the multiple keystrokes because it's synchronous.
Is there a separate thread I can use in Kivy that will run "in the background"? this could solve the issue but I'm not sure.
The code can be found here: https://github.com/DeWolfRobin/Pythesia/blob/main/gui.py
Multi-threading in combination with the schedule_once did the trick
Clock.schedule_once(game.startThread)