aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2024-01-06 16:35:53 +0100
committerBad Diode <bd@badd10de.dev>2024-01-06 16:35:53 +0100
commitfcef6e404587accd09439739a7e660f1d94069a1 (patch)
treefe48b5a60f41374ac9f7a2368c3ebaf74658e472
parenta5f47ed59a29486c7ad3ee60811c5928862b24f8 (diff)
downloadstepper-fcef6e404587accd09439739a7e660f1d94069a1.tar.gz
stepper-fcef6e404587accd09439739a7e660f1d94069a1.zip
Add more sync in options
-rw-r--r--src/drawing.c6
-rw-r--r--src/main.c3
-rw-r--r--src/sequencer.c53
-rw-r--r--src/settings.c21
-rw-r--r--src/settings.h12
5 files changed, 84 insertions, 11 deletions
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() {
418 draw_rect(x, y, x + R_COL_W - 2, y + BPM_H - 3, COL_FG); 418 draw_rect(x, y, x + R_COL_W - 2, y + BPM_H - 3, COL_FG);
419 txt_drawf_small("BPM", x + 7, y - 10, COL_FG); 419 txt_drawf_small("BPM", x + 7, y - 10, COL_FG);
420 420
421 if (settings.sync == SYNC_IN_LINK) { 421 if (settings.sync == SYNC_IN_LINK_96BPQ ||
422 settings.sync == SYNC_IN_LINK_48BPQ ||
423 settings.sync == SYNC_IN_LINK_24BPQ ||
424 settings.sync == SYNC_IN_LINK_12BPQ ||
425 settings.sync == SYNC_IN_LINK_4BPQ) {
422 txt_drawf("SYNC", x + 2, y + 2, COL_FG); 426 txt_drawf("SYNC", x + 2, y + 2, COL_FG);
423 } else { 427 } else {
424 // Make sure its horizontally centered if only 2 digits 428 // 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.
16// + Look back again at the emulator issues... (I give up) 16// + Look back again at the emulator issues... (I give up)
17// + Sync via MIDI with the Analogue cables. 17// + Sync via MIDI with the Analogue cables.
18// + Fix bank switching behaviour (bug) 18// + Fix bank switching behaviour (bug)
19// + Add more sync options
19// - Fix any bugs we currently have 20// - Fix any bugs we currently have
20// - Add an envelope to ch3, would need to work with a timer in order to make 21// - Add an envelope to ch3, would need to work with a timer in order to make
21// it work I think. 22// it work I think (Can reuse the 96bpq sequencer timer for this).
22// - Hold L/R retriggers at short intervals? 23// - Hold L/R retriggers at short intervals?
23// - Channel params should show if there are some already on all triggers and 24// - Channel params should show if there are some already on all triggers and
24// modify only the selected parameter, not all of them. 25// 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) {
362 362
363void 363void
364set_time(int bpm) { 364set_time(int bpm) {
365 if (settings.sync == SYNC_IN_LINK) { 365 if (settings.sync == SYNC_IN_LINK_96BPQ ||
366 settings.sync == SYNC_IN_LINK_48BPQ ||
367 settings.sync == SYNC_IN_LINK_24BPQ ||
368 settings.sync == SYNC_IN_LINK_12BPQ ||
369 settings.sync == SYNC_IN_LINK_4BPQ) {
366 return; 370 return;
367 } 371 }
368 // We use a high resolution 96 PPQ clock for sequencing. With the following 372 // We use a high resolution 96 PPQ clock for sequencing. With the following
@@ -552,7 +556,11 @@ toggle_playing(void) {
552 current_pattern = next_pattern; 556 current_pattern = next_pattern;
553 } 557 }
554 558
555 if (settings.sync == SYNC_IN_LINK) { 559 if (settings.sync == SYNC_IN_LINK_96BPQ ||
560 settings.sync == SYNC_IN_LINK_48BPQ ||
561 settings.sync == SYNC_IN_LINK_24BPQ ||
562 settings.sync == SYNC_IN_LINK_12BPQ ||
563 settings.sync == SYNC_IN_LINK_4BPQ) {
556 return; 564 return;
557 } 565 }
558 566
@@ -1503,17 +1511,54 @@ handle_sequencer_input(void) {
1503} 1511}
1504 1512
1505void 1513void
1506serial_irq(void) { 1514sync_in_96(void) {
1507 if (play_status) { 1515 if (play_status) {
1508 // 12bpq -> 96bpq? 1516 sequencer_tick();
1517 }
1518}
1519
1520void
1521sync_in_48(void) {
1522 if (play_status) {
1523 // 48bpq -> 96bpq.
1524 sequencer_tick();
1525 sequencer_tick();
1526 }
1527}
1528
1529void
1530sync_in_24(void) {
1531 if (play_status) {
1532 // 24bpq -> 96bpq.
1533 sequencer_tick();
1509 sequencer_tick(); 1534 sequencer_tick();
1510 sequencer_tick(); 1535 sequencer_tick();
1511 sequencer_tick(); 1536 sequencer_tick();
1537 }
1538}
1539
1540void
1541sync_in_12(void) {
1542 if (play_status) {
1543 // 12bpq -> 96bpq.
1544 sequencer_tick();
1545 sequencer_tick();
1512 sequencer_tick(); 1546 sequencer_tick();
1513 sequencer_tick(); 1547 sequencer_tick();
1514 sequencer_tick(); 1548 sequencer_tick();
1515 sequencer_tick(); 1549 sequencer_tick();
1516 sequencer_tick(); 1550 sequencer_tick();
1551 sequencer_tick();
1552 }
1553}
1554
1555void
1556sync_in_4(void) {
1557 if (play_status) {
1558 // 4bpq -> 96bpq.
1559 for (size_t i = 0; i < 24; i++) {
1560 sequencer_tick();
1561 }
1517 } 1562 }
1518} 1563}
1519 1564
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 = {
8}; 8};
9static int settings_cursor_loc = 0; 9static int settings_cursor_loc = 0;
10 10
11void serial_irq(void); 11void sync_in_96(void);
12void sync_in_48(void);
13void sync_in_24(void);
14void sync_in_12(void);
15void sync_in_4(void);
12void stop_sound(void); 16void stop_sound(void);
13void toggle_playing(void); 17void toggle_playing(void);
14 18
15void 19void
16set_audio_settings(void) { 20set_audio_settings(void) {
17 stop_sound(); 21 stop_sound();
18 if (settings.sync == SYNC_IN_LINK) { 22 if (settings.sync == SYNC_IN_LINK_96BPQ ||
19 irs_set(IRQ_SERIAL, serial_irq); 23 settings.sync == SYNC_IN_LINK_48BPQ ||
24 settings.sync == SYNC_IN_LINK_24BPQ ||
25 settings.sync == SYNC_IN_LINK_12BPQ ||
26 settings.sync == SYNC_IN_LINK_4BPQ) {
27 switch (settings.sync) {
28 case SYNC_IN_LINK_96BPQ: { irs_set(IRQ_SERIAL, sync_in_96); } break;
29 case SYNC_IN_LINK_48BPQ: { irs_set(IRQ_SERIAL, sync_in_48); } break;
30 case SYNC_IN_LINK_24BPQ: { irs_set(IRQ_SERIAL, sync_in_24); } break;
31 case SYNC_IN_LINK_12BPQ: { irs_set(IRQ_SERIAL, sync_in_12); } break;
32 case SYNC_IN_LINK_4BPQ: { irs_set(IRQ_SERIAL, sync_in_4); } break;
33 default: break;
34 }
20 irs_set(IRQ_TIMER_2, NULL); 35 irs_set(IRQ_TIMER_2, NULL);
21 SIO_MODE = SIO_MODE_GP 36 SIO_MODE = SIO_MODE_GP
22 | SIO_SC_OUT(0) 37 | 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 {
22 SYNC_OUT_LINK_AUDIO_16, 22 SYNC_OUT_LINK_AUDIO_16,
23 SYNC_OUT_LINK_AUDIO_8, 23 SYNC_OUT_LINK_AUDIO_8,
24 SYNC_OUT_LINK_AUDIO_4, 24 SYNC_OUT_LINK_AUDIO_4,
25 SYNC_IN_LINK, 25 SYNC_IN_LINK_96BPQ,
26 SYNC_IN_LINK_48BPQ,
27 SYNC_IN_LINK_24BPQ,
28 SYNC_IN_LINK_12BPQ,
29 SYNC_IN_LINK_4BPQ,
26 SYNC_NUM, 30 SYNC_NUM,
27} SyncSetting; 31} SyncSetting;
28 32
@@ -37,7 +41,11 @@ char * sync_setting_str[] = {
37 "LINK+AUDIO OUT (16)", 41 "LINK+AUDIO OUT (16)",
38 "LINK+AUDIO OUT (8)", 42 "LINK+AUDIO OUT (8)",
39 "LINK+AUDIO OUT (4)", 43 "LINK+AUDIO OUT (4)",
40 "LINK IN", 44 "LINK IN (96BPQ)",
45 "LINK IN (48BPQ)",
46 "LINK IN (24BPQ)",
47 "LINK IN (12BPQ)",
48 "LINK IN (4BPQ)",
41}; 49};
42 50
43typedef enum ThemeSetting { 51typedef enum ThemeSetting {