diff options
Diffstat (limited to 'src/sequencer.c')
-rw-r--r-- | src/sequencer.c | 65 |
1 files changed, 36 insertions, 29 deletions
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 | ||
117 | void | 117 | void |
118 | select_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 | |||
140 | void | ||
118 | play_step(void) { | 141 | play_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 | ||
576 | void | 605 | void |
577 | select_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 | |||
599 | void | ||
600 | handle_right_col_selection(void) { | 606 | handle_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; |