Gate kinda works, but needs some tweaking of the values

This commit is contained in:
Oleksiy
2024-10-18 00:13:24 +03:00
parent c5b9ebe868
commit 0d41ff9cbd
3 changed files with 28 additions and 15 deletions

View File

@ -8,7 +8,7 @@
#define VERSION "V:1.2A" #define VERSION "V:1.2A"
byte memCode = 'E'; //Change to different letter if you changed the data structure byte memCode = 'G'; //Change to different letter if you changed the data structure
#define PPQN 24 #define PPQN 24
#define PULSE_LENGTH 120 //1/10ms resolution. 12ms was failing at 1ms resolution at higher bpm. 60000/200/24 = 12.5 the max pulse length at 1ms resolution for 200bpm is 11ms #define PULSE_LENGTH 120 //1/10ms resolution. 12ms was failing at 1ms resolution at higher bpm. 60000/200/24 = 12.5 the max pulse length at 1ms resolution for 200bpm is 11ms
@ -72,15 +72,15 @@ struct channel {
}; };
channel channels[6] = { //array of channel settings channel channels[6] = { //array of channel settings
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 }, { 0, 7, 0, 0, 0, 0, 0, 23, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 }, { 0, 7, 0, 0, 0, 0, 0, 23, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 }, { 0, 7, 0, 0, 0, 0, 0, 23, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 }, { 0, 7, 0, 0, 0, 0, 0, 23, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 }, { 0, 7, 0, 0, 0, 0, 0, 23, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 } { 0, 7, 0, 0, 0, 0, 0, 23, 0 }
}; };
bool seqA1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1}; bool seqA1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1}; //switch to struct { uint32_t sequence; uint8_t length; uint8_t subdiv }. test with lengthOf
bool seqA2[16] = {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}; bool seqA2[16] = {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0};
bool seqA3[16] = {1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0}; bool seqA3[16] = {1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0};
bool seqA4[16] = {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1}; bool seqA4[16] = {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1};
@ -122,6 +122,7 @@ unsigned long lastExtPulseTime = 0;
unsigned long newExtPulseTime = 0; unsigned long newExtPulseTime = 0;
bool needPulseReset[6] = { true, true, true, true, true, true }; bool needPulseReset[6] = { true, true, true, true, true, true };
int gatePulseCount[6] = {0,0,0,0,0,0};
byte displayTab = 0; byte displayTab = 0;
bool insideTab = false; bool insideTab = false;
@ -303,7 +304,16 @@ 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 < 6; i++) {
digitalWrite(outsPins[i], LOW); if (channels[i].mode == 4) { //channels in gate mode
if (gatePulseCount[i] == channels[i].gate * 100) { //I thought this would be number of pulses, but it seems to be msecs (??) that's why there's *100. need to investigate
digitalWrite(outsPins[i], LOW);
gatePulseCount[i] = 0;
} else {
gatePulseCount[i]++;
}
} else { //everything else
digitalWrite(outsPins[i], LOW);
}
} }
digitalWrite(clockOutPin, LOW); digitalWrite(clockOutPin, LOW);
} }
@ -428,7 +438,7 @@ void sendTriggers() {
} else if (seqPattern == 15) { } else if (seqPattern == 15) {
currentSeq = seqB8; currentSeq = seqB8;
} }
if (channels[i].mode == 2 && currentSeq[currentStep]) { // EXT CLOCK SEQUENCER BUG IS SOMEWHERE HERE ???? && channelPulseCount[i] == 0 might be related to channelPulsesPerCycle not calculated in time if (channels[i].mode == 2 && currentSeq[currentStep]) {
digitalWrite(outsPins[i], HIGH); digitalWrite(outsPins[i], HIGH);
} }
} }
@ -482,6 +492,7 @@ void sendTriggers() {
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) + 1) > randAmount) //RND || (channels[i].mode == 1 && channelPulseCount[i] == 0 && (random(10) + 1) > randAmount) //RND
|| (channels[i].mode == 4 && channelPulseCount[i] == 0) //gate
) { ) {
digitalWrite(outsPins[i], HIGH); digitalWrite(outsPins[i], HIGH);
} }

View File

@ -195,8 +195,8 @@ void checkInputs() {
channels[displayTab - 1].gate = channels[displayTab - 1].gate + change; channels[displayTab - 1].gate = channels[displayTab - 1].gate + change;
if (channels[displayTab - 1].gate > 100) { if (channels[displayTab - 1].gate > 100) {
channels[displayTab - 1].gate = 0; channels[displayTab - 1].gate = 0;
} else if (channels[displayTab - 1].gate > 15) { } else if (channels[displayTab - 1].gate > 40) {
channels[displayTab - 1].gate = 15; channels[displayTab - 1].gate = 40;
} }
saveState(); saveState();
} else if (insideTab && !shiftBtnPushed && !menuItemSelected) { } else if (insideTab && !shiftBtnPushed && !menuItemSelected) {
@ -289,7 +289,7 @@ void checkInputs() {
&& (menuItemSelected || shiftBtnPushed) && (menuItemSelected || shiftBtnPushed)
&& displayTab != 0 && displayTab != 0
&& menuItem == 2 && menuItem == 2
&& channels[displayTab - 1].mode == 1) { //SUBDIV for RANDOM && (channels[displayTab - 1].mode == 1 || channels[displayTab - 1].mode == 4)) { //SUBDIV for RANDOM and GATE
channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - change; channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - change;
if (channels[displayTab - 1].subDiv > 200) { if (channels[displayTab - 1].subDiv > 200) {
channels[displayTab - 1].subDiv = 0; channels[displayTab - 1].subDiv = 0;
@ -401,6 +401,7 @@ void checkInputs() {
sendMIDIStart(); sendMIDIStart();
} else { } else {
isPlaying = false; isPlaying = false;
resetClocks();
sendMIDIStop(); sendMIDIStop();
} }
} }

View File

@ -231,7 +231,7 @@ void updateScreen() {
} else if (channels[displayTab - 1].mode == 3) { } else if (channels[displayTab - 1].mode == 3) {
valueStr = String(channels[displayTab - 1].swing) + "%"; valueStr = String(channels[displayTab - 1].swing) + "%";
} else if (channels[displayTab - 1].mode == 4) { } else if (channels[displayTab - 1].mode == 4) {
valueStr = String(channels[displayTab - 1].gate) + "%"; valueStr = String(channels[displayTab - 1].gate);
} }
u8g2.setFont(stkL); u8g2.setFont(stkL);
if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) { if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) {
@ -272,10 +272,11 @@ void updateScreen() {
} }
} }
valueStr = F("t");
if (masterClockMode == 0 && !isPlaying) { if (masterClockMode == 0 && !isPlaying) {
valueStr = F("t");
u8g2.drawUTF8(121, yPos, valueStr.c_str() ); u8g2.drawUTF8(121, yPos, valueStr.c_str() );
} else if (masterClockMode == 0 && isPlaying) { } else if (masterClockMode == 0 && isPlaying) {
valueStr = F("r");
u8g2.drawUTF8(122, yPos, valueStr.c_str() ); u8g2.drawUTF8(122, yPos, valueStr.c_str() );
} }
} }