diff --git a/examples/MidiUSB/MidiUSB.ino b/examples/MidiUSB/MidiUSB.ino new file mode 100644 index 0000000..d51eccd --- /dev/null +++ b/examples/MidiUSB/MidiUSB.ino @@ -0,0 +1,39 @@ +#include +#include + +static const unsigned sUsbTransportBufferSize = 16; +typedef midi::UsbTransport UsbTransport; + +UsbTransport sUsbTransport; + +MIDI_CREATE_INSTANCE(UsbTransport, sUsbTransport, MIDI); + +// -- + +void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) +{ + Serial.print("NoteOn "); + Serial.print(inNumber); + Serial.print("\tvelocity: "); + Serial.println(inVelocity); +} +void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity) +{ + Serial.print("NoteOff "); + Serial.print(inNumber); + Serial.print("\tvelocity: "); + Serial.println(inVelocity); +} + +void setup() { + Serial.begin(115200); + while (!Serial); + MIDI.begin(); + MIDI.setHandleNoteOn(handleNoteOn); + MIDI.setHandleNoteOff(handleNoteOff); + Serial.println("Arduino ready."); +} + +void loop() { + MIDI.read(); +} \ No newline at end of file