diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index 3c77656..67a76c3 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -44,7 +44,7 @@ struct channel { byte CV1Range; byte CV2Target; byte CV2Range; - byte offset; + unsigned int offset; byte random; byte seqPattern; }; diff --git a/Software/Gravity/Interactions.ino b/Software/Gravity/Interactions.ino index 9d95714..2aaf48b 100644 --- a/Software/Gravity/Interactions.ino +++ b/Software/Gravity/Interactions.ino @@ -108,22 +108,13 @@ void checkInputs() { } saveState(); calculateBPMTiming(); - } else if (((!insideTab && shiftBtnPushed) + } else if (((!insideTab && shiftBtnPushed) //Change Subdiv and reset offset || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) && displayTab != 0 - && channels[displayTab - 1].mode == 0) { //Change Subdiv and reset offset + && channels[displayTab - 1].mode == 0) { channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - change; //channels[displayTab - 1].offset = 0; - int PulsesPerStep; - if (subDivs[channels[displayTab - 1].subDiv] < 0) { - PulsesPerStep = PPQN / subDivs[channels[displayTab - 1].subDiv] * -1 ; - } else { - PulsesPerStep = subDivs[channels[displayTab - 1].subDiv] * PPQN; - } - if (channels[displayTab - 1].offset >= PulsesPerStep) { - channels[displayTab - 1].offset = PulsesPerStep - 1; - } if (channels[displayTab - 1].subDiv > 100) { channels[displayTab - 1].subDiv = 0; } if (channels[displayTab - 1].subDiv > (sizeof(subDivs) / sizeof(int)) - 1) { @@ -132,6 +123,15 @@ void checkInputs() { if (!isPlaying) { calculateCycles(); } + int PulsesPerStep; //offset part + if (subDivs[channels[displayTab - 1].subDiv] < 0) { + PulsesPerStep = PPQN / subDivs[channels[displayTab - 1].subDiv] * -1 ; + } else { + PulsesPerStep = subDivs[channels[displayTab - 1].subDiv] * PPQN; + } + if (channels[displayTab - 1].offset >= PulsesPerStep) { + channels[displayTab - 1].offset = PulsesPerStep - 1; + } saveState(); } else if (((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 @@ -208,7 +208,7 @@ void checkInputs() { saveState(); } else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 0) { //Offset channels[displayTab - 1].offset = channels[displayTab - 1].offset + change; - if (channels[displayTab - 1].offset > 100) { + if (channels[displayTab - 1].offset > 1000) { channels[displayTab - 1].offset = 0; } else if (channels[displayTab - 1].offset > channelPulsesPerCycle[displayTab-1]) { channels[displayTab - 1].offset = channelPulsesPerCycle[displayTab-1];