microsoft / MIDI

Windows MIDI Services
MIT License
300 stars 24 forks source link

[BUG] MT4 to USB MIDI 1.0 message conversion issue. #328

Open m-komo opened 5 months ago

m-komo commented 5 months ago

Describe the bug MT4 messages sent to USB MIDI 1.0 devices that work with the USB MIDI 2.0 driver have several message conversion issues.

1) Note On/Off velocity value is always zero. image

2) RPN/NRPN Data Entry value converted to 14bits value is incorrect. image

To Reproduce

  1. Set the Roland UM-ONE mk2 to class-compliant mode and short INPUPT and OUTPUT to loop back messages.
  2. Attach the UM-ONE to PC.
  3. Update the driver to the USB MIDI 2.0 driver (UsbMidi2.sys).
  4. Open midi.exe in two windows.
  5. From one, monitor UM-ONE.
  6. From the other, send following messages to UM-ONE.
    0x40804000 0x02000000
    0x40904000 0xFFFF0000
    0x40201357 0x55555555
    0x40302468 0xCDCDCDCD
  7. Verify received messages.

Installer Name or Version

Desktop (please complete the following information):

Device information, if this is with an external MIDI device:

Psychlist1972 commented 5 months ago

Thank you for this test and report.

Psychlist1972 commented 5 months ago

On this one, the MIDI 1.0 velocity will need to be 7 bits, not 8.

09 90 40 FF should actually be 09 90 40 7F

In either case, 00 is not correct, but it shouldn't be FF

m-komo commented 5 months ago

In either case, 00 is not correct, but it shouldn't be FF

Yes, it was my miswriting. Thank you.

Psychlist1972 commented 5 months ago

Found a casting bug which caused the FFFF to become zero. Thanks.

Psychlist1972 commented 4 months ago

Also: Velocity 0 for Note off (0x8) is valid. It's only the Note On message (0x9) where a 0 velocity in MIDI 2.0 protocol is translated to 1 when in MIDI 1.0 protocol.

m-komo commented 2 months ago

Hmm, there is still something wrong with the translator.

First, I would like to make sure the expected result. Following is the expected result based on my understanding. image

Is this right?

If so, Note ON velocity and Data Entry seem not translated correctly. image

I sent Test328.txt to verify.

Psychlist1972 commented 2 months ago

Looking into this.

Psychlist1972 commented 2 months ago

Verified this works with DP7.

Results sending Test328.txt to a MIDI 1.0 hardware loopback

image

The only difference is the 0 vs 1 for velocity in the first message. I see Andrew's libmidi2 translates the Note Off with zero velocity to Note off with 1 velocity, like it does for note on.

Edit: Actually, that's the down-scaling of the 0x0200 velocity in the second MT4 word of the note off message, which also happens to be the example in the spec. "MIDI Velocity = 0x01: translates to 0x0200"

0x40804000 0x02000000
0x40904000 0xFFFF0000
0x40201357 0x55555555
0x40302468 0xCDCDCDCD
m-komo commented 2 months ago

Edit: Actually, that's the down-scaling of the 0x0200 velocity in the second MT4 word of the note off message, which also happens to be the example in the spec. "MIDI Velocity = 0x01: translates to 0x0200"

My apologies, the table I shared should be as below:

image