diff --git a/Source/DSP/Arpeggiator.h b/Source/DSP/Arpeggiator.h index 2e689f7..ef67536 100644 --- a/Source/DSP/Arpeggiator.h +++ b/Source/DSP/Arpeggiator.h @@ -68,6 +68,12 @@ public: bool wasIdle = heldNotes.empty(); heldNotes.push_back(note); velocities[note] = velocity; + // The held set changed, so the pitch pool changed too. Restart the + // sequence from the top so the pattern always starts from a known + // note instead of continuing at stepIndex % newPoolSize. + stepIndex = 0; + randomOncePool.clear(); + randomOnceOrder.clear(); // A fresh key press should sound immediately instead of waiting for // the next host-synced tick. if (wasIdle) @@ -76,8 +82,12 @@ public: void noteOff(int note) { auto it = std::find(heldNotes.begin(), heldNotes.end(), note); - if (it != heldNotes.end()) + if (it != heldNotes.end()) { heldNotes.erase(it); + stepIndex = 0; + randomOncePool.clear(); + randomOnceOrder.clear(); + } } bool hasHeldNotes() const { return !heldNotes.empty(); } @@ -97,6 +107,8 @@ public: heldNotes.clear(); stepIndex = 0; needsImmediateStep = false; + randomOncePool.clear(); + randomOnceOrder.clear(); } // Advances one step. Notes that should stop go into `notesToStop` diff --git a/shot.png b/shot.png index 0b1eb5a..f431b8a 100644 Binary files a/shot.png and b/shot.png differ