added subdiv modulation, but it still needs some work
This commit is contained in:
@ -36,17 +36,17 @@ struct channel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
channel channels[6] = { //array of channel settings
|
channel channels[6] = { //array of channel settings
|
||||||
{ 8, 0, 0, 0, 0 },
|
{ 7, 0, 0, 0, 0 },
|
||||||
{ 8, 0, 0, 0, 0 },
|
{ 7, 0, 0, 0, 0 },
|
||||||
{ 8, 0, 0, 0, 0 },
|
{ 7, 0, 0, 0, 0 },
|
||||||
{ 8, 0, 0, 0, 0 },
|
{ 7, 0, 0, 0, 0 },
|
||||||
{ 8, 0, 0, 0, 0 },
|
{ 7, 0, 0, 0, 0 },
|
||||||
{ 8, 0, 0, 0, 0 }
|
{ 7, 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
int channelPulseCount[6];
|
int channelPulseCount[6];
|
||||||
int channelPulsesPerCycle[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;
|
unsigned int pulsePeriod;
|
||||||
bool isPlaying = false;
|
bool isPlaying = false;
|
||||||
@ -192,14 +192,17 @@ void externalClock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendTriggers() {
|
void sendTriggers() {
|
||||||
|
calculateCycles();
|
||||||
|
|
||||||
//switching modes on the beat and resetting channel clock
|
//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]) {
|
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;
|
channelPulseCount[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// calculateCycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
//multiplier
|
//multiplier
|
||||||
@ -218,13 +221,41 @@ void sendTriggers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void calculateCycles() {
|
void calculateCycles() {
|
||||||
|
/*modulation
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i<6; i++) {
|
||||||
|
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];
|
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) {
|
if (playingModes[i] > 0) {
|
||||||
channelPulsesPerCycle[i] = (playingModes[i] * PPQN) - 1;
|
channelPulsesPerCycle[i] = (playingModes[i] * PPQN) - 1;
|
||||||
} else {
|
} else {
|
||||||
channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1;
|
channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user