diff options
author | Bad Diode <bd@badd10de.dev> | 2023-07-19 10:03:33 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-07-19 10:03:33 +0200 |
commit | e8be8a52e999b7a9ee4fc935a33ebfefad5bae3a (patch) | |
tree | e87b4a6899dc2ece106fb8e9f886ea3dc7ea08cb /src/sequencer.c | |
parent | 1e666da666081bece2c244c2297d08801add3103 (diff) | |
download | stepper-e8be8a52e999b7a9ee4fc935a33ebfefad5bae3a.tar.gz stepper-e8be8a52e999b7a9ee4fc935a33ebfefad5bae3a.zip |
Allow removing the last chain when playing
Diffstat (limited to 'src/sequencer.c')
-rw-r--r-- | src/sequencer.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/sequencer.c b/src/sequencer.c index 9de08f8..038b608 100644 --- a/src/sequencer.c +++ b/src/sequencer.c | |||
@@ -565,22 +565,27 @@ handle_pattern_chain(void) { | |||
565 | } else if (key_tap(KEY_B)) { | 565 | } else if (key_tap(KEY_B)) { |
566 | if (chain.active[param_selection_loc]) { | 566 | if (chain.active[param_selection_loc]) { |
567 | // Can't toggle current chain. | 567 | // Can't toggle current chain. |
568 | if (!play_status || param_selection_loc != chain.current) { | 568 | if (!play_status |
569 | || param_selection_loc != chain.current | ||
570 | || chain.len == 1) { | ||
569 | chain.active[param_selection_loc] = 0; | 571 | chain.active[param_selection_loc] = 0; |
570 | chain.len--; | 572 | chain.len--; |
571 | } | 573 | } |
572 | } else { | 574 | } else { |
575 | if (chain.len == 0) { | ||
576 | chain.current = param_selection_loc; | ||
577 | } | ||
573 | chain.active[param_selection_loc] = 1; | 578 | chain.active[param_selection_loc] = 1; |
574 | chain.len++; | 579 | chain.len++; |
575 | } | 580 | } |
576 | } else if (key_tap(KEY_L)) { | 581 | } else if (key_tap(KEY_L)) { |
577 | if (chain.active[param_selection_loc] | 582 | if (chain.active[param_selection_loc] |
578 | && chain.chain[param_selection_loc] > 0 | 583 | && chain.chain[param_selection_loc] > 0 |
579 | && (!play_status || param_selection_loc != chain.current)) { | 584 | && (!play_status || param_selection_loc != chain.current)) { |
580 | chain.chain[param_selection_loc]--; | 585 | chain.chain[param_selection_loc]--; |
581 | } | 586 | } |
582 | } else if (key_tap(KEY_R)) { | 587 | } else if (key_tap(KEY_R)) { |
583 | if (chain.active[param_selection_loc] | 588 | if (chain.active[param_selection_loc] |
584 | && chain.chain[param_selection_loc] < 7 | 589 | && chain.chain[param_selection_loc] < 7 |
585 | && (!play_status || param_selection_loc != chain.current)) { | 590 | && (!play_status || param_selection_loc != chain.current)) { |
586 | chain.chain[param_selection_loc]++; | 591 | chain.chain[param_selection_loc]++; |
@@ -663,7 +668,7 @@ handle_pattern_selection(void) { | |||
663 | size_t idx = 15 - i; | 668 | size_t idx = 15 - i; |
664 | if (chain.active[idx] == 1) { | 669 | if (chain.active[idx] == 1) { |
665 | // If the pattern is currently playing it can't be removed. | 670 | // If the pattern is currently playing it can't be removed. |
666 | if (play_status && idx == chain.current) { | 671 | if (play_status && idx == chain.current && chain.len > 1) { |
667 | continue; | 672 | continue; |
668 | } else if (idx == chain.current) { | 673 | } else if (idx == chain.current) { |
669 | update_current = true; | 674 | update_current = true; |