aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-04-04 11:08:58 +0200
committerBad Diode <bd@badd10de.dev>2023-04-04 11:08:58 +0200
commit912c37a54c13aca6bbdf290984f7eeccad4ccc0b (patch)
tree36840d3c1f060939f8180880e49615e236bedc34
parenta3f5ae41e96e4a0b77870483864f660a797ea506 (diff)
downloadstepper-912c37a54c13aca6bbdf290984f7eeccad4ccc0b.tar.gz
stepper-912c37a54c13aca6bbdf290984f7eeccad4ccc0b.zip
Add UI for bank selection
-rw-r--r--src/sequencer.c62
1 files changed, 54 insertions, 8 deletions
diff --git a/src/sequencer.c b/src/sequencer.c
index 587a720..c4a1d2a 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -6,7 +6,7 @@
6// - Copy paste trigs/notes/params 6// - Copy paste trigs/notes/params
7// - Different banks for storing patterns 7// - Different banks for storing patterns
8// - Finish noise channel (parameter editing) 8// - Finish noise channel (parameter editing)
9 9void set_time(int bpm);
10 10
11// 11//
12// Color indexes. 12// Color indexes.
@@ -69,6 +69,9 @@
69#define STOP_START_Y (TRIG_START_Y + 14) 69#define STOP_START_Y (TRIG_START_Y + 14)
70#define PLAY_STOP_H (10) 70#define PLAY_STOP_H (10)
71 71
72#define BANK_START_X (R_SIDEBAR_X + 5)
73#define BANK_START_Y (PAT_START_Y)
74
72#define SEQ_N_CHANNELS 4 75#define SEQ_N_CHANNELS 4
73 76
74// 77//
@@ -207,11 +210,16 @@ int right_col_selection_loc = 0;
207int play_status = 0; 210int play_status = 0;
208static int current_pattern = 0; 211static int current_pattern = 0;
209static int next_pattern = 0; 212static int next_pattern = 0;
213static int current_bank = 0;
210 214
211enum RIGHT_COL_LOC { 215enum RIGHT_COL_LOC {
212 R_COL_BPM = 0, 216 R_COL_BPM = 0,
213 R_COL_STOP = 1, 217 R_COL_STOP = 1,
214 R_COL_PLAY = 2, 218 R_COL_PLAY = 2,
219 R_COL_BANK_D = 3,
220 R_COL_BANK_C = 4,
221 R_COL_BANK_B = 5,
222 R_COL_BANK_A = 6,
215}; 223};
216 224
217typedef struct TriggerNote { 225typedef struct TriggerNote {
@@ -426,7 +434,7 @@ typedef struct Pattern {
426 ChannelSquare ch2; 434 ChannelSquare ch2;
427 ChannelWave ch3; 435 ChannelWave ch3;
428 ChannelNoise ch4; 436 ChannelNoise ch4;
429 u8 bpm; 437 int bpm;
430 u8 bank; 438 u8 bank;
431} Pattern; 439} Pattern;
432 440
@@ -562,6 +570,26 @@ draw_right_col_cursor(u8 clr) {
562 x1 = x0 + R_COL_W; 570 x1 = x0 + R_COL_W;
563 y = PLAY_START_Y + PLAY_STOP_H + 2; 571 y = PLAY_START_Y + PLAY_STOP_H + 2;
564 } break; 572 } break;
573 case R_COL_BANK_A: {
574 x0 = BANK_START_X;
575 x1 = x0 + PAT_W;
576 y = BANK_START_Y + PAT_H + 2;
577 } break;
578 case R_COL_BANK_B: {
579 x0 = BANK_START_X;
580 x1 = x0 + PAT_W;
581 y = BANK_START_Y + PAT_H + 2 + 1 * PAT_OFFSET_Y;
582 } break;
583 case R_COL_BANK_C: {
584 x0 = BANK_START_X;
585 x1 = x0 + PAT_W;
586 y = BANK_START_Y + PAT_H + 2 + 2 * PAT_OFFSET_Y;
587 } break;
588 case R_COL_BANK_D: {
589 x0 = BANK_START_X;
590 x1 = x0 + PAT_W;
591 y = BANK_START_Y + PAT_H + 2 + 3 * PAT_OFFSET_Y;
592 } break;
565 } 593 }
566 draw_line(x0, y, x1, y, clr); 594 draw_line(x0, y, x1, y, clr);
567} 595}
@@ -578,16 +606,15 @@ draw_current_step(u8 col) {
578 606
579void 607void
580draw_bank_buttons() { 608draw_bank_buttons() {
581 size_t x = R_SIDEBAR_X + 5; 609 size_t x = BANK_START_X;
582 size_t y = PAT_START_Y; 610 size_t y = BANK_START_Y;
583 txt_drawf_small("BANK", x - 2, y - 10, 4, COL_FG); 611 txt_drawf_small("BANK", x - 2, y - 10, 4, COL_FG);
584 char bank_names[] = { 612 char bank_names[] = {
585 'A', 'B', 'C', 'D', 613 'A', 'B', 'C', 'D',
586 }; 614 };
587 for (int i = 0; i < 4; i++) { 615 for (int i = 0; i < 4; i++) {
588 int color = COL_GREY; 616 int color = COL_GREY;
589 if (i == current_pattern) { 617 if (i == current_bank) {
590 // TODO: current bank.
591 color = COL_FG; 618 color = COL_FG;
592 } 619 }
593 draw_filled_rect(x, y, x + PAT_W, y + PAT_H, COL_BG); 620 draw_filled_rect(x, y, x + PAT_W, y + PAT_H, COL_BG);
@@ -1789,13 +1816,13 @@ handle_right_col_selection(void) {
1789 draw_note(trig->note, COL_NOTE_PRESSED); 1816 draw_note(trig->note, COL_NOTE_PRESSED);
1790 draw_parameters(); 1817 draw_parameters();
1791 } else if (key_tap(KEY_UP)) { 1818 } else if (key_tap(KEY_UP)) {
1792 if (right_col_selection_loc < 2) { 1819 if (right_col_selection_loc < R_COL_BANK_A) {
1793 draw_right_col_cursor(COL_BG); 1820 draw_right_col_cursor(COL_BG);
1794 right_col_selection_loc++; 1821 right_col_selection_loc++;
1795 draw_right_col_cursor(COL_CURSOR); 1822 draw_right_col_cursor(COL_CURSOR);
1796 } 1823 }
1797 } else if (key_tap(KEY_DOWN)) { 1824 } else if (key_tap(KEY_DOWN)) {
1798 if (right_col_selection_loc > 0) { 1825 if (right_col_selection_loc > R_COL_BPM) {
1799 draw_right_col_cursor(COL_BG); 1826 draw_right_col_cursor(COL_BG);
1800 right_col_selection_loc--; 1827 right_col_selection_loc--;
1801 draw_right_col_cursor(COL_CURSOR); 1828 draw_right_col_cursor(COL_CURSOR);
@@ -1834,6 +1861,25 @@ handle_right_col_selection(void) {
1834 case R_COL_PLAY: { 1861 case R_COL_PLAY: {
1835 pause_playing(); 1862 pause_playing();
1836 } break; 1863 } break;
1864 // TODO: stop playing
1865 // TODO: reset cursors if applicable
1866 // TODO: load bank from sram
1867 case R_COL_BANK_A: {
1868 current_bank = 0;
1869 draw_bank_buttons();
1870 } break;
1871 case R_COL_BANK_B: {
1872 current_bank = 1;
1873 draw_bank_buttons();
1874 } break;
1875 case R_COL_BANK_C: {
1876 current_bank = 2;
1877 draw_bank_buttons();
1878 } break;
1879 case R_COL_BANK_D: {
1880 current_bank = 3;
1881 draw_bank_buttons();
1882 } break;
1837 } 1883 }
1838 } 1884 }
1839} 1885}