aboutsummaryrefslogtreecommitdiffstats
path: root/src/sequencer.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-04-24 16:27:50 +0200
committerBad Diode <bd@badd10de.dev>2023-04-24 16:27:50 +0200
commit595cfc36afbe4192bf24b0a2f5c2f95e87e12295 (patch)
treeff8b440c86ae7e63a9d9aaaae3fc77f58b6e1d3a /src/sequencer.c
parent0c9d588f5f91127333afbd209de20cbf15851516 (diff)
downloadstepper-595cfc36afbe4192bf24b0a2f5c2f95e87e12295.tar.gz
stepper-595cfc36afbe4192bf24b0a2f5c2f95e87e12295.zip
Fix potential recursive loop on interrupt
Diffstat (limited to 'src/sequencer.c')
-rw-r--r--src/sequencer.c49
1 files changed, 13 insertions, 36 deletions
diff --git a/src/sequencer.c b/src/sequencer.c
index 179e72f..44ee8be 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -17,15 +17,14 @@ bool redraw_bank_buttons = true;
17bool redraw_params = true; 17bool redraw_params = true;
18bool redraw_bpm = true; 18bool redraw_bpm = true;
19bool redraw_piano_note = true; 19bool redraw_piano_note = true;
20bool update_bpm = false;
20 21
21void 22void
22play_step(void) { 23play_step(void) {
23 if (current_pattern != next_pattern && step_counter == 15) { 24 if (current_pattern != next_pattern && step_counter == 15) {
24 current_pattern = next_pattern; 25 current_pattern = next_pattern;
25 redraw_pattern_buttons = true; 26 redraw_pattern_buttons = true;
26 set_time(patterns[current_pattern].bpm); 27 update_bpm = true;
27 play_step();
28 return;
29 } 28 }
30 Pattern *pat = &patterns[current_pattern]; 29 Pattern *pat = &patterns[current_pattern];
31 if (pat->ch1.active) { 30 if (pat->ch1.active) {
@@ -90,21 +89,11 @@ play_step(void) {
90 SOUND_WAVE_MODE |= SOUND_WAVE_ENABLE; 89 SOUND_WAVE_MODE |= SOUND_WAVE_ENABLE;
91 90
92 switch (params->wave_volume) { 91 switch (params->wave_volume) {
93 case 0: { 92 case 0: { SOUND_WAVE_CTRL = SOUND_WAVE_MUTE; } break;
94 SOUND_WAVE_CTRL = SOUND_WAVE_MUTE; 93 case 1: { SOUND_WAVE_CTRL = SOUND_WAVE_VOL_25; } break;
95 } break; 94 case 2: { SOUND_WAVE_CTRL = SOUND_WAVE_VOL_50; } break;
96 case 1: { 95 case 3: { SOUND_WAVE_CTRL = SOUND_WAVE_VOL_75; } break;
97 SOUND_WAVE_CTRL = SOUND_WAVE_VOL_25; 96 case 4: { SOUND_WAVE_CTRL = SOUND_WAVE_VOL_100; } break;
98 } break;
99 case 2: {
100 SOUND_WAVE_CTRL = SOUND_WAVE_VOL_50;
101 } break;
102 case 3: {
103 SOUND_WAVE_CTRL = SOUND_WAVE_VOL_75;
104 } break;
105 case 4: {
106 SOUND_WAVE_CTRL = SOUND_WAVE_VOL_100;
107 } break;
108 } 97 }
109 SOUND_WAVE_FREQ = SOUND_FREQ_RESET 98 SOUND_WAVE_FREQ = SOUND_FREQ_RESET
110 | sound_rates[trig->note]; 99 | sound_rates[trig->note];
@@ -755,30 +744,18 @@ set_param_selection_wave(size_t i, InputHandler return_handler) {
755 u32 *wave_a = &pat->ch3.params[i].wave_a; 744 u32 *wave_a = &pat->ch3.params[i].wave_a;
756 u32 *wave_b = &pat->ch3.params[i].wave_b; 745 u32 *wave_b = &pat->ch3.params[i].wave_b;
757 switch (param_selection_loc) { 746 switch (param_selection_loc) {
758 case 64: { 747 case 64: { memcpy32(wave_a, sine_wave, 16); } break;
759 memcpy32(wave_a, sine_wave, 16); 748 case 65: { memcpy32(wave_a, saw_wave, 16); } break;
760 } break; 749 case 66: { memcpy32(wave_a, square_wave, 16); } break;
761 case 65: {
762 memcpy32(wave_a, saw_wave, 16);
763 } break;
764 case 66: {
765 memcpy32(wave_a, square_wave, 16);
766 } break;
767 case 67: { 750 case 67: {
768 u32 rand_wave[4] = { 751 u32 rand_wave[4] = {
769 rng32(), rng32(), rng32(), rng32(), 752 rng32(), rng32(), rng32(), rng32(),
770 }; 753 };
771 memcpy32(wave_a, rand_wave, 16); 754 memcpy32(wave_a, rand_wave, 16);
772 } break; 755 } break;
773 case 68: { 756 case 68: { memcpy32(wave_b, sine_wave, 16); } break;
774 memcpy32(wave_b, sine_wave, 16); 757 case 69: { memcpy32(wave_b, saw_wave, 16); } break;
775 } break; 758 case 70: { memcpy32(wave_b, square_wave, 16); } break;
776 case 69: {
777 memcpy32(wave_b, saw_wave, 16);
778 } break;
779 case 70: {
780 memcpy32(wave_b, square_wave, 16);
781 } break;
782 case 71: { 759 case 71: {
783 u32 rand_wave[4] = { 760 u32 rand_wave[4] = {
784 rng32(), rng32(), rng32(), rng32(), 761 rng32(), rng32(), rng32(), rng32(),