diff --git a/software/o_c_REV/HEM_Carpeggio.ino b/software/o_c_REV/HEM_Carpeggio.ino index 746896200..1d8230ac3 100644 --- a/software/o_c_REV/HEM_Carpeggio.ino +++ b/software/o_c_REV/HEM_Carpeggio.ino @@ -86,7 +86,7 @@ public: cursor = 0; // Don't advance cursor when chord is changed ImprintChord(chord); } - if (++cursor > 2) cursor = 0; + if (++cursor > 3) cursor = 0; ResetCursor(); } @@ -94,6 +94,17 @@ public: if (cursor == 0) sequence[step] = constrain(sequence[step] += direction, -24, 60); if (cursor == 1) chord = constrain(chord += direction, 0, Nr_of_arp_chords - 1); if (cursor == 2) transpose = constrain(transpose += direction, -24, 24); + if (cursor == 3) { + // only imprint cord when turning left from shuffle + if (shuffle && direction < 0) { + ImprintChord(sel_chord); + } + // shuffle chord every time we turn right + if (direction > 0) { + ShuffleChord(); + } + + } if (cursor != 1) replay = 1; } @@ -131,6 +142,7 @@ private: int chord; // Selected chord int sel_chord; // Most recently-imprinted chord int transpose; // Transposition setting (-24 ~ +24) + bool shuffle = false; // Variables to handle imprint confirmation animation int confirm_animation_countdown; @@ -150,6 +162,12 @@ private: gfxPrint(transpose); if (cursor == 2) gfxCursor(32, 33, 30); + // Shuffle selector + gfxBitmap(37, 36, 8, PLAY_ICON); + gfxBitmap(49, 36, 8, LOOP_ICON); + gfxInvert(36 + (shuffle ? 12 : 0), 35, 10, 10); + if (cursor == 3) gfxCursor(37, 46, 20); + // Note name editor uint8_t midi_note = constrain(sequence[step] + 36 + transpose, 0, 127); gfxPrint(38, 50, midi_note_numbers[midi_note]); @@ -189,6 +207,22 @@ private: chord = new_chord; confirm_animation_position = 16; confirm_animation_countdown = HEM_CARPEGGIO_ANIMATION_SPEED; + shuffle = false; + } + + void ShuffleChord() { + int16_t old; // temp var for note being swapped + int16_t rnd; // temp var for index of note swapping in + for (int i = 0; i < 16; i++) { + // set old to current step value + old = sequence[i]; + rnd = random(0, 16); + sequence[i] = sequence[rnd]; + sequence[rnd] = old; + } + confirm_animation_position = 16; + confirm_animation_countdown = HEM_CARPEGGIO_ANIMATION_SPEED; + shuffle = true; } void pitch_out_for_step() {