InvisibleWrench / FlutterMidiCommand

A Flutter plugin to send and receive MIDI
BSD 3-Clause "New" or "Revised" License
91 stars 48 forks source link

Does NRPN work? #73

Open electricmonk opened 1 year ago

electricmonk commented 1 year ago

I'm sending NRPN messages to a Sequential Rev2 synth connected to an iPhone running my app, using a BLE MIDI adapter (MD-BT01).

The synth is receiving the message in the correct param, but the value is always interpreted as 0 value.

Sending an NRPN message from my DAW (Logic Pro X) works properly so I know that the synth is treating the NRPN according to its MIDI specification.

Are you sure that NRPN messages work as expected?

mortenboye commented 1 year ago

Thank you for reporting this. I do see an issue with the NRPN message implementation. Will fix shortly

mortenboye commented 1 year ago

HI @electricmonk try the latest v0.4.10, i believe it works as intended

electricmonk commented 1 year ago

Wow. That was fast. I'll check soon.

electricmonk commented 1 year ago

Nope, same behavior.

mortenboye commented 1 year ago

Can you provide some more information? What data are you sending? If you connect to something that can log the midi data (could be your Mac), what data is being received?

electricmonk commented 1 year ago

I need to find some time, I’ll record the nrpn message from Logic to raw bytes and write a unit test, then submit a PR. On 26 Jan 2023, at 20:54, Morten Boye Mortensen @.***> wrote: Can you provide some more information? What data are you sending? If you connect to something that can log the midi data (could be your Mac), what data is being received?

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

maks commented 1 year ago

For what its worth, I did successfully use nrpn's in my elfer project: https://github.com/maks/elfer but that was on linux & android only, I never tried running it on macos.

Elfers all very specific to the Korg Electribe E2 running the Hacktribe firmware but maybe this could be of some help? https://github.com/maks/elfer/blob/main/lib/midi/e2_device.dart#L191

mortenboye commented 1 year ago

@electricmonk perhaps you can give this commit a try https://github.com/InvisibleWrench/FlutterMidiCommand/commit/f874421419c474a0570ee0f5b8c5355abf54b402 I changed the NRPN message from sending bytes as Running Status to individual CC messages instead. Maybe that makes a difference?

electricmonk commented 1 year ago

Still no go.

see #74, I did a hex dump of a working NRPN message from Logic Pro to my synth, and wrote a unit test to assert the message.

It appears that you're not sending the last 3 bytes (data LSB) which according to a spec I just read seems to be optional but my synth doesn't respond to the message without it.

To corroborate I edited the raw MIDI message, removed the data LSB part and sent to my synth, and it indeed doesn't like it.

Since it's optional, would it hurt to always send it?

mortenboye commented 1 year ago

I'm surprised to learn that a Sequential synth doesn't understand NRPN without the optional value LSB byte. After all Sequential was founded by Dave Smith who also had a leading role in forming the MIDI spec.

Anyways, I'm reluctant to always send the optional valueMSB byte if it is not generally required. In fact I would prefer to always send the bytes as running status, and save 2-3 bytes with every message.

In your case it seems your synth does not follow the spec, so I would suggest you write your own MidiMessage subclass and send the exact bytes you need.

mortenboye commented 1 year ago

You are right about the value LSB being off. Thanks.

I just did some testing with some other equipment (I dont have a Rev2) and monitored some midi logs, and it leads me to believe that I've "overinterpreted" the NRPN spec. I think that instead of a single NRPN message that decides to include the valueLSB based on the value instead it should be decided with the message type. Some parameters/controls seems to always send/receive 14 bit values (MSB+LSB) and some only 7 bit. I will make an update that includes two types of NRPN messages.

intonarumori commented 1 year ago

I have both iOS and Android devices, a DSI Tetra and a Pioneer Toraiz AS-1 (both basically Sequential).

What I found:

I also verified these results by running through an iConnectivity MIDI patchbay, where I can inspect all the messages. For now I have a conditional when sending NRPN with the following:

if (Platform.isIOS) {
      // Send 4 separate 3 byte NRPN messages for ParamMSB, ParamLSB, ValueLSB, ValueLSB
      ...
} else if (Platform.isAndroid) {
      // Send 9 byte NRPN message with ParamMSB, ParamLSB, ValueLSB, ValueLSB in one message
      ...
}

It works for now, curious to hear more about your experience.