From 41c393c4bedf2550c6e2cae9e22bb2c14259dad0 Mon Sep 17 00:00:00 2001 From: --global <--global> Date: Sun, 21 May 2023 14:38:52 +0300 Subject: [PATCH] 1/16 EXT seems to work, although sync happens only on beat for now, not 4 times a beat --- software/GToE/GToE.ino | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/software/GToE/GToE.ino b/software/GToE/GToE.ino index 62355a3..71589ad 100644 --- a/software/GToE/GToE.ino +++ b/software/GToE/GToE.ino @@ -195,12 +195,13 @@ void clock() { //EXT-16 if (masterClockMode == 3) { - if (tickCount >= pulsePeriod && pulseCount < ((6 * (extTriggerCount + 1))-1)) { //hardcoded for 24ppqn + if (tickCount >= pulsePeriod && pulseCount < (PPQN-1)) { // ((6 * (extTriggerCount + 1)) - 1)) { //this formula puts it out of sync, so there's PPQN-1 for now tickCount = 0; pulseCount++; } } + // pull low all outputs after set pulse length if (tickCount >= PULSE_LENGTH) { for (int i = 0; i<6; i++) { @@ -250,30 +251,34 @@ void externalClock() { extResetCountdown++; //to get out of the loop } - } else if (masterClockMode == 3) { // EXT-1/16 + } else if (masterClockMode == 3) { // EXT-16 if (!isPlaying) { isPlaying = true; } - if ((newExtPulseTime - lastExtPulseTime) > 1000) { //750ms is 1/16 at 20bpm + if ((newExtPulseTime - lastExtPulseTime) > 750) { resetClocks(); extResetCountdown = 0; + extTriggerCount = 0; } - tickCount = 0; - if (extTriggerCount == 0) { + + if (extTriggerCount == 0) { //happens on beat pulseCount = 0; + tickCount = 0; } - - if (extTriggerCount < 2) { + if (extTriggerCount < 3) { extTriggerCount++; } else { extTriggerCount = 0; } - if (extResetCountdown < 4) { //reset on the first beat (5th pulse), so that BPM is already calculated correctly + + if (extResetCountdown < 4) { //reset on the second beat (5th pulse), so that BPM is already calculated correctly extResetCountdown++; } else if (extResetCountdown == 4) { resetClocks(); extResetCountdown++; //to get out of the loop } + + } } @@ -338,7 +343,7 @@ void calculateCycles() { void calculateBPMTiming() { int mod = 0; - if (masterClockMode == 0) { + if (masterClockMode == 0) { //Internal clock if (bpmModulationRange != 0 && !bpmModulationChannel) { mod = map (a1Input, 0, 1023, 0, bpmModulationRange*10); } else if (bpmModulationRange != 0 && bpmModulationChannel) { @@ -349,8 +354,8 @@ void calculateBPMTiming() { } else if (masterClockMode == 2) { //for external beat clock pulsePeriod = (newExtPulseTime - lastExtPulseTime) / PPQN; - } else if (masterClockMode == 3) { //for external 1/16 clock - pulsePeriod = (newExtPulseTime - lastExtPulseTime) / 6; //6 is hardcoded 1/16 at 24ppqn + } else if (masterClockMode == 3) { //for ext 1/16 clock (hardcoded) + pulsePeriod = (newExtPulseTime - lastExtPulseTime) / 6; } }