Sending MIDI over USB

Status
Not open for further replies.

C0d3man

Well-known member
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
 
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
 
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
 
Status
Not open for further replies.
Back
Top