Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: midi input and midi output at the same time ?

  1. #1
    Junior Member
    Join Date
    Dec 2018

    midi input and midi output at the same time ?


    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,

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Colmar, France
    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.

  3. #3
    Junior Member
    Join Date
    Dec 2018
    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.

  4. #4
    Senior Member
    Join Date
    Nov 2012
    Here's an example of reading MIDI messages from the USB Host port and sending them to the PC on the normal USB port.

      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:
    // 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) {
    void setup(void)
      // 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);
        usbMIDI.sendNoteOff(49, 0, 1);
    void loop(void)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts