Control Surface  1.2.0
MIDI Control Surface library for Arduino
MIDI-Note-Callback-IR.ino

MIDI-Note-Callback-IR

https://forum.arduino.cc/index.php?topic=653004

Listen to MIDI notes 0 and 1, and print when Note On events are received.
This was initially intended to send IR remote commands when a note event is received for one of these notes.

USBMIDI_Interface midi; // MIDI Interface to use
void sendIR(uint32_t cmd) {
Serial << "Send IR 0x" << hex << cmd << dec << endl;
// Implement this
}
struct MyCallback final : SimpleNoteCCValueCallback {
// Function is called when note event for given range of notes is received.
void update(const INoteCCValue &noteInput, uint8_t index) override {
if (noteInput.getValue(index) == 0) // check that velocity > 0
return;
switch (index) { // index in the range of notes
case 0: sendIR(0xFFE01F); break;
case 1: sendIR(0xFF609F); break;
}
}
};
// Listen to a range of 2 notes, and use MyCallback.
0, // first note number
MyCallback(), // callback to use
};
void setup() {
Serial.begin(115200);
}
void loop() {
}
USBMIDI_Interface
A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.
Definition: USBMIDI_Interface.hpp:41
GenericNoteCCRange
Definition: NoteCCRange.hpp:156
INoteCCValue
Interface for NoteCCValue objects: provides getters for the velocity or controller values.
Definition: NoteCCRange.hpp:13
SimpleNoteCCValueCallback
A callback for NoteCCRange with an action that can be implemented by the user.
Definition: NoteCCRange.hpp:46
AH::dec
Print & dec(Print &printer)
Definition: PrintStream.cpp:77
Control_Surface.h
The main header file that includes all Control-Surface header files.
Control_Surface_::loop
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Definition: Control_Surface_Class.cpp:68
Control_Surface
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
Definition: Control_Surface_Class.cpp:203
AH::hex
Print & hex(Print &printer)
Definition: PrintStream.cpp:62
INoteCCValue::getValue
virtual uint8_t getValue(uint8_t index) const =0
Get the velocity or controller value for the given index in the range.
SimpleNoteCCValueCallback::update
virtual void update(const INoteCCValue &noteccval, uint8_t index)=0
Update the given index: called when a new message is received for this index.
AH::endl
Print & endl(Print &printer)
Definition: PrintStream.cpp:27
Control_Surface_::begin
void begin()
Initialize the Control_Surface.
Definition: Control_Surface_Class.cpp:25