Skip to content

Instantly share code, notes, and snippets.

@NickCulbertson
Last active February 26, 2023 20:41
Show Gist options
  • Save NickCulbertson/7961bb91e27e93dc364bff97dbd79d7e to your computer and use it in GitHub Desktop.
Save NickCulbertson/7961bb91e27e93dc364bff97dbd79d7e to your computer and use it in GitHub Desktop.
Teensy Arcade Midi Controller
#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);
}
}
@buretz
Copy link

buretz commented Feb 14, 2023

Thanks! Will try that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment