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

Handle RPN / NRPN CC messages #37

Closed
ghost opened this issue Sep 23, 2015 · 4 comments
Closed

Handle RPN / NRPN CC messages #37

ghost opened this issue Sep 23, 2015 · 4 comments
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Sep 23, 2015

I need to implement Sending/receiving Midi NRPN /RPN
https://en.wikipedia.org/wiki/NRPN
http://www.philrees.co.uk/nrpnq.htm
http://www.2writers.com/eddie/TutNrpn.htm

What is the best way to include them in library???

How I can write a callback for NRPN handling??

void sendNRPN(uint8_t channel, uint16_t parameter, uint8_t value) {
MIDI.sendControlChange( 99, (parameter >> 7) & 0x7F, channel);
MIDI.sendControlChange( 98, (parameter & 0x7F), channel);
MIDI.sendControlChange( 6 , value, channel);
}
void sendNRPN(uint8_t channel, uint16_t parameter, uint16_t value) {
MIDI.sendControlChange( 99, (parameter >> 7) & 0x7F, channel);
MIDI.sendControlChange( 98, (parameter & 0x7F), channel);
MIDI.sendControlChange( 6, (value >> 7) & 0x7F, channel);
MIDI.sendControlChange( 38, (value & 0x7F), channel);
}

void sendRPN(uint8_t channel, uint16_t parameter, uint8_t value) {
MIDI.sendControlChange(101, (parameter >> 7) & 0x7F, channel);
MIDI.sendControlChange(100, (parameter & 0x7F), channel);
MIDI.sendControlChange(6, value, channel);
}
void sendRPN(uint8_t channel, uint16_t parameter, uint16_t value) {
MIDI.sendControlChange(101, (parameter >> 7) & 0x7F, channel);
MIDI.sendControlChange(100, (parameter & 0x7F), channel);
MIDI.sendControlChange(6, (value >> 7) & 0x7F, channel);
MIDI.sendControlChange(38, (value & 0x7F), channel);
}

@franky47
Copy link
Member

RPN/NRPN are not natively implemented in the library because it would make the parser much more complex, where not many people are using them in the end.

To receive them, you can add a little state machine in a handleControlChange callback that would recompose RPN/NRPN and call your own handlers.

@starfishmod
Copy link

I certainly would love to be able to send and receive RPN and NRPN as I have a lot of equipment that rely on this (unfortunately).

At least sending would be nice although I will use the above code for the time being

@franky47
Copy link
Member

franky47 commented Nov 9, 2015

I'll see what I can do.

@franky47 franky47 added this to the 4.3 milestone Apr 9, 2016
@franky47 franky47 self-assigned this Apr 9, 2016
@franky47
Copy link
Member

franky47 commented Oct 6, 2016

I've pushed an (untested) example that handles RPN & NRPN reading, I'm working on adding the send methods to the library core.

As you can see in the example, it's not trivial: RPN & NRPN reading requires a bit of a state machine / parser to handle the CC stream, and potentially separate state data (of the values of the RPN / NRPN of interest, as we don't want to try and read them all, it would not fit in RAM).

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

No branches or pull requests

2 participants