jcfrgmn
Member
I am having problems with the Teensy usbmidi.read() examples to work (either the printincomming or the code listed to flash a LED with incoming MIDI messages, in the midi tutorial on pjrc.com). The code is posted below, but right out of the example menu. My setup consists of a PC running Windows 10 and a Macbook Air running Sierra. I am on Arduino IDE 1.8.2 and Tweensyduino 1.36. I have tried 3 Teensy 3.2's and 1 3.6 (all have Audio Shields except one 3.2). I am using Reaper 5.40, and MAX MSP 7.3.3 and finally (and maybe the culprit) and Akai MPK mini II.
"Buttons" works just fine, using Reaper DAW to respond to button presses to generate notes. However, "Printincoming" does not work from the example code (with one exception below) e.g. when I press a key, no messages are printed in the Serial Console. To clarify, when I enter a key from a the Akai MPK mini on USB powered hub, connected with an adjacent USB as the Teensy 3.2, with the port selected as MIDI, I do not get any indication of a key down, or up, or a button press, etc. No control messages are printed out whatsoever. And I have tried the LED flashing example too. It is as if there is no MIDI message (but I can verify that messages from the MIDI controller are being sent with both the Mac's MIDI monitor & MAX). I have tried this on all the combos listed above, and I have even changed the cables. The Akai works just fine with say Reaper, MAX, and GarageBand to play notes when the keys are pressed.
The only way I can get Printincoming to work is using MAX MSP's midiout capability. That works, but any combination using the external USB MIDI controller does not work. I have ordered a new and different MIDI controller, and maybe that is it, but I doubt it as the MPK works with MAX, GarageBand and Reaper.
The goal I have is to create different user experience sounds using the Audio Design Tool, and to do so efficiently, I want to create a MIDI controller as a 'front panel/patch bay' to program the Teensy's parameters. So I need usbMIDI.read() to work.
Any help to this very strange problem would be appreciated. I do not think it is the Teensy BTW, but I can't figure it out.
Thank you!
John
--------------------------------------------------------------------------------------------
/* Print Incoming Message USB MIDI Example
Use the Arduino Serial Monitor to view the messages
as Teensy receives them by USB MIDI
You must select MIDI from the "Tools > USB Type" menu
This example code is in the public domain.
*/
void setup() {
Serial.begin(115200);
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn);
usbMIDI.setHandleVelocityChange(OnVelocityChange);
usbMIDI.setHandleControlChange(OnControlChange);
usbMIDI.setHandleProgramChange(OnProgramChange);
usbMIDI.setHandleAfterTouch(OnAfterTouch);
usbMIDI.setHandlePitchChange(OnPitchChange);
}
void loop() {
usbMIDI.read(); // USB MIDI receive
}
void OnNoteOn(byte channel, byte note, byte velocity) {
Serial.print("Note On, ch=");
Serial.print(channel, DEC);
Serial.print(", note=");
Serial.print(note, DEC);
Serial.print(", velocity=");
Serial.print(velocity, DEC);
Serial.println();
}
void OnNoteOff(byte channel, byte note, byte velocity) {
Serial.print("Note Off, ch=");
Serial.print(channel, DEC);
Serial.print(", note=");
Serial.print(note, DEC);
Serial.print(", velocity=");
Serial.print(velocity, DEC);
Serial.println();
}
void OnVelocityChange(byte channel, byte note, byte velocity) {
Serial.print("Velocity Change, ch=");
Serial.print(channel, DEC);
Serial.print(", note=");
Serial.print(note, DEC);
Serial.print(", velocity=");
Serial.print(velocity, DEC);
Serial.println();
}
void OnControlChange(byte channel, byte control, byte value) {
Serial.print("Control Change, ch=");
Serial.print(channel, DEC);
Serial.print(", control=");
Serial.print(control, DEC);
Serial.print(", value=");
Serial.print(value, DEC);
Serial.println();
}
void OnProgramChange(byte channel, byte program) {
Serial.print("Program Change, ch=");
Serial.print(channel, DEC);
Serial.print(", program=");
Serial.print(program, DEC);
Serial.println();
}
void OnAfterTouch(byte channel, byte pressure) {
Serial.print("After Touch, ch=");
Serial.print(channel, DEC);
Serial.print(", pressure=");
Serial.print(pressure, DEC);
Serial.println();
}
void OnPitchChange(byte channel, int pitch) {
Serial.print("Pitch Change, ch=");
Serial.print(channel, DEC);
Serial.print(", pitch=");
Serial.print(pitch, DEC);
Serial.println();
}
"Buttons" works just fine, using Reaper DAW to respond to button presses to generate notes. However, "Printincoming" does not work from the example code (with one exception below) e.g. when I press a key, no messages are printed in the Serial Console. To clarify, when I enter a key from a the Akai MPK mini on USB powered hub, connected with an adjacent USB as the Teensy 3.2, with the port selected as MIDI, I do not get any indication of a key down, or up, or a button press, etc. No control messages are printed out whatsoever. And I have tried the LED flashing example too. It is as if there is no MIDI message (but I can verify that messages from the MIDI controller are being sent with both the Mac's MIDI monitor & MAX). I have tried this on all the combos listed above, and I have even changed the cables. The Akai works just fine with say Reaper, MAX, and GarageBand to play notes when the keys are pressed.
The only way I can get Printincoming to work is using MAX MSP's midiout capability. That works, but any combination using the external USB MIDI controller does not work. I have ordered a new and different MIDI controller, and maybe that is it, but I doubt it as the MPK works with MAX, GarageBand and Reaper.
The goal I have is to create different user experience sounds using the Audio Design Tool, and to do so efficiently, I want to create a MIDI controller as a 'front panel/patch bay' to program the Teensy's parameters. So I need usbMIDI.read() to work.
Any help to this very strange problem would be appreciated. I do not think it is the Teensy BTW, but I can't figure it out.
Thank you!
John
--------------------------------------------------------------------------------------------
/* Print Incoming Message USB MIDI Example
Use the Arduino Serial Monitor to view the messages
as Teensy receives them by USB MIDI
You must select MIDI from the "Tools > USB Type" menu
This example code is in the public domain.
*/
void setup() {
Serial.begin(115200);
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn);
usbMIDI.setHandleVelocityChange(OnVelocityChange);
usbMIDI.setHandleControlChange(OnControlChange);
usbMIDI.setHandleProgramChange(OnProgramChange);
usbMIDI.setHandleAfterTouch(OnAfterTouch);
usbMIDI.setHandlePitchChange(OnPitchChange);
}
void loop() {
usbMIDI.read(); // USB MIDI receive
}
void OnNoteOn(byte channel, byte note, byte velocity) {
Serial.print("Note On, ch=");
Serial.print(channel, DEC);
Serial.print(", note=");
Serial.print(note, DEC);
Serial.print(", velocity=");
Serial.print(velocity, DEC);
Serial.println();
}
void OnNoteOff(byte channel, byte note, byte velocity) {
Serial.print("Note Off, ch=");
Serial.print(channel, DEC);
Serial.print(", note=");
Serial.print(note, DEC);
Serial.print(", velocity=");
Serial.print(velocity, DEC);
Serial.println();
}
void OnVelocityChange(byte channel, byte note, byte velocity) {
Serial.print("Velocity Change, ch=");
Serial.print(channel, DEC);
Serial.print(", note=");
Serial.print(note, DEC);
Serial.print(", velocity=");
Serial.print(velocity, DEC);
Serial.println();
}
void OnControlChange(byte channel, byte control, byte value) {
Serial.print("Control Change, ch=");
Serial.print(channel, DEC);
Serial.print(", control=");
Serial.print(control, DEC);
Serial.print(", value=");
Serial.print(value, DEC);
Serial.println();
}
void OnProgramChange(byte channel, byte program) {
Serial.print("Program Change, ch=");
Serial.print(channel, DEC);
Serial.print(", program=");
Serial.print(program, DEC);
Serial.println();
}
void OnAfterTouch(byte channel, byte pressure) {
Serial.print("After Touch, ch=");
Serial.print(channel, DEC);
Serial.print(", pressure=");
Serial.print(pressure, DEC);
Serial.println();
}
void OnPitchChange(byte channel, int pitch) {
Serial.print("Pitch Change, ch=");
Serial.print(channel, DEC);
Serial.print(", pitch=");
Serial.print(pitch, DEC);
Serial.println();
}