fixed unwanted offset bug
This commit is contained in:
@ -48,7 +48,6 @@ int playingModes[6]; //actual channel modes array updated from channels each bea
|
|||||||
int pulsePeriod;
|
int pulsePeriod;
|
||||||
bool isPlaying = false;
|
bool isPlaying = false;
|
||||||
|
|
||||||
bool beatCounted = false;
|
|
||||||
bool pulseCounted = false;
|
bool pulseCounted = false;
|
||||||
|
|
||||||
unsigned int tickCount = 0;
|
unsigned int tickCount = 0;
|
||||||
@ -123,7 +122,7 @@ void setup() {
|
|||||||
display.setTextColor(SSD1306_WHITE);
|
display.setTextColor(SSD1306_WHITE);
|
||||||
display.println(F("V:0.1a")); //Version
|
display.println(F("V:0.1a")); //Version
|
||||||
display.display();
|
display.display();
|
||||||
delay(1200);
|
delay(800);
|
||||||
|
|
||||||
updateScreen();
|
updateScreen();
|
||||||
updateTiming();
|
updateTiming();
|
||||||
@ -151,12 +150,22 @@ void clock() {
|
|||||||
tickCount++;
|
tickCount++;
|
||||||
} else {
|
} else {
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
if (pulseCount < PPQN) {
|
if (pulseCount < (PPQN-1)) { //-1 is here to avoid extra IF to reset to 0
|
||||||
pulseCount++;
|
pulseCount++;
|
||||||
beatCounted = false; //reset pulse and beat count AFTER the pulse is incremented
|
|
||||||
pulseCounted = false;
|
|
||||||
} else {
|
} else {
|
||||||
pulseCount = 0; //Beat happens here
|
pulseCount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//pulse and beat count reset
|
||||||
|
if (tickCount == 0) {
|
||||||
|
pulseCounted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pull low all outputs after set pulse length
|
||||||
|
if (tickCount >= PULSE_LENGTH) {
|
||||||
|
for (int i = 0; i<6; i++) {
|
||||||
|
digitalWrite(outsPins[i], LOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,9 +174,12 @@ void clock() {
|
|||||||
|
|
||||||
void sendTriggers() {
|
void sendTriggers() {
|
||||||
//divider
|
//divider
|
||||||
if (pulseCount == 0 && !beatCounted) {
|
if (pulseCount == 0) {
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i<6; i++) {
|
||||||
playingModes[i] = clockModes[channels[i].mode]; //updated here to prevent sync problems for multipliers
|
if (playingModes[i] != clockModes[channels[i].mode]) { //switching modes on the beat and resetting channel clock
|
||||||
|
playingModes[i] = clockModes[channels[i].mode];
|
||||||
|
outsClocksCounts[i] = 0;
|
||||||
|
}
|
||||||
if (playingModes[i] > 0) {
|
if (playingModes[i] > 0) {
|
||||||
if (outsClocksCounts[i] == 0) { //Pulse on 0
|
if (outsClocksCounts[i] == 0) { //Pulse on 0
|
||||||
if (channels[i].random == 0 || random(10) > channels[i].random) {
|
if (channels[i].random == 0 || random(10) > channels[i].random) {
|
||||||
@ -181,7 +193,6 @@ void sendTriggers() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
beatCounted = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//multiplier
|
//multiplier
|
||||||
@ -192,7 +203,7 @@ void sendTriggers() {
|
|||||||
digitalWrite(outsPins[i], HIGH);
|
digitalWrite(outsPins[i], HIGH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (outsClocksCounts[i] < (PPQN / abs(playingModes[i])) - 1) {
|
if (playingModes[i] < 0 && outsClocksCounts[i] < (PPQN / abs(playingModes[i])) - 1) { //multiplier
|
||||||
outsClocksCounts[i]++;
|
outsClocksCounts[i]++;
|
||||||
} else {
|
} else {
|
||||||
outsClocksCounts[i] = 0;
|
outsClocksCounts[i] = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user