Started working on bpm modulation (a lot of stuff broken atm)

This commit is contained in:
--global
2023-05-13 00:33:52 +03:00
parent dfba1ef3e5
commit 395e5e7a4a

View File

@ -145,7 +145,7 @@ void loop() {
display.clearDisplay();
display.display();
}
if (masterClockMode == 2) {
if (masterClockMode == 2 || bpmModulationRange != 0) {
calculateBPMTiming();
}
}
@ -282,8 +282,15 @@ void calculateCycles() {
}
void calculateBPMTiming() {
int mod;
if (masterClockMode == 0) {
pulsePeriod = 60000 / (bpm * PPQN);
if (bpmModulationRange != 0 && !bpmModulationChannel) {
mod = map (a1Input, 0, 1023, 0, bpmModulationRange*10);
} else if (bpmModulationRange != 0 && bpmModulationChannel) {
mod = map (a2Input, 0, 1023, 0, bpmModulationRange*10);
}
pulsePeriod = 60000 / ((bpm + mod) * PPQN);
} else if (masterClockMode == 2) { //for external beat clock
pulsePeriod = (newExtPulseTime - lastExtPulseTime) / PPQN;
}
@ -358,7 +365,12 @@ void checkInputs() {
masterClockMode = 0;
}
} else if (displayTab == 0 && insideTab == 2 && masterClockMode == 0) { //bpm modulation
if (bpmModulationRange < 9) {
bpmModulationRange = bpmModulationRange + change;
} else {
bpmModulationChannel = !bpmModulationChannel;
bpmModulationRange = 1;
}
} else if (displayTab != 0 && insideTab == 0) { //subdivision
channels[displayTab-1].mode = channels[displayTab-1].mode - change;
if (channels[displayTab-1].mode == 65535) { //65535 is 0-1 for unsigned vars