diff options
Diffstat (limited to 'src/sequencer.c')
-rw-r--r-- | src/sequencer.c | 46 |
1 files changed, 34 insertions, 12 deletions
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) { | |||
182 | 182 | ||
183 | void | 183 | void |
184 | set_time(int bpm) { | 184 | set_time(int bpm) { |
185 | if (settings.sync == SYNC_IN_LINK) { | ||
186 | return; | ||
187 | } | ||
185 | // The number of ticks of a 1024 cycle clock in a step based on the BPM can | 188 | // The number of ticks of a 1024 cycle clock in a step based on the BPM can |
186 | // be calculated as: | 189 | // be calculated as: |
187 | // X bpm -> 60000 / 4 / bpm = Y ms = Ye-3 s | 190 | // X bpm -> 60000 / 4 / bpm = Y ms = Ye-3 s |
@@ -299,9 +302,8 @@ handle_channel_selection(void) { | |||
299 | } | 302 | } |
300 | 303 | ||
301 | void | 304 | void |
302 | stop_playing(void) { | 305 | stop_sound(void) { |
303 | play_status = 0; | 306 | play_status = 0; |
304 | step_counter = 0; | ||
305 | TIMER_CTRL_2 = 0; | 307 | TIMER_CTRL_2 = 0; |
306 | SOUND_SQUARE1_CTRL = 0; | 308 | SOUND_SQUARE1_CTRL = 0; |
307 | SOUND_SQUARE2_CTRL = 0; | 309 | SOUND_SQUARE2_CTRL = 0; |
@@ -311,9 +313,24 @@ stop_playing(void) { | |||
311 | } | 313 | } |
312 | 314 | ||
313 | void | 315 | void |
316 | stop_playing(void) { | ||
317 | step_counter = 0; | ||
318 | stop_sound(); | ||
319 | } | ||
320 | |||
321 | void | ||
314 | toggle_playing(void) { | 322 | toggle_playing(void) { |
315 | play_status ^= 1; | 323 | play_status ^= 1; |
316 | step_counter = 0; | 324 | step_counter = 0; |
325 | SOUND_SQUARE1_CTRL = 0; | ||
326 | SOUND_SQUARE2_CTRL = 0; | ||
327 | SOUND_WAVE_CTRL = 0; | ||
328 | SOUND_NOISE_CTRL = 0; | ||
329 | redraw_play_pause = true; | ||
330 | if (settings.sync == SYNC_IN_LINK) { | ||
331 | return; | ||
332 | } | ||
333 | |||
317 | if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) == 0) { | 334 | if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) == 0) { |
318 | if (current_pattern != next_pattern) { | 335 | if (current_pattern != next_pattern) { |
319 | current_pattern = next_pattern; | 336 | current_pattern = next_pattern; |
@@ -323,17 +340,20 @@ toggle_playing(void) { | |||
323 | play_step(); | 340 | play_step(); |
324 | } else { | 341 | } else { |
325 | TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE; | 342 | TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE; |
326 | SOUND_SQUARE1_CTRL = 0; | ||
327 | SOUND_SQUARE2_CTRL = 0; | ||
328 | SOUND_WAVE_CTRL = 0; | ||
329 | SOUND_NOISE_CTRL = 0; | ||
330 | } | 343 | } |
331 | redraw_play_pause = true; | ||
332 | } | 344 | } |
333 | 345 | ||
334 | void | 346 | void |
335 | pause_playing(void) { | 347 | pause_playing(void) { |
336 | play_status ^= 1; | 348 | play_status ^= 1; |
349 | SOUND_SQUARE1_CTRL = 0; | ||
350 | SOUND_SQUARE2_CTRL = 0; | ||
351 | SOUND_WAVE_CTRL = 0; | ||
352 | SOUND_NOISE_CTRL = 0; | ||
353 | redraw_play_pause = true; | ||
354 | if (settings.sync == SYNC_IN_LINK) { | ||
355 | return; | ||
356 | } | ||
337 | if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) == 0) { | 357 | if ((TIMER_CTRL_2 & TIMER_CTRL_ENABLE) == 0) { |
338 | if (current_pattern != next_pattern && step_counter == 0) { | 358 | if (current_pattern != next_pattern && step_counter == 0) { |
339 | current_pattern = next_pattern; | 359 | current_pattern = next_pattern; |
@@ -343,12 +363,7 @@ pause_playing(void) { | |||
343 | play_step(); | 363 | play_step(); |
344 | } else { | 364 | } else { |
345 | TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE; | 365 | TIMER_CTRL_2 ^= TIMER_CTRL_ENABLE; |
346 | SOUND_SQUARE1_CTRL = 0; | ||
347 | SOUND_SQUARE2_CTRL = 0; | ||
348 | SOUND_WAVE_CTRL = 0; | ||
349 | SOUND_NOISE_CTRL = 0; | ||
350 | } | 366 | } |
351 | redraw_play_pause = true; | ||
352 | } | 367 | } |
353 | 368 | ||
354 | void | 369 | void |
@@ -1007,6 +1022,13 @@ handle_sequencer_input(void) { | |||
1007 | } | 1022 | } |
1008 | 1023 | ||
1009 | void | 1024 | void |
1025 | serial_irq() { | ||
1026 | if (play_status) { | ||
1027 | play_step(); | ||
1028 | } | ||
1029 | } | ||
1030 | |||
1031 | void | ||
1010 | sequencer_init(void) { | 1032 | sequencer_init(void) { |
1011 | stop_playing(); | 1033 | stop_playing(); |
1012 | 1034 | ||