MIDIUSB
MIDIUSB copied to clipboard
fixed midi input event loss issue with high data rates
While receiving midi packets from a high-rate stream (such as from an expressive controller like a Continuum, Seaboard, Linnstrument, etc) I discovered that the low-level USB_Recv() call when asked to read only the next 4 bytes (as it was being used before my patch) apparently throws away any other data sitting in its USB recv queue at the time, instead of returning the next 4 bytes on the next call as presumably expected. The solution is to allow it to read more data at once if available, in my testing reading up to 8 events (32 bytes) was more than enough to handle what I was throwing at it in a stress test. USB_Recv only returns what it actually reads. However, with large sysex I wouldn't be surprised for it to require more, probably the right thing to do is allow up to MIDI_BUFFER_SIZE, but I didn't want to impose that kind of extra memory use for the temporary read buffer.
Superseded by #109.