Added off counter but with value 0

This commit is contained in:
əlemi 2018-10-31 17:44:56 +01:00
parent 54fc6f26ab
commit 3e477f4ca8

View file

@ -18,7 +18,7 @@
#define Oct4 10 #define Oct4 10
#define noteOffset 36 #define noteOffset 36
#define offCounter 100 #define offCounter 0
#include <MIDI.h> #include <MIDI.h>
#include <HID.h> #include <HID.h>
@ -60,12 +60,18 @@ void send() {
for (int c = 48; c >= 0; c--) { for (int c = 48; c >= 0; c--) {
if (flip[c] == HIGH) { if (flip[c] == HIGH) {
flip[c] = LOW; flip[c] = LOW;
noteBuffer = c + noteOffset; if (noteCounter[c] > 0) {
if (status[c] == HIGH) { noteCounter[c]--;
MIDI.sendNoteOn(noteBuffer, velocity, 1);
} }
else if (status[c] == LOW) { else {
MIDI.sendNoteOff(noteBuffer, velocity, 1); noteCounter[c] = offCounter;
noteBuffer = c + noteOffset;
if (status[c] == HIGH) {
MIDI.sendNoteOn(noteBuffer, velocity, 1);
}
else if (status[c] == LOW) {
MIDI.sendNoteOff(noteBuffer, velocity, 1);
}
} }
} }
} }
@ -73,6 +79,7 @@ void send() {
void scan() { void scan() {
for (int cOctave = 0; cOctave < 4; cOctave++) { for (int cOctave = 0; cOctave < 4; cOctave++) {
octBuffer = 12 * cOctave;
digitalWrite(octave[cOctave], HIGH); digitalWrite(octave[cOctave], HIGH);