thestk / rtmidi

A set of C++ classes that provide a common API for realtime MIDI input/output across Linux (ALSA & JACK), Macintosh OS X (CoreMIDI) and Windows (Multimedia)
Other
993 stars 275 forks source link

Note On with velocity 0 is sent as Note Off on macOS #320

Open GuruGurra opened 1 year ago

GuruGurra commented 1 year ago

The Midi spec says a Note On message with velocity 0 should be treated as a Note Off message. The Mackie Control spec, on the other hand, says that the release of a button should be reported as a Note On message with velocity 0.

When I make a call to send a Note On Message with velocity 0; this is sent as a Note On (90 xx 00) on Windows but is sent as a Note Off (80 xx 40) on macOS.

Some daws have implemented the Mackie Control protocol strictly after the Mackie spec, meaning that they require a Note On/vel 0 message and ignore Note Off messages. My app doesn't work with these daws since the wrong Midi message is sent.

How can I ensure the Note On message is sent as I have defined it on macOS and not translated to a Note Off message?

insolace commented 1 year ago

Hello,This is not an issue with RtMidi, which does no interpretation or filtering of the midi data that you send or receive. I would suspect that whatever software you’re using to look at the data on MacOS, you aren’t looking at the raw hex, but rather an interpretation of the meaning of the data. If you use Snoize’s free Midi Monitor application you can verify the hex and wether the status byte is 0x80 or 0x90.While the note on with velocity 0 is valid, I will caution you that some applications have bugs with this implementation. For instance, Ableton Live properly recognizes an All Notes Off CC message, but any notes not on channel 1 that are ended with a note on velocity 0 message will not be properly counted as off when the All Notes Off CC message is received, which can lead to strange behavior like notes turning back on.Some would say that any device following the Mackie control spec that doesn't recognize a note off message is not compliant with the midi specification, and is therefore buggy.Cheers,Eric BatemanOn Sep 4, 2023, at 6:17 AM, Gunnar Carlson @.***> wrote: The Midi spec says a Note On message with velocity 0 should be treated as a Note Off message. The Mackie Control spec, on the other hand, says that the release of a button should be reported as a Note On message with velocity 0. When I make a call to send a Note On Message with velocity 0; this is sent as a Note On (90 xx 00) on Windows but is sent as a Note Off (80 xx 40) on macOS. Some daws have implemented the Mackie Control protocol strictly after the Mackie spec, meaning that they require a Note On/vel 0 message and ignore Note Off messages. My app doesn't work with these daws since the wrong Midi message is sent. How can I ensure the Note On message is sent as I have defined it on macOS and not translated to a Note Off message?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

GuruGurra commented 1 year ago

I was afraid that would be the answer. :-/

Midi monitor verifies that the sent command is a Note Off (80 xx 40), not the requested Note On (90 xx 00).

I agree that any program that doesn't consider Note Off as a release is buggy. Still, it would have been nice if the messages I specify would have been sent...

insolace commented 1 year ago

Are you saying that MacOS is modifying the data that RtMidi is sending? Can you share some simplified example code?On Sep 4, 2023, at 10:56 AM, Gunnar Carlson @.***> wrote: I was afraid that would be the answer. :-/ Midi monitor verifies that the sent command is a Note Off (80 xx 40), not the requested Note On (90 xx 00). I agree that any program that doesn't consider Note Off as a release is buggy. Still, it would have been nice if the messages I specify would have been sent...

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

GuruGurra commented 1 year ago

Well, something is modifying the data. I'm using C#, so my calls are going through the RtMidi.Core wrapper.


A call to send a Note On with velocity 1:

NoteOnMessage msg = new NoteOnMessage(RtMidi.Core.Enums.Channel.Channel1, RtMidi.Core.Enums.Key.Key50, 1);
MidiOut.Send(in msg);

When I make this call, the msg buffer contains "90 32 01", and what is sent is "90 32 01".

A call to send a Note On with velocity 0:

NoteOnMessage msg = new NoteOnMessage(RtMidi.Core.Enums.Channel.Channel1, RtMidi.Core.Enums.Key.Key50, 0);
MidiOut.Send(in msg);

When I make this call, the msg buffer contains "90 32 00", and what is sent is "80 32 40". 

On Windows, the correct message is sent; it's only on Mac that it is changed.

insolace commented 1 year ago

I’m not familiar with C# and RtMidi, but I don’t see anything in the current RtMidi repository that references it. I have never seen any enums or methods in RtMidi similar to your example code, all RtMidi does is send ram data to the port, there are no note on/off functions or enums.Are you sure you’re asking your question in the right place?On Sep 5, 2023, at 12:26 AM, Gunnar Carlson @.***> wrote: Well, something is modifying the data. I'm using C#, so my calls are going through the RtMidi.Core wrapper.

A call to send a Note On with velocity 1:

NoteOnMessage msg = new NoteOnMessage(RtMidi.Core.Enums.Channel.Channel1, RtMidi.Core.Enums.Key.Key50, 1); MidiOut.Send(in msg);

When I make this call, the msg buffer contains "90 32 01", and what is sent is "90 32 01".

A call to send a Note On with velocity 0:

NoteOnMessage msg = new NoteOnMessage(RtMidi.Core.Enums.Channel.Channel1, RtMidi.Core.Enums.Key.Key50, 0); MidiOut.Send(in msg);

When I make this call, the msg buffer contains "90 32 00", and what is sent is "80 32 40".

On Windows, the correct message is sent; it's only on Mac that it is changed.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

GuruGurra commented 1 year ago

Yes, I am.

RtMidi.Core is a separate C# wrapper Github project that exposes RtMidi to C# programs.

It is doing so by exposing a number of functions for various message types (Note, CC, PC Sysex, and so on). I'm calling RtMidi.Core and can only show you the type of code I have. The functions and enums are, of course, part of RtMidi.Core, not RtMidi.

The developer of RtMidi.Core claims to do nothing regarding message modification before forwarding the calls to RtMidi.

Similar discussions are held in other Githib projects using coreMIDI, so I guess it is coreMIDI that performs this modification.

You can try it yourself. Just send the byte sequence 0x90,0x32,0x00 (or how you are accustomed to seeing byte arrays). What will be sent on the Midi port is 0x80,0x32,0x40.

sagamusix commented 1 year ago

As a potential workaround, if it's worth the money it to you, you could get a MIDI Solutions Event Processor, put it between your Mac and the Mackie (assuming it's a 5-pin MIDI connection and not a USB connection) and translate the note-offs to note-on events with a velocity of 0.

GuruGurra commented 1 year ago

Well, there are about 83,000 users of my software, so I don't think that is a good solution. :-)

sagamusix commented 1 year ago

Ah, indeed, if it's not just a personal project that might be a bit impractical ;)