switched to pulses per cycle, got rid of separate divider and multiplier
This commit is contained in:
@ -42,7 +42,8 @@ channel channels[6] = { //array of channel settings
|
|||||||
{ 8, 0, 0, 0 }
|
{ 8, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
int outsClocksCounts[6];
|
int channelPulseCount[6];
|
||||||
|
int channelPulsesPerCycle[6];
|
||||||
int playingModes[6]; //actual channel modes array updated from channels each beat
|
int playingModes[6]; //actual channel modes array updated from channels each beat
|
||||||
|
|
||||||
int pulsePeriod;
|
int pulsePeriod;
|
||||||
@ -91,7 +92,7 @@ const unsigned char splash_logo [] PROGMEM = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
//Serial.begin(9600);
|
||||||
|
|
||||||
//check last bit in eeprom to know if settings were stored
|
//check last bit in eeprom to know if settings were stored
|
||||||
if (EEPROM.read(1023) == 'H') {
|
if (EEPROM.read(1023) == 'H') {
|
||||||
@ -173,42 +174,33 @@ void clock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendTriggers() {
|
void sendTriggers() {
|
||||||
//divider
|
//switching modes on the beat and resetting channel clock
|
||||||
if (pulseCount == 0) {
|
if (pulseCount == 0) {
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i<6; i++) {
|
||||||
if (playingModes[i] != clockModes[channels[i].mode]) { //switching modes on the beat and resetting channel clock
|
if (playingModes[i] != clockModes[channels[i].mode]) {
|
||||||
playingModes[i] = clockModes[channels[i].mode];
|
playingModes[i] = clockModes[channels[i].mode];
|
||||||
outsClocksCounts[i] = 0;
|
if (playingModes[i] > 0) {
|
||||||
}
|
channelPulsesPerCycle[i] = (playingModes[i] * PPQN) - 1;
|
||||||
if (playingModes[i] > 0) {
|
|
||||||
if (outsClocksCounts[i] == 0) { //Pulse on 0
|
|
||||||
if (channels[i].random == 0 || random(10) > channels[i].random) {
|
|
||||||
digitalWrite(outsPins[i], HIGH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (outsClocksCounts[i] < (playingModes[i] - 1)) {
|
|
||||||
outsClocksCounts[i]++;
|
|
||||||
} else {
|
} else {
|
||||||
outsClocksCounts[i] = 0;
|
channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1;
|
||||||
}
|
}
|
||||||
|
channelPulseCount[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//multiplier
|
//multiplier
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i<6; i++) {
|
||||||
if (playingModes[i] < 0) {
|
if (channelPulseCount[i] == 0) { //Pulse on 0
|
||||||
if (outsClocksCounts[i] == 0) { //Pulse on 0
|
if (channels[i].random == 0 || random(10) > channels[i].random) { //random
|
||||||
if (channels[i].random == 0 || random(10) > channels[i].random) { //random
|
digitalWrite(outsPins[i], HIGH);
|
||||||
digitalWrite(outsPins[i], HIGH);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (playingModes[i] < 0 && outsClocksCounts[i] < (PPQN / abs(playingModes[i])) - 1) { //multiplier
|
}
|
||||||
outsClocksCounts[i]++;
|
if (channelPulseCount[i] < channelPulsesPerCycle[i]) {
|
||||||
} else {
|
channelPulseCount[i]++;
|
||||||
outsClocksCounts[i] = 0;
|
} else {
|
||||||
}
|
channelPulseCount[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +219,7 @@ void updateTiming() {
|
|||||||
|
|
||||||
void resetClocks() {
|
void resetClocks() {
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i<6; i++) {
|
||||||
outsClocksCounts[i] = 0;
|
channelPulseCount[i] = 0;
|
||||||
digitalWrite(outsPins[i], LOW); //to avoid stuck leds
|
digitalWrite(outsPins[i], LOW); //to avoid stuck leds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user