-
In a project I'm working on, I'm receiving every NRPN MIDIEvent twice, once with Examples:
I'll add that I believe the device I'm working with uses MIDI 1.0, but I seem to get better parsing leaving the MIDIKit API settings at the default. Maybe I should switch to newer API with MIDI 1.0? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
What you're seeing is actually intended behavior - it's what Core MIDI does in a mixed MIDI 1.0 and MIDI 2.0 environment. MIDIKit is not parsing received RPN/NRPN messages in any special way internally. The MIDI 2.0 Spec outlines conventions that must be implemented when translating messages between MIDI 1.0 and 2.0 and back again. Core MIDI implements these conventions under the hood.
According to the MIDI 2.0 Spec, when translating 1.0 → 2.0, what Core MIDI is doing is aggregating the first 3 raw MIDI 1.0 CC messages and producing a single RPN/NRPN MIDI 2.0 UMP packet (Param MSB/LSB and Data Entry MSB). When it sees a Data Entry LSB following, it sends the same packet again but including the LSB. This might feel unintuitive but it's by design. The Data LSB may not always be present, and they decided that this algorithm was best. Data Entry is a cumulative value as per the MIDI Spec, so this is not a bug or an error. If you want to filter them until they contain non-zero data LSBs that's your prerogative -- that comes down to the specific behavior of the device you're talking to. When working in a purely legacy MIDI 1.0 API environment, you would have to parse it in a similar way any how since the CC messages all come in separately. You would have to make the decision to act upon MSBs or wait until LSBs show up. So MIDIKit is just handling events as Core MIDI is providing them.
You can use whichever API mode is most convenient, but keep in mind that the legacy API has been deprecated for several years now and one day it may be completely obsoleted. |
Beta Was this translation helpful? Give feedback.
UMP will fill zeroes for Data Entry bytes so I'm afraid you will probably come up dry testing for
nil
. That was implemented in MIDIKit more for when using legacy API and talking to MIDI 1.0 devices, it was possible to transmit only some of the bytes. I imagine once legacy API is fully obsoleted, I would change the Data Entry bytes to non-Optionals.