aboutsummaryrefslogtreecommitdiffstats
path: root/src/sequencer.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2024-01-08 15:32:13 +0100
committerBad Diode <bd@badd10de.dev>2024-01-08 15:32:13 +0100
commitbe37f274be067e92f9240112b7a047b8ef9e09b0 (patch)
treefb5a45cd6f605e607c5bd8e7e5a4127b95230976 /src/sequencer.c
parent2eb3cfba2bdd569ffeaf94e6e29faac9a83b5b77 (diff)
downloadstepper-be37f274be067e92f9240112b7a047b8ef9e09b0.tar.gz
stepper-be37f274be067e92f9240112b7a047b8ef9e09b0.zip
Add input retriggering with configurable rate and offset
Diffstat (limited to 'src/sequencer.c')
-rw-r--r--src/sequencer.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/sequencer.c b/src/sequencer.c
index a032481..3433da1 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -442,7 +442,7 @@ handle_channel_selection(void) {
442 } 442 }
443 } 443 }
444 redraw_params = true; 444 redraw_params = true;
445 } else if (key_tap(KEY_L)) { 445 } else if (key_retrig(KEY_L)) {
446 s32 inc = -1; 446 s32 inc = -1;
447 if (key_hold(KEY_SELECT)) { 447 if (key_hold(KEY_SELECT)) {
448 inc = -12; 448 inc = -12;
@@ -466,7 +466,7 @@ handle_channel_selection(void) {
466 } 466 }
467 } 467 }
468 redraw_trigs = true; 468 redraw_trigs = true;
469 } else if (key_tap(KEY_R)) { 469 } else if (key_retrig(KEY_R)) {
470 s32 inc = 1; 470 s32 inc = 1;
471 if (key_hold(KEY_SELECT)) { 471 if (key_hold(KEY_SELECT)) {
472 inc = 12; 472 inc = 12;
@@ -491,16 +491,16 @@ handle_channel_selection(void) {
491 } 491 }
492 redraw_trigs = true; 492 redraw_trigs = true;
493 } 493 }
494 if (key_tap(KEY_RIGHT)) { 494 if (key_retrig(KEY_RIGHT)) {
495 trig_selection_loc = 0; 495 trig_selection_loc = 0;
496 param_selection_loc = 0; 496 param_selection_loc = 0;
497 input_handler = handle_trigger_selection; 497 input_handler = handle_trigger_selection;
498 redraw_params = true; 498 redraw_params = true;
499 } else if (key_tap(KEY_LEFT)) { 499 } else if (key_retrig(KEY_LEFT)) {
500 input_handler = handle_pattern_selection; 500 input_handler = handle_pattern_selection;
501 param_selection_loc = 0; 501 param_selection_loc = 0;
502 redraw_params = true; 502 redraw_params = true;
503 } else if (key_tap(KEY_UP)) { 503 } else if (key_retrig(KEY_UP)) {
504 if (channel_selection_loc == 0) { 504 if (channel_selection_loc == 0) {
505 channel_selection_loc = SEQ_N_CHANNELS - 1; 505 channel_selection_loc = SEQ_N_CHANNELS - 1;
506 } else { 506 } else {
@@ -509,7 +509,7 @@ handle_channel_selection(void) {
509 param_selection_loc = 0; 509 param_selection_loc = 0;
510 redraw_trigs = true; 510 redraw_trigs = true;
511 redraw_params = true; 511 redraw_params = true;
512 } else if (key_tap(KEY_DOWN)) { 512 } else if (key_retrig(KEY_DOWN)) {
513 if (channel_selection_loc == SEQ_N_CHANNELS - 1) { 513 if (channel_selection_loc == SEQ_N_CHANNELS - 1) {
514 channel_selection_loc = 0; 514 channel_selection_loc = 0;
515 } else { 515 } else {
@@ -601,7 +601,7 @@ toggle_playing(void) {
601 601
602void 602void
603handle_right_col_selection(void) { 603handle_right_col_selection(void) {
604 if (key_tap(KEY_LEFT)) { 604 if (key_retrig(KEY_LEFT)) {
605 switch (right_col_selection_loc) { 605 switch (right_col_selection_loc) {
606 case R_COL_STOP: 606 case R_COL_STOP:
607 case R_COL_BANK_B: 607 case R_COL_BANK_B:
@@ -624,7 +624,7 @@ handle_right_col_selection(void) {
624 } else { 624 } else {
625 trig_selection_loc = 7; 625 trig_selection_loc = 7;
626 } 626 }
627 } else if (key_tap(KEY_RIGHT)) { 627 } else if (key_retrig(KEY_RIGHT)) {
628 switch (right_col_selection_loc) { 628 switch (right_col_selection_loc) {
629 case R_COL_PLAY: 629 case R_COL_PLAY:
630 case R_COL_BANK_A: 630 case R_COL_BANK_A:
@@ -638,7 +638,7 @@ handle_right_col_selection(void) {
638 case R_COL_SETTINGS: 638 case R_COL_SETTINGS:
639 case R_COL_STOP: { input_handler = handle_pattern_selection; } break; 639 case R_COL_STOP: { input_handler = handle_pattern_selection; } break;
640 } 640 }
641 } else if (key_tap(KEY_UP)) { 641 } else if (key_retrig(KEY_UP)) {
642 switch (right_col_selection_loc) { 642 switch (right_col_selection_loc) {
643 case R_COL_BANK_A: { right_col_selection_loc = R_COL_PLAY; } break; 643 case R_COL_BANK_A: { right_col_selection_loc = R_COL_PLAY; } break;
644 case R_COL_BANK_B: { right_col_selection_loc = R_COL_STOP; } break; 644 case R_COL_BANK_B: { right_col_selection_loc = R_COL_STOP; } break;
@@ -650,7 +650,7 @@ handle_right_col_selection(void) {
650 case R_COL_SCALE: { right_col_selection_loc -= 2; } break; 650 case R_COL_SCALE: { right_col_selection_loc -= 2; } break;
651 default: { right_col_selection_loc--; } break; 651 default: { right_col_selection_loc--; } break;
652 } 652 }
653 } else if (key_tap(KEY_DOWN)) { 653 } else if (key_retrig(KEY_DOWN)) {
654 switch (right_col_selection_loc) { 654 switch (right_col_selection_loc) {
655 case R_COL_BANK_A: 655 case R_COL_BANK_A:
656 case R_COL_BANK_B: 656 case R_COL_BANK_B:
@@ -661,7 +661,7 @@ handle_right_col_selection(void) {
661 case R_COL_STOP: { right_col_selection_loc = R_COL_BANK_B; } break; 661 case R_COL_STOP: { right_col_selection_loc = R_COL_BANK_B; } break;
662 default: { right_col_selection_loc++; } break; 662 default: { right_col_selection_loc++; } break;
663 } 663 }
664 } else if (key_tap(KEY_L)) { 664 } else if (key_retrig(KEY_L)) {
665 switch (right_col_selection_loc) { 665 switch (right_col_selection_loc) {
666 case R_COL_BPM: { 666 case R_COL_BPM: {
667 s32 bpm_inc = -1; 667 s32 bpm_inc = -1;
@@ -701,7 +701,7 @@ handle_right_col_selection(void) {
701 } 701 }
702 } break; 702 } break;
703 } 703 }
704 } else if (key_tap(KEY_R)) { 704 } else if (key_retrig(KEY_R)) {
705 switch (right_col_selection_loc) { 705 switch (right_col_selection_loc) {
706 case R_COL_BPM: { 706 case R_COL_BPM: {
707 s32 bpm_inc = 1; 707 s32 bpm_inc = 1;
@@ -759,7 +759,7 @@ handle_pattern_chain(void) {
759 static int previous_loc = 0; 759 static int previous_loc = 0;
760 if (key_tap(KEY_A)) { 760 if (key_tap(KEY_A)) {
761 input_handler = handle_pattern_selection; 761 input_handler = handle_pattern_selection;
762 } else if (key_tap(KEY_LEFT)) { 762 } else if (key_retrig(KEY_LEFT)) {
763 if (param_selection_loc == 8) { 763 if (param_selection_loc == 8) {
764 param_selection_loc = 15; 764 param_selection_loc = 15;
765 } else if (param_selection_loc == 16) { 765 } else if (param_selection_loc == 16) {
@@ -769,7 +769,7 @@ handle_pattern_chain(void) {
769 } else if (param_selection_loc == 0) { 769 } else if (param_selection_loc == 0) {
770 param_selection_loc = 7; 770 param_selection_loc = 7;
771 } 771 }
772 } else if (key_tap(KEY_RIGHT)) { 772 } else if (key_retrig(KEY_RIGHT)) {
773 if (param_selection_loc < 15 && param_selection_loc != 7) { 773 if (param_selection_loc < 15 && param_selection_loc != 7) {
774 param_selection_loc++; 774 param_selection_loc++;
775 } else if (param_selection_loc < 18 && param_selection_loc >= 16) { 775 } else if (param_selection_loc < 18 && param_selection_loc >= 16) {
@@ -885,14 +885,14 @@ handle_pattern_chain(void) {
885 } 885 }
886 } break; 886 } break;
887 } 887 }
888 } else if (key_tap(KEY_L)) { 888 } else if (key_retrig(KEY_L)) {
889 if (chain.active[param_selection_loc] 889 if (chain.active[param_selection_loc]
890 && chain.chain[param_selection_loc] > 0 890 && chain.chain[param_selection_loc] > 0
891 && param_selection_loc <= 15 891 && param_selection_loc <= 15
892 && (!play_status || param_selection_loc != chain.current)) { 892 && (!play_status || param_selection_loc != chain.current)) {
893 chain.chain[param_selection_loc]--; 893 chain.chain[param_selection_loc]--;
894 } 894 }
895 } else if (key_tap(KEY_R)) { 895 } else if (key_retrig(KEY_R)) {
896 if (chain.active[param_selection_loc] 896 if (chain.active[param_selection_loc]
897 && chain.chain[param_selection_loc] < 7 897 && chain.chain[param_selection_loc] < 7
898 && param_selection_loc <= 15 898 && param_selection_loc <= 15
@@ -934,11 +934,11 @@ handle_pattern_selection(void) {
934 if (key_tap(KEY_A)) { 934 if (key_tap(KEY_A)) {
935 input_handler = handle_pattern_chain; 935 input_handler = handle_pattern_chain;
936 } 936 }
937 if (key_tap(KEY_RIGHT)) { 937 if (key_retrig(KEY_RIGHT)) {
938 param_selection_loc = 0; 938 param_selection_loc = 0;
939 input_handler = handle_channel_selection; 939 input_handler = handle_channel_selection;
940 redraw_params = true; 940 redraw_params = true;
941 } else if (key_tap(KEY_UP)) { 941 } else if (key_retrig(KEY_UP)) {
942 if (pattern_selection_loc > 0) { 942 if (pattern_selection_loc > 0) {
943 pattern_selection_loc = pattern_selection_loc - 1; 943 pattern_selection_loc = pattern_selection_loc - 1;
944 } else { 944 } else {
@@ -947,7 +947,7 @@ handle_pattern_selection(void) {
947 redraw_channels = true; 947 redraw_channels = true;
948 redraw_trigs = true; 948 redraw_trigs = true;
949 redraw_bpm = true; 949 redraw_bpm = true;
950 } else if (key_tap(KEY_DOWN)) { 950 } else if (key_retrig(KEY_DOWN)) {
951 if (pattern_selection_loc < 7) { 951 if (pattern_selection_loc < 7) {
952 pattern_selection_loc = pattern_selection_loc + 1; 952 pattern_selection_loc = pattern_selection_loc + 1;
953 } else { 953 } else {
@@ -957,7 +957,7 @@ handle_pattern_selection(void) {
957 redraw_trigs = true; 957 redraw_trigs = true;
958 redraw_bpm = true; 958 redraw_bpm = true;
959 } 959 }
960 if (key_tap(KEY_LEFT)) { 960 if (key_retrig(KEY_LEFT)) {
961 redraw_params = true; 961 redraw_params = true;
962 input_handler = handle_right_col_selection; 962 input_handler = handle_right_col_selection;
963 param_selection_loc = 0; 963 param_selection_loc = 0;
@@ -1032,8 +1032,8 @@ set_param_selection_sq1(ChannelSquareParams *params, InputHandler return_handler
1032 } 1032 }
1033 1033
1034 // Cursor movement. 1034 // Cursor movement.
1035 if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { 1035 if (key_retrig(KEY_LEFT) || key_retrig(KEY_RIGHT)) {
1036 if (key_tap(KEY_RIGHT)) { 1036 if (key_retrig(KEY_RIGHT)) {
1037 if (param_selection_loc == 4) { 1037 if (param_selection_loc == 4) {
1038 param_selection_loc = 0; 1038 param_selection_loc = 0;
1039 } else if (param_selection_loc == 9) { 1039 } else if (param_selection_loc == 9) {
@@ -1073,9 +1073,9 @@ set_param_selection_sq1(ChannelSquareParams *params, InputHandler return_handler
1073 } 1073 }
1074 1074
1075 // Adjust parameter. 1075 // Adjust parameter.
1076 if (key_tap(KEY_R) || key_tap(KEY_L)) { 1076 if (key_retrig(KEY_R) || key_retrig(KEY_L)) {
1077 int inc; 1077 int inc;
1078 if (key_tap(KEY_L)) { 1078 if (key_retrig(KEY_L)) {
1079 inc = -1; 1079 inc = -1;
1080 } else { 1080 } else {
1081 inc = 1; 1081 inc = 1;
@@ -1116,8 +1116,8 @@ set_param_selection_sq2(ChannelSquareParams *params, InputHandler return_handler
1116 } 1116 }
1117 1117
1118 // Cursor movement. 1118 // Cursor movement.
1119 if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { 1119 if (key_retrig(KEY_LEFT) || key_retrig(KEY_RIGHT)) {
1120 if (key_tap(KEY_RIGHT)) { 1120 if (key_retrig(KEY_RIGHT)) {
1121 if (param_selection_loc == 4) { 1121 if (param_selection_loc == 4) {
1122 param_selection_loc = 0; 1122 param_selection_loc = 0;
1123 } else if (param_selection_loc == 7) { 1123 } else if (param_selection_loc == 7) {
@@ -1149,9 +1149,9 @@ set_param_selection_sq2(ChannelSquareParams *params, InputHandler return_handler
1149 } 1149 }
1150 1150
1151 // Adjust parameter. 1151 // Adjust parameter.
1152 if (key_tap(KEY_R) || key_tap(KEY_L)) { 1152 if (key_retrig(KEY_R) || key_retrig(KEY_L)) {
1153 int inc; 1153 int inc;
1154 if (key_tap(KEY_L)) { 1154 if (key_retrig(KEY_L)) {
1155 inc = -1; 1155 inc = -1;
1156 } else { 1156 } else {
1157 inc = 1; 1157 inc = 1;
@@ -1189,8 +1189,8 @@ set_param_selection_wave(ChannelWaveParams *params, InputHandler return_handler)
1189 } 1189 }
1190 1190
1191 // Cursor movement. 1191 // Cursor movement.
1192 if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { 1192 if (key_retrig(KEY_LEFT) || key_retrig(KEY_RIGHT)) {
1193 if (key_tap(KEY_RIGHT)) { 1193 if (key_retrig(KEY_RIGHT)) {
1194 if (param_selection_loc == 4) { 1194 if (param_selection_loc == 4) {
1195 param_selection_loc = 0; 1195 param_selection_loc = 0;
1196 } else if (param_selection_loc == 6) { 1196 } else if (param_selection_loc == 6) {
@@ -1230,9 +1230,9 @@ set_param_selection_wave(ChannelWaveParams *params, InputHandler return_handler)
1230 } 1230 }
1231 1231
1232 // Adjust parameter. 1232 // Adjust parameter.
1233 if (key_tap(KEY_R) || key_tap(KEY_L)) { 1233 if (key_retrig(KEY_R) || key_retrig(KEY_L)) {
1234 int inc; 1234 int inc;
1235 if (key_tap(KEY_L)) { 1235 if (key_retrig(KEY_L)) {
1236 inc = -1; 1236 inc = -1;
1237 } else { 1237 } else {
1238 inc = 1; 1238 inc = 1;
@@ -1264,8 +1264,8 @@ set_param_selection_noise(ChannelNoiseParams *params, InputHandler return_handle
1264 } 1264 }
1265 1265
1266 // Cursor movement. 1266 // Cursor movement.
1267 if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { 1267 if (key_retrig(KEY_LEFT) || key_retrig(KEY_RIGHT)) {
1268 if (key_tap(KEY_RIGHT)) { 1268 if (key_retrig(KEY_RIGHT)) {
1269 if (param_selection_loc == 4) { 1269 if (param_selection_loc == 4) {
1270 param_selection_loc = 0; 1270 param_selection_loc = 0;
1271 } else if (param_selection_loc == 7) { 1271 } else if (param_selection_loc == 7) {
@@ -1297,9 +1297,9 @@ set_param_selection_noise(ChannelNoiseParams *params, InputHandler return_handle
1297 } 1297 }
1298 1298
1299 // Adjust parameter. 1299 // Adjust parameter.
1300 if (key_tap(KEY_R) || key_tap(KEY_L)) { 1300 if (key_retrig(KEY_R) || key_retrig(KEY_L)) {
1301 int inc; 1301 int inc;
1302 if (key_tap(KEY_L)) { 1302 if (key_retrig(KEY_L)) {
1303 inc = -1; 1303 inc = -1;
1304 } else { 1304 } else {
1305 inc = 1; 1305 inc = 1;
@@ -1547,7 +1547,7 @@ handle_trigger_selection(void) {
1547 } 1547 }
1548 } 1548 }
1549 redraw_trigs = true; 1549 redraw_trigs = true;
1550 } else if (key_tap(KEY_L)) { 1550 } else if (key_retrig(KEY_L)) {
1551 s32 inc = -1; 1551 s32 inc = -1;
1552 if (key_hold(KEY_SELECT)) { 1552 if (key_hold(KEY_SELECT)) {
1553 inc = -12; 1553 inc = -12;
@@ -1564,7 +1564,7 @@ handle_trigger_selection(void) {
1564 } 1564 }
1565 } 1565 }
1566 redraw_trigs = true; 1566 redraw_trigs = true;
1567 } else if (key_tap(KEY_R)) { 1567 } else if (key_retrig(KEY_R)) {
1568 s32 inc = 1; 1568 s32 inc = 1;
1569 if (key_hold(KEY_SELECT)) { 1569 if (key_hold(KEY_SELECT)) {
1570 inc = 12; 1570 inc = 12;
@@ -1584,7 +1584,7 @@ handle_trigger_selection(void) {
1584 } 1584 }
1585 1585
1586 // Move trigger cursor. 1586 // Move trigger cursor.
1587 if (key_tap(KEY_LEFT)) { 1587 if (key_retrig(KEY_LEFT)) {
1588 if (key_hold(KEY_B)) { 1588 if (key_hold(KEY_B)) {
1589 if (trig_selection_loc != 0 && trig_selection_loc != 8) { 1589 if (trig_selection_loc != 0 && trig_selection_loc != 8) {
1590 int next_selection_loc = MAX(trig_selection_loc - 1, 0); 1590 int next_selection_loc = MAX(trig_selection_loc - 1, 0);
@@ -1602,7 +1602,7 @@ handle_trigger_selection(void) {
1602 } 1602 }
1603 } 1603 }
1604 redraw_params = true; 1604 redraw_params = true;
1605 } else if (key_tap(KEY_RIGHT)) { 1605 } else if (key_retrig(KEY_RIGHT)) {
1606 if (key_hold(KEY_B)) { 1606 if (key_hold(KEY_B)) {
1607 if (trig_selection_loc != 7 && trig_selection_loc != 15) { 1607 if (trig_selection_loc != 7 && trig_selection_loc != 15) {
1608 int next_selection_loc = MIN(trig_selection_loc + 1, 15); 1608 int next_selection_loc = MIN(trig_selection_loc + 1, 15);