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"
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 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
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 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, 23, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 23, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 23, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 23, 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 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};
@ -122,6 +122,7 @@ 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};
byte displayTab = 0;
bool insideTab = false;
@ -303,7 +304,16 @@ void clock() {
// pull low all outputs after set pulse length
if (tickCount >= PULSE_LENGTH) {
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);
}
@ -428,7 +438,7 @@ void sendTriggers() {
} else if (seqPattern == 15) {
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);
}
}
@ -482,6 +492,7 @@ void sendTriggers() {
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 == 4 && channelPulseCount[i] == 0) //gate
) {
digitalWrite(outsPins[i], HIGH);
}