|
#include <Control_Surface.h> |
|
|
|
USBMIDI_Interface midi; |
|
unsigned int octave = 1; |
|
int val1; |
|
int val2; |
|
int val3; |
|
int val4; |
|
bool playing1; |
|
bool playing2; |
|
bool playing3; |
|
bool playing4; |
|
|
|
NoteButton button1 {0, {MIDI_Notes::A(octave), CHANNEL_1}}; |
|
NoteButton button2 {4, {MIDI_Notes::B(octave), CHANNEL_1}}; |
|
NoteButton button3 {8, {MIDI_Notes::C(octave+1), CHANNEL_1}}; |
|
NoteButton button4 {12, {MIDI_Notes::D(octave+1), CHANNEL_1}}; |
|
NoteButton button5 {1, {MIDI_Notes::E(octave+1), CHANNEL_1}}; |
|
NoteButton button6 {5, {MIDI_Notes::F_(octave+1), CHANNEL_1}}; |
|
NoteButton button7 {9, {MIDI_Notes::G(octave+1), CHANNEL_1}}; |
|
NoteButton button8 {13, {MIDI_Notes::A(octave+1), CHANNEL_1}}; |
|
NoteButton button9 {2, {MIDI_Notes::B(octave+1), CHANNEL_1}}; |
|
NoteButton button10 {6, {MIDI_Notes::C(octave+2), CHANNEL_1}}; |
|
NoteButton button11 {10, {MIDI_Notes::D(octave+2), CHANNEL_1}}; |
|
NoteButton button12 {14, {MIDI_Notes::E(octave+2), CHANNEL_1}}; |
|
NoteButton button13 {3, {MIDI_Notes::F_(octave+2), CHANNEL_1}}; |
|
NoteButton button14 {7, {MIDI_Notes::G(octave+2), CHANNEL_1}}; |
|
NoteButton button15 {11, {MIDI_Notes::A(octave+2), CHANNEL_1}}; |
|
NoteButton button16 {15, {MIDI_Notes::B(octave+2), CHANNEL_1}}; |
|
|
|
void setup() { |
|
Control_Surface.begin(); |
|
} |
|
|
|
void loop() { |
|
Control_Surface.loop(); |
|
val1 = analogRead(2); |
|
val2 = analogRead(3); |
|
val3 = analogRead(4); |
|
val4 = analogRead(5); |
|
|
|
if (val1 > 4000 && playing1 == false) { |
|
playing1 = true; |
|
midi.sendNoteOff({MIDI_Notes::A(octave-1), CHANNEL_1}, 0); |
|
} else if (val1 < 2000 && playing1 == true) { |
|
playing1 = false; |
|
midi.sendNoteOn({MIDI_Notes::A(octave-1), CHANNEL_1}, 127); |
|
} |
|
|
|
if (val2 > 4000 && playing2 == false) { |
|
playing2 = true; |
|
midi.sendNoteOff({MIDI_Notes::F_(octave-1), CHANNEL_1}, 0); |
|
} else if (val2 < 2000 && playing2 == true) { |
|
playing2 = false; |
|
midi.sendNoteOn({MIDI_Notes::F_(octave-1), CHANNEL_1}, 127); |
|
} |
|
|
|
if (val3 > 4000 && playing3 == false) { |
|
playing3 = true; |
|
midi.sendNoteOff({MIDI_Notes::C(octave), CHANNEL_1}, 0); |
|
} else if (val3 < 2000 && playing3 == true) { |
|
playing3 = false; |
|
midi.sendNoteOn({MIDI_Notes::C(octave), CHANNEL_1}, 127); |
|
} |
|
|
|
if (val4 > 4000 && playing4 == false) { |
|
playing4 = true; |
|
midi.sendNoteOff({MIDI_Notes::G(octave), CHANNEL_1}, 0); |
|
} else if (val4 < 2000 && playing4 == true) { |
|
playing4 = false; |
|
midi.sendNoteOn({MIDI_Notes::G(octave), CHANNEL_1}, 127); |
|
} |
|
} |
That's awesome! I'm not too sure about custom implementations of Control Surface. I think what you could try is instead of using
NoteButton button1 {0, {MIDI_Notes::A(octave), CHANNEL_1}};
do something similar to how I'm handling analogRead in the loop usingbuttonState0 = digitalRead(0);
. Then change the CHANNEL_1 value based on the top button presses.