From ac038887279d43f0a8c346b4392619dfe2e6084a Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Mon, 24 Apr 2023 14:58:59 +0200 Subject: Add per-channel parameter adjustment control --- src/sequencer.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 12 deletions(-) (limited to 'src/sequencer.c') diff --git a/src/sequencer.c b/src/sequencer.c index 1280f5f..b5339fa 100644 --- a/src/sequencer.c +++ b/src/sequencer.c @@ -468,13 +468,13 @@ handle_pattern_selection(void) { } } -void +bool set_param_selection_sq1(size_t i, InputHandler return_handler) { // Go back to trigger selection. if (key_released(KEY_A)) { input_handler = return_handler; redraw_params = true; - return; + return false; } // Cursor movement. @@ -496,7 +496,9 @@ set_param_selection_sq1(size_t i, InputHandler return_handler) { } param_selection_loc = CLAMP(loc + inc, 0, 6); redraw_params = true; + return false; } + if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { int inc = 0; int loc = param_selection_loc; @@ -519,6 +521,7 @@ set_param_selection_sq1(size_t i, InputHandler return_handler) { } param_selection_loc = CLAMP(loc + inc, 0, 6); redraw_params = true; + return false; } // Adjust parameter. @@ -555,16 +558,19 @@ set_param_selection_sq1(size_t i, InputHandler return_handler) { } break; } redraw_params = true; + return true; } + + return false; } -void +bool set_param_selection_sq2(size_t i, InputHandler return_handler) { // Go back to trigger selection. if (key_released(KEY_A)) { input_handler = return_handler; redraw_params = true; - return; + return false; } // Cursor movement. @@ -578,6 +584,7 @@ set_param_selection_sq2(size_t i, InputHandler return_handler) { } param_selection_loc = CLAMP(loc + inc, 0, 3); redraw_params = true; + return false; } // Adjust parameter. @@ -605,10 +612,13 @@ set_param_selection_sq2(size_t i, InputHandler return_handler) { } break; } redraw_params = true; + return true; } + + return false; } -void +bool set_param_selection_wave(size_t i, InputHandler return_handler) { Pattern *pat = &patterns[pattern_selection_loc]; @@ -616,7 +626,7 @@ set_param_selection_wave(size_t i, InputHandler return_handler) { if (key_released(KEY_A)) { input_handler = return_handler; redraw_params = true; - return; + return false; } // Cursor movement. @@ -644,7 +654,9 @@ set_param_selection_wave(size_t i, InputHandler return_handler) { } param_selection_loc = CLAMP(loc + inc, 0, 73); redraw_params = true; + return false; } + if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { int inc = 0; int loc = param_selection_loc; @@ -699,6 +711,7 @@ set_param_selection_wave(size_t i, InputHandler return_handler) { } param_selection_loc = CLAMP(loc + inc, 0, 73); redraw_params = true; + return false; } // Adjust parameter. @@ -779,16 +792,19 @@ set_param_selection_wave(size_t i, InputHandler return_handler) { *wave_volume = CLAMP(*wave_volume + inc, 0, 4); } redraw_params = true; + return true; } + + return false; } -void +bool set_param_selection_noise(size_t i, InputHandler return_handler) { // Go back to trigger selection. if (key_released(KEY_A)) { input_handler = return_handler; redraw_params = true; - return; + return false; } // Cursor movement. @@ -802,6 +818,7 @@ set_param_selection_noise(size_t i, InputHandler return_handler) { } param_selection_loc = CLAMP(loc + inc, 0, 3); redraw_params = true; + return false; } // Adjust parameter. @@ -829,27 +846,50 @@ set_param_selection_noise(size_t i, InputHandler return_handler) { } break; } redraw_params = true; + return true; } + + return false; } void handle_param_selection_ch1() { - set_param_selection_sq1(16, handle_channel_selection); + Pattern *pat = &patterns[pattern_selection_loc]; + if (set_param_selection_sq1(16, handle_channel_selection)) { + for (size_t i = 0; i < 16; i++) { + pat->ch1.params[i] = pat->ch1.params[16]; + } + } } void handle_param_selection_ch2() { - set_param_selection_sq2(16, handle_channel_selection); + Pattern *pat = &patterns[pattern_selection_loc]; + if (set_param_selection_sq2(16, handle_channel_selection)) { + for (size_t i = 0; i < 16; i++) { + pat->ch2.params[i] = pat->ch2.params[16]; + } + } } void handle_param_selection_ch3() { - set_param_selection_wave(16, handle_channel_selection); + Pattern *pat = &patterns[pattern_selection_loc]; + if (set_param_selection_wave(16, handle_channel_selection)) { + for (size_t i = 0; i < 16; i++) { + pat->ch3.params[i] = pat->ch3.params[16]; + } + } } void handle_param_selection_ch4() { - set_param_selection_noise(16, handle_channel_selection); + Pattern *pat = &patterns[pattern_selection_loc]; + if (set_param_selection_noise(16, handle_channel_selection)) { + for (size_t i = 0; i < 16; i++) { + pat->ch4.params[i] = pat->ch4.params[16]; + } + } } void -- cgit v1.2.1