From 0f74f054b6b5b81620f6e6ef4e1848b87ee1e43b Mon Sep 17 00:00:00 2001 From: lathoub Date: Sun, 22 Mar 2020 20:30:37 +0100 Subject: [PATCH] Create NoteNames.ino demonstrate use of MIDI_NAMESPACE::NoteValues[inNote].strptr --- examples/NoteNames/NoteNames.ino | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 examples/NoteNames/NoteNames.ino 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(); +}