From 0d41ff9cbdefbcb2dc2024e2b7180fc770b6450a Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Fri, 18 Oct 2024 00:13:24 +0300 Subject: [PATCH] Gate kinda works, but needs some tweaking of the values --- Software/Gravity/Gravity.ino | 31 +++++++++++++++++++++---------- Software/Gravity/Interactions.ino | 7 ++++--- Software/Gravity/UI.ino | 5 +++-- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index 069adaf..ab93df3 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -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); } diff --git a/Software/Gravity/Interactions.ino b/Software/Gravity/Interactions.ino index 615311a..7f6822f 100644 --- a/Software/Gravity/Interactions.ino +++ b/Software/Gravity/Interactions.ino @@ -195,8 +195,8 @@ void checkInputs() { channels[displayTab - 1].gate = channels[displayTab - 1].gate + change; if (channels[displayTab - 1].gate > 100) { channels[displayTab - 1].gate = 0; - } else if (channels[displayTab - 1].gate > 15) { - channels[displayTab - 1].gate = 15; + } else if (channels[displayTab - 1].gate > 40) { + channels[displayTab - 1].gate = 40; } saveState(); } else if (insideTab && !shiftBtnPushed && !menuItemSelected) { @@ -289,7 +289,7 @@ void checkInputs() { && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && 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; if (channels[displayTab - 1].subDiv > 200) { channels[displayTab - 1].subDiv = 0; @@ -401,6 +401,7 @@ void checkInputs() { sendMIDIStart(); } else { isPlaying = false; + resetClocks(); sendMIDIStop(); } } diff --git a/Software/Gravity/UI.ino b/Software/Gravity/UI.ino index 68cbe67..645102d 100644 --- a/Software/Gravity/UI.ino +++ b/Software/Gravity/UI.ino @@ -231,7 +231,7 @@ void updateScreen() { } else if (channels[displayTab - 1].mode == 3) { valueStr = String(channels[displayTab - 1].swing) + "%"; } else if (channels[displayTab - 1].mode == 4) { - valueStr = String(channels[displayTab - 1].gate) + "%"; + valueStr = String(channels[displayTab - 1].gate); } u8g2.setFont(stkL); if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) { @@ -272,10 +272,11 @@ void updateScreen() { } } - valueStr = F("t"); if (masterClockMode == 0 && !isPlaying) { + valueStr = F("t"); u8g2.drawUTF8(121, yPos, valueStr.c_str() ); } else if (masterClockMode == 0 && isPlaying) { + valueStr = F("r"); u8g2.drawUTF8(122, yPos, valueStr.c_str() ); } }