Fixed EXT-B (added reset on the second incoming pulse. EXT-1/16 is still broken
This commit is contained in:
@ -57,6 +57,7 @@ bool isPlaying = false;
|
|||||||
unsigned int tickCount = 0;
|
unsigned int tickCount = 0;
|
||||||
unsigned int pulseCount = 0;
|
unsigned int pulseCount = 0;
|
||||||
unsigned int extTriggerCount = 0;
|
unsigned int extTriggerCount = 0;
|
||||||
|
byte extResetCountdown = 0;
|
||||||
|
|
||||||
byte masterClockMode = 0; // 0 - internal, 1 - external 24ppqn, 2 - external beat
|
byte masterClockMode = 0; // 0 - internal, 1 - external 24ppqn, 2 - external beat
|
||||||
unsigned long lastExtPulseTime;
|
unsigned long lastExtPulseTime;
|
||||||
@ -185,7 +186,7 @@ void clock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//EXT-B
|
//EXT-B
|
||||||
if (masterClockMode == 2 || masterClockMode == 3) {
|
if (masterClockMode == 2) {
|
||||||
if (tickCount >= pulsePeriod && pulseCount < (PPQN-1)) {
|
if (tickCount >= pulsePeriod && pulseCount < (PPQN-1)) {
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
pulseCount++;
|
pulseCount++;
|
||||||
@ -193,12 +194,12 @@ void clock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//EXT-16
|
//EXT-16
|
||||||
/*if (masterClockMode == 3) {
|
if (masterClockMode == 3) {
|
||||||
if (tickCount >= pulsePeriod && pulseCount < ((PPQN*2)-1)) { // ((6 * (extTriggerCount + 1))-1)) { //hardcoded for 24ppqn
|
if (tickCount >= pulsePeriod && pulseCount < ((6 * (extTriggerCount + 1))-1)) { //hardcoded for 24ppqn
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
pulseCount++;
|
pulseCount++;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// pull low all outputs after set pulse length
|
// pull low all outputs after set pulse length
|
||||||
if (tickCount >= PULSE_LENGTH) {
|
if (tickCount >= PULSE_LENGTH) {
|
||||||
@ -238,27 +239,41 @@ void externalClock() {
|
|||||||
}
|
}
|
||||||
if ((newExtPulseTime - lastExtPulseTime) > 3000) { //3000ms is 1/4 at 20bpm
|
if ((newExtPulseTime - lastExtPulseTime) > 3000) { //3000ms is 1/4 at 20bpm
|
||||||
resetClocks();
|
resetClocks();
|
||||||
|
extResetCountdown = 0;
|
||||||
}
|
}
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
pulseCount = 0;
|
pulseCount = 0;
|
||||||
|
if (extResetCountdown < 1) { //reset on the second pulse, so that BPM is already calculated correctly
|
||||||
|
extResetCountdown++;
|
||||||
|
} else if (extResetCountdown == 1) {
|
||||||
|
resetClocks();
|
||||||
|
extResetCountdown++; //to get out of the loop
|
||||||
|
}
|
||||||
|
|
||||||
} else if (masterClockMode == 3) { // EXT-1/16
|
} else if (masterClockMode == 3) { // EXT-1/16
|
||||||
if (!isPlaying) {
|
if (!isPlaying) {
|
||||||
isPlaying = true;
|
isPlaying = true;
|
||||||
}
|
}
|
||||||
if ((newExtPulseTime - lastExtPulseTime) > 750) { //750ms is 1/16 at 20bpm
|
if ((newExtPulseTime - lastExtPulseTime) > 1000) { //750ms is 1/16 at 20bpm
|
||||||
resetClocks();
|
resetClocks();
|
||||||
|
extResetCountdown = 0;
|
||||||
}
|
}
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
if (extTriggerCount == 0) {
|
if (extTriggerCount == 0) {
|
||||||
pulseCount = 0;
|
pulseCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extTriggerCount < 3) {
|
if (extTriggerCount < 2) {
|
||||||
extTriggerCount++;
|
extTriggerCount++;
|
||||||
} else {
|
} else {
|
||||||
extTriggerCount = 0;
|
extTriggerCount = 0;
|
||||||
}
|
}
|
||||||
|
if (extResetCountdown < 4) { //reset on the first beat (5th pulse), so that BPM is already calculated correctly
|
||||||
|
extResetCountdown++;
|
||||||
|
} else if (extResetCountdown == 4) {
|
||||||
|
resetClocks();
|
||||||
|
extResetCountdown++; //to get out of the loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user