Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GuruGurra opened this issue Sep 4, 2023 · 1 comment
Open

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

GuruGurra opened this issue Sep 4, 2023 · 1 comment

Comments

@GuruGurra
Copy link

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 IMidiOutputDevice.Send() with a NoteOnMessage 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?

@micdah
Copy link
Owner

micdah commented Sep 4, 2023

RtMidi.Core is mostly a wrapper around rtmidi which is a C++ library which does much of the MIDI heavy lifting, particularly it handles the OS-specific macOS/Windows API's.

So I looked into my code and I can see this is what I'm sending to the underlying library:

        internal byte[] Encode()
        {
            return new[]
            {
                StructHelper.StatusByte(Midi.Status.NoteOnBitmask, Channel),
                StructHelper.DataByte(Key),
                StructHelper.DataByte(Velocity)
            };
        }
        
public static byte DataByte(Key key)
            => (byte) (Midi.DataBitmask & (int) key);
            
internal const byte NoteOnBitmask = 0b1001_0000;

So I'm actually sending what you expect to rtmidi, the question then becomes whether rtmidi does the translation or whether it's the macOS specific OS API's which does this interpretation.

This is the repo I'm building on top of, though it's been a while since I last pulled from upstream: https://github.com/thestk/rtmidi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants