If you compile with usb type set to MIDI your Teensy should appear as a class compliant MIDI device.
You send it MIDI from the DAW just as you would any sound module.
void OnNoteOn(byte channel, byte note, byte velocity) {
digitalWrite(LED_BUILTIN, HIGH); // Any Note-On turns on LED
}
void OnNoteOff(byte channel, byte note, byte velocity) {
digitalWrite(LED_BUILTIN, LOW); // Any Note-Off turns off LED
}
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn) ;
digitalWrite(LED_BUILTIN, HIGH);
delay(400); // Blink LED once at startup
digitalWrite(LED_BUILTIN, LOW);
}
void loop() {
usbMIDI.read();
}
Code:void OnNoteOn(byte channel, byte note, byte velocity) { digitalWrite(LED_BUILTIN, HIGH); // Any Note-On turns on LED } void OnNoteOff(byte channel, byte note, byte velocity) { digitalWrite(LED_BUILTIN, LOW); // Any Note-Off turns off LED } void setup() { Serial.begin(115200); pinMode(LED_BUILTIN, OUTPUT); usbMIDI.setHandleNoteOff(OnNoteOff); usbMIDI.setHandleNoteOn(OnNoteOn) ; digitalWrite(LED_BUILTIN, HIGH); delay(400); // Blink LED once at startup digitalWrite(LED_BUILTIN, LOW); } void loop() { usbMIDI.read(); }
Where is my mistake? I cant even understand it. I selected USB Type MIDI.
Hello there - this compiles and works fine, but I do have a couple of suggestions.
For your first post, with getting usb plugged/unplugged sounds, if you then get teensy not responding, then shut down the IDE, unplug the teensy, plug the teensy back in and then start the IDE again. Gets stuck occasionally, windows thing
Also, if you send output from your daw to teensy, this code should work fine - I tested it using midiox, but I think that your issue might be that your code is responding to note off - a lot of MIDI kit doesn't actually send note off, but sends a note on with velocity zero, instead. Have fun.
Paul.
Hairless is an Arduino kludge to push midi thru usb serial. Teensy does not require it as it sends class compliant usb midi.
What DAW are you using?