aboutsummaryrefslogtreecommitdiff
path: root/quantum/audio.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/audio.c')
-rw-r--r--quantum/audio.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/quantum/audio.c b/quantum/audio.c
index 470dc8e0c..40d09d62f 100644
--- a/quantum/audio.c
+++ b/quantum/audio.c
@@ -61,7 +61,11 @@ uint16_t note_position = 0;
61float (* notes_pointer)[][2]; 61float (* notes_pointer)[][2];
62uint8_t notes_length; 62uint8_t notes_length;
63bool notes_repeat; 63bool notes_repeat;
64float notes_rest;
65bool note_resting = false;
66
64uint8_t current_note = 0; 67uint8_t current_note = 0;
68uint8_t rest_counter = 0;
65 69
66audio_config_t audio_config; 70audio_config_t audio_config;
67 71
@@ -314,13 +318,21 @@ ISR(TIMER3_COMPA_vect) {
314 return; 318 return;
315 } 319 }
316 } 320 }
317 #ifdef PWM_AUDIO 321 if (!note_resting && ((int)notes_rest != 0)) {
318 note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE; 322 note_resting = true;
319 note_length = (*notes_pointer)[current_note][1]; 323 note_frequency = 0;
320 #else 324 note_length = notes_rest;
321 note_frequency = (*notes_pointer)[current_note][0]; 325 current_note--;
322 note_length = (*notes_pointer)[current_note][1] / 4; 326 } else {
323 #endif 327 note_resting = false;
328 #ifdef PWM_AUDIO
329 note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE;
330 note_length = (*notes_pointer)[current_note][1];
331 #else
332 note_frequency = (*notes_pointer)[current_note][0];
333 note_length = (*notes_pointer)[current_note][1] / 4;
334 #endif
335 }
324 note_position = 0; 336 note_position = 0;
325 } 337 }
326 338
@@ -332,7 +344,7 @@ ISR(TIMER3_COMPA_vect) {
332 } 344 }
333} 345}
334 346
335void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat) { 347void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat, float n_rest) {
336 348
337if (audio_config.enable) { 349if (audio_config.enable) {
338 350
@@ -343,6 +355,7 @@ if (audio_config.enable) {
343 notes_pointer = np; 355 notes_pointer = np;
344 notes_length = n_length; 356 notes_length = n_length;
345 notes_repeat = n_repeat; 357 notes_repeat = n_repeat;
358 notes_rest = n_rest;
346 359
347 place = 0; 360 place = 0;
348 current_note = 0; 361 current_note = 0;