Added Random modulation
This commit is contained in:
@ -57,12 +57,12 @@ struct channel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
channel channels[6] = { //array of channel settings
|
channel channels[6] = { //array of channel settings
|
||||||
{ 2, 10, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 },
|
||||||
{ 0, 7, 0, 0, 0, 1, 0, 0, 0 },
|
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 },
|
||||||
{ 0, 7, 0, 0, 0, 1, 0, 0, 0 },
|
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 },
|
||||||
{ 0, 7, 0, 0, 0, 1, 0, 0, 0 },
|
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 },
|
||||||
{ 0, 7, 0, 0, 0, 1, 0, 0, 0 },
|
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 },
|
||||||
{ 0, 7, 0, 0, 0, 1, 0, 0, 0 }
|
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
bool sequences[8][16] {
|
bool sequences[8][16] {
|
||||||
@ -286,8 +286,28 @@ void sendTriggers() {
|
|||||||
//multiplier
|
//multiplier
|
||||||
for (byte i = 0; i < 6; i++) {
|
for (byte i = 0; i < 6; i++) {
|
||||||
int currentSeq = channels[i].seqPattern;
|
int currentSeq = channels[i].seqPattern;
|
||||||
|
|
||||||
|
//RND modulation
|
||||||
|
byte randMod = 0;
|
||||||
|
if (channels[i].CV1Target == 2) {
|
||||||
|
randMod = randMod + a1Input;
|
||||||
|
}
|
||||||
|
if (channels[i].CV2Target == 2) {
|
||||||
|
randMod = randMod + a2Input;
|
||||||
|
}
|
||||||
|
if (channels[i].CV1Target == 2 || channels[i].CV2Target == 2) {
|
||||||
|
randMod = map(randMod, 0, 1023, -5, +5);
|
||||||
|
}
|
||||||
|
byte randAmount = channels[i].random + randMod;
|
||||||
|
if (randAmount > 100) {
|
||||||
|
randAmount = 0;
|
||||||
|
} else if (randAmount > 10) {
|
||||||
|
randAmount = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((channels[i].mode == 0 && channelPulseCount[i] == channels[i].offset) || //CLK with offset
|
if ((channels[i].mode == 0 && channelPulseCount[i] == channels[i].offset) || //CLK with offset
|
||||||
(channels[i].mode == 1 && channelPulseCount[i] == 0 && random(10) > channels[i].random) //|| //RND
|
(channels[i].mode == 1 && channelPulseCount[i] == 0 && (random(10) + 1) > randAmount) //|| //RND
|
||||||
//(channels[i].mode == 2 && channelPulseCount[i] == 0 && sequences[currentSeq][0]) //SEQ (for some reason doesn't lke variables inside the index)
|
//(channels[i].mode == 2 && channelPulseCount[i] == 0 && sequences[currentSeq][0]) //SEQ (for some reason doesn't lke variables inside the index)
|
||||||
) {
|
) {
|
||||||
digitalWrite(outsPins[i], HIGH);
|
digitalWrite(outsPins[i], HIGH);
|
||||||
@ -305,16 +325,16 @@ void calculateCycles() {
|
|||||||
for (byte i = 0; i < 6; i++) {
|
for (byte i = 0; i < 6; i++) {
|
||||||
if (channels[i].CV1Target != 1 && channels[i].CV2Target != 1) {
|
if (channels[i].CV1Target != 1 && channels[i].CV2Target != 1) {
|
||||||
playingModes[i] = subDivs[channels[i].subDiv];
|
playingModes[i] = subDivs[channels[i].subDiv];
|
||||||
} else if (channels[i].CV1Target == 1) { //modulation happens here
|
} else if (channels[i].CV1Target == 1) { //subdiv modulation happens here
|
||||||
int mod;
|
int mod;
|
||||||
mod = a1Input;
|
mod = a1Input;
|
||||||
mod = map(mod, 0, 1023, (channels[i].CV1Value * -1), channels[i].CV1Value);
|
mod = map(mod, 0, 1023, (channels[i].CV1Value * -1), channels[i].CV1Value);
|
||||||
playingModes[i] = subDivs[channels[i].subDiv - mod]; //subtracting because the innitial array is backwards
|
playingModes[i] = subDivs[channels[i].subDiv - mod]; //subtracting because the innitial array is backwards
|
||||||
} else if (channels[i].CV2Target == 1) { //modulation happens here
|
} else if (channels[i].CV2Target == 1) {
|
||||||
int mod;
|
int mod;
|
||||||
mod = a2Input;
|
mod = a2Input;
|
||||||
mod = map(mod, 0, 1023, (channels[i].CV2Value * -1), channels[i].CV2Value);
|
mod = map(mod, 0, 1023, (channels[i].CV2Value * -1), channels[i].CV2Value);
|
||||||
playingModes[i] = subDivs[channels[i].subDiv - mod]; //subtracting because the innitial array is backwards
|
playingModes[i] = subDivs[channels[i].subDiv - mod];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playingModes[i] > 0) {
|
if (playingModes[i] > 0) {
|
||||||
|
|||||||
@ -137,30 +137,7 @@ void checkInputs() {
|
|||||||
channels[displayTab - 1].CV2Target = 2;
|
channels[displayTab - 1].CV2Target = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
|
||||||
} else if (displayTab != 0 && insideTab == 2) { //modulation
|
|
||||||
channels[displayTab - 1].modulationRange = channels[displayTab - 1].modulationRange + change;
|
|
||||||
if (channels[displayTab - 1].modulationRange < 0 && channels[displayTab - 1].modulationChannel == 0) {
|
|
||||||
channels[displayTab - 1].modulationRange = 0;
|
|
||||||
} else if (channels[displayTab - 1].modulationRange > 6 && channels[displayTab - 1].modulationChannel == 0) {
|
|
||||||
channels[displayTab - 1].modulationChannel = 1;
|
|
||||||
channels[displayTab - 1].modulationRange = 0;
|
|
||||||
} else if (channels[displayTab - 1].modulationRange < 0 && channels[displayTab - 1].modulationChannel == 1) {
|
|
||||||
channels[displayTab - 1].modulationChannel = 0;
|
|
||||||
channels[displayTab - 1].modulationRange = 6;
|
|
||||||
} else if (channels[displayTab - 1].modulationRange > 6 && channels[displayTab - 1].modulationChannel == 1) {
|
|
||||||
channels[displayTab - 1].modulationRange = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (displayTab != 0 && insideTab == 3) { //offset
|
|
||||||
channels[displayTab - 1].offset = channels[displayTab - 1].offset + change;
|
|
||||||
if (channels[displayTab - 1].offset == 65535) {
|
|
||||||
channels[displayTab - 1].offset = 0;
|
|
||||||
} else if (channels[displayTab - 1].offset >= channelPulsesPerCycle[displayTab - 1]) {
|
|
||||||
channels[displayTab - 1].offset = channelPulsesPerCycle[displayTab - 1];
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
updateScreen();
|
updateScreen();
|
||||||
encPositionOld = encPosition;
|
encPositionOld = encPosition;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -184,12 +184,8 @@ void updateScreen() {
|
|||||||
display.print(channelPulsesPerCycle[displayTab-1]+1);
|
display.print(channelPulsesPerCycle[displayTab-1]+1);
|
||||||
display.print(F(" "));
|
display.print(F(" "));
|
||||||
} else if (channels[displayTab - 1].mode == 1) { //RANDOM
|
} else if (channels[displayTab - 1].mode == 1) { //RANDOM
|
||||||
if (channels[displayTab - 1].random > 0) {
|
|
||||||
display.print(channels[displayTab - 1].random);
|
display.print(channels[displayTab - 1].random);
|
||||||
display.print(F("0% "));
|
display.print(F("0% "));
|
||||||
} else {
|
|
||||||
display.print(F("OFF "));
|
|
||||||
}
|
|
||||||
} else if (channels[displayTab - 1].mode == 2) { //SEQ
|
} else if (channels[displayTab - 1].mode == 2) { //SEQ
|
||||||
display.print(channels[displayTab - 1].seqPattern + 1);
|
display.print(channels[displayTab - 1].seqPattern + 1);
|
||||||
}
|
}
|
||||||
@ -200,7 +196,7 @@ void updateScreen() {
|
|||||||
}
|
}
|
||||||
display.setCursor(94, 25);
|
display.setCursor(94, 25);
|
||||||
if (channels[displayTab - 1].CV1Target == 1) {
|
if (channels[displayTab - 1].CV1Target == 1) {
|
||||||
display.print(F("SUBDIV"));
|
display.print(F("DIV"));
|
||||||
//display.print(channels[displayTab - 1].CV1Value);
|
//display.print(channels[displayTab - 1].CV1Value);
|
||||||
} else if (channels[displayTab - 1].CV1Target == 2) {
|
} else if (channels[displayTab - 1].CV1Target == 2) {
|
||||||
display.print(F("RND"));
|
display.print(F("RND"));
|
||||||
|
|||||||
Reference in New Issue
Block a user