micdah / RtMidi.Core

RtMidi for .Net Standard
https://rtmidicore.micdah.dk/
Other
36 stars 12 forks source link

RtMidi not reporting SysEx input #16

Closed mat1jaczyyy closed 6 years ago

mat1jaczyyy commented 6 years ago

Having a bit of trouble with the SysEx input (which, ironically, I wrote).

Tests I wrote do work and confirm that the library is able to receive and parse them properly. However, I'm trying to listen to a SysEx message event in my application, but it doesn't seem to trigger at all.

I've done debugging to confirm the issue isn't my implementation. SysExMessage.TryDecode is never being called. I've tried tracing the calls back to the best of my knowledge, and it looks like MidiInputDevice.Decode is never called either. I've set a breakpoint at the method's entry point, and it does pause execution if I send a note on/off, but not a SysEx message from my MIDI controller. MidiInputDevice.RtMidiInputDevice_Message exhibits the same behaviour.

Now entering very unfamiliar territory, it seems RtMidiInputDevice.HandleRtMidiCallback is not called either when a SysEx message is triggered. From what I can tell, this method transfers all of the data from RtMidi into the C# library. It is, again, called when I send a note on/off, and stepping into it the message variable does get updated with that information.

To me, this suggests this is an issue with RtMidi not reporting the SysEx received from the MIDI device. I don't know if it's simply not configured to receive this kind of message when it is initialized, or if it's an issue in itself (you mentioned in the README we're using a custom build of RtMidi).

SysEx output works perfectly fine, and I've also confirmed using MIDI Monitor that the SysEx messages are actually being transmitted both ways: image

So far this has been reproduced on macOS, pending testing on Windows.

mat1jaczyyy commented 6 years ago

After testing and debugging, the exact same behavior occurs on Windows (64-bit).

mat1jaczyyy commented 6 years ago

I suspect it has to do with RtMidiC.IgnoreTypes, however I cannot seem to find where this function is called such that the midiSysex parameter is passed. Perhaps the default values after initialization are set to ignore the messages, and we should explicitly call the function and tell RtMidi not to ignore Sysex? If so, what would be a good place to call this function? How about after this line in RtMidiInputDevice?

mat1jaczyyy commented 6 years ago

I've confirmed this change allows the library to receive SysEx. Making a pull request.

micdah commented 6 years ago

@mat1jaczyyy You are awesome!

I'll have a look at your PR asap, but probably a bit later today. Excellent work!