Skip to content

Instantly share code, notes, and snippets.

@wware
Last active July 1, 2016 20:18
Show Gist options
  • Save wware/5f24ae66273938a75b5c8921a4b4db69 to your computer and use it in GitHub Desktop.
Save wware/5f24ae66273938a75b5c8921a4b4db69 to your computer and use it in GitHub Desktop.
Teensy MIDI controller
const int channel = 1;
const int led = 13;
void setup() {
pinMode(led, OUTPUT);
}
int programs[] = {
1, // acoustic grand piano
9, // celesta
20, // church organ
43, // cello
53, // choir aahs
74, // flute
105, // sitar
115 // steel drums
};
#define P (sizeof(programs) / sizeof(int))
int notes[] = {
48, 50, 52, 53, 55, 57, 59,
60, 62, 64, 65, 67, 69, 71,
72
};
#define N (sizeof(notes) / sizeof(int))
void loop() {
unsigned i, j, note;
while (1) {
for (j = 0; j < P; j++) {
usbMIDI.sendProgramChange(programs[j] - 1, channel);
for (i = 0; i < N; i++) {
note = notes[i];
usbMIDI.sendNoteOn(note, 100, channel);
digitalWrite(led, HIGH);
delay(500);
usbMIDI.sendNoteOff(note, 100, channel);
digitalWrite(led, LOW);
delay(200);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment