diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index fbec7f1..afff33d 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -65,23 +65,18 @@ channel channels[6] = { //array of channel settings { 0, 7, 0, 3, 0, 3, 0, 0, 0 } }; -bool sequences[8][16] { - {1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0}, - {1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0} -}; - -byte seqStepCount[8] = {0,0,0,0,0,0,0,0}; +bool seqA1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}; +bool seqA2[16] = {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0}; +bool seqA3[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +bool seqA4[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}; +bool *currentSeq; +int currentStep = 0; byte memCode = 'A'; //Change to different letter if you changed the data structure int channelPulseCount[6]; int channelPulsesPerCycle[6]; +int sixteenthPulseCount = 0; int playingModes[6]; //actual channel modes array updated from channels object on each beat unsigned int pulsePeriod; @@ -272,6 +267,25 @@ void sendTriggers() { } } + //16th notes for sequencer + if (sixteenthPulseCount == 0) { + for (byte i = 0; i < 6; i++) { + if (channels[i].mode == 2 && channelPulseCount[i] == 0 && currentSeq[currentStep]) { + digitalWrite(outsPins[i], HIGH); + } + } + } + if (sixteenthPulseCount < (PPQN / 4) - 1) { + sixteenthPulseCount++; + } else { + sixteenthPulseCount = 0; + if (currentStep < 15) { + currentStep ++; + } else { + currentStep = 0; + } + } + //switching modes on the beat and resetting channel clock if (pulseCount == 0) { calculateCycles(); @@ -285,7 +299,6 @@ void sendTriggers() { //multiplier for (byte i = 0; i < 6; i++) { - int currentSeq = channels[i].seqPattern; //RND modulation byte randMod = 0; @@ -306,9 +319,9 @@ 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 == 2 && channelPulseCount[i] == 0 && sequences[currentSeq][0]) //SEQ (for some reason doesn't lke variables inside the index) + 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 == 2 && channelPulseCount[i] == 0 && currentSeq[currentStep]) ) { digitalWrite(outsPins[i], HIGH); } @@ -318,6 +331,7 @@ void sendTriggers() { channelPulseCount[i] = 0; } } + } void calculateCycles() { @@ -337,10 +351,12 @@ void calculateCycles() { playingModes[i] = subDivs[channels[i].subDiv - mod]; } - if (playingModes[i] > 0) { + if (playingModes[i] > 0 && channels[i].mode != 2) { channelPulsesPerCycle[i] = (playingModes[i] * PPQN) - 1; - } else { + } else if (playingModes[i] <= 0 && channels[i].mode != 2) { channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1; + } else if (channels[i].mode == 2) { //Sequencer plays 1/16th + channelPulsesPerCycle[i] = (PPQN / 4) - 1; } if (channels[i].offset > channelPulsesPerCycle[i]) { channels[i].offset = channelPulsesPerCycle[i]; diff --git a/Software/Gravity/InputsCheck.ino b/Software/Gravity/InputsCheck.ino index 4d1691b..8d9bf54 100644 --- a/Software/Gravity/InputsCheck.ino +++ b/Software/Gravity/InputsCheck.ino @@ -106,6 +106,23 @@ void checkInputs() { } else if (channels[displayTab - 1].random > 9) { channels[displayTab - 1].random = 9; } + } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 1 && channels[displayTab - 1].mode == 2) { //Seq PAttern + channels[displayTab - 1].seqPattern = channels[displayTab - 1].seqPattern + change; + if (channels[displayTab - 1].seqPattern > 100) { + channels[displayTab - 1].seqPattern = 0; + } else if (channels[displayTab - 1].seqPattern > 8) { + channels[displayTab - 1].seqPattern = 8; + } + + if (channels[displayTab - 1].seqPattern == 0) { + currentSeq = seqA1; + } else if (channels[displayTab - 1].seqPattern == 1) { + currentSeq = seqA2; + } else if (channels[displayTab - 1].seqPattern == 2) { + currentSeq = seqA3; + } else if (channels[displayTab - 1].seqPattern == 3) { + currentSeq = seqA4; + } } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 0) { //CV1 for CLK channels[displayTab - 1].CV1Target = channels[displayTab - 1].CV1Target + change; if (channels[displayTab - 1].CV1Target > 100) { @@ -137,7 +154,7 @@ void checkInputs() { channels[displayTab - 1].CV2Target = 2; } } - + updateScreen(); encPositionOld = encPosition; }