-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example https://forum.arduino.cc/index.php?topic=653004
- Loading branch information
Showing
3 changed files
with
104 additions
and
24 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
examples/Other/Arduino-Forum/MIDI-Note-Callback-IR/MIDI-Note-Callback-IR.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* <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. | ||
*/ | ||
|
||
#include <Control_Surface.h> | ||
|
||
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 ¬eInput, 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. | ||
GenericNoteRange<2, MyCallback> noteInput = { | ||
0, // first note number | ||
MyCallback(), // callback to use | ||
}; | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
Control_Surface.begin(); | ||
} | ||
|
||
void loop() { | ||
Control_Surface.loop(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters