added modulation input
This commit is contained in:
@ -3,6 +3,7 @@ Features:
|
||||
- Master BPM
|
||||
- Separate divider or multiplier per chennel (from /32 to x24)
|
||||
- Random (currently only for on beat pulses)
|
||||
- 1 input for external modulation (currently hardcoded to channel 6)
|
||||
|
||||
TODO:
|
||||
- 1/8 and 1/16 random
|
||||
@ -10,8 +11,7 @@ TODO:
|
||||
- Switch to U8G2 for screen
|
||||
- Save state to EEPROM when stopped
|
||||
- swing
|
||||
- long-press encoder for settings (input mode, pulse length)
|
||||
- analogue input for modulations
|
||||
- long-press encoder for settings (input mode, pulse length, modulation targets)
|
||||
- Design PCB
|
||||
|
||||
Timer library available here
|
||||
|
||||
@ -18,14 +18,15 @@
|
||||
#define ENC_D1_PIN 4
|
||||
#define ENC_D2_PIN 3
|
||||
#define START_STOP_BTN_PIN 14
|
||||
#define ANALOGUE_INPUT_1_PIN A1
|
||||
|
||||
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
|
||||
int outsModeIndex[6] = {10, 8, 12, 14, 9, 21}; //10 - /1, 9 - off
|
||||
int outsModeIndex[6] = {10, 8, 12, 14, 9, 8}; //10 - /1, 9 - off
|
||||
int outsPeriods[6];
|
||||
int outsClocksCounts[6];
|
||||
int outsModesPlay[6]; //actual channel modes array
|
||||
int outsModesPlay[6]; //actual channel modes array updated from outsModeIndex each beat
|
||||
|
||||
bool clockMode;
|
||||
bool clockModeOld;
|
||||
@ -47,6 +48,8 @@ int displayTabOld;
|
||||
bool needToChangeTab = 0;
|
||||
bool buttonPushed = false;
|
||||
|
||||
int a1Input = 0;
|
||||
|
||||
bool changesSaved;
|
||||
|
||||
int encPositionOld = 0;
|
||||
@ -60,6 +63,7 @@ void setup() {
|
||||
pinMode(INPUT_CONNECTED_PIN, INPUT_PULLUP);
|
||||
pinMode(ENC_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(START_STOP_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(START_STOP_BTN_PIN, ANALOGUE_INPUT_1_PIN);
|
||||
pinMode(INPUT_PIN, INPUT_PULLUP); //probably will need interrupt
|
||||
|
||||
for (int i=0; i<6; i++) {
|
||||
@ -89,6 +93,9 @@ void internalClock() {
|
||||
if (pulseCount == 0 && !beatCounted) {
|
||||
for (int i = 0; i<6; i++) {
|
||||
outsModesPlay[i] = outsModes[outsModeIndex[i]]; //updated here to prevent sync problems for multipliers
|
||||
if (a1Input != 0 && i == 5) { //TESTING THE MODULATION ON 6th CHANNEL
|
||||
outsModesPlay[i] = outsModes[outsModeIndex[i] - a1Input];
|
||||
}
|
||||
if (outsModesPlay[i] > 0 && outsModesPlay[i] != 100) {
|
||||
if (outsClocksCounts[i] == 0) { //Pulse on 0
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
@ -114,11 +121,9 @@ void internalClock() {
|
||||
if (outsModesPlay[i] < 0) {
|
||||
if (outsClocksCounts[i] == 0) { //Pulse on 0
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
//Serial.print(" mult ");
|
||||
}
|
||||
if (outsClocksCounts[i] < (PPQN / abs(outsModesPlay[i])) - 1) {
|
||||
outsClocksCounts[i]++;
|
||||
//if (i == 1) {Serial.println(PPQN / abs(outsModesPlay[1]));}
|
||||
} else {
|
||||
outsClocksCounts[i] = 0;
|
||||
}
|
||||
@ -129,7 +134,6 @@ void internalClock() {
|
||||
|
||||
//internal pulse
|
||||
if (pulseClockCount == 0) {
|
||||
//Serial.println(pulseCount);
|
||||
pulseCount++;
|
||||
beatCounted = false;
|
||||
pulseCounted = false;
|
||||
@ -219,6 +223,10 @@ void checkInputs() {
|
||||
} else if (digitalRead(START_STOP_BTN_PIN) && buttonPushed) {
|
||||
buttonPushed = false;
|
||||
}
|
||||
|
||||
//modulations
|
||||
a1Input = analogRead(ANALOGUE_INPUT_1_PIN);
|
||||
a1Input = map (a1Input, 0, 1023, 0, 4);
|
||||
}
|
||||
|
||||
void updateScreen() {
|
||||
|
||||
Reference in New Issue
Block a user