diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/audio.c | 17 | ||||
| -rw-r--r-- | quantum/audio.h | 2 | ||||
| -rw-r--r-- | quantum/keymap_common.c | 14 | ||||
| -rw-r--r-- | quantum/musical_notes.h | 5 | ||||
| -rw-r--r-- | quantum/song_list.h | 104 |
5 files changed, 117 insertions, 25 deletions
diff --git a/quantum/audio.c b/quantum/audio.c index 3ccd5ab9b..602366973 100644 --- a/quantum/audio.c +++ b/quantum/audio.c | |||
| @@ -351,7 +351,7 @@ void play_notes(float (*np)[][2], uint8_t n_count, bool n_repeat, float n_rest) | |||
| 351 | 351 | ||
| 352 | if (audio_config.enable) { | 352 | if (audio_config.enable) { |
| 353 | 353 | ||
| 354 | if (note) | 354 | if (note || notes) |
| 355 | stop_all_notes(); | 355 | stop_all_notes(); |
| 356 | 356 | ||
| 357 | notes_pointer = np; | 357 | notes_pointer = np; |
| @@ -406,7 +406,7 @@ void play_note(double freq, int vol) { | |||
| 406 | 406 | ||
| 407 | if (audio_config.enable && voices < 8) { | 407 | if (audio_config.enable && voices < 8) { |
| 408 | 408 | ||
| 409 | if (notes) | 409 | if (note || notes) |
| 410 | stop_all_notes(); | 410 | stop_all_notes(); |
| 411 | #ifdef PWM_AUDIO | 411 | #ifdef PWM_AUDIO |
| 412 | freq = freq / SAMPLE_RATE; | 412 | freq = freq / SAMPLE_RATE; |
| @@ -471,3 +471,16 @@ void increase_tempo(uint8_t tempo_change) | |||
| 471 | } | 471 | } |
| 472 | } | 472 | } |
| 473 | 473 | ||
| 474 | //------------------------------------------------------------------------------ | ||
| 475 | // Override these functions in your keymap file to play different tunes on | ||
| 476 | // startup and bootloader jump | ||
| 477 | __attribute__ ((weak)) | ||
| 478 | void play_startup_tone() | ||
| 479 | { | ||
| 480 | } | ||
| 481 | |||
| 482 | __attribute__ ((weak)) | ||
| 483 | void play_goodbye_tone() | ||
| 484 | { | ||
| 485 | } | ||
| 486 | //------------------------------------------------------------------------------ | ||
diff --git a/quantum/audio.h b/quantum/audio.h index 05d314c94..44cafccd6 100644 --- a/quantum/audio.h +++ b/quantum/audio.h | |||
| @@ -44,5 +44,7 @@ void decrease_tempo(uint8_t tempo_change); | |||
| 44 | #define NOTE_ARRAY_SIZE(x) ((int)(sizeof(x) / (sizeof(x[0])))) | 44 | #define NOTE_ARRAY_SIZE(x) ((int)(sizeof(x) / (sizeof(x[0])))) |
| 45 | #define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style)); | 45 | #define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style)); |
| 46 | 46 | ||
| 47 | void play_goodbye_tone(void); | ||
| 48 | void play_startup_tone(void); | ||
| 47 | 49 | ||
| 48 | #endif \ No newline at end of file | 50 | #endif \ No newline at end of file |
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 2001438b9..4ee290ad0 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
| @@ -34,12 +34,6 @@ extern keymap_config_t keymap_config; | |||
| 34 | #include <inttypes.h> | 34 | #include <inttypes.h> |
| 35 | #ifdef AUDIO_ENABLE | 35 | #ifdef AUDIO_ENABLE |
| 36 | #include "audio.h" | 36 | #include "audio.h" |
| 37 | |||
| 38 | #ifndef TONE_GOODBYE | ||
| 39 | #define TONE_GOODBYE OLKB_GOODBYE | ||
| 40 | #endif /*! TONE_GOODBYE */ | ||
| 41 | |||
| 42 | float tone_goodbye[][2] = SONG(TONE_GOODBYE); | ||
| 43 | #endif /* AUDIO_ENABLE */ | 37 | #endif /* AUDIO_ENABLE */ |
| 44 | 38 | ||
| 45 | static action_t keycode_to_action(uint16_t keycode); | 39 | static action_t keycode_to_action(uint16_t keycode); |
| @@ -47,7 +41,7 @@ static action_t keycode_to_action(uint16_t keycode); | |||
| 47 | /* converts key to action */ | 41 | /* converts key to action */ |
| 48 | action_t action_for_key(uint8_t layer, keypos_t key) | 42 | action_t action_for_key(uint8_t layer, keypos_t key) |
| 49 | { | 43 | { |
| 50 | // 16bit keycodes - important | 44 | // 16bit keycodes - important |
| 51 | uint16_t keycode = keymap_key_to_keycode(layer, key); | 45 | uint16_t keycode = keymap_key_to_keycode(layer, key); |
| 52 | 46 | ||
| 53 | switch (keycode) { | 47 | switch (keycode) { |
| @@ -190,7 +184,7 @@ static action_t keycode_to_action(uint16_t keycode) | |||
| 190 | case RESET: ; // RESET is 0x5000, which is why this is here | 184 | case RESET: ; // RESET is 0x5000, which is why this is here |
| 191 | clear_keyboard(); | 185 | clear_keyboard(); |
| 192 | #ifdef AUDIO_ENABLE | 186 | #ifdef AUDIO_ENABLE |
| 193 | PLAY_NOTE_ARRAY(tone_goodbye, false, 0); | 187 | play_goodbye_tone(); |
| 194 | #endif | 188 | #endif |
| 195 | _delay_ms(250); | 189 | _delay_ms(250); |
| 196 | #ifdef ATREUS_ASTAR | 190 | #ifdef ATREUS_ASTAR |
| @@ -303,7 +297,7 @@ static action_t keycode_to_action(uint16_t keycode) | |||
| 303 | /* translates key to keycode */ | 297 | /* translates key to keycode */ |
| 304 | uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) | 298 | uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) |
| 305 | { | 299 | { |
| 306 | // Read entire word (16bits) | 300 | // Read entire word (16bits) |
| 307 | return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]); | 301 | return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]); |
| 308 | } | 302 | } |
| 309 | 303 | ||
| @@ -315,7 +309,7 @@ action_t keymap_fn_to_action(uint16_t keycode) | |||
| 315 | 309 | ||
| 316 | action_t keymap_func_to_action(uint16_t keycode) | 310 | action_t keymap_func_to_action(uint16_t keycode) |
| 317 | { | 311 | { |
| 318 | // For FUNC without 8bit limit | 312 | // For FUNC without 8bit limit |
| 319 | return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) }; | 313 | return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) }; |
| 320 | } | 314 | } |
| 321 | 315 | ||
diff --git a/quantum/musical_notes.h b/quantum/musical_notes.h index ccdc34f27..b08d16a6f 100644 --- a/quantum/musical_notes.h +++ b/quantum/musical_notes.h | |||
| @@ -51,7 +51,10 @@ | |||
| 51 | 51 | ||
| 52 | 52 | ||
| 53 | // Notes - # = Octave | 53 | // Notes - # = Octave |
| 54 | |||
| 54 | #define NOTE_REST 0.00 | 55 | #define NOTE_REST 0.00 |
| 56 | |||
| 57 | /* These notes are currently bugged | ||
| 55 | #define NOTE_C0 16.35 | 58 | #define NOTE_C0 16.35 |
| 56 | #define NOTE_CS0 17.32 | 59 | #define NOTE_CS0 17.32 |
| 57 | #define NOTE_D0 18.35 | 60 | #define NOTE_D0 18.35 |
| @@ -75,6 +78,8 @@ | |||
| 75 | #define NOTE_GS1 51.91 | 78 | #define NOTE_GS1 51.91 |
| 76 | #define NOTE_A1 55.00 | 79 | #define NOTE_A1 55.00 |
| 77 | #define NOTE_AS1 58.27 | 80 | #define NOTE_AS1 58.27 |
| 81 | */ | ||
| 82 | |||
| 78 | #define NOTE_B1 61.74 | 83 | #define NOTE_B1 61.74 |
| 79 | #define NOTE_C2 65.41 | 84 | #define NOTE_C2 65.41 |
| 80 | #define NOTE_CS2 69.30 | 85 | #define NOTE_CS2 69.30 |
diff --git a/quantum/song_list.h b/quantum/song_list.h index b626c3fa6..e992bd18a 100644 --- a/quantum/song_list.h +++ b/quantum/song_list.h | |||
| @@ -4,20 +4,98 @@ | |||
| 4 | #define SONG_LIST_H | 4 | #define SONG_LIST_H |
| 5 | 5 | ||
| 6 | #define ODE_TO_JOY \ | 6 | #define ODE_TO_JOY \ |
| 7 | Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \ | 7 | Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \ |
| 8 | Q__NOTE(_G4), Q__NOTE(_F4), Q__NOTE(_E4), Q__NOTE(_D4), \ | 8 | Q__NOTE(_G4), Q__NOTE(_F4), Q__NOTE(_E4), Q__NOTE(_D4), \ |
| 9 | Q__NOTE(_C4), Q__NOTE(_C4), Q__NOTE(_D4), Q__NOTE(_E4), \ | 9 | Q__NOTE(_C4), Q__NOTE(_C4), Q__NOTE(_D4), Q__NOTE(_E4), \ |
| 10 | QD_NOTE(_E4), E__NOTE(_D4), H__NOTE(_D4), | 10 | QD_NOTE(_E4), E__NOTE(_D4), H__NOTE(_D4), |
| 11 | 11 | ||
| 12 | #define ROCK_A_BYE_BABY \ | 12 | #define ROCK_A_BYE_BABY \ |
| 13 | QD_NOTE(_B4), E__NOTE(_D4), Q__NOTE(_B5), \ | 13 | QD_NOTE(_B4), E__NOTE(_D4), Q__NOTE(_B5), \ |
| 14 | H__NOTE(_A5), Q__NOTE(_G5), \ | 14 | H__NOTE(_A5), Q__NOTE(_G5), \ |
| 15 | QD_NOTE(_B4), E__NOTE(_D5), Q__NOTE(_G5), \ | 15 | QD_NOTE(_B4), E__NOTE(_D5), Q__NOTE(_G5), \ |
| 16 | H__NOTE(_FS5), | 16 | H__NOTE(_FS5), |
| 17 | 17 | ||
| 18 | #define OLKB_GOODBYE \ | 18 | #define CLOSE_ENCOUNTERS_5_NOTE \ |
| 19 | E__NOTE(_E7), \ | 19 | Q__NOTE(_D5), \ |
| 20 | E__NOTE(_A6), \ | 20 | Q__NOTE(_E5), \ |
| 21 | ED_NOTE(_E6), | 21 | Q__NOTE(_C5), \ |
| 22 | Q__NOTE(_C4), \ | ||
| 23 | Q__NOTE(_G4), | ||
| 24 | |||
| 25 | #define DOE_A_DEER \ | ||
| 26 | QD_NOTE(_C4), E__NOTE(_D4), \ | ||
| 27 | QD_NOTE(_E4), E__NOTE(_C4), \ | ||
| 28 | Q__NOTE(_E4), Q__NOTE(_C4), \ | ||
| 29 | Q__NOTE(_E4), | ||
| 30 | |||
| 31 | #define GOODBYE_SOUND \ | ||
| 32 | E__NOTE(_E7), \ | ||
| 33 | E__NOTE(_A6), \ | ||
| 34 | ED_NOTE(_E6), | ||
| 35 | |||
| 36 | #define STARTUP_SOUND \ | ||
| 37 | ED_NOTE(_E7 ), \ | ||
| 38 | E__NOTE(_CS7), \ | ||
| 39 | E__NOTE(_E6 ), \ | ||
| 40 | E__NOTE(_A6 ), \ | ||
| 41 | M__NOTE(_CS7, 20), | ||
| 42 | |||
| 43 | #define QWERTY_SOUND \ | ||
| 44 | E__NOTE(_GS6 ), \ | ||
| 45 | E__NOTE(_A6 ), \ | ||
| 46 | S__NOTE(_REST), \ | ||
| 47 | Q__NOTE(_E7 ), | ||
| 48 | |||
| 49 | #define COLEMAK_SOUND \ | ||
| 50 | E__NOTE(_GS6 ), \ | ||
| 51 | E__NOTE(_A6 ), \ | ||
| 52 | S__NOTE(_REST), \ | ||
| 53 | ED_NOTE(_E7 ), \ | ||
| 54 | S__NOTE(_REST), \ | ||
| 55 | ED_NOTE(_GS7 ), | ||
| 56 | |||
| 57 | #define DVORAK_SOUND \ | ||
| 58 | E__NOTE(_GS6 ), \ | ||
| 59 | E__NOTE(_A6 ), \ | ||
| 60 | S__NOTE(_REST), \ | ||
| 61 | E__NOTE(_E7 ), \ | ||
| 62 | S__NOTE(_REST), \ | ||
| 63 | E__NOTE(_FS7 ), \ | ||
| 64 | S__NOTE(_REST), \ | ||
| 65 | E__NOTE(_E7 ), | ||
| 66 | |||
| 67 | #define MUSIC_SCALE_SOUND \ | ||
| 68 | E__NOTE(_A5 ), \ | ||
| 69 | E__NOTE(_B5 ), \ | ||
| 70 | E__NOTE(_CS6), \ | ||
| 71 | E__NOTE(_D6 ), \ | ||
| 72 | E__NOTE(_E6 ), \ | ||
| 73 | E__NOTE(_FS6), \ | ||
| 74 | E__NOTE(_GS6), \ | ||
| 75 | E__NOTE(_A6 ), | ||
| 76 | |||
| 77 | #define CAPS_LOCK_ON_SOUND \ | ||
| 78 | E__NOTE(_A3), \ | ||
| 79 | E__NOTE(_B3), | ||
| 80 | |||
| 81 | #define CAPS_LOCK_OFF_SOUND \ | ||
| 82 | E__NOTE(_B3), \ | ||
| 83 | E__NOTE(_A3), | ||
| 84 | |||
| 85 | #define SCROLL_LOCK_ON_SOUND \ | ||
| 86 | E__NOTE(_D4), \ | ||
| 87 | E__NOTE(_E4), | ||
| 88 | |||
| 89 | #define SCROLL_LOCK_OFF_SOUND \ | ||
| 90 | E__NOTE(_E4), \ | ||
| 91 | E__NOTE(_D4), | ||
| 92 | |||
| 93 | #define NUM_LOCK_ON_SOUND \ | ||
| 94 | E__NOTE(_D5), \ | ||
| 95 | E__NOTE(_E5), | ||
| 96 | |||
| 97 | #define NUM_LOCK_OFF_SOUND \ | ||
| 98 | E__NOTE(_E5), \ | ||
| 99 | E__NOTE(_D5), | ||
| 22 | 100 | ||
| 23 | #endif | 101 | #endif |
