added subdiv modulation, but it still needs some work

This commit is contained in:
--global
2023-05-09 20:17:45 +03:00
parent 2df29ec1cb
commit 4425550f5b

View File

@ -36,17 +36,17 @@ struct channel {
};
channel channels[6] = { //array of channel settings
{ 8, 0, 0, 0, 0 },
{ 8, 0, 0, 0, 0 },
{ 8, 0, 0, 0, 0 },
{ 8, 0, 0, 0, 0 },
{ 8, 0, 0, 0, 0 },
{ 8, 0, 0, 0, 0 }
{ 7, 0, 0, 0, 0 },
{ 7, 0, 0, 0, 0 },
{ 7, 0, 0, 0, 0 },
{ 7, 0, 0, 0, 0 },
{ 7, 0, 0, 0, 0 },
{ 7, 0, 0, 0, 0 }
};
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 object on each beat
unsigned int pulsePeriod;
bool isPlaying = false;
@ -192,14 +192,17 @@ void externalClock() {
}
void sendTriggers() {
calculateCycles();
//switching modes on the beat and resetting channel clock
if (pulseCount == 0) {
for (int i = 0; i<6; i++) {
if (playingModes[i] != clockModes[channels[i].mode]) {
calculateCycles();
// calculateCycles(); this shouldn't be inside the loop. but it was here and it worked
channelPulseCount[i] = 0;
}
}
// calculateCycles();
}
//multiplier
@ -218,13 +221,41 @@ void sendTriggers() {
}
void calculateCycles() {
/*modulation
for (int i = 0; i<6; i++) {
playingModes[i] = clockModes[channels[i].mode];
if (channels[i].modulationRange != 0) {
int mod;
if (!channels[i].modulationChannel) {
mod = a1Input;
} else {
mod = a2Input;
}
mod = map (mod, 0, 1023, 0, channels[i].modulationRange);
playingModes[i] = clockModes[channels[i].mode - mod]; //subtracting because the innitiall array is backwards
}
}*/
for (int i = 0; i<6; i++) {
if (channels[i].modulationRange == 0) {
playingModes[i] = clockModes[channels[i].mode];
} else { //modulation happens here
int mod;
if (!channels[i].modulationChannel) {
mod = a1Input;
} else {
mod = a2Input;
}
mod = map (mod, 0, 1023, 0, channels[i].modulationRange);
playingModes[i] = clockModes[channels[i].mode - mod]; //subtracting because the innitiall array is backwards
}
if (playingModes[i] > 0) {
channelPulsesPerCycle[i] = (playingModes[i] * PPQN) - 1;
} else {
channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1;
}
}
}