From 84f7dd59c87506a29f534a2f6a558799db38d256 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Thu, 24 Aug 2023 17:21:04 +0200 Subject: Add bank queuing like patterns --- src/drawing.c | 3 +++ src/globals.c | 1 + src/main.c | 17 +++++---------- src/sequencer.c | 65 ++++++++++++++++++++++++++++++++------------------------- 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() { if (i == current_bank) { color = COL_FG; } + if (i == next_bank && current_bank != next_bank) { + color = COL_ACC_0; + } u8 x0 = x + x_offset[i]; u8 x1 = x + x_offset[i] + BANK_W; 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; int current_pattern = 0; int next_pattern = 0; int current_bank = 0; +int next_bank = 0; u32 last_trig_loc = 0; u32 last_channel_loc = 0; u32 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. // in all channels. LFO amount? LFO speed? Would need a dedicated page for // configuring LFOs // - Per-channel N steps to create polymeters? -// - Study how to better embed data into the cart that doesn't involve the -// build system to generate .c files. Just use the linker to put binary data -// into the ROM. +// - Channel params should show if there are some already on all triggers and +// modify only the selected parameter, not all of them. // // WIP (1.7) // + Improve "grey" cursor with dithering instead. @@ -52,13 +51,13 @@ WITH REGARD TO THIS SOFTWARE. // + Fix keyboard note drawing bugs. // + Fix stop button behaviour. // + Scale mode for entering notes. +// + Make sure bank switching is queued like patterns. +// - Should scale mode be toggleable? // - Shortcut to quickly exit/enter chain mode. -// - Make sure bank switching is queued like patterns. +// - If we are on sync in, BPM should display SYNC // // - Improve SRAM saving to make room for longer patterns and/or more banks. // - Higher resolution clock to allow for microtiming and more accurate tempo. -// - Multiple pattern chains per bank that we can toggle between, gotta study -// if they fit in the SRAM. // - Add settings for "performance mode" in which banks are not saved by // default while changing patterns. // - Make sure sync works with the same cable for in/out. @@ -67,12 +66,6 @@ WITH REGARD TO THIS SOFTWARE. // - Study more improvements for a "performance mode". // - Add CREDITS to the documentation for now, should probably be a menu item // later. -// -// Bug notes (catbeat): -// -// + Bug: GUI scale disappeared -// + Bug: cut and pasted note on noise voice and showed parameter paste but -// not note, had to push B again for note #include "gba/gba.h" diff --git a/src/sequencer.c b/src/sequencer.c index 0558323..3635657 100644 --- a/src/sequencer.c +++ b/src/sequencer.c @@ -114,6 +114,29 @@ should_play(u8 prob) { return true; } +void +select_bank(int i) { + chain.current = 15; + chain.current = find_next_pattern(); + current_pattern = 0; + next_pattern = 0; + next_bank = i; + clipboard.type = CLIP_EMPTY; + save_bank(current_bank); + metadata.current_pattern = current_pattern; + metadata.current_bank = i; + save_metadata(); + if (current_bank != i) { + load_bank(i); + } + current_bank = i; + redraw_pattern_buttons = true; + redraw_trigs = true; + redraw_channels = true; + redraw_bank_buttons = true; + redraw_bpm = true; +} + void play_step(void) { static s8 pan[4] = {0}; @@ -122,6 +145,9 @@ play_step(void) { current_pattern = next_pattern; redraw_pattern_buttons = true; update_bpm = true; + } else if (current_bank != next_bank && step_counter == 15) { + select_bank(next_bank); + update_bpm = true; } else if (chain.len != 0 && step_counter == 15) { redraw_pattern_buttons = true; update_bpm = true; @@ -528,6 +554,9 @@ toggle_playing(void) { current_pattern = next_pattern; redraw_pattern_buttons = true; } + if (current_bank != next_bank) { + select_bank(next_bank); + } set_time(patterns[current_pattern].bpm); play_step(); } else { @@ -573,29 +602,6 @@ pause_playing(void) { } } -void -select_bank(int i) { - // TODO: queue bank if we are currently playing? - chain.current = 15; - chain.current = find_next_pattern(); - current_pattern = 0; - next_pattern = 0; - clipboard.type = CLIP_EMPTY; - save_bank(current_bank); - metadata.current_pattern = current_pattern; - metadata.current_bank = i; - save_metadata(); - if (current_bank != i) { - load_bank(i); - } - current_bank = i; - redraw_pattern_buttons = true; - redraw_trigs = true; - redraw_channels = true; - redraw_bank_buttons = true; - redraw_bpm = true; -} - void handle_right_col_selection(void) { if (key_tap(KEY_LEFT)) { @@ -721,12 +727,12 @@ handle_right_col_selection(void) { // case R_COL_SCALE: { stop_playing(); } break; // TODO: Should scale be toggleable? case R_COL_STOP: { stop_playing(); } break; case R_COL_PLAY: { pause_playing(); } break; - case R_COL_BANK_A: { select_bank(0); } break; - case R_COL_BANK_B: { select_bank(1); } break; - case R_COL_BANK_C: { select_bank(2); } break; - case R_COL_BANK_D: { select_bank(3); } break; - case R_COL_BANK_E: { select_bank(4); } break; - case R_COL_BANK_F: { select_bank(5); } break; + case R_COL_BANK_A: { if (play_status) { next_bank = 0; } else { select_bank(0); } redraw_bank_buttons = true; } break; + case R_COL_BANK_B: { if (play_status) { next_bank = 1; } else { select_bank(1); } redraw_bank_buttons = true; } break; + case R_COL_BANK_C: { if (play_status) { next_bank = 2; } else { select_bank(2); } redraw_bank_buttons = true; } break; + case R_COL_BANK_D: { if (play_status) { next_bank = 3; } else { select_bank(3); } redraw_bank_buttons = true; } break; + case R_COL_BANK_E: { if (play_status) { next_bank = 4; } else { select_bank(4); } redraw_bank_buttons = true; } break; + case R_COL_BANK_F: { if (play_status) { next_bank = 5; } else { select_bank(5); } redraw_bank_buttons = true; } break; } } } @@ -1439,6 +1445,7 @@ sequencer_init(void) { save_bank(5); } else { current_bank = metadata.current_bank; + next_bank = metadata.current_bank; current_pattern = metadata.current_pattern; next_pattern = metadata.current_pattern; pattern_selection_loc = current_pattern; -- cgit v1.2.1