microsoft / MIDI

Windows MIDI Services
MIT License
304 stars 25 forks source link

[BUG] MIDI SYSEX / Real-Time Interleave Error with USB MIDI 1.0 Device #365

Closed AmeNote-Michael closed 2 months ago

AmeNote-Michael commented 2 months ago

Describe the bug When using new USBMidi2.sys driver with a USB MIDI 1.0 Device (mio4 with loopback set), injecting a system real-time message with more than one byte like Song Select (0xf3) or Song Position Pointer (0xf2) does not process rest of current SYSEX message correctly, causing a random start of SYSEX (0xf0) to be created and rest of data to be corrupted until a SYSEX end (0xf7)

To Reproduce Connect a USB MIDI 1.0 device such as mio4 or a UM-One and configure for DIN to be loopback and change to use new USBMidi2.sys driver. In one command window, setup to monitor MIDI from device: midi endpoint monitor --verbose

In another command window, use following test file with MIDI Console app using command midi endpoint send-file TestInterleaveError.txt TestInterleaveError.txt

Observe output

Expected behavior The expected output is something like the following which is from successful test with same test file but on a loopback USB MIDI 2.0 Device image

Screenshots The actual with error is as follows. You will note that the first SYSEX which is injected with a Song Select does not continue existing in process SYSEX and instead starts a new SYSEX at some point later.

image

Installer Name or Version Windows 11 Pro Insider Preview Build 26236.ge_prerelease.240607-1502 MIDI Services and Console App - DP5 (yep, I need to update) Driver Debug version based on code release: 240719-USBMidi2-x86-TESTSIGNED released version.

AmeNote-Michael commented 2 months ago

Investigating further today, it seems that the USB In handler is not properly handling continuing SYSEX in case of 2 or 3 byte system real time messages.

MusicMaker commented 2 months ago

AFAIK, only single byte System messages (A.K.A system realtime) are allowed in a sysex. System Common messages are not. So an SPP etc.. would be an invalid test case ?

Psychlist1972 commented 2 months ago

@AmeNote-Michael I believe @MusicMaker is correct here, and that it's only single-byte messages which can arrive at any time (in SysEx, or even right after the status byte in another message, or between the data bytes in those messages, etc.). Andrew is having to update his libmidi2 code to handle this as well.

Psychlist1972 commented 2 months ago

Closing as fixed in the August 2024 driver release. If you find it not to be when testing, will reopen.