midi NRPN glitch due to having to split value into two 7-bit bytes

I’m sending NRPNs to an OB6 synthesizer. It works fine except when the data crosses from 127 to 128 in either direction. Values are split into two 7-bit bytes so that 127 is sent as MSB 0 followed by LSB 127 and 128 is sent as 1 followed by 0. This would be fine except that each byte is sent one at a time, so the sequence 127, 128 is actually sent as MSB 0, LSB 127, MSB 1, LSB 0. After the third message, the synth has seen LSB 127 and MSB 1 which it interprets as 255. What the synth then performs is 127, 255, 128. Similarly counting down through this transition results in the sequence 128, 0, 127. The glitch value is short but very noticable. Any ideas what I can do to remove this glitch and have the synth respond to a smooth transition from 127 to 128?

Excerpt from OB6 manual attached

int waitABit = 2000;
byte dataMSB = 0;
byte paramMSB = 0;

void setup() {
 Serial.begin(9600);  //diagnostics
  Serial1.begin(31250);
}

void loop() {


  NRPN (1,45,126); //midi channel, NRPN number for filter cutoff, NRPN value
  delay (waitABit);
  NRPN (1,45,127);
  delay (waitABit);
  NRPN (1,45,128);
  delay (waitABit);
  NRPN (1,45,129);
  delay (waitABit);
  NRPN (1,45,128);
  delay (waitABit);
  NRPN (1,45,127);
  delay (waitABit);
  NRPN (1,45,126);
  delay (waitABit);
  NRPN (1,45,125);
  delay (waitABit);
    
}

void NRPN(byte chan,byte paramNumber,byte value) 
{
  Serial1.write(176 + chan - 1); // 176 control change. add (channel number minus 1) to this, eg Ch 2 would be 177
  Serial1.write(99);
  if (paramNumber > 127 ) {paramMSB = 1;} else paramMSB =0;
  Serial1.write(paramMSB);
  
  Serial1.write(176 + chan - 1); // 
  Serial1.write(98);
  Serial1.write(paramNumber & 127);
  
  Serial1.write(176 + chan - 1); // 
  Serial1.write(6);
  if (value > 127) {dataMSB = 1;} else dataMSB = 0;
  Serial1.write(dataMSB); // value MSB
  
  Serial1.write(176 + chan - 1); 
  Serial1.write(38);
  Serial1.write(value & 127);



  
  
  Serial.println("");
  Serial.println(dataMSB);
  Serial.println(value & 127);
  
}

At first glance, that will all be resolved by using an unsigned byte variable
You’re seeing wraparound 127-128 - becoming negative with the MSb set.
Unsigned leaves that alone, and there is no wraparound until 255-256 (0)

I don't think it's that at all!

OK, you’re in charge.

…each byte is sent one at a time, so the sequence
127, 128 is actually sent as
MSB 0, LSB 127,
MSB 1, LSB 0.

After the third message, the synth has seen
LSB 127 and MSB 1 which it interprets as 255.

That looks like you should be looking at signed/unsigned…
Maybe not as-is, but perhaps stripping and adding MSb when needed.

Data isn't sent as pairs like
MSB 0, LSB 127,
MSB 1, LSB 0.

it's send one message at a time
MSB 0, LSB 127, MSB 1, LSB 0.

Upon arrival of the third message, LSB is still set to 127 and MSB is now set to 1. These two 7-bit bytes are re-combined by the synth to make 256 because it uses the LSb of the MSB to make the MSb of a single 8-bit Byte: 256. I still don't see how this is anything to do with unsigned. It's to do with the sequence of messages and the way the synth combines the latest pair rather than the intended pair.

It's a midi and/or synth problem. If I turn local Off in the synth and connect midi out to midi in - NO ARDUINO EVEN IN THE SAME ROOM - then the glitch is still there as I turn the synth's knobs past the centre (127/128) point. Not an unsigned variable in sight...

OK, lets start again.
In reply #3, I merely quoted your OP - but you said that was wrong.
Perhaps worth re-stating the problem.
My suggestion to use signed/unsigned was also in response to your question…

Values are split into two 7-bit bytes so that 127 is sent as MSB 0 followed by LSB 127 and 128 is sent as 1 followed by 0. This would be fine except that each byte is sent one at a time,

For more help - maybe rewording the question will get more bettter suggestions for a solution.

  • from the manual
    a04df026c29349494bc271a60420f6e13ac90a5a.jpg