1/16 EXT seems to work, although sync happens only on beat for now, not 4 times a beat

This commit is contained in:
--global
2023-05-21 14:38:52 +03:00
parent f07d072a40
commit 41c393c4be

View File

@ -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;
}
}