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

View File

@ -67,6 +67,8 @@ void checkInputs() {
showDone = true; showDone = true;
updateScreen(); updateScreen();
} else if (displayScreen == 2 && menuItem == 3) { } else if (displayScreen == 2 && menuItem == 3) {
extraChannel = !extraChannel;
} else if (displayScreen == 2 && menuItem == 4) {
EEPROM.put(1023, memCode - 1); EEPROM.put(1023, memCode - 1);
reboot(); reboot();
} }
@ -111,8 +113,8 @@ void checkInputs() {
displayTab = displayTab + change; displayTab = displayTab + change;
if (displayTab > 100) { //to address "negative" numbers if (displayTab > 100) { //to address "negative" numbers
displayTab = 0; displayTab = 0;
} else if (displayTab > 6) { } else if (displayTab > (extraChannel ? 7 : 6)) {
displayTab = 6; displayTab = (extraChannel ? 7 : 6);
} }
} else if (((!insideTab && shiftBtnPushed) } else if (((!insideTab && shiftBtnPushed)
|| (insideTab && menuItem == 0 || (insideTab && menuItem == 0

View File

@ -266,7 +266,7 @@ void updateScreen() {
u8g2.drawButtonUTF8(xWidth/2, yPos, U8G2_BTN_BW0|U8G2_BTN_HCENTER, xWidth, 0, 2, valueStr.c_str() ); u8g2.drawButtonUTF8(xWidth/2, yPos, U8G2_BTN_BW0|U8G2_BTN_HCENTER, xWidth, 0, 2, valueStr.c_str() );
} }
for (int i = 1; i <= 6; i++) { for (int i = 1; i <= (extraChannel ? 7 : 6); i++) {
valueStr = String(i); valueStr = String(i);
if (displayTab == i) { if (displayTab == i) {
if (insideTab == true || shiftBtnPushed == true) { if (insideTab == true || shiftBtnPushed == true) {
@ -334,7 +334,7 @@ void updateScreen() {
u8g2.drawStr(8, 5, valueStr.c_str() ); u8g2.drawStr(8, 5, valueStr.c_str() );
u8g2.drawStr(122 - (u8g2.getStrWidth(version.c_str())), 5, version.c_str() ); u8g2.drawStr(122 - (u8g2.getStrWidth(version.c_str())), 5, version.c_str() );
u8g2.drawHLine(0, 8, 128); u8g2.drawHLine(0, 8, 128);
lastMenuItem = 3; lastMenuItem = 4;
byte width = 112; byte width = 112;
for (byte i = 0; i <= lastMenuItem; i++) { for (byte i = 0; i <= lastMenuItem; i++) {
switch(i) { switch(i) {
@ -348,6 +348,9 @@ void updateScreen() {
valueStr = F("REVERSE ENCODER"); valueStr = F("REVERSE ENCODER");
break; break;
case 3: case 3:
valueStr = F("7TH CHANNEL");
break;
case 4:
valueStr = F("FACTORY RESET"); valueStr = F("FACTORY RESET");
break; break;
}; };

View File

@ -16,8 +16,8 @@
#define EXT_INPUT_PIN 2 //needs to be an interrupt pin #define EXT_INPUT_PIN 2 //needs to be an interrupt pin
#define ANALOGUE_INPUT_1_PIN A7 #define ANALOGUE_INPUT_1_PIN A7
#define ANALOGUE_INPUT_2_PIN A6 #define ANALOGUE_INPUT_2_PIN A6
const byte outsPins[6] = { 7, 8, 10, 6, 9, 11 };
const byte clockOutPin = 3; const byte clockOutPin = 3;
const byte outsPins[] = { 7, 8, 10, 6, 9, 11, clockOutPin };
bool rotateScreen = false; bool rotateScreen = false;
bool reverseEnc = false; bool reverseEnc = false;
// //