mauer / xmidictrl

XMidiCtrl is an X-Plane plugin to use midi controllers within the flight simulator
https://mauer.github.io/xmidictrl/#/
GNU Affero General Public License v3.0
32 stars 10 forks source link

Use of discreet MIDI note offs means controller LEDs can't be turned off #25

Closed beely closed 1 year ago

beely commented 1 year ago

One issue I've found when implementing feedback with outbound messages and having problems turning lights off.

Using: { ch = 1, note = 74, type = "drf", dataref = "hypothetical_XP_dataref", value_on = "1", value_off = "0" }

When sending an on/off dataref as a MIDI note, XMidiCtrl is sending an ON/1 dataref value as a Note On (9n), velocity 127 (which is fine) but the OFF/0 value is being sent as a discreet MIDI Note Off (8n), with a velocity of 0. My controller ignores this, despite using a note on and off to toggle the LED's. So a note off/zero value sent from XMidiCtrl never turns off the associated LED.

The reason being is that most MIDI devices since the very early days of the MIDI spec tend not to use use discreet MIDI note offs, but actually MIDI note ons with a velocity of zero - this is always interpreted as a note off. This also has the MIDI bandwidth benefit of being able to use Running Status, which is why it was used like this in the first place (MIDI bandwidth, and data processing on MIDI equipment was a lot more limited back then) - although that's not really an issue these days.

So in my case, I can't actually turn an LED off with the features provided by XMidiCtrl, from what I can see.

I'm not sure what the best proposed solution for this would be. I'd prefer all dataref off values to be sent as MIDI Note Ons with a velocity of 0. This shouldn't interfere with any current user scripts, as any device that correctly interprets 8n discreet Note Offs, will also correctly interpret 9n Note On / velocity 0 as note offs, and the desired effect would be the same.

Or maybe a preference, or a setting in a the script, to determine the preferred note off format? Or a command option?

In any case, as it is now, I can't change my controller's MIDI receive implementation (this is a standard Apple Mackie Control format), so as it is, I can't implement feedback - LEDs will turn on correctly, but can't be turned off.

mauer commented 1 year ago

Hi,

Have a look at the latest version, please! I think it will solve your problem.

Thanks, Marco

beely commented 1 year ago

Hi thanks - adding support for include files is great as I'd started to hit the point where managing multiple aircraft definitions had become unwieldy!

Edit: Ah, found the note off setting in Devices - thanks, checking... Yes - this works great here - thank you for adding this!

mauer commented 1 year ago

Cool, many thanks for the feedback :-)