From 61e5c85454fe3293bb9adae950ed837622f3e0c6 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Sun, 23 Feb 2020 23:48:40 +0100 Subject: [PATCH] pitchbend --- send.py | 2 +- src/main.cpp | 43 ++++++++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/send.py b/send.py index 8d16d76..bc8c10b 100644 --- a/send.py +++ b/send.py @@ -36,7 +36,7 @@ def main(argv): for msg in mid: time.sleep(msg.time) if not msg.is_meta: - if msg.type == 'note_on' or msg.type == 'note_off': + if msg.type == 'note_on' or msg.type == 'note_off' or msg.type == 'pitchwheel': if (not (msg.channel in drum_channels)) or args.with_drums: print(msg) ser.write(msg.bin()) diff --git a/src/main.cpp b/src/main.cpp index bac279d..fa2ce20 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,20 +26,25 @@ Tone freq[NUM_STEPPER]; unsigned long previousMillis[NUM_STEPPER] = {0}; // will store last time LED was updated const long interval = 1000; // interval at which to blink (milliseconds) -volatile byte playing[NUM_STEPPER] = {0}; int enable_pin[NUM_STEPPER] = {X_ENABLE_PIN, Y_ENABLE_PIN, Z_ENABLE_PIN, E0_ENABLE_PIN, E1_ENABLE_PIN}; +struct playing_t { + byte noteNumber; + byte channel; +}; +volatile playing_t playing[NUM_STEPPER] = {0,255}; + int findSameNotes(byte noteNumber) { int candidate = -1; bool alreadyPlayingHarmonic = false; for (int i=0; i= 0) { digitalWrite(enable_pin[i], LOW); freq[i].play(f); - playing[i] = inNumber; + playing[i].noteNumber = inNumber; + playing[i].channel = inChannel; previousMillis[i] = millis(); } } @@ -101,14 +108,26 @@ void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity) digitalWrite(LED_PIN, LOW); for (int i=0; i> 7; + for (int i=0; i= interval || previousMillis[i] == 0) { digitalWrite(enable_pin[i], HIGH); - playing[i] = 0; + playing[i].noteNumber = 0; + playing[i].channel = 255; } }