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

emitEvent() should emit multiple events with the same tick #87

Open serg472 opened 2 years ago

serg472 commented 2 years ago

Currently play() method is returning a single emitEvent() every 5ms even if there was a series of events on the same tick. It should return all events from the same tick in an array. For example if your midi starts with the standard sequence "time signature", "key signature" etc all these are returned with 5ms intervals between them. Imagine if your midi starts with a hundred of silent system events this would delay the playback for seconds. Not only that, but It's adding 5ms delays where they are not expected to be, which causes all sorts of weird timing issues (silent events are decreasing the durations of following note-on events; note-off and note-on are 5ms apart where they should be smoothly following each other, etc).

Thanks.