diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2016-04-16 21:31:40 -0400 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2016-04-16 21:31:40 -0400 |
| commit | 41cc35425ab32c9a9492006da8b667d01d32dfa6 (patch) | |
| tree | 23813e84df2687694ba82adf416f59a9e52e89b9 /quantum | |
| parent | 8f4ce501eb41cdd195d61e05c7e9dbe54545e6b9 (diff) | |
| download | qmk_firmware-41cc35425ab32c9a9492006da8b667d01d32dfa6.tar.gz qmk_firmware-41cc35425ab32c9a9492006da8b667d01d32dfa6.zip | |
rests between notes as an argument
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/audio.c | 29 | ||||
| -rw-r--r-- | quantum/audio.h | 3 | ||||
| -rw-r--r-- | quantum/keymap_common.c | 2 |
3 files changed, 24 insertions, 10 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; | |||
| 61 | float (* notes_pointer)[][2]; | 61 | float (* notes_pointer)[][2]; |
| 62 | uint8_t notes_length; | 62 | uint8_t notes_length; |
| 63 | bool notes_repeat; | 63 | bool notes_repeat; |
| 64 | float notes_rest; | ||
| 65 | bool note_resting = false; | ||
| 66 | |||
| 64 | uint8_t current_note = 0; | 67 | uint8_t current_note = 0; |
| 68 | uint8_t rest_counter = 0; | ||
| 65 | 69 | ||
| 66 | audio_config_t audio_config; | 70 | audio_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 | ||
| 335 | void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat) { | 347 | void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat, float n_rest) { |
| 336 | 348 | ||
| 337 | if (audio_config.enable) { | 349 | if (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; |
diff --git a/quantum/audio.h b/quantum/audio.h index 58270015d..65a6f9434 100644 --- a/quantum/audio.h +++ b/quantum/audio.h | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #include <stdbool.h> | 2 | #include <stdbool.h> |
| 3 | #include <avr/io.h> | 3 | #include <avr/io.h> |
| 4 | #include <util/delay.h> | 4 | #include <util/delay.h> |
| 5 | #include "musical_notes.h" | ||
| 5 | 6 | ||
| 6 | typedef union { | 7 | typedef union { |
| 7 | uint8_t raw; | 8 | uint8_t raw; |
| @@ -20,4 +21,4 @@ void play_note(double freq, int vol); | |||
| 20 | void stop_note(double freq); | 21 | void stop_note(double freq); |
| 21 | void stop_all_notes(); | 22 | void stop_all_notes(); |
| 22 | void init_notes(); | 23 | void init_notes(); |
| 23 | void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat); | 24 | void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat, float n_rest); |
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 899437f44..457f70a44 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
| @@ -189,7 +189,7 @@ static action_t keycode_to_action(uint16_t keycode) | |||
| 189 | case RESET: ; // RESET is 0x5000, which is why this is here | 189 | case RESET: ; // RESET is 0x5000, which is why this is here |
| 190 | clear_keyboard(); | 190 | clear_keyboard(); |
| 191 | #ifdef AUDIO_ENABLE | 191 | #ifdef AUDIO_ENABLE |
| 192 | play_notes(&goodbye, 3, false); | 192 | play_notes(&goodbye, 3, false, 0); |
| 193 | #endif | 193 | #endif |
| 194 | _delay_ms(250); | 194 | _delay_ms(250); |
| 195 | #ifdef ATREUS_ASTAR | 195 | #ifdef ATREUS_ASTAR |
