gbevin / SendMIDI

Multi-platform command-line tool to send out MIDI messages
https://uwyn.com
GNU General Public License v3.0
695 stars 51 forks source link

Pass 7-bit values via NRPN #54

Open texelec opened 2 months ago

texelec commented 2 months ago

I have a Midi device based on the SAM2695 wavetable IC, and it uses 7-bit values instead of 14-bit. Can you add an option to pass 7-bit values only? I was able to get it to compile on LInux, but the windows build looks a bit more obnoxious and I'm not even sure what all I'm missing to compile it other than parts of VS2017. I only have WSL running at the moment and no MIDI support, so I need the Windows build. :-)

This is the change I made:

auto number = state.asDecOrHex14BitValue(opts[0]); auto value = state.asDecOrHex7BitValue(opts[1]); state.sendMidiMessage(MidiMessage::controllerEvent(state.channel, 99, (number >> 7) & 0x7f)); state.sendMidiMessage(MidiMessage::controllerEvent(state.channel, 98, number & 0x7f)); state.sendMidiMessage(MidiMessage::controllerEvent(state.channel, 6, value & 0x7f)); //state.sendMidiMessage(MidiMessage::controllerEvent(state.channel, 38, value & 0x7f)); //state.sendMidiMessage(MidiMessage::controllerEvent(state.channel, 101, 0x7f)); //state.sendMidiMessage(MidiMessage::controllerEvent(state.channel, 100, 0x7f));

Clearly this change will only support 7-bit values, but maybe an option to send 7, or 14-bit values?

The datasheet for the SAM2965 doesn't show midi command 38 is not used for NRPN in my case. Long story short, NRPN messages do not seem to be processed, but others are fine.

Also, command 101 & 101 are for RPN. Is there a reason they are called at the end? It may be something I don't understand about the spec, but I don't see any reason to need to send them here.

Thanks! -Kevin

gbevin commented 2 months ago

That sounds like the SAM2695 is not following the MIDI spec. CC 6 and 38 are the MSB and LSB for NRPN messages, the number is selected with 98 and 99 and the last NRPN or RPN number is reset with CCs 100 and 101. SendMIDI does exactly what the MIDI spec specifies. If you want to send an NRPN that's out of spec, you can always send CC messages directly.