aboutsummaryrefslogtreecommitdiffstats
path: root/src/sequencer.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2024-01-04 15:36:09 +0100
committerBad Diode <bd@badd10de.dev>2024-01-04 15:36:09 +0100
commit024e372b9e271ea817353f7d07a810b99c62eb60 (patch)
tree8f545792ac2b6de4aed8467b7aed5d1f932aef9f /src/sequencer.c
parent2d397003e2acbfd04019425bef00d0834191cd92 (diff)
downloadstepper-024e372b9e271ea817353f7d07a810b99c62eb60.tar.gz
stepper-024e372b9e271ea817353f7d07a810b99c62eb60.zip
Add initial Analogue MIDI sync functionality (needs options)
Diffstat (limited to 'src/sequencer.c')
-rw-r--r--src/sequencer.c20
1 files changed, 17 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
349static nseq_ticks = 0;
350void 349void
351sequencer_tick(void) { 350sequencer_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
1552static int in_ticks = 0;
1553
1554void
1555reset_serial_in(void) {
1556 in_ticks = 0;
1557}
1558
1552void 1559void
1553serial_irq() { 1560serial_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