Added basic External Beat clock mode. Still needs a lot of work

This commit is contained in:
--global
2023-05-12 01:38:46 +03:00
parent 2d3c3dd683
commit c63418fb37

View File

@ -151,15 +151,19 @@ void clock() {
sendTriggers(); sendTriggers();
} }
if (masterClockMode == 2) {
updateTiming();
}
//this part gets the Pulse and Ticks ticking //this part gets the Pulse and Ticks ticking
//it's placed after the triggers to avoid problems on the start (when pulseCount==0) //it's placed after the triggers to avoid problems on the start (when pulseCount==0)
tickCount++; tickCount++;
if (masterClockMode == 0) { if (masterClockMode == 0 || 2) {
if (tickCount == pulsePeriod) { if (tickCount == pulsePeriod) {
tickCount = 0; tickCount = 0;
if (pulseCount < (PPQN-1)) { //-1 is here to avoid extra IF to reset to 0 if (pulseCount < (PPQN-1)) { //-1 is here to avoid extra IF to reset to 0
pulseCount++; pulseCount++;
} else { } else if (masterClockMode == 0) {
pulseCount = 0; pulseCount = 0;
} }
} }
@ -179,6 +183,8 @@ void externalClock() {
lastExtPulseTime = newExtPulseTime; lastExtPulseTime = newExtPulseTime;
newExtPulseTime = millis(); newExtPulseTime = millis();
if (masterClockMode == 1) { // EXT-24
//reset cycles if there was no pulses for a while //reset cycles if there was no pulses for a while
if ((newExtPulseTime - lastExtPulseTime) > 125) { //125ms is 20bpm if ((newExtPulseTime - lastExtPulseTime) > 125) { //125ms is 20bpm
for (int i = 0; i<6; i++) { for (int i = 0; i<6; i++) {
@ -186,7 +192,6 @@ void externalClock() {
} }
} }
if (masterClockMode == 1) { // EXT-24
if (!isPlaying) { if (!isPlaying) {
isPlaying = true; isPlaying = true;
} }
@ -196,6 +201,12 @@ void externalClock() {
} else { } else {
pulseCount = 0; pulseCount = 0;
} }
} else if (masterClockMode == 2) { // EXT-Beat
if (!isPlaying) {
isPlaying = true;
}
pulseCount = 0;
tickCount = 0;
} }
} }