Create NoteNames.ino

demonstrate use of MIDI_NAMESPACE::NoteValues[inNote].strptr
This commit is contained in:
lathoub 2020-03-22 20:30:37 +01:00
parent e79fb67d17
commit 0f74f054b6
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
#include <MIDI.h>
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();
}