chrisguttandin / midi-json-parser

This module is parsing midi files into a human-readable JSON object.
MIT License
115 stars 6 forks source link

Gaps in midi playback #369

Closed spobwoode closed 4 years ago

spobwoode commented 4 years ago

Thanks for writing this parser - it's very useful! I'm having a slightly annoying issue where I successfully parse with parseArrayBuffer(arrayBuffer), but when I load the json into my midi sequencer I get gaps during playback.

I know it's not the midi sequencer because when I load in straight midi files, it works OK.

I've been going through the generated midi events from parseArrayBuffer and it seems that it could not be handling keyPressure events correctly. Some keyPressure events seem to be generated (in the json) with large delta values which cause my sequencer to pause between notes.

If I load the midi file directly into the sequencer there are no gaps, and if I iterate through all events, excluding all keyPressure events using:

if (jsonEvent.keyPressure != null) { return; }

then it also plays correctly (without the unwanted gaps).

MorozovS07.zip

This is an example of .MID file that is creating these gaps. I'm hoping that you might have some inside knowledge as to what might be causing this issue.

Thanks in advance!

chrisguttandin commented 4 years ago

Hi @spobwoode, thanks a lot for reporting this and thanks for providing a test case. Apparently the logic for the keyPressure and channelPressure events was flipped. That should be fixed now for the midi-json-parser as well as for the json-midi-encoder.

spobwoode commented 4 years ago

That's fixed the issue. Thanks!