Extra Channel setting WIP

This commit is contained in:
Oleksiy
2025-03-04 22:05:51 +02:00
parent d04e7b0dbb
commit 1201d206a0
4 changed files with 29 additions and 18 deletions

View File

@ -17,7 +17,7 @@ uint16_t CV1Calibration = 512;
uint16_t CV2Calibration = 512;
bool showDone = false;
const int subDivs[20] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 24, 32, 64, 128 }; //positive - divide, negative - multiply, 0 - off
const int subDivs[] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16, 24, 32, 64, 128 }; //positive - divide, negative - multiply, 0 - off
byte bpm = 130;
byte bpmModulationChannel = 200; //0 - CV1, 1 - CV2, 255 - OFF
@ -36,7 +36,8 @@ struct channel {
bool isMute : 1;
};
channel channels[6] = { //array of channel settings
channel channels[7] = { //array of channel settings
{ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0 },
@ -82,11 +83,12 @@ unsigned int pulseCount = 0;
byte masterClockMode = 0; // 0 - internal, 1 - external 24ppqn, 2 - MIDI
byte extClockPPQN = 0; // 0 - 24, 1 - 4 (1/16)
byte extraChannel = 0; // 0 - off, 1 - pulse out = 7th channel
unsigned long lastExtPulseTime = 0;
unsigned long newExtPulseTime = 0;
bool needPulseReset[6] = { true, true, true, true, true, true };
int gatePulseCount[6] = {0,0,0,0,0,0};
bool needPulseReset[] = { true, true, true, true, true, true, true };
int gatePulseCount[] = {0,0,0,0,0,0,0};
bool stepIsOdd = 1;
byte displayTab = 0;
@ -193,7 +195,9 @@ void clock() {
// Action on each pulse
if (tickCount == 0) {
sendTriggers();
digitalWrite(clockOutPin, HIGH);
if (!extraChannel) {
digitalWrite(clockOutPin, HIGH);
}
sendMIDIClock();
}
@ -232,12 +236,14 @@ void clock() {
// pull low all outputs after set pulse length
if (tickCount >= PULSE_LENGTH) {
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
if (channels[i].mode != 4) { //everything but gate mode
digitalWrite(outsPins[i], LOW);
}
}
digitalWrite(clockOutPin, LOW);
if (!extraChannel) {
digitalWrite(clockOutPin, LOW);
}
}
}
}
@ -293,7 +299,7 @@ void externalClock() {
void sendTriggers() { //rename to onPulse or something
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
if (playingModes[i] != subDivs[channels[i].subDiv] && playingModesOld[i] != playingModes[i]) {
needPulseReset[i] = true;
playingModesOld[i] = playingModes[i];
@ -303,7 +309,7 @@ void sendTriggers() { //rename to onPulse or something
if (sixteenthPulseCount == 0) {
bool *currentSeq;
stepIsOdd = !stepIsOdd;
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
//pattern modulation
int seqMod = 0;
@ -381,7 +387,7 @@ void sendTriggers() { //rename to onPulse or something
//switching modes on the beat and resetting channel clock
if (pulseCount == 0) {
calculateCycles();
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
if (needPulseReset[i] == true) {
channelPulseCount[i] = 0;
needPulseReset[i] = false;
@ -390,7 +396,7 @@ void sendTriggers() { //rename to onPulse or something
}
//multiplier
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
//RND modulation
byte randMod = 0;
@ -441,7 +447,7 @@ void sendTriggers() { //rename to onPulse or something
void calculateCycles() {
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
int mod = 0; //subdiv modulation happens here
if (channels[i].CV1Target == 1) {
mod = map(CV1Input, -1, 1024, -5, 5);
@ -479,7 +485,7 @@ void calculateBPMTiming() {
}
void resetClocks() {
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
channelPulseCount[i] = 0;
digitalWrite(outsPins[i], LOW); //to avoid stuck leds
}