midi input and midi output at the same time ?

Status
Not open for further replies.

emmanuel63

Well-known member
Hello,

I am working on a small project with the following workflow :
1 - teensy receives midi data from a keyboard
2 - the program applies changes and transformations to the midi data
3 - the new midi data are sent to a DAW or an expander

I don't know how the teensy can receive and send midi through a unique USB socket.
I know there is a second USB host on the board. Is it possible to use it as a midi input port, then the second USB as the midi output port ? If so, what do I have to specify in my code ?

Thanks for any help,
Emmanuel
 
The second USB (host) port can be used to send Midi over USB.

Besides the two USB ports, the Teensy 3.6 has 6 hardware UARTs which can do „classic“ Midi with DIN plugs.
 
Thank you for your answer.
Do I have to use specific code to route midi OUT to the USB host port ?
UARTs is a good solution too.
Thanks again for your help.
 
Here's an example of reading MIDI messages from the USB Host port and sending them to the PC on the normal USB port.

Pete
Code:
/*
  Receive incoming MIDI messages from a device on the
  USB Host port and relay them to the PC via the standard
  USB port.
  On Windows, use MIDI-Ox to monitor the received messages.
  Set up MIDI-Ox using Options|MIDI Devices and make sure
  that "Teensy MIDI" appears as a device in MIDI Inputs.
  
>>To compile this, you must select Serial + MIDI from the "Tools|USB Type" menu
   
   This example code is in the public domain.

   PJRC USB host cable for T3.6 is available at:
   https://www.pjrc.com/store/cable_usb_host_t36.html
*/

// Add USB Host MIDI to handle the 61es keyboard
#include <USBHost_t36.h>
USBHost myusb;
MIDIDevice midi1(myusb);

// Each of these callback functions handles a
// specific type of MIDI message from the
// USB Host interface and then passes it on to
// the PC thru the normal USB interface.
// You can change what is sent to the PC.
// For example, No matter what channel is used
// by the 61-es keyboard, I send it to the
// PC on channel 2 with:
// usbMIDI.sendNoteOn(note, velocity, 2);
void myNoteOn(byte channel, byte note, byte velocity) {
  usbMIDI.sendNoteOn(note, velocity, channel);
}

void myNoteOff(byte channel, byte note, byte velocity) {
  usbMIDI.sendNoteOn(note, 0, channel);
}

void myControlChange(byte channel, byte control, byte value) {
  usbMIDI.sendControlChange(control,value,channel);
}

void setup(void)
{
  Serial.begin(115200);
  myusb.begin();
  midi1.setHandleNoteOn(myNoteOn);
  midi1.setHandleNoteOff(myNoteOff);

  usbMIDI.begin();
  // Testing. Can be removed. If you are
  // monitoring with MIDI-Ox you should see
  // these 5 notes sent to the PC
  Serial.println("Send midi notes to the PC");
  for (int i = 0; i < 5; i++) {
    usbMIDI.sendNoteOn(49, 100, 1);
    delay(500);
    usbMIDI.sendNoteOff(49, 0, 1);
    delay(100);
  }
  Serial.println("Start");
}

void loop(void)
{
  myusb.Task();
  midi1.read();
}
 
Status
Not open for further replies.
Back
Top