Hi Guys,
I am currently building my own MIDI controller for Lightroom processing. For this I use the plugin MIDI2LR. In order to be able to fine-tune the settings, I use NRPN to send my values. That works too (code below).
Now I also want to receive feedback on the controller positions when changing them with my computer. However, I don't know how this works with NRPN. The values that I get back are mixed up. Does anyone have experience with that?
Below is my code for an encoder and video to test it out.
I am currently building my own MIDI controller for Lightroom processing. For this I use the plugin MIDI2LR. In order to be able to fine-tune the settings, I use NRPN to send my values. That works too (code below).
Now I also want to receive feedback on the controller positions when changing them with my computer. However, I don't know how this works with NRPN. The values that I get back are mixed up. Does anyone have experience with that?
Below is my code for an encoder and video to test it out.
Code:
#include <MIDI.h>
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
int MSB = 0;
int LSB = 0;
volatile int encoderWert=8191;
void setup() {
Serial.begin(9600);
MIDI.begin(MIDI_CHANNEL_OMNI);
pinMode(0,INPUT);
pinMode(1,INPUT);
pinMode(2,INPUT);
attachInterrupt(digitalPinToInterrupt(0), encoderMessung, FALLING);
attachInterrupt(digitalPinToInterrupt(2), switchMessung, RISING);
usbMIDI.setHandleControlChange(myControlChange);
}
void loop() {
usbMIDI.read();
}
void encoderMessung() {
if(digitalRead(1)==HIGH) {
encoderWert=encoderWert+100;
MSB = encoderWert / 128;
LSB = encoderWert % 128;
usbMIDI.sendControlChange(99,0,1);
usbMIDI.sendControlChange(98,1,1);
usbMIDI.sendControlChange(6,MSB,1);
usbMIDI.sendControlChange(38,LSB,1);
}
else {
encoderWert=encoderWert-100;
MSB = encoderWert / 128;
LSB = encoderWert % 128;
usbMIDI.sendControlChange(99,0,1);
usbMIDI.sendControlChange(98,1,1);
usbMIDI.sendControlChange(6,MSB,1);
usbMIDI.sendControlChange(38,LSB,1);
}
}
void switchMessung() {
usbMIDI.sendControlChange(99,0,1);
usbMIDI.sendControlChange(98,2,1);
usbMIDI.sendControlChange(6,127,1);
usbMIDI.sendControlChange(38,127,1);
encoderWert=8191;
}
void myControlChange(byte channel, byte control, byte value) {
Serial.print("control = ");
Serial.println(control);
Serial.print("value = ");
Serial.println(value);
Serial.print("channel = ");
Serial.println(channel);
}