aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-07-20 23:57:11 -0400
committerJack Humbert <jack.humb@gmail.com>2017-07-23 14:59:29 -0400
commit6a3c66776cb10888b24400526241b46deeb051a8 (patch)
tree7604aafe7087d9ab40aa0bb6bc603975e31d7e2e
parent8edb67b08242f2ab641d7e658a0a7adb579bbae2 (diff)
downloadqmk_firmware-6a3c66776cb10888b24400526241b46deeb051a8.tar.gz
qmk_firmware-6a3c66776cb10888b24400526241b46deeb051a8.zip
clean-up planck and preonic keymaps, move audio stuff around
-rw-r--r--keyboards/planck/keymaps/default/config.h10
-rw-r--r--keyboards/planck/keymaps/default/keymap.c100
-rw-r--r--keyboards/preonic/keymaps/default/config.h10
-rw-r--r--keyboards/preonic/keymaps/default/keymap.c95
-rw-r--r--quantum/audio/audio.c14
-rw-r--r--quantum/audio/audio.h2
-rw-r--r--quantum/audio/song_list.h42
-rw-r--r--quantum/config_common.h2
-rw-r--r--quantum/process_keycode/process_music.c20
-rw-r--r--quantum/quantum.c47
-rw-r--r--quantum/quantum.h3
-rw-r--r--quantum/quantum_keycodes.h4
12 files changed, 184 insertions, 165 deletions
diff --git a/keyboards/planck/keymaps/default/config.h b/keyboards/planck/keymaps/default/config.h
index 4c6158199..1ce547b94 100644
--- a/keyboards/planck/keymaps/default/config.h
+++ b/keyboards/planck/keymaps/default/config.h
@@ -15,6 +15,16 @@
15*/ 15*/
16#define MIDI_BASIC 16#define MIDI_BASIC
17 17
18#ifdef AUDIO_ENABLE
19 #define STARTUP_SONG SONG(PLANCK_SOUND)
20 // #define STARTUP_SONG SONG(NO_SOUND)
21
22 #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \
23 SONG(COLEMAK_SOUND), \
24 SONG(DVORAK_SOUND) \
25 }
26#endif
27
18/* enable advanced MIDI features: 28/* enable advanced MIDI features:
19 - MIDI notes can be added to the keymap 29 - MIDI notes can be added to the keymap
20 - Octave shift and transpose 30 - Octave shift and transpose
diff --git a/keyboards/planck/keymaps/default/keymap.c b/keyboards/planck/keymaps/default/keymap.c
index 61275cb26..ddb93c885 100644
--- a/keyboards/planck/keymaps/default/keymap.c
+++ b/keyboards/planck/keymaps/default/keymap.c
@@ -1,20 +1,28 @@
1// This is the canonical layout file for the Quantum project. If you want to add another keyboard, 1/* Copyright 2015-2017 Jack Humbert
2// this is the style you want to emulate. 2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
3 16
4#include "planck.h" 17#include "planck.h"
5#include "action_layer.h" 18#include "action_layer.h"
19#include "eeconfig.h"
6#ifdef AUDIO_ENABLE 20#ifdef AUDIO_ENABLE
7 #include "audio.h" 21 #include "audio.h"
8#endif 22#endif
9#include "eeconfig.h"
10 23
11extern keymap_config_t keymap_config; 24extern keymap_config_t keymap_config;
12 25
13// Each layer gets a name for readability, which is then used in the keymap matrix below.
14// The underscores don't mean anything - you can have a layer called STUFF or any other name.
15// Layer names don't all need to be of the same length, obviously, and you can also skip them
16// entirely and just use numbers.
17
18enum planck_layers { 26enum planck_layers {
19 _QWERTY, 27 _QWERTY,
20 _COLEMAK, 28 _COLEMAK,
@@ -36,10 +44,6 @@ enum planck_keycodes {
36 EXT_PLV 44 EXT_PLV
37}; 45};
38 46
39// Fillers to make layering more clear
40#define _______ KC_TRNS
41#define XXXXXXX KC_NO
42
43const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 47const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
44 48
45/* Qwerty 49/* Qwerty
@@ -173,50 +177,27 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
173}; 177};
174 178
175#ifdef AUDIO_ENABLE 179#ifdef AUDIO_ENABLE
176 180 float plover_song[][2] = SONG(PLOVER_SOUND);
177float tone_startup[][2] = SONG(STARTUP_SOUND); 181 float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
178float tone_qwerty[][2] = SONG(QWERTY_SOUND);
179float tone_dvorak[][2] = SONG(DVORAK_SOUND);
180float tone_colemak[][2] = SONG(COLEMAK_SOUND);
181float tone_plover[][2] = SONG(PLOVER_SOUND);
182float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
183float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
184
185float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
186#endif 182#endif
187 183
188
189void persistent_default_layer_set(uint16_t default_layer) {
190 eeconfig_update_default_layer(default_layer);
191 default_layer_set(default_layer);
192}
193
194bool process_record_user(uint16_t keycode, keyrecord_t *record) { 184bool process_record_user(uint16_t keycode, keyrecord_t *record) {
195 switch (keycode) { 185 switch (keycode) {
196 case QWERTY: 186 case QWERTY:
197 if (record->event.pressed) { 187 if (record->event.pressed) {
198 #ifdef AUDIO_ENABLE 188 set_single_persistent_default_layer(_QWERTY);
199 PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
200 #endif
201 persistent_default_layer_set(1UL<<_QWERTY);
202 } 189 }
203 return false; 190 return false;
204 break; 191 break;
205 case COLEMAK: 192 case COLEMAK:
206 if (record->event.pressed) { 193 if (record->event.pressed) {
207 #ifdef AUDIO_ENABLE 194 set_single_persistent_default_layer(_COLEMAK);
208 PLAY_NOTE_ARRAY(tone_colemak, false, 0);
209 #endif
210 persistent_default_layer_set(1UL<<_COLEMAK);
211 } 195 }
212 return false; 196 return false;
213 break; 197 break;
214 case DVORAK: 198 case DVORAK:
215 if (record->event.pressed) { 199 if (record->event.pressed) {
216 #ifdef AUDIO_ENABLE 200 set_single_persistent_default_layer(_DVORAK);
217 PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
218 #endif
219 persistent_default_layer_set(1UL<<_DVORAK);
220 } 201 }
221 return false; 202 return false;
222 break; 203 break;
@@ -255,7 +236,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
255 if (record->event.pressed) { 236 if (record->event.pressed) {
256 #ifdef AUDIO_ENABLE 237 #ifdef AUDIO_ENABLE
257 stop_all_notes(); 238 stop_all_notes();
258 PLAY_NOTE_ARRAY(tone_plover, false, 0); 239 PLAY_SONG(plover_song);
259 #endif 240 #endif
260 layer_off(_RAISE); 241 layer_off(_RAISE);
261 layer_off(_LOWER); 242 layer_off(_LOWER);
@@ -273,7 +254,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
273 case EXT_PLV: 254 case EXT_PLV:
274 if (record->event.pressed) { 255 if (record->event.pressed) {
275 #ifdef AUDIO_ENABLE 256 #ifdef AUDIO_ENABLE
276 PLAY_NOTE_ARRAY(tone_plover_gb, false, 0); 257 PLAY_SONG(plover_gb_song);
277 #endif 258 #endif
278 layer_off(_PLOVER); 259 layer_off(_PLOVER);
279 } 260 }
@@ -281,37 +262,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
281 break; 262 break;
282 } 263 }
283 return true; 264 return true;
284} 265} \ No newline at end of file
285
286void matrix_init_user(void) {
287 #ifdef AUDIO_ENABLE
288 startup_user();
289 #endif
290}
291
292#ifdef AUDIO_ENABLE
293
294void startup_user()
295{
296 _delay_ms(20); // gets rid of tick
297 PLAY_NOTE_ARRAY(tone_startup, false, 0);
298}
299
300void shutdown_user()
301{
302 PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
303 _delay_ms(150);
304 stop_all_notes();
305}
306
307void music_on_user(void)
308{
309 music_scale_user();
310}
311
312void music_scale_user(void)
313{
314 PLAY_NOTE_ARRAY(music_scale, false, 0);
315}
316
317#endif
diff --git a/keyboards/preonic/keymaps/default/config.h b/keyboards/preonic/keymaps/default/config.h
index 4c6158199..1ce547b94 100644
--- a/keyboards/preonic/keymaps/default/config.h
+++ b/keyboards/preonic/keymaps/default/config.h
@@ -15,6 +15,16 @@
15*/ 15*/
16#define MIDI_BASIC 16#define MIDI_BASIC
17 17
18#ifdef AUDIO_ENABLE
19 #define STARTUP_SONG SONG(PLANCK_SOUND)
20 // #define STARTUP_SONG SONG(NO_SOUND)
21
22 #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \
23 SONG(COLEMAK_SOUND), \
24 SONG(DVORAK_SOUND) \
25 }
26#endif
27
18/* enable advanced MIDI features: 28/* enable advanced MIDI features:
19 - MIDI notes can be added to the keymap 29 - MIDI notes can be added to the keymap
20 - Octave shift and transpose 30 - Octave shift and transpose
diff --git a/keyboards/preonic/keymaps/default/keymap.c b/keyboards/preonic/keymaps/default/keymap.c
index 2516a726b..a05117c9e 100644
--- a/keyboards/preonic/keymaps/default/keymap.c
+++ b/keyboards/preonic/keymaps/default/keymap.c
@@ -1,3 +1,19 @@
1/* Copyright 2015-2017 Jack Humbert
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
1#include "preonic.h" 17#include "preonic.h"
2#include "action_layer.h" 18#include "action_layer.h"
3#include "eeconfig.h" 19#include "eeconfig.h"
@@ -5,11 +21,6 @@
5 #include "audio.h" 21 #include "audio.h"
6#endif 22#endif
7 23
8// Each layer gets a name for readability, which is then used in the keymap matrix below.
9// The underscores don't mean anything - you can have a layer called STUFF or any other name.
10// Layer names don't all need to be of the same length, obviously, and you can also skip them
11// entirely and just use numbers.
12
13enum preonic_layers { 24enum preonic_layers {
14 _QWERTY, 25 _QWERTY,
15 _COLEMAK, 26 _COLEMAK,
@@ -28,10 +39,6 @@ enum preonic_keycodes {
28 BACKLIT 39 BACKLIT
29}; 40};
30 41
31// Fillers to make layering more clear
32#define _______ KC_TRNS
33#define XXXXXXX KC_NO
34
35const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 42const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
36 43
37/* Qwerty 44/* Qwerty
@@ -163,54 +170,23 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
163 170
164}; 171};
165 172
166#ifdef AUDIO_ENABLE
167float tone_startup[][2] = {
168 {NOTE_B5, 20},
169 {NOTE_B6, 8},
170 {NOTE_DS6, 20},
171 {NOTE_B6, 8}
172};
173
174float tone_qwerty[][2] = SONG(QWERTY_SOUND);
175float tone_dvorak[][2] = SONG(DVORAK_SOUND);
176float tone_colemak[][2] = SONG(COLEMAK_SOUND);
177
178float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
179
180float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
181#endif
182
183void persistent_default_layer_set(uint16_t default_layer) {
184 eeconfig_update_default_layer(default_layer);
185 default_layer_set(default_layer);
186}
187
188bool process_record_user(uint16_t keycode, keyrecord_t *record) { 173bool process_record_user(uint16_t keycode, keyrecord_t *record) {
189 switch (keycode) { 174 switch (keycode) {
190 case QWERTY: 175 case QWERTY:
191 if (record->event.pressed) { 176 if (record->event.pressed) {
192 #ifdef AUDIO_ENABLE 177 set_single_persistent_default_layer(_QWERTY);
193 PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
194 #endif
195 persistent_default_layer_set(1UL<<_QWERTY);
196 } 178 }
197 return false; 179 return false;
198 break; 180 break;
199 case COLEMAK: 181 case COLEMAK:
200 if (record->event.pressed) { 182 if (record->event.pressed) {
201 #ifdef AUDIO_ENABLE 183 set_single_persistent_default_layer(_COLEMAK);
202 PLAY_NOTE_ARRAY(tone_colemak, false, 0);
203 #endif
204 persistent_default_layer_set(1UL<<_COLEMAK);
205 } 184 }
206 return false; 185 return false;
207 break; 186 break;
208 case DVORAK: 187 case DVORAK:
209 if (record->event.pressed) { 188 if (record->event.pressed) {
210 #ifdef AUDIO_ENABLE 189 set_single_persistent_default_layer(_DVORAK);
211 PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
212 #endif
213 persistent_default_layer_set(1UL<<_DVORAK);
214 } 190 }
215 return false; 191 return false;
216 break; 192 break;
@@ -248,36 +224,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
248 } 224 }
249 return true; 225 return true;
250}; 226};
251
252void matrix_init_user(void) {
253 #ifdef AUDIO_ENABLE
254 startup_user();
255 #endif
256}
257
258#ifdef AUDIO_ENABLE
259
260void startup_user()
261{
262 _delay_ms(20); // gets rid of tick
263 PLAY_NOTE_ARRAY(tone_startup, false, 0);
264}
265
266void shutdown_user()
267{
268 PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
269 _delay_ms(150);
270 stop_all_notes();
271}
272
273void music_on_user(void)
274{
275 music_scale_user();
276}
277
278void music_scale_user(void)
279{
280 PLAY_NOTE_ARRAY(music_scale, false, 0);
281}
282
283#endif
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c
index c924f2bd5..5b8563093 100644
--- a/quantum/audio/audio.c
+++ b/quantum/audio/audio.c
@@ -13,6 +13,7 @@
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16
16#include <stdio.h> 17#include <stdio.h>
17#include <string.h> 18#include <string.h>
18//#include <math.h> 19//#include <math.h>
@@ -119,9 +120,17 @@ audio_config_t audio_config;
119uint16_t envelope_index = 0; 120uint16_t envelope_index = 0;
120bool glissando = true; 121bool glissando = true;
121 122
123#ifndef STARTUP_SONG
124 #define STARTUP_SONG SONG(STARTUP_SOUND)
125#endif
126float startup_song[][2] = STARTUP_SONG;
127
122void audio_init() 128void audio_init()
123{ 129{
124 130
131 if (audio_initialized)
132 return;
133
125 // Check EEPROM 134 // Check EEPROM
126 if (!eeconfig_is_enabled()) 135 if (!eeconfig_is_enabled())
127 { 136 {
@@ -169,6 +178,11 @@ void audio_init()
169 #endif 178 #endif
170 179
171 audio_initialized = true; 180 audio_initialized = true;
181
182 if (audio_config.enable) {
183 PLAY_NOTE_ARRAY(startup_song, false, LEGATO);
184 }
185
172} 186}
173 187
174void stop_all_notes() 188void stop_all_notes()
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h
index 27fdc2ab6..ad3abeb78 100644
--- a/quantum/audio/audio.h
+++ b/quantum/audio/audio.h
@@ -99,7 +99,7 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest)
99// The global float array for the song must be used here. 99// The global float array for the song must be used here.
100#define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0])))) 100#define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0]))))
101#define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style)); 101#define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style));
102 102#define PLAY_SONG(song) PLAY_NOTE_ARRAY(song, false, STACCATO)
103 103
104bool is_playing_notes(void); 104bool is_playing_notes(void);
105 105
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h
index db2d1a94c..6960bee6d 100644
--- a/quantum/audio/song_list.h
+++ b/quantum/audio/song_list.h
@@ -18,9 +18,7 @@
18#ifndef SONG_LIST_H 18#ifndef SONG_LIST_H
19#define SONG_LIST_H 19#define SONG_LIST_H
20 20
21#define COIN_SOUND \ 21#define NO_SOUND
22 E__NOTE(_A5 ),\
23 HD_NOTE(_E6 ),
24 22
25#define ODE_TO_JOY \ 23#define ODE_TO_JOY \
26 Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \ 24 Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \
@@ -55,18 +53,29 @@
55 E__NOTE(_CS4), E__NOTE(_B4), QD_NOTE(_AS4), \ 53 E__NOTE(_CS4), E__NOTE(_B4), QD_NOTE(_AS4), \
56 E__NOTE(_AS4), E__NOTE(_AS4), QD_NOTE(_B4), 54 E__NOTE(_AS4), E__NOTE(_AS4), QD_NOTE(_B4),
57 55
56#define STARTUP_SOUND \
57 E__NOTE(_E6), \
58 E__NOTE(_A6), \
59 ED_NOTE(_E7),
60
58#define GOODBYE_SOUND \ 61#define GOODBYE_SOUND \
59 E__NOTE(_E7), \ 62 E__NOTE(_E7), \
60 E__NOTE(_A6), \ 63 E__NOTE(_A6), \
61 ED_NOTE(_E6), 64 ED_NOTE(_E6),
62 65
63#define STARTUP_SOUND \ 66#define PLANCK_SOUND \
64 ED_NOTE(_E7 ), \ 67 ED_NOTE(_E7 ), \
65 E__NOTE(_CS7), \ 68 E__NOTE(_CS7), \
66 E__NOTE(_E6 ), \ 69 E__NOTE(_E6 ), \
67 E__NOTE(_A6 ), \ 70 E__NOTE(_A6 ), \
68 M__NOTE(_CS7, 20), 71 M__NOTE(_CS7, 20),
69 72
73#define PREONIC_SOUND \
74 M__NOTE(_B5, 20), \
75 E__NOTE(_B6), \
76 M__NOTE(_DS6, 20), \
77 E__NOTE(_B6),
78
70#define QWERTY_SOUND \ 79#define QWERTY_SOUND \
71 E__NOTE(_GS6 ), \ 80 E__NOTE(_GS6 ), \
72 E__NOTE(_A6 ), \ 81 E__NOTE(_A6 ), \
@@ -107,7 +116,8 @@
107 S__NOTE(_REST), \ 116 S__NOTE(_REST), \
108 ED_NOTE(_E7 ), 117 ED_NOTE(_E7 ),
109 118
110#define MUSIC_SCALE_SOUND \ 119
120#define MUSIC_ON_SOUND \
111 E__NOTE(_A5 ), \ 121 E__NOTE(_A5 ), \
112 E__NOTE(_B5 ), \ 122 E__NOTE(_B5 ), \
113 E__NOTE(_CS6), \ 123 E__NOTE(_CS6), \
@@ -117,6 +127,18 @@
117 E__NOTE(_GS6), \ 127 E__NOTE(_GS6), \
118 E__NOTE(_A6 ), 128 E__NOTE(_A6 ),
119 129
130#define MUSIC_SCALE_SOUND MUSIC_ON_SOUND
131
132#define MUSIC_OFF_SOUND \
133 E__NOTE(_A6 ), \
134 E__NOTE(_GS6 ), \
135 E__NOTE(_FS6), \
136 E__NOTE(_E6 ), \
137 E__NOTE(_D6 ), \
138 E__NOTE(_CS6), \
139 E__NOTE(_B5), \
140 E__NOTE(_A5 ),
141
120#define CAPS_LOCK_ON_SOUND \ 142#define CAPS_LOCK_ON_SOUND \
121 E__NOTE(_A3), \ 143 E__NOTE(_A3), \
122 E__NOTE(_B3), 144 E__NOTE(_B3),
@@ -141,6 +163,16 @@
141 E__NOTE(_E5), \ 163 E__NOTE(_E5), \
142 E__NOTE(_D5), 164 E__NOTE(_D5),
143 165
166#define AG_NORM_SOUND \
167 E__NOTE(_A5), \
168 E__NOTE(_A5),
169
170#define AG_SWAP_SOUND \
171 SD_NOTE(_B5), \
172 SD_NOTE(_A5), \
173 SD_NOTE(_B5), \
174 SD_NOTE(_A5),
175
144#define UNICODE_WINDOWS \ 176#define UNICODE_WINDOWS \
145 E__NOTE(_B5), \ 177 E__NOTE(_B5), \
146 S__NOTE(_E6), 178 S__NOTE(_E6),
diff --git a/quantum/config_common.h b/quantum/config_common.h
index c88e02d91..4c6a702af 100644
--- a/quantum/config_common.h
+++ b/quantum/config_common.h
@@ -100,4 +100,6 @@
100 100
101#define API_SYSEX_MAX_SIZE 32 101#define API_SYSEX_MAX_SIZE 32
102 102
103#include "song_list.h"
104
103#endif 105#endif
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c
index 217dca280..c01740a7f 100644
--- a/quantum/process_keycode/process_music.c
+++ b/quantum/process_keycode/process_music.c
@@ -39,6 +39,15 @@ static uint8_t music_sequence_position = 0;
39static uint16_t music_sequence_timer = 0; 39static uint16_t music_sequence_timer = 0;
40static uint16_t music_sequence_interval = 100; 40static uint16_t music_sequence_interval = 100;
41 41
42#ifndef MUSIC_ON_SONG
43 #define MUSIC_ON_SONG SONG(MUSIC_ON_SOUND)
44#endif
45#ifndef MUSIC_OFF_SONG
46 #define MUSIC_OFF_SONG SONG(MUSIC_OFF_SOUND)
47#endif
48float music_on_song[][2] = MUSIC_ON_SONG;
49float music_off_song[][2] = MUSIC_OFF_SONG;
50
42static void music_noteon(uint8_t note) { 51static void music_noteon(uint8_t note) {
43 #ifdef AUDIO_ENABLE 52 #ifdef AUDIO_ENABLE
44 process_audio_noteon(note); 53 process_audio_noteon(note);
@@ -79,12 +88,9 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
79 } 88 }
80 89
81 if (keycode == MU_TOG && record->event.pressed) { 90 if (keycode == MU_TOG && record->event.pressed) {
82 if (music_activated) 91 if (music_activated) {
83 {
84 music_off(); 92 music_off();
85 } 93 } else {
86 else
87 {
88 music_on(); 94 music_on();
89 } 95 }
90 return false; 96 return false;
@@ -175,12 +181,14 @@ void music_toggle(void) {
175 181
176void music_on(void) { 182void music_on(void) {
177 music_activated = 1; 183 music_activated = 1;
184 PLAY_SONG(music_on_song);
178 music_on_user(); 185 music_on_user();
179} 186}
180 187
181void music_off(void) { 188void music_off(void) {
182 music_activated = 0;
183 music_all_notes_off(); 189 music_all_notes_off();
190 music_activated = 0;
191 PLAY_SONG(music_off_song);
184} 192}
185 193
186void matrix_scan_music(void) { 194void matrix_scan_music(void) {
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 36e586d31..31a6fc713 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -30,6 +30,28 @@ extern backlight_config_t backlight_config;
30#include "fauxclicky.h" 30#include "fauxclicky.h"
31#endif 31#endif
32 32
33#ifdef AUDIO_ENABLE
34 #ifndef GOODBYE_SONG
35 #define GOODBYE_SONG SONG(GOODBYE_SOUND)
36 #endif
37 #ifndef AG_NORM_SONG
38 #define AG_NORM_SONG SONG(AG_NORM_SOUND)
39 #endif
40 #ifndef AG_SWAP_SONG
41 #define AG_SWAP_SONG SONG(AG_SWAP_SOUND)
42 #endif
43 #ifndef DEFAULT_LAYER_SONGS
44 #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \
45 SONG(COLEMAK_SOUND) \
46 SONG(DVORAK_SOUND) \
47 }
48 #endif
49 float goodbye_song[][2] = GOODBYE_SONG;
50 float ag_norm_song[][2] = AG_NORM_SONG;
51 float ag_swap_song[][2] = AG_SWAP_SONG;
52 float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
53#endif
54
33static void do_code16 (uint16_t code, void (*f) (uint8_t)) { 55static void do_code16 (uint16_t code, void (*f) (uint8_t)) {
34 switch (code) { 56 switch (code) {
35 case QK_MODS ... QK_MODS_MAX: 57 case QK_MODS ... QK_MODS_MAX:
@@ -116,9 +138,15 @@ void reset_keyboard(void) {
116 clear_keyboard(); 138 clear_keyboard();
117#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC)) 139#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC))
118 music_all_notes_off(); 140 music_all_notes_off();
141 uint16_t timer_start = timer_read();
142 PLAY_SONG(goodbye_song);
119 shutdown_user(); 143 shutdown_user();
120#endif 144 while(timer_elapsed(timer_start) < 250)
145 wait_ms(1);
146 stop_all_notes();
147#else
121 wait_ms(250); 148 wait_ms(250);
149#endif
122#ifdef CATERINA_BOOTLOADER 150#ifdef CATERINA_BOOTLOADER
123 *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific 151 *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
124#endif 152#endif
@@ -351,6 +379,9 @@ bool process_record_quantum(keyrecord_t *record) {
351 case MAGIC_SWAP_ALT_GUI: 379 case MAGIC_SWAP_ALT_GUI:
352 keymap_config.swap_lalt_lgui = true; 380 keymap_config.swap_lalt_lgui = true;
353 keymap_config.swap_ralt_rgui = true; 381 keymap_config.swap_ralt_rgui = true;
382 #ifdef AUDIO_ENABLE
383 PLAY_SONG(ag_swap_song);
384 #endif
354 break; 385 break;
355 case MAGIC_UNSWAP_CONTROL_CAPSLOCK: 386 case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
356 keymap_config.swap_control_capslock = false; 387 keymap_config.swap_control_capslock = false;
@@ -379,6 +410,9 @@ bool process_record_quantum(keyrecord_t *record) {
379 case MAGIC_UNSWAP_ALT_GUI: 410 case MAGIC_UNSWAP_ALT_GUI:
380 keymap_config.swap_lalt_lgui = false; 411 keymap_config.swap_lalt_lgui = false;
381 keymap_config.swap_ralt_rgui = false; 412 keymap_config.swap_ralt_rgui = false;
413 #ifdef AUDIO_ENABLE
414 PLAY_SONG(ag_norm_song);
415 #endif
382 break; 416 break;
383 case MAGIC_TOGGLE_NKRO: 417 case MAGIC_TOGGLE_NKRO:
384 keymap_config.nkro = !keymap_config.nkro; 418 keymap_config.nkro = !keymap_config.nkro;
@@ -521,6 +555,14 @@ void send_string_with_delay(const char *str, uint8_t interval) {
521 } 555 }
522} 556}
523 557
558void set_single_persistent_default_layer(uint8_t default_layer) {
559 #ifdef AUDIO_ENABLE
560 PLAY_SONG(default_layer_songs[default_layer]);
561 #endif
562 eeconfig_update_default_layer(1U<<default_layer);
563 default_layer_set(1U<<default_layer);
564}
565
524void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { 566void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
525 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { 567 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
526 layer_on(layer3); 568 layer_on(layer3);
@@ -571,6 +613,9 @@ void matrix_init_quantum() {
571 #ifdef BACKLIGHT_ENABLE 613 #ifdef BACKLIGHT_ENABLE
572 backlight_init_ports(); 614 backlight_init_ports();
573 #endif 615 #endif
616 #ifdef AUDIO_ENABLE
617 audio_init();
618 #endif
574 matrix_init_kb(); 619 matrix_init_kb();
575} 620}
576 621
diff --git a/quantum/quantum.h b/quantum/quantum.h
index e00fe2346..6c0e46573 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -56,6 +56,7 @@ extern uint32_t default_layer_state;
56#endif // MIDI_ENABLE 56#endif // MIDI_ENABLE
57 57
58#ifdef AUDIO_ENABLE 58#ifdef AUDIO_ENABLE
59 #include "audio.h"
59 #include "process_audio.h" 60 #include "process_audio.h"
60#endif 61#endif
61 62
@@ -103,6 +104,8 @@ void send_string_with_delay(const char *str, uint8_t interval);
103// For tri-layer 104// For tri-layer
104void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); 105void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
105 106
107void set_single_persistent_default_layer(uint8_t default_layer);
108
106void tap_random_base64(void); 109void tap_random_base64(void);
107 110
108#define IS_LAYER_ON(layer) (layer_state & (1UL << (layer))) 111#define IS_LAYER_ON(layer) (layer_state & (1UL << (layer)))
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index 6038e31c4..c863b887a 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -26,6 +26,10 @@
26#endif 26#endif
27#endif 27#endif
28 28
29// Fillers to make layering more clear
30#define _______ KC_TRNS
31#define XXXXXXX KC_NO
32
29enum quantum_keycodes { 33enum quantum_keycodes {
30 // Ranges used in shortucuts - not to be used directly 34 // Ranges used in shortucuts - not to be used directly
31 QK_TMK = 0x0000, 35 QK_TMK = 0x0000,