Definition of USB MIDI setHandlePitchChange differs between Teensy 2.0 and 3.0
Arduino 1..4 with Teensyduino 1.13
example Teensy > USB_MIDI > PrintIncoming
Teensy 2.0, USB type set to USB_MIDI
fails to compile, the error is
changing
to
makes the example compile for Teensy 2.0 with USB MIDI. However, it then fails for Teensy 3.0 and USB MIDI, as follows:
looking at the definitions, in hardware/teensy/cores/usb_midi/usb_api.h I see
while in hardware/teensy/cores/teensy3/usb_midi.h I see
and
According to the MIDI specification, this parameter is a 14bit unsigned integer, with 0x2000 corresponding to no pitch bend.
In the Teensy 3.0 code, shouldn't that be changed to either uint16_t or unsigned int?
Arduino 1..4 with Teensyduino 1.13
example Teensy > USB_MIDI > PrintIncoming
Teensy 2.0, USB type set to USB_MIDI
fails to compile, the error is
Code:
PrintIncoming.pde: In function 'void setup()':
PrintIncoming:19: error: invalid conversion from 'void (*)(byte, int)' to 'void (*)(uint8_t, uint16_t)'
PrintIncoming:19: error: initializing argument 1 of 'void usb_midi_class::setHandlePitchChange(void (*)(uint8_t, uint16_t))'
changing
Code:
void OnPitchChange(byte channel, int pitch) {
Code:
void OnPitchChange(byte channel, unsigned int pitch) {
Code:
PrintIncoming.pde: In function 'void setup()':
PrintIncoming.pde:19:45: error: invalid conversion from 'void (*)(byte, unsigned int) {aka void (*)(unsigned char, unsigned int)}' to 'void (*)(uint8_t, int) {aka void (*)(unsigned char, int)}' [-fpermissive]
In file included from F:\Arduino\arduino-1.0.4-teensyduino113\hardware\teensy\cores\teensy3/WProgram.h:28:0,
from F:\Arduino\arduino-1.0.4-teensyduino113\hardware\teensy\cores\teensy3/Arduino.h:1,
from PrintIncoming.pde:11:
F:\Arduino\arduino-1.0.4-teensyduino113\hardware\teensy\cores\teensy3/usb_midi.h:124:21: error: initializing argument 1 of 'void usb_midi_class::setHandlePitchChange(void (*)(uint8_t, int))' [-fpermissive]
looking at the definitions, in hardware/teensy/cores/usb_midi/usb_api.h I see
Code:
inline void setHandlePitchChange(void (*fptr)(uint8_t channel, uint16_t pitch)) {
Code:
extern void (*usb_midi_handlePitchChange)(uint8_t ch, int pitch);
Code:
inline void setHandlePitchChange(void (*fptr)(uint8_t channel, int pitch)) {
According to the MIDI specification, this parameter is a 14bit unsigned integer, with 0x2000 corresponding to no pitch bend.
0lllllll 0mmmmmmm
Pitch Wheel Change. 0mmmmmmm This message is sent to indicate a change in the pitch wheel. The pitch wheel is measured by a fourteen bit value. Center (no pitch change) is 2000H. Sensitivity is a function of the transmitter. (llllll) are the least significant 7 bits. (mmmmmm) are the most significant 7 bits.
In the Teensy 3.0 code, shouldn't that be changed to either uint16_t or unsigned int?
Last edited: