From c7c789096ec6aa31ed98396fd066f1b39dfa8e01 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Mon, 24 Apr 2023 12:16:55 +0200 Subject: Fix copy-paste behaviour when copying channels --- src/clipboard.c | 9 +++++ src/main.c | 2 + src/sequencer.c | 117 ++++++++++++++++++++++++++++++++++---------------------- 3 files changed, 83 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/clipboard.c b/src/clipboard.c index 7491d4b..d802645 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -175,11 +175,13 @@ clipboard_paste(void) { case 0: { for (size_t i = 0; i < 16; i++) { pat_dst->ch1.notes[i] = pat_src->ch1.notes[i]; + pat_dst->ch1.params[i] = pat_src->ch1.params[i]; } } break; case 1: { for (size_t i = 0; i < 16; i++) { pat_dst->ch2.notes[i] = pat_src->ch1.notes[i]; + pat_dst->ch2.params[i] = pat_src->ch1.params[i]; } } break; case 2: { @@ -199,11 +201,16 @@ clipboard_paste(void) { case 0: { for (size_t i = 0; i < 16; i++) { pat_dst->ch1.notes[i] = pat_src->ch2.notes[i]; + pat_dst->ch1.params[i].env_volume = pat_src->ch2.params[i].env_volume; + pat_dst->ch1.params[i].env_time = pat_src->ch2.params[i].env_time; + pat_dst->ch1.params[i].env_direction = pat_src->ch2.params[i].env_direction; + pat_dst->ch1.params[i].duty_cycle = pat_src->ch2.params[i].duty_cycle; } } break; case 1: { for (size_t i = 0; i < 16; i++) { pat_dst->ch2.notes[i] = pat_src->ch2.notes[i]; + pat_dst->ch2.params[i] = pat_src->ch2.params[i]; } } break; case 2: { @@ -233,6 +240,7 @@ clipboard_paste(void) { case 2: { for (size_t i = 0; i < 16; i++) { pat_dst->ch3.notes[i] = pat_src->ch3.notes[i]; + pat_dst->ch3.params[i] = pat_src->ch3.params[i]; } } break; case 3: { @@ -262,6 +270,7 @@ clipboard_paste(void) { case 3: { for (size_t i = 0; i < 16; i++) { pat_dst->ch4.notes[i] = pat_src->ch4.notes[i]; + pat_dst->ch4.params[i] = pat_src->ch4.params[i]; } } break; } diff --git a/src/main.c b/src/main.c index 3cc5345..54f14b4 100644 --- a/src/main.c +++ b/src/main.c @@ -32,6 +32,8 @@ WITH REGARD TO THIS SOFTWARE. // Advanced // - Sync via MIDI via arduinoboy or something similar. // - Sync via CV by using the link cable. +// +// FIXME: Update readme and project pages with control changes. #include "gba/gba.h" diff --git a/src/sequencer.c b/src/sequencer.c index 2940b25..4528e0f 100644 --- a/src/sequencer.c +++ b/src/sequencer.c @@ -186,21 +186,31 @@ get_current_trig(void) { void handle_channel_selection(void) { if (key_tap(KEY_B)) { - switch (channel_selection_loc) { - case 0: { - patterns[pattern_selection_loc].ch1.active ^= 1; - } break; - case 1: { - patterns[pattern_selection_loc].ch2.active ^= 1; - } break; - case 2: { - patterns[pattern_selection_loc].ch3.active ^= 1; - } break; - case 3: { - patterns[pattern_selection_loc].ch4.active ^= 1; - } break; + if (key_hold(KEY_SELECT)) { + clipboard_copy(); + } else { + switch (channel_selection_loc) { + case 0: { + patterns[pattern_selection_loc].ch1.active ^= 1; + } break; + case 1: { + patterns[pattern_selection_loc].ch2.active ^= 1; + } break; + case 2: { + patterns[pattern_selection_loc].ch3.active ^= 1; + } break; + case 3: { + patterns[pattern_selection_loc].ch4.active ^= 1; + } break; + } + redraw_channels = true; + } + } else { + if (key_tap(KEY_A)) { + if (key_hold(KEY_SELECT)) { + clipboard_paste(); + } } - redraw_channels = true; } if (key_tap(KEY_RIGHT)) { trig_selection_loc = 0; @@ -384,8 +394,17 @@ handle_right_col_selection(void) { void handle_pattern_selection(void) { if (key_tap(KEY_B)) { - next_pattern = pattern_selection_loc; - redraw_pattern_buttons = true; + if (key_hold(KEY_SELECT)) { + clipboard_copy(); + } else { + next_pattern = pattern_selection_loc; + redraw_pattern_buttons = true; + } + } + if (key_tap(KEY_A)) { + if (key_hold(KEY_SELECT)) { + clipboard_paste(); + } } if (key_tap(KEY_RIGHT)) { input_handler = handle_channel_selection; @@ -773,9 +792,13 @@ handle_trigger_selection(void) { TriggerNote *trig = get_current_trig(); if (key_tap(KEY_B)) { - // Toggle trigger. - trig->active ^= 1; - redraw_trigs = true; + if (key_hold(KEY_SELECT)) { + clipboard_copy(); + } else { + // Toggle trigger. + trig->active ^= 1; + redraw_trigs = true; + } } else if (key_tap(KEY_L)) { // Decrease note. if (trig->active) { @@ -819,23 +842,27 @@ handle_trigger_selection(void) { redraw_params = true; redraw_piano_note = true; } else if (key_tap(KEY_A)) { - // Switch to parameter selection. - switch (channel_selection_loc) { - case 0: { - input_handler = handle_param_selection_sq1; - } break; - case 1: { - input_handler = handle_param_selection_sq2; - } break; - case 2: { - input_handler = handle_param_selection_wave; - } break; - case 3: { - input_handler = handle_param_selection_noise; - } break; + if (key_hold(KEY_SELECT)) { + clipboard_paste(); + } else { + // Switch to parameter selection. + switch (channel_selection_loc) { + case 0: { + input_handler = handle_param_selection_sq1; + } break; + case 1: { + input_handler = handle_param_selection_sq2; + } break; + case 2: { + input_handler = handle_param_selection_wave; + } break; + case 3: { + input_handler = handle_param_selection_noise; + } break; + } + redraw_params = true; + redraw_piano_note = true; } - redraw_params = true; - redraw_piano_note = true; } } @@ -850,17 +877,17 @@ handle_sequencer_input(void) { input_handler == handle_param_selection_wave || input_handler == handle_param_selection_noise) { clipboard_copy(); - input_handler(); - } - if (input_handler == handle_right_col_selection) { - input_handler(); - } - // Clipboard combo. - else if (key_tap(KEY_A)) { - clipboard_paste(); - } else if (key_tap(KEY_B)){ - clipboard_copy(); } + input_handler(); + // // if (input_handler == handle_right_col_selection) { + // // input_handler(); + // // } + // // // Clipboard combo. + // // else if (key_tap(KEY_A)) { + // // clipboard_paste(); + // // } else if (key_tap(KEY_B)){ + // // clipboard_copy(); + // // } } else { input_handler(); } -- cgit v1.2.1