Added random
This commit is contained in:
@ -2,15 +2,17 @@ Features:
|
|||||||
- 6 output channels
|
- 6 output channels
|
||||||
- Master BPM
|
- Master BPM
|
||||||
- Separate divider or multiplier per chennel (from /32 to x24)
|
- Separate divider or multiplier per chennel (from /32 to x24)
|
||||||
|
- Random (currently only for on beat pulses)
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
- Add min and max values
|
- 1/8 and 1/16 random
|
||||||
- External clock
|
- External clock
|
||||||
- Switch to U8G2 for screen
|
- Switch to U8G2 for screen
|
||||||
- Save state to EEPROM when stopped
|
- Save state to EEPROM when stopped
|
||||||
- swing
|
- swing
|
||||||
- long-press encoder for settings (input mode, pulse length)
|
- long-press encoder for settings (input mode, pulse length)
|
||||||
- analogue input for modulations
|
- analogue input for modulations
|
||||||
|
- Design PCB
|
||||||
|
|
||||||
Timer library available here
|
Timer library available here
|
||||||
https://github.com/PaulStoffregen/FlexiTimer2
|
https://github.com/PaulStoffregen/FlexiTimer2
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
const int outsPins[6] = {5, 6, 7, 8, 9, 10};
|
const int outsPins[6] = {5, 6, 7, 8, 9, 10};
|
||||||
|
|
||||||
const int outsModes[22] = {-24, -16, -12, -8, -6, -4, -3, -2, -1, 0, 1, 1.5, 2, 3, 4, 5, 6, 7, 8, 16, 32, 100}; //positive - divide, negative - multiply, 0 - off, 100 - random
|
const int outsModes[22] = {-24, -16, -12, -8, -6, -4, -3, -2, -1, 0, 1, 1.5, 2, 3, 4, 5, 6, 7, 8, 16, 32, 100}; //positive - divide, negative - multiply, 0 - off, 100 - random
|
||||||
int outsModeIndex[6] = {10, 8, 9, 9, 9, 9}; //10 - /1, 9 - off
|
int outsModeIndex[6] = {10, 8, 12, 14, 9, 21}; //10 - /1, 9 - off
|
||||||
int outsPeriods[6];
|
int outsPeriods[6];
|
||||||
int outsClocksCounts[6];
|
int outsClocksCounts[6];
|
||||||
int outsModesPlay[6]; //actual channel modes array
|
int outsModesPlay[6]; //actual channel modes array
|
||||||
@ -82,44 +82,28 @@ void loop() {
|
|||||||
void internalClock() {
|
void internalClock() {
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
|
|
||||||
/*/ Dividers and actual modes array update
|
|
||||||
if (pulseCount == 0 && !beatCounted) {
|
|
||||||
for (int i = 0; i<6; i++) {
|
|
||||||
outsModesPlay[i] = outsModes[outsModeIndex[i]]; //updated here to prevent sync out for multipliers
|
|
||||||
if (outsModesPlay[i] > 0) { //Dividers (>0)
|
|
||||||
if (outsClocksCounts[i] == 0) { //Pulse on 0
|
|
||||||
digitalWrite(outsPins[i], HIGH);
|
|
||||||
Serial.print(" div ");
|
|
||||||
}
|
|
||||||
if (outsClocksCounts[i] < (outsModesPlay[i] - 1)) { //-1??
|
|
||||||
outsClocksCounts[i]++;
|
|
||||||
//if (i == 0) {Serial.println(outsClocksCounts[i]);}
|
|
||||||
} else {
|
|
||||||
outsClocksCounts[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
beatCounted = true;
|
|
||||||
} */
|
|
||||||
|
|
||||||
// Action on each pulse
|
// Action on each pulse
|
||||||
if (pulseClockCount == 0 && !pulseCounted) {
|
if (pulseClockCount == 0 && !pulseCounted) {
|
||||||
|
|
||||||
//divider
|
//divider
|
||||||
if (pulseCount == 0 && !beatCounted) {
|
if (pulseCount == 0 && !beatCounted) {
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i<6; i++) {
|
||||||
outsModesPlay[i] = outsModes[outsModeIndex[i]]; //updated here to prevent sync out for multipliers
|
outsModesPlay[i] = outsModes[outsModeIndex[i]]; //updated here to prevent sync problems for multipliers
|
||||||
if (outsModesPlay[i] > 0) {
|
if (outsModesPlay[i] > 0 && outsModesPlay[i] != 100) {
|
||||||
if (outsClocksCounts[i] == 0) { //Pulse on 0
|
if (outsClocksCounts[i] == 0) { //Pulse on 0
|
||||||
digitalWrite(outsPins[i], HIGH);
|
digitalWrite(outsPins[i], HIGH);
|
||||||
//Serial.print(" div ");
|
|
||||||
}
|
}
|
||||||
if (outsClocksCounts[i] < (outsModesPlay[i] - 1)) { //-1??
|
if (outsClocksCounts[i] < (outsModesPlay[i] - 1)) {
|
||||||
outsClocksCounts[i]++;
|
outsClocksCounts[i]++;
|
||||||
//if (i == 0) {Serial.println(outsClocksCounts[i]);}
|
|
||||||
} else {
|
} else {
|
||||||
outsClocksCounts[i] = 0;
|
outsClocksCounts[i] = 0;
|
||||||
}
|
}
|
||||||
|
} else if (outsModesPlay[i] == 100) { //random
|
||||||
|
if (outsClocksCounts[i] == 0) {
|
||||||
|
if (random(2)) { // random(2) gives either 0 or 1, so it's 50/50 chance
|
||||||
|
digitalWrite(outsPins[i], HIGH);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
beatCounted = true;
|
beatCounted = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user