Convert the MIDI timer into an SDL thread.
Timers are apparently not guaranteed to run in their own threads, and may therefore not be locked.