diff --git a/examples/NoteNames/NoteNames.ino b/examples/NoteNames/NoteNames.ino new file mode 100644 index 0000000..cc34ab5 --- /dev/null +++ b/examples/NoteNames/NoteNames.ino @@ -0,0 +1,34 @@ +#include + +MIDI_CREATE_DEFAULT_INSTANCE(); + +// ----------------------------------------------------------------------------- + +// This function will print the name of th note played. +// (check the callback example for more details on callbacks) + +void handleNoteOn(byte inChannel, byte inNote, byte inVelocity) +{ + Serial.print("Note On: "); + Serial.println(MIDI_NAMESPACE::NoteValues[inNote].strptr); +} + +// ----------------------------------------------------------------------------- + +void setup() +{ + Serial.begin(115200); + while (!Serial); + Serial.println("Arduino Ready"); + + MIDI.setHandleNoteOn(handleNoteOn); // Put only the name of the function + + // Initiate MIDI communications, listen to all channels + MIDI.begin(MIDI_CHANNEL_OMNI); +} + +void loop() +{ + // Call MIDI.read the fastest you can for real-time performance. + MIDI.read(); +}