So I have a midi controller with analog pot sliders and they work, however I made a mistake and soldered some pot upside down, meaning the top reads 0 and the bottom reads 127, whereas I want the opposite.
So hear is my code for sending the midi control messages:
void controlChange(byte channel, byte control, byte value)
{
// 0xB0 is the first of 16 control change channels. Subtract one to go from MIDI's 1-16 channels to 0-15
channel += 0xB0 - 1;
// Ensure we're between channels 1 and 16 for a CC message
if (channel >= 0xB0 && channel <= 0xBF)
{
#ifdef DEBUG
Serial.print(control - MIDI_CC);
Serial.print(": ");
Serial.println(value);
#else
Serial.write(channel);
Serial.write(control);
Serial.write(value);
#endif
}
}
For controllers, I want to send the opposite, i.e. if it is 0 I want to 127, if it is 50 I want to send 77 etc.
What's the easiest way to do this?
I was thinking of creating an array like
#define REVERSE_ARRAY 127, 126, 125, 124..... etc. to 0
Then reference the array with the value to get the "opposite" value.
Any ideas? Thanks!