MIDI Problems

Status
Not open for further replies.
That only leaves the mystery of how this code was supposed to work on a Mega and Teensy2 ...
OP namedrops 'Hairless' which appears to be a kludge around Arduino's clumsy USB connectivity. So it was using regular MIDI to send via serial USB connection.

Of course this why so many MIDI projects find their way on to Teensy but the non-symmetrical implementation in usbMIDI compared with the standard MIDI library does lead to some confusion and porting working sketches isn't as trivial as it might be.
 
I've just realized why the <<7 was necessary.
The original code had its own function to send the MIDI message:
Code:
MIDImessage(pitchBEND, 0, bendVal);
The three bytes were sent in the order they appear as arguments. Therefore the low-order 7 bits of bendVal were sent as the third byte of the message which is the high-order 7 bits of the pitchbend value. In effect, it was doing an implicit <<7 of the value.
When the switch was made to usbSerial, it uses this statement structure
Code:
usbMIDI.sendPitchBend( bendVal,1);
The bendVal is split into low- and high-order pieces. In this case the low-order 7 bits of bendVal are sent as the low-order 7 bits of the command (2nd byte). To make this work the same as the original code, the <<7 is necessary.

Pete
 
That only leaves the mystery of how this code was supposed to work on a Mega and Teensy2 but needs a modification to work with USBSerial when AFAICT all the drivers involved handle the pitchbend value in the same way.

Pete

Yes......maybe the other ones aren't using the full 14 bit and this: MIDImessage(pitchBEND, 0, bendVal); sends a different byte order.........As I say, I'm more a muso than a coder. Thanks again.
 
Status
Not open for further replies.
Back
Top