From fcef6e404587accd09439739a7e660f1d94069a1 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sat, 6 Jan 2024 16:35:53 +0100 Subject: Add more sync in options --- src/drawing.c | 6 +++++- src/main.c | 3 ++- src/sequencer.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- src/settings.c | 21 ++++++++++++++++++--- src/settings.h | 12 ++++++++++-- 5 files changed, 84 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/drawing.c b/src/drawing.c index 8226d62..048b4de 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -418,7 +418,11 @@ draw_bpm() { draw_rect(x, y, x + R_COL_W - 2, y + BPM_H - 3, COL_FG); txt_drawf_small("BPM", x + 7, y - 10, COL_FG); - if (settings.sync == SYNC_IN_LINK) { + if (settings.sync == SYNC_IN_LINK_96BPQ || + settings.sync == SYNC_IN_LINK_48BPQ || + settings.sync == SYNC_IN_LINK_24BPQ || + settings.sync == SYNC_IN_LINK_12BPQ || + settings.sync == SYNC_IN_LINK_4BPQ) { txt_drawf("SYNC", x + 2, y + 2, COL_FG); } else { // Make sure its horizontally centered if only 2 digits diff --git a/src/main.c b/src/main.c index a6d02e1..0a2c22d 100644 --- a/src/main.c +++ b/src/main.c @@ -16,9 +16,10 @@ WITH REGARD TO THIS SOFTWARE. // + Look back again at the emulator issues... (I give up) // + Sync via MIDI with the Analogue cables. // + Fix bank switching behaviour (bug) +// + Add more sync options // - Fix any bugs we currently have // - Add an envelope to ch3, would need to work with a timer in order to make -// it work I think. +// it work I think (Can reuse the 96bpq sequencer timer for this). // - Hold L/R retriggers at short intervals? // - Channel params should show if there are some already on all triggers and // modify only the selected parameter, not all of them. diff --git a/src/sequencer.c b/src/sequencer.c index 9f7f1ad..e452822 100644 --- a/src/sequencer.c +++ b/src/sequencer.c @@ -362,7 +362,11 @@ sequencer_tick(void) { void set_time(int bpm) { - if (settings.sync == SYNC_IN_LINK) { + if (settings.sync == SYNC_IN_LINK_96BPQ || + settings.sync == SYNC_IN_LINK_48BPQ || + settings.sync == SYNC_IN_LINK_24BPQ || + settings.sync == SYNC_IN_LINK_12BPQ || + settings.sync == SYNC_IN_LINK_4BPQ) { return; } // We use a high resolution 96 PPQ clock for sequencing. With the following @@ -552,7 +556,11 @@ toggle_playing(void) { current_pattern = next_pattern; } - if (settings.sync == SYNC_IN_LINK) { + if (settings.sync == SYNC_IN_LINK_96BPQ || + settings.sync == SYNC_IN_LINK_48BPQ || + settings.sync == SYNC_IN_LINK_24BPQ || + settings.sync == SYNC_IN_LINK_12BPQ || + settings.sync == SYNC_IN_LINK_4BPQ) { return; } @@ -1503,17 +1511,54 @@ handle_sequencer_input(void) { } void -serial_irq(void) { +sync_in_96(void) { if (play_status) { - // 12bpq -> 96bpq? + sequencer_tick(); + } +} + +void +sync_in_48(void) { + if (play_status) { + // 48bpq -> 96bpq. + sequencer_tick(); + sequencer_tick(); + } +} + +void +sync_in_24(void) { + if (play_status) { + // 24bpq -> 96bpq. + sequencer_tick(); sequencer_tick(); sequencer_tick(); sequencer_tick(); + } +} + +void +sync_in_12(void) { + if (play_status) { + // 12bpq -> 96bpq. + sequencer_tick(); + sequencer_tick(); sequencer_tick(); sequencer_tick(); sequencer_tick(); sequencer_tick(); sequencer_tick(); + sequencer_tick(); + } +} + +void +sync_in_4(void) { + if (play_status) { + // 4bpq -> 96bpq. + for (size_t i = 0; i < 24; i++) { + sequencer_tick(); + } } } diff --git a/src/settings.c b/src/settings.c index 374618c..406abe3 100644 --- a/src/settings.c +++ b/src/settings.c @@ -8,15 +8,30 @@ static Settings settings = { }; static int settings_cursor_loc = 0; -void serial_irq(void); +void sync_in_96(void); +void sync_in_48(void); +void sync_in_24(void); +void sync_in_12(void); +void sync_in_4(void); void stop_sound(void); void toggle_playing(void); void set_audio_settings(void) { stop_sound(); - if (settings.sync == SYNC_IN_LINK) { - irs_set(IRQ_SERIAL, serial_irq); + if (settings.sync == SYNC_IN_LINK_96BPQ || + settings.sync == SYNC_IN_LINK_48BPQ || + settings.sync == SYNC_IN_LINK_24BPQ || + settings.sync == SYNC_IN_LINK_12BPQ || + settings.sync == SYNC_IN_LINK_4BPQ) { + switch (settings.sync) { + case SYNC_IN_LINK_96BPQ: { irs_set(IRQ_SERIAL, sync_in_96); } break; + case SYNC_IN_LINK_48BPQ: { irs_set(IRQ_SERIAL, sync_in_48); } break; + case SYNC_IN_LINK_24BPQ: { irs_set(IRQ_SERIAL, sync_in_24); } break; + case SYNC_IN_LINK_12BPQ: { irs_set(IRQ_SERIAL, sync_in_12); } break; + case SYNC_IN_LINK_4BPQ: { irs_set(IRQ_SERIAL, sync_in_4); } break; + default: break; + } irs_set(IRQ_TIMER_2, NULL); SIO_MODE = SIO_MODE_GP | SIO_SC_OUT(0) diff --git a/src/settings.h b/src/settings.h index a348517..fc8e8a0 100644 --- a/src/settings.h +++ b/src/settings.h @@ -22,7 +22,11 @@ typedef enum SyncSetting { SYNC_OUT_LINK_AUDIO_16, SYNC_OUT_LINK_AUDIO_8, SYNC_OUT_LINK_AUDIO_4, - SYNC_IN_LINK, + SYNC_IN_LINK_96BPQ, + SYNC_IN_LINK_48BPQ, + SYNC_IN_LINK_24BPQ, + SYNC_IN_LINK_12BPQ, + SYNC_IN_LINK_4BPQ, SYNC_NUM, } SyncSetting; @@ -37,7 +41,11 @@ char * sync_setting_str[] = { "LINK+AUDIO OUT (16)", "LINK+AUDIO OUT (8)", "LINK+AUDIO OUT (4)", - "LINK IN", + "LINK IN (96BPQ)", + "LINK IN (48BPQ)", + "LINK IN (24BPQ)", + "LINK IN (12BPQ)", + "LINK IN (4BPQ)", }; typedef enum ThemeSetting { -- cgit v1.2.1