TempoChangeRatio of 0.0 is not supported.
jeroenwalter opened this issue · 2 comments
jeroenwalter commented
This will cause a divide by zero.
Result is that the music is played at ludicrous speed.
jeroenwalter commented
Can be fixed by rewriting the timing mechanism of the MidiEventLooper class. Don't block the thread via WaitBy(ms), but use a timer to increase a tick counter, using the current tempo, every millisecond and then playback all midi events that are expired.
Needs a highres (1m) timer.
The current implementation uses Task.Delay, which is not acceptable here and which brings a lot of overhead.
jeroenwalter commented
Leaving this here as a reminder to myself...
https://pastebin.com/58QbCQVZ
https://stackoverflow.com/questions/41696144/c-sharp-timer-resolution-linux-mono-dotnet-core-vs-windows