From ff6bf0111b3a00267ffc3ab7cc0654d99a1bdb19 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Mon, 10 Oct 2016 17:05:59 +0200 Subject: [PATCH] Added MidiUSB example (wip). --- examples/MidiUSB/MidiUSB.ino | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 examples/MidiUSB/MidiUSB.ino 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