usbMIDI.read() and external USB Keyboard Not Playing Well Together

Status
Not open for further replies.

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();
}
 
It actually sounds like a software issue on your Mac to me.

As I understand things you would need to have software repeating the incoming MIDI from your device and directing it towards the Teensy as a MIDI target.

In Windows there's a thing called 'MIDI yoke' that gets used for this and, while I don't know the Mac world (at least since 1999 when I used them last), these threads from Ableton's forum suggests there's something called IAC Driver that can redirect:
https://forum.ableton.com/viewtopic.php?f=1&t=88514&start=0
https://help.ableton.com/hc/en-us/articles/209774225-Using-virtual-MIDI-buses-in-Live
 
...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.
Do you mean you want to set parameters on the Teensy from a separate hardware controller or you want to set parameters with a software GUI in the Mac with Max or some other software?
 
Dear Oddson, Thank you for the quick reply! I have read both threads on Ableton's site and they provide some useful information. I will dig in when back at the lab. (1) However, to clarify, I have exactly the same problems on three computers: One Macbook Air (where I was able to get MAX to send MIDI to Teensy), but two different intel machines, one i5 ASUS Z17 running Win 10 & 1 i7 Intel NUC running Win 10 as well. So both the Mac and the 2 Windows machine have problems. Thus I suspect the AKAI MIDI controller.
(2) My goal was to have a MIDI controller with lots of pots act as an external controller to adjust many parameters (8-16) on an Audio Design Tool design running on a Teensy (say to control patching, filter cutoffs, modulation percentage, ADSR, etc.). However, if I can't get that going, I will use MAX MSP or SuperCollider as a MIDI interface, where I will create a GUI that will emulate a MIDI controller/and or custom controller, to control a Teensy's parameters with many adjustments.

The overall goal is to use Teensy as an intelligent sound source to provide user experience feedback for button and knob feedback, timers, alerts, and other state changes. With the goal of much richer audio indicators than a simple beep when a timer is over.

Thank you for any thoughts,

John

PS - I have ordered another controller that should arrive today (Novation)
 
Sorry maybe I'm still just not getting this... but what is the physical connection between the MIDI device and the Teensy?

If it's via computer and you're not redirecting the MIDI it will not just appear on a second MIDI port. There's no "MIDI thru" built in.

On Windows MIDI-Yoke or similar software is required to bridge the two MIDI ports. On Mac I'm relying on Google http://feelyoursound.com/setup-midi-os-x/

It is HIGHLY unlikely your controller is defective.
 
Yes, connection is Teensy<->USB<->hub<->USB<->Controller. Yes, it’s not the controller. I finally sorted it, though!!! I used MAX MSP 7 (on Win 10 NUC) to route the MIDI Controller (in) to Teensy (out). What I was missing was that the USB MIDI connections need to be ‘routed’. Gak! That was not intuitive to me. All working now. Thank you, Oddson!
 
Status
Not open for further replies.
Back
Top