gate pulsewidth (almost) works for subdivs, but not for multipliers

This commit is contained in:
Oleksiy
2025-03-08 14:57:17 +02:00
parent fd240e0341
commit 9840f23f77
3 changed files with 24 additions and 22 deletions

View File

@ -88,8 +88,8 @@ unsigned long lastExtPulseTime = 0;
unsigned long newExtPulseTime = 0;
bool needPulseReset[] = { true, true, true, true, true, true, true };
int gatePulseCount[] = {0,0,0,0,0,0,0};
int gateLengthTime[] = {120, 120, 120, 120, 120, 120, 120};
uint16_t gateLengthTime[] = {120, 120, 120, 120, 120, 120, 120};
uint16_t gateCountDown[7];
bool stepIsOdd = 1;
byte displayTab = 0;
@ -235,9 +235,13 @@ void clock() {
// pull low all outputs after set pulse length
for (byte i = 0; i < 7; i++) {
if ((channels[i].mode != 4 && tickCount >= PULSE_LENGTH) ||
(channels[i].mode == 4 && tickCount >= gateLengthTime[i])) { //everything but gate mode
if (channels[i].mode != 4 && tickCount >= PULSE_LENGTH) { //everything but gate mode
digitalWrite(outsPins[i], LOW);
} else if (channels[i].mode == 4 && tickCount >= gateCountDown[i]) { //gate mode gateLengthTime[i] < pulsePeriod
digitalWrite(outsPins[i], LOW);
gateCountDown[i] = gateLengthTime[i];
} else if (channels[i].mode == 4 && gateCountDown[i] > pulsePeriod && tickCount == 0) {
gateCountDown[i] = gateCountDown[i] - pulsePeriod;
}
}
@ -412,12 +416,6 @@ void sendTriggers() { //rename to onPulse or something
randAmount = 10;
}
if (channels[i].mode == 4) { //Gate mode turning off
gatePulseCount[i]++;
if (gatePulseCount[i] > channels[i].gate) {
digitalWrite(outsPins[i], LOW);
}
}
if (!channels[i].isMute) {
if ((channels[i].mode == 3 && channelPulseCount[i] == 0 && stepIsOdd == 0)
|| (channels[i].mode == 3 && channelPulseCount[i] == channels[i].swing && stepIsOdd == 1) //swing
@ -430,7 +428,6 @@ void sendTriggers() { //rename to onPulse or something
|| (channels[i].mode == 4 && channelPulseCount[i] == 0) //Gate
) {
digitalWrite(outsPins[i], HIGH);
gatePulseCount[i] = 0; //reset gate here to avoid length "countdown" effect
}
}
if (channelPulseCount[i] < channelPulsesPerCycle[i]) {
@ -466,8 +463,11 @@ void calculateCycles() {
}
}
void calculateGate(int channel) {
gateLengthTime[channel] = (channelPulsesPerCycle[channel] * pulsePeriod / 100) * channels[channel].gate;
void calculateGate(uint8_t channel) {
//if (subDivs[channels[channel].subDiv] > 0) {
gateLengthTime[channel] = (channelPulsesPerCycle[channel] * pulsePeriod / 100) * channels[channel].gate;
gateCountDown[channel] = gateLengthTime[channel];
//}
}
void calculateBPMTiming() {