From 2abcb70459499dc5d729ec47b39bc43718ac6ced Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Mon, 24 Apr 2023 19:13:03 +0200 Subject: Add contextual drawing of piano notes --- src/drawing.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'src/drawing.c') diff --git a/src/drawing.c b/src/drawing.c index 149aa19..3264ad8 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -11,6 +11,10 @@ draw_channel_sprite(size_t x, size_t y, u8 clr, u8 idx) { void draw_channels(void) { + // NOTE: Different channel colors can be interesting. + u8 colors[] = { + 1, 1, 1, 1, + }; for (size_t i = 0; i < 4; i++) { bool active = false; switch (i) { @@ -19,7 +23,7 @@ draw_channels(void) { case 2: { active = patterns[pattern_selection_loc].ch3.active; } break; case 3: { active = patterns[pattern_selection_loc].ch4.active; } break; } - u8 clr = active ? COL_FG : COL_GREY; + u8 clr = active ? colors[i] : COL_GREY; size_t y = CHAN_START_Y + i * CHAN_OFFSET_Y; draw_channel_sprite(CHAN_START_X, y, clr, i); } @@ -1107,3 +1111,56 @@ draw_cursors(void) { draw_params_cursor(param_selection_loc, COL_CURSOR); } } + +TriggerNote * get_current_trig(void); + +void +draw_piano_notes(void) { + draw_piano(); + if (input_handler == handle_channel_selection) { + // Show note on current channel only. + Pattern *pat = &patterns[current_pattern]; + u8 step = (step_counter - 1) % 16; + switch (channel_selection_loc) { + case 0: { + if (pat->ch1.active && pat->ch1.notes[step].active) { + draw_note(pat->ch1.notes[step].note, COL_NOTE_PRESSED); + } + } break; + case 1: { + if (pat->ch2.active && pat->ch2.notes[step].active) { + draw_note(pat->ch2.notes[step].note, COL_NOTE_PRESSED); + } + } break; + case 2: { + if (pat->ch3.active && pat->ch3.notes[step].active) { + draw_note(pat->ch3.notes[step].note, COL_NOTE_PRESSED); + } + } break; + } + + } else if (input_handler == handle_trigger_selection || + input_handler == handle_param_selection_sq1 || + input_handler == handle_param_selection_sq2 || + input_handler == handle_param_selection_wave || + input_handler == handle_param_selection_noise) { + // Show currently selected trigger note. + TriggerNote *trig = get_current_trig(); + draw_note(trig->note, COL_NOTE_PRESSED); + } else { + // Show last/current played notes in all channels. + if (play_status == 1) { + Pattern *pat = &patterns[current_pattern]; + u8 step = (step_counter - 1) % 16; + if (pat->ch3.active && pat->ch3.notes[step].active) { + draw_note(pat->ch3.notes[step].note, COL_NOTE_PRESSED); + } + if (pat->ch2.active && pat->ch2.notes[step].active) { + draw_note(pat->ch2.notes[step].note, COL_NOTE_PRESSED); + } + if (pat->ch1.active && pat->ch1.notes[step].active) { + draw_note(pat->ch1.notes[step].note, COL_NOTE_PRESSED); + } + } + } +} -- cgit v1.2.1