From 300ca4c16a45ef129a65a5520eab068f1f74c29b Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Wed, 31 May 2023 18:21:30 +0200 Subject: Add link cable sync in --- src/sequencer.c | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'src/sequencer.c') diff --git a/src/sequencer.c b/src/sequencer.c index 2ee6b07..5120805 100644 --- a/src/sequencer.c +++ b/src/sequencer.c @@ -182,6 +182,9 @@ play_step(void) { void set_time(int bpm) { + if (settings.sync == SYNC_IN_LINK) { + return; + } // The number of ticks of a 1024 cycle clock in a step based on the BPM can // be calculated as: // X bpm -> 60000 / 4 / bpm = Y ms = Ye-3 s @@ -299,9 +302,8 @@ handle_channel_selection(void) { } void -stop_playing(void) { +stop_sound(void) { play_status = 0; - step_counter = 0; TIMER_CTRL_2 = 0; SOUND_SQUARE1_CTRL = 0; SOUND_SQUARE2_CTRL = 0; @@ -310,10 +312,25 @@ stop_playing(void) { redraw_play_pause = true; } +void +stop_playing(void) { + step_counter = 0; + stop_sound(); +} + void toggle_playing(void) { play_status ^= 1; step_counter = 0; + SOUND_SQUARE1_CTRL = 0; + SOUND_SQUARE2_CTRL = 0; + SOUND_WAVE_CTRL = 0; + SOUND_NOISE_CTRL = 0; + redraw_play_pause = true; + if (settings.sync == SYNC_IN_LINK) { + return; + } + if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) == 0) { if (current_pattern != next_pattern) { current_pattern = next_pattern; @@ -323,17 +340,20 @@ toggle_playing(void) { play_step(); } else { TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE; - SOUND_SQUARE1_CTRL = 0; - SOUND_SQUARE2_CTRL = 0; - SOUND_WAVE_CTRL = 0; - SOUND_NOISE_CTRL = 0; } - redraw_play_pause = true; } void pause_playing(void) { play_status ^= 1; + SOUND_SQUARE1_CTRL = 0; + SOUND_SQUARE2_CTRL = 0; + SOUND_WAVE_CTRL = 0; + SOUND_NOISE_CTRL = 0; + redraw_play_pause = true; + if (settings.sync == SYNC_IN_LINK) { + return; + } if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) == 0) { if (current_pattern != next_pattern && step_counter == 0) { current_pattern = next_pattern; @@ -343,12 +363,7 @@ pause_playing(void) { play_step(); } else { TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE; - SOUND_SQUARE1_CTRL = 0; - SOUND_SQUARE2_CTRL = 0; - SOUND_WAVE_CTRL = 0; - SOUND_NOISE_CTRL = 0; } - redraw_play_pause = true; } void @@ -1006,6 +1021,13 @@ handle_sequencer_input(void) { } } +void +serial_irq() { + if (play_status) { + play_step(); + } +} + void sequencer_init(void) { stop_playing(); -- cgit v1.2.1