diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index 536d663..43f6676 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -85,22 +85,7 @@ sequence sequences[] { {0b000000000000000000000000000000000, 15}, {0b000000000000000000000000000000000, 15} }; -/*bool seqA1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1}; -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}; -bool seqA5[16] = {0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1}; -bool seqA6[16] = {0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0}; -bool seqA7[16] = {1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0}; -bool seqA8[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1}; -bool seqB1[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -bool seqB2[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -bool seqB3[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -bool seqB4[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -bool seqB5[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -bool seqB6[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -bool seqB7[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -bool seqB8[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};*/ + byte currentStep[7] = {0}; int8_t stepNumSelected = 0; byte patternToEdit; @@ -216,7 +201,7 @@ void sendMIDIStop() { void receiveMIDI( uint8_t msg, uint8_t status ) { if (masterClockMode == 2) { - if (msg == 0xF8) { //Clock + if (msg == 0xF8) { //Clock tick MIDIClockReceived = true; } else if (msg == 0xFC) { //stop isPlaying = false; @@ -279,19 +264,14 @@ void clock() { // pull low all outputs after set pulse length for (byte i = 0; i < 7; i++) { - if (channels[i].mode != 4 && tickCount >= PULSE_LENGTH) { //everything but gate mode + if (channels[i].mode != 4 && tickCount >= PULSE_LENGTH) { //everything but gate mode digitalWrite(outsPins[i], LOW); - } - - if (channels[i].mode == 4 && gateCountDown[i] > pulsePeriod && tickCount >= pulsePeriod) { //tickCount == 0? - gateCountDown[i] = gateCountDown[i] - pulsePeriod; // !!! Most likely something is wrong here that causing the drift - } - - if (channels[i].mode == 4 && tickCount >= gateCountDown[i]) { //gate mode + } else if (channels[i].mode == 4 && tickCount >= gateCountDown[i]) { //gate mode gateLengthTime[i] < pulsePeriod digitalWrite(outsPins[i], LOW); gateCountDown[i] = gateLengthTime[i]; + } else if (channels[i].mode == 4 && gateCountDown[i] > pulsePeriod && tickCount == 0) { + gateCountDown[i] = gateCountDown[i] - pulsePeriod; } - } } @@ -393,7 +373,7 @@ void sendTriggers() { //rename to onPulse or something } else { sixteenthPulseCount = 0; for (byte i; i < 7; i++) { - if (channels[i].mode == 2 && currentStep[i] <= sequences[channels[i].seqPattern].length) { + if (channels[i].mode == 2 && currentStep[i] < sequences[channels[i].seqPattern].length) { currentStep[i] ++; } else { currentStep[i] = 0; @@ -482,15 +462,12 @@ void calculateCycles() { void calculateGate(uint8_t channel) { //if (subDivs[channels[channel].subDiv] > 0) { - uint16_t gateLengthOld = gateLengthTime[channel]; - //gateLengthTime[channel] = ((channelPulsesPerCycle[channel] + 1) * (pulsePeriod + 1) / 100) * channels[channel].gate; // this seemed to work, but at some point started drifting - gateLengthTime[channel] = ((channelPulsesPerCycle[channel] + 1) * (pulsePeriod - 1) / 100) * channels[channel].gate; - if (gateLengthOld != gateLengthTime[channel]) { - gateCountDown[channel] = gateLengthTime[channel]; - } + gateLengthTime[channel] = ((channelPulsesPerCycle[channel] + 1) * (pulsePeriod + 1) / 100) * channels[channel].gate; + gateCountDown[channel] = gateLengthTime[channel]; //} } + void calculateBPMTiming() { int mod = 0; if (masterClockMode == 0) { //Internal clock @@ -506,12 +483,6 @@ void calculateBPMTiming() { } else if (masterClockMode == 1 && extClockPPQN == 1) { //for ext 1/16 clock pulsePeriod = (newExtPulseTime - lastExtPulseTime) * 10 / 6; } - - for (byte i = 0; i < (extraChannel ? 7 : 6); i++) { - if (channels[i].mode == 4) { - calculateGate(i); - } - } } void resetClocks() { diff --git a/Software/Gravity/config.h b/Software/Gravity/config.h index c06418e..4773afc 100644 --- a/Software/Gravity/config.h +++ b/Software/Gravity/config.h @@ -20,7 +20,6 @@ const byte clockOutPin = 3; const byte outsPins[] = { 7, 8, 10, 6, 9, 11, clockOutPin }; bool rotateScreen = false; bool reverseEnc = false; -// /* Rev 1 Config #define ENC_BTN_PIN 14 @@ -34,7 +33,7 @@ bool reverseEnc = false; #define ANALOGUE_INPUT_2_PIN A1 const byte clockOutPin = 13; -const byte outsPins[6] = {6, 11, 7, 10, 8, 9}; +const byte outsPins[6] = {6, 11, 7, 10, 8, 9, clockOutPin}; bool rotateScreen = true; */