grimmdude / MidiPlayerJS

♬ MIDI parser & player engine for browser or Node. As a parser converts MIDI events into JSON. Works well with single or multitrack MIDI files.
https://grimmdude.com/MidiPlayerJS/
MIT License
357 stars 52 forks source link

Fix lag on large midis #72

Open LapisHusky opened 3 years ago

LapisHusky commented 3 years ago

This provides a fix for https://github.com/grimmdude/MidiPlayerJS/issues/25 where only one event per track could play each playLoop interval. This means that if there are multiple simultaneous events, they won't play all at the same time, which can be seen when playing black midis. This fix works by doing playLoops until there are no more events to play. This might not be the most efficient way to solve the issue, because it now needs to do a playLoop twice every time there's an event, but it's better than setting sampleRate to 0 which just makes the issue require more events to see.