aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-08-24 17:21:04 +0200
committerBad Diode <bd@badd10de.dev>2023-08-24 17:21:04 +0200
commit84f7dd59c87506a29f534a2f6a558799db38d256 (patch)
treec3c9450e4566931a23f4be50abdb098c3b546ae4
parent1e8c7a50b4295383b0d16ab105a4b8f26bbaa438 (diff)
downloadstepper-84f7dd59c87506a29f534a2f6a558799db38d256.tar.gz
stepper-84f7dd59c87506a29f534a2f6a558799db38d256.zip
Add bank queuing like patterns
-rw-r--r--src/drawing.c3
-rw-r--r--src/globals.c1
-rw-r--r--src/main.c17
-rw-r--r--src/sequencer.c65
4 files changed, 45 insertions, 41 deletions
diff --git a/src/drawing.c b/src/drawing.c
index 3aa5de8..a432285 100644
--- a/src/drawing.c
+++ b/src/drawing.c
@@ -267,6 +267,9 @@ draw_bank_buttons() {
267 if (i == current_bank) { 267 if (i == current_bank) {
268 color = COL_FG; 268 color = COL_FG;
269 } 269 }
270 if (i == next_bank && current_bank != next_bank) {
271 color = COL_ACC_0;
272 }
270 u8 x0 = x + x_offset[i]; 273 u8 x0 = x + x_offset[i];
271 u8 x1 = x + x_offset[i] + BANK_W; 274 u8 x1 = x + x_offset[i] + BANK_W;
272 u8 y0 = y + y_offset[i]; 275 u8 y0 = y + y_offset[i];
diff --git a/src/globals.c b/src/globals.c
index 23012c8..b94cb11 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -12,6 +12,7 @@ int play_status = 0;
12int current_pattern = 0; 12int current_pattern = 0;
13int next_pattern = 0; 13int next_pattern = 0;
14int current_bank = 0; 14int current_bank = 0;
15int next_bank = 0;
15u32 last_trig_loc = 0; 16u32 last_trig_loc = 0;
16u32 last_channel_loc = 0; 17u32 last_channel_loc = 0;
17u32 last_pattern_loc = 0; 18u32 last_pattern_loc = 0;
diff --git a/src/main.c b/src/main.c
index 0efcc73..e3c60f8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -34,9 +34,8 @@ WITH REGARD TO THIS SOFTWARE.
34// in all channels. LFO amount? LFO speed? Would need a dedicated page for 34// in all channels. LFO amount? LFO speed? Would need a dedicated page for
35// configuring LFOs 35// configuring LFOs
36// - Per-channel N steps to create polymeters? 36// - Per-channel N steps to create polymeters?
37// - Study how to better embed data into the cart that doesn't involve the 37// - Channel params should show if there are some already on all triggers and
38// build system to generate .c files. Just use the linker to put binary data 38// modify only the selected parameter, not all of them.
39// into the ROM.
40// 39//
41// WIP (1.7) 40// WIP (1.7)
42// + Improve "grey" cursor with dithering instead. 41// + Improve "grey" cursor with dithering instead.
@@ -52,13 +51,13 @@ WITH REGARD TO THIS SOFTWARE.
52// + Fix keyboard note drawing bugs. 51// + Fix keyboard note drawing bugs.
53// + Fix stop button behaviour. 52// + Fix stop button behaviour.
54// + Scale mode for entering notes. 53// + Scale mode for entering notes.
54// + Make sure bank switching is queued like patterns.
55// - Should scale mode be toggleable?
55// - Shortcut to quickly exit/enter chain mode. 56// - Shortcut to quickly exit/enter chain mode.
56// - Make sure bank switching is queued like patterns. 57// - If we are on sync in, BPM should display SYNC
57// 58//
58// - Improve SRAM saving to make room for longer patterns and/or more banks. 59// - Improve SRAM saving to make room for longer patterns and/or more banks.
59// - Higher resolution clock to allow for microtiming and more accurate tempo. 60// - Higher resolution clock to allow for microtiming and more accurate tempo.
60// - Multiple pattern chains per bank that we can toggle between, gotta study
61// if they fit in the SRAM.
62// - Add settings for "performance mode" in which banks are not saved by 61// - Add settings for "performance mode" in which banks are not saved by
63// default while changing patterns. 62// default while changing patterns.
64// - Make sure sync works with the same cable for in/out. 63// - Make sure sync works with the same cable for in/out.
@@ -67,12 +66,6 @@ WITH REGARD TO THIS SOFTWARE.
67// - Study more improvements for a "performance mode". 66// - Study more improvements for a "performance mode".
68// - Add CREDITS to the documentation for now, should probably be a menu item 67// - Add CREDITS to the documentation for now, should probably be a menu item
69// later. 68// later.
70//
71// Bug notes (catbeat):
72//
73// + Bug: GUI scale disappeared
74// + Bug: cut and pasted note on noise voice and showed parameter paste but
75// not note, had to push B again for note
76 69
77#include "gba/gba.h" 70#include "gba/gba.h"
78 71
diff --git a/src/sequencer.c b/src/sequencer.c
index 0558323..3635657 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -115,6 +115,29 @@ should_play(u8 prob) {
115} 115}
116 116
117void 117void
118select_bank(int i) {
119 chain.current = 15;
120 chain.current = find_next_pattern();
121 current_pattern = 0;
122 next_pattern = 0;
123 next_bank = i;
124 clipboard.type = CLIP_EMPTY;
125 save_bank(current_bank);
126 metadata.current_pattern = current_pattern;
127 metadata.current_bank = i;
128 save_metadata();
129 if (current_bank != i) {
130 load_bank(i);
131 }
132 current_bank = i;
133 redraw_pattern_buttons = true;
134 redraw_trigs = true;
135 redraw_channels = true;
136 redraw_bank_buttons = true;
137 redraw_bpm = true;
138}
139
140void
118play_step(void) { 141play_step(void) {
119 static s8 pan[4] = {0}; 142 static s8 pan[4] = {0};
120 Pattern *pat = &patterns[current_pattern]; 143 Pattern *pat = &patterns[current_pattern];
@@ -122,6 +145,9 @@ play_step(void) {
122 current_pattern = next_pattern; 145 current_pattern = next_pattern;
123 redraw_pattern_buttons = true; 146 redraw_pattern_buttons = true;
124 update_bpm = true; 147 update_bpm = true;
148 } else if (current_bank != next_bank && step_counter == 15) {
149 select_bank(next_bank);
150 update_bpm = true;
125 } else if (chain.len != 0 && step_counter == 15) { 151 } else if (chain.len != 0 && step_counter == 15) {
126 redraw_pattern_buttons = true; 152 redraw_pattern_buttons = true;
127 update_bpm = true; 153 update_bpm = true;
@@ -528,6 +554,9 @@ toggle_playing(void) {
528 current_pattern = next_pattern; 554 current_pattern = next_pattern;
529 redraw_pattern_buttons = true; 555 redraw_pattern_buttons = true;
530 } 556 }
557 if (current_bank != next_bank) {
558 select_bank(next_bank);
559 }
531 set_time(patterns[current_pattern].bpm); 560 set_time(patterns[current_pattern].bpm);
532 play_step(); 561 play_step();
533 } else { 562 } else {
@@ -574,29 +603,6 @@ pause_playing(void) {
574} 603}
575 604
576void 605void
577select_bank(int i) {
578 // TODO: queue bank if we are currently playing?
579 chain.current = 15;
580 chain.current = find_next_pattern();
581 current_pattern = 0;
582 next_pattern = 0;
583 clipboard.type = CLIP_EMPTY;
584 save_bank(current_bank);
585 metadata.current_pattern = current_pattern;
586 metadata.current_bank = i;
587 save_metadata();
588 if (current_bank != i) {
589 load_bank(i);
590 }
591 current_bank = i;
592 redraw_pattern_buttons = true;
593 redraw_trigs = true;
594 redraw_channels = true;
595 redraw_bank_buttons = true;
596 redraw_bpm = true;
597}
598
599void
600handle_right_col_selection(void) { 606handle_right_col_selection(void) {
601 if (key_tap(KEY_LEFT)) { 607 if (key_tap(KEY_LEFT)) {
602 switch (right_col_selection_loc) { 608 switch (right_col_selection_loc) {
@@ -721,12 +727,12 @@ handle_right_col_selection(void) {
721 // case R_COL_SCALE: { stop_playing(); } break; // TODO: Should scale be toggleable? 727 // case R_COL_SCALE: { stop_playing(); } break; // TODO: Should scale be toggleable?
722 case R_COL_STOP: { stop_playing(); } break; 728 case R_COL_STOP: { stop_playing(); } break;
723 case R_COL_PLAY: { pause_playing(); } break; 729 case R_COL_PLAY: { pause_playing(); } break;
724 case R_COL_BANK_A: { select_bank(0); } break; 730 case R_COL_BANK_A: { if (play_status) { next_bank = 0; } else { select_bank(0); } redraw_bank_buttons = true; } break;
725 case R_COL_BANK_B: { select_bank(1); } break; 731 case R_COL_BANK_B: { if (play_status) { next_bank = 1; } else { select_bank(1); } redraw_bank_buttons = true; } break;
726 case R_COL_BANK_C: { select_bank(2); } break; 732 case R_COL_BANK_C: { if (play_status) { next_bank = 2; } else { select_bank(2); } redraw_bank_buttons = true; } break;
727 case R_COL_BANK_D: { select_bank(3); } break; 733 case R_COL_BANK_D: { if (play_status) { next_bank = 3; } else { select_bank(3); } redraw_bank_buttons = true; } break;
728 case R_COL_BANK_E: { select_bank(4); } break; 734 case R_COL_BANK_E: { if (play_status) { next_bank = 4; } else { select_bank(4); } redraw_bank_buttons = true; } break;
729 case R_COL_BANK_F: { select_bank(5); } break; 735 case R_COL_BANK_F: { if (play_status) { next_bank = 5; } else { select_bank(5); } redraw_bank_buttons = true; } break;
730 } 736 }
731 } 737 }
732} 738}
@@ -1439,6 +1445,7 @@ sequencer_init(void) {
1439 save_bank(5); 1445 save_bank(5);
1440 } else { 1446 } else {
1441 current_bank = metadata.current_bank; 1447 current_bank = metadata.current_bank;
1448 next_bank = metadata.current_bank;
1442 current_pattern = metadata.current_pattern; 1449 current_pattern = metadata.current_pattern;
1443 next_pattern = metadata.current_pattern; 1450 next_pattern = metadata.current_pattern;
1444 pattern_selection_loc = current_pattern; 1451 pattern_selection_loc = current_pattern;