Created
August 23, 2022 04:36
-
-
Save cowboy/f764ca1c6ce163f62f06fd0140c932c6 to your computer and use it in GitHub Desktop.
Revisions
-
cowboy created this gist
Aug 23, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ // Settings: // Tools > Board = "Teensy 4.1" // Tools > USB Type to "MIDI" #include <USBHost_t36.h> // access to USB MIDI devices (plugged into 2nd USB port) // Create the ports for USB devices plugged into Teensy's 2nd USB port (via hubs) USBHost myusb; USBHub hub1(myusb); MIDIDevice midiDevice(myusb); void setup() { pinMode(LED_BUILTIN, OUTPUT); digitalWriteFast(LED_BUILTIN, HIGH); delay(100); digitalWriteFast(LED_BUILTIN, LOW); delay(100); digitalWriteFast(LED_BUILTIN, HIGH); delay(100); digitalWriteFast(LED_BUILTIN, LOW); myusb.begin(); } void loop() { // Read messages arriving from the (up to) 4 USB devices plugged into the USB Host port while (midiDevice.read()) { uint8_t type = midiDevice.getType(); uint8_t data1 = midiDevice.getData1(); uint8_t data2 = midiDevice.getData2(); uint8_t channel = midiDevice.getChannel(); usbMIDI.send(type, data1, data2, channel, 0); } // Read messages the PC (upstream host) sends and ignore them while (usbMIDI.read()); }