diff options
author | Bad Diode <bd@badd10de.dev> | 2024-01-04 15:36:09 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2024-01-04 15:36:09 +0100 |
commit | 024e372b9e271ea817353f7d07a810b99c62eb60 (patch) | |
tree | 8f545792ac2b6de4aed8467b7aed5d1f932aef9f /src | |
parent | 2d397003e2acbfd04019425bef00d0834191cd92 (diff) | |
download | stepper-024e372b9e271ea817353f7d07a810b99c62eb60.tar.gz stepper-024e372b9e271ea817353f7d07a810b99c62eb60.zip |
Add initial Analogue MIDI sync functionality (needs options)
Diffstat (limited to 'src')
-rw-r--r-- | src/sequencer.c | 20 | ||||
-rw-r--r-- | src/settings.c | 2 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/sequencer.c b/src/sequencer.c index 11c0f5a..9dcaa89 100644 --- a/src/sequencer.c +++ b/src/sequencer.c | |||
@@ -346,9 +346,9 @@ play_step(void) { | |||
346 | step_counter = (step_counter + 1) % 16; | 346 | step_counter = (step_counter + 1) % 16; |
347 | } | 347 | } |
348 | 348 | ||
349 | static nseq_ticks = 0; | ||
350 | void | 349 | void |
351 | sequencer_tick(void) { | 350 | sequencer_tick(void) { |
351 | static int nseq_ticks = 0; | ||
352 | if (nseq_ticks++ < 24) { | 352 | if (nseq_ticks++ < 24) { |
353 | return; | 353 | return; |
354 | } | 354 | } |
@@ -1549,10 +1549,24 @@ handle_sequencer_input(void) { | |||
1549 | } | 1549 | } |
1550 | } | 1550 | } |
1551 | 1551 | ||
1552 | static int in_ticks = 0; | ||
1553 | |||
1554 | void | ||
1555 | reset_serial_in(void) { | ||
1556 | in_ticks = 0; | ||
1557 | } | ||
1558 | |||
1552 | void | 1559 | void |
1553 | serial_irq() { | 1560 | serial_irq(void) { |
1554 | if (play_status) { | 1561 | if (play_status) { |
1555 | play_step(); | 1562 | if (in_ticks++ == 0) { |
1563 | // TODO: Instead of play_step use the nseq_ticks instead! | ||
1564 | play_step(); | ||
1565 | // MIDI: 24 / 8 = 3 | ||
1566 | // set to 6 for half tempo | ||
1567 | } else if (in_ticks == 3) { | ||
1568 | in_ticks = 0; | ||
1569 | } | ||
1556 | } | 1570 | } |
1557 | } | 1571 | } |
1558 | 1572 | ||
diff --git a/src/settings.c b/src/settings.c index 374618c..7cebcf6 100644 --- a/src/settings.c +++ b/src/settings.c | |||
@@ -8,6 +8,7 @@ static Settings settings = { | |||
8 | }; | 8 | }; |
9 | static int settings_cursor_loc = 0; | 9 | static int settings_cursor_loc = 0; |
10 | 10 | ||
11 | void reset_serial_in(void); | ||
11 | void serial_irq(void); | 12 | void serial_irq(void); |
12 | void stop_sound(void); | 13 | void stop_sound(void); |
13 | void toggle_playing(void); | 14 | void toggle_playing(void); |
@@ -16,6 +17,7 @@ void | |||
16 | set_audio_settings(void) { | 17 | set_audio_settings(void) { |
17 | stop_sound(); | 18 | stop_sound(); |
18 | if (settings.sync == SYNC_IN_LINK) { | 19 | if (settings.sync == SYNC_IN_LINK) { |
20 | reset_serial_in(); | ||
19 | irs_set(IRQ_SERIAL, serial_irq); | 21 | irs_set(IRQ_SERIAL, serial_irq); |
20 | irs_set(IRQ_TIMER_2, NULL); | 22 | irs_set(IRQ_TIMER_2, NULL); |
21 | SIO_MODE = SIO_MODE_GP | 23 | SIO_MODE = SIO_MODE_GP |