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

Thread: Sending MIDI over USB

Hybrid View

  1. #1

    Sending MIDI over USB

    Hi all,

    I try to send MIDI over the USB port of a Teensy-3.6. I use the following simple test script:
    Code:
    #include <MIDI.h>
    
    #include <midi_UsbTransport.h>
    
    static const unsigned sUsbTransportBufferSize = 16;
    typedef midi::UsbTransport<sUsbTransportBufferSize> UsbTransport;
    
    UsbTransport sUsbTransport;
    
    MIDI_CREATE_INSTANCE(UsbTransport, sUsbTransport, MIDI);
    
    void setup() {
      Serial.begin(115200);
      MIDI.begin();
      Serial.println("Arduino ready.");
    }
    
    void loop() {
      Serial.println("*");
      MIDI.sendNoteOn(68, 100, 1);
      delay(500);
      MIDI.sendNoteOff(68, 100, 1);
      delay(500);
    }
    On Linux I am searching for the alsa MIDI port like this:
    Code:
    $ amidi -l
    Dir Device    Name
    IO  hw:1,0,0  Teensy MIDI MIDI 1
    So I have my Teemsy on port hw:1,0,0 and started a simple test to see if there are note-on/note-offs:
    Code:
    $ amidi -p hw:1,0,0 -d
    But nothing happens... there are no MIDI events.

    Has anybody an idea what I am doing wrong?

    TIA, Holger

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,083
    Maybe try the examples? In Arduino, click File > Examples > Teensy > USB_MIDI.

    See this page for details.

    https://www.pjrc.com/teensy/td_midi.html

    Do it this way first. Even if you *really* want to use that other MIDI stuff, use the simple known-working way first.

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,089
    I tried your code on Windows 10 on a T3.6 compiled as type "Serial + MIDI". It doesn't work - MidiOx doesn't see anything.
    Then I removed all of the headers - everything before the setup function and changed MIDI. to usbMIDI. so that I ended up with this:
    Code:
    void setup() {
      Serial.begin(115200);
      while(!Serial);
      usbMIDI.begin();
      Serial.println("Teensy ready.");
    }
    
    void loop() {
      Serial.println("*");
      usbMIDI.sendNoteOn(68, 100, 1);
      delay(500);
      usbMIDI.sendNoteOff(68, 100, 1);
      delay(500);
    }
    Works.

    Pete

  4. #4
    Hi Paul,
    hi Pete,

    Thank you so much for your help. I made a very simple mistake: I didn't use the Teensy example as a template, but one from the MIDI_Library. After I did it the way @Pete described it and looked at the examples from the Teensy area, it worked.

    Thanks again!

    Holger

Posting Permissions

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