diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/audio/audio.c | 17 | ||||
-rw-r--r-- | quantum/audio/audio.h | 6 | ||||
-rw-r--r-- | quantum/keymap_common.c | 3 | ||||
-rw-r--r-- | quantum/quantum.c | 69 | ||||
-rw-r--r-- | quantum/quantum.h | 4 |
5 files changed, 52 insertions, 47 deletions
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 32f64417e..3ca249fdf 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c | |||
@@ -475,20 +475,3 @@ void increase_tempo(uint8_t tempo_change) { | |||
475 | note_tempo -= tempo_change; | 475 | note_tempo -= tempo_change; |
476 | } | 476 | } |
477 | } | 477 | } |
478 | |||
479 | |||
480 | //------------------------------------------------------------------------------ | ||
481 | // Override these functions in your keymap file to play different tunes on | ||
482 | // startup and bootloader jump | ||
483 | __attribute__ ((weak)) | ||
484 | void play_startup_tone() {} | ||
485 | |||
486 | __attribute__ ((weak)) | ||
487 | void play_goodbye_tone() {} | ||
488 | |||
489 | __attribute__ ((weak)) | ||
490 | void audio_on_user() {} | ||
491 | |||
492 | __attribute__ ((weak)) | ||
493 | void play_music_scale() {} | ||
494 | //------------------------------------------------------------------------------ | ||
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index b46f587bb..00d45f7ac 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "musical_notes.h" | 5 | #include "musical_notes.h" |
6 | #include "song_list.h" | 6 | #include "song_list.h" |
7 | #include "voices.h" | 7 | #include "voices.h" |
8 | #include "quantum.h" | ||
8 | 9 | ||
9 | #ifndef AUDIO_H | 10 | #ifndef AUDIO_H |
10 | #define AUDIO_H | 11 | #define AUDIO_H |
@@ -87,9 +88,4 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) | |||
87 | 88 | ||
88 | bool is_playing_notes(void); | 89 | bool is_playing_notes(void); |
89 | 90 | ||
90 | void play_goodbye_tone(void); | ||
91 | void play_startup_tone(void); | ||
92 | void audio_on_user(void); | ||
93 | void play_music_scale(void); | ||
94 | |||
95 | #endif \ No newline at end of file | 91 | #endif \ No newline at end of file |
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 1d9ab2e05..ba7269388 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
26 | #include "backlight.h" | 26 | #include "backlight.h" |
27 | #include "bootloader.h" | 27 | #include "bootloader.h" |
28 | #include "eeconfig.h" | 28 | #include "eeconfig.h" |
29 | #include "quantum.h" | ||
29 | 30 | ||
30 | #ifdef MIDI_ENABLE | 31 | #ifdef MIDI_ENABLE |
31 | #include "keymap_midi.h" | 32 | #include "keymap_midi.h" |
@@ -190,7 +191,7 @@ static action_t keycode_to_action(uint16_t keycode) | |||
190 | clear_keyboard(); | 191 | clear_keyboard(); |
191 | #ifdef AUDIO_ENABLE | 192 | #ifdef AUDIO_ENABLE |
192 | stop_all_notes(); | 193 | stop_all_notes(); |
193 | play_goodbye_tone(); | 194 | shutdown_user(); |
194 | #endif | 195 | #endif |
195 | _delay_ms(250); | 196 | _delay_ms(250); |
196 | #ifdef ATREUS_ASTAR | 197 | #ifdef ATREUS_ASTAR |
diff --git a/quantum/quantum.c b/quantum/quantum.c index 34c575af4..eb64a99a4 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -23,17 +23,16 @@ int offset = 7; | |||
23 | 23 | ||
24 | #ifdef AUDIO_ENABLE | 24 | #ifdef AUDIO_ENABLE |
25 | bool music_activated = false; | 25 | bool music_activated = false; |
26 | float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); | ||
27 | 26 | ||
28 | // music sequencer | 27 | // music sequencer |
29 | static bool music_sequence_recording = false; | 28 | static bool music_sequence_recording = false; |
30 | static bool music_sequence_playing = false; | 29 | static bool music_sequence_playing = false; |
31 | static float music_sequence[16] = {0}; | 30 | static float music_sequence[16] = {0}; |
32 | static uint8_t music_sequence_count = 0; | 31 | static uint8_t music_sequence_count = 0; |
33 | static uint8_t music_sequence_position = 0; | 32 | static uint8_t music_sequence_position = 0; |
34 | 33 | ||
35 | static uint16_t music_sequence_timer = 0; | 34 | static uint16_t music_sequence_timer = 0; |
36 | static uint16_t music_sequence_interval = 100; | 35 | static uint16_t music_sequence_interval = 100; |
37 | 36 | ||
38 | #endif | 37 | #endif |
39 | 38 | ||
@@ -133,7 +132,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
133 | #ifdef MIDI_ENABLE | 132 | #ifdef MIDI_ENABLE |
134 | if (keycode == MI_ON && record->event.pressed) { | 133 | if (keycode == MI_ON && record->event.pressed) { |
135 | midi_activated = true; | 134 | midi_activated = true; |
136 | play_music_scale(); | 135 | music_scale_user(); |
137 | return false; | 136 | return false; |
138 | } | 137 | } |
139 | 138 | ||
@@ -230,37 +229,37 @@ bool process_record_quantum(keyrecord_t *record) { | |||
230 | } | 229 | } |
231 | 230 | ||
232 | if (keycode == MU_ON && record->event.pressed) { | 231 | if (keycode == MU_ON && record->event.pressed) { |
233 | music_on(); | 232 | music_on(); |
234 | return false; | 233 | return false; |
235 | } | 234 | } |
236 | 235 | ||
237 | if (keycode == MU_OFF && record->event.pressed) { | 236 | if (keycode == MU_OFF && record->event.pressed) { |
238 | music_off(); | 237 | music_off(); |
239 | return false; | 238 | return false; |
240 | } | 239 | } |
241 | 240 | ||
242 | if (keycode == MU_TOG && record->event.pressed) { | 241 | if (keycode == MU_TOG && record->event.pressed) { |
243 | if (music_activated) | 242 | if (music_activated) |
244 | { | 243 | { |
245 | music_off(); | 244 | music_off(); |
246 | } | 245 | } |
247 | else | 246 | else |
248 | { | 247 | { |
249 | music_on(); | 248 | music_on(); |
250 | } | 249 | } |
251 | return false; | 250 | return false; |
252 | } | 251 | } |
253 | 252 | ||
254 | if (keycode == MUV_IN && record->event.pressed) { | 253 | if (keycode == MUV_IN && record->event.pressed) { |
255 | voice_iterate(); | 254 | voice_iterate(); |
256 | play_music_scale(); | 255 | music_scale_user(); |
257 | return false; | 256 | return false; |
258 | } | 257 | } |
259 | 258 | ||
260 | if (keycode == MUV_DE && record->event.pressed) { | 259 | if (keycode == MUV_DE && record->event.pressed) { |
261 | voice_deiterate(); | 260 | voice_deiterate(); |
262 | play_music_scale(); | 261 | music_scale_user(); |
263 | return false; | 262 | return false; |
264 | } | 263 | } |
265 | 264 | ||
266 | if (music_activated) { | 265 | if (music_activated) { |
@@ -272,12 +271,14 @@ bool process_record_quantum(keyrecord_t *record) { | |||
272 | music_sequence_count = 0; | 271 | music_sequence_count = 0; |
273 | return false; | 272 | return false; |
274 | } | 273 | } |
274 | |||
275 | if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing | 275 | if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing |
276 | stop_all_notes(); | 276 | stop_all_notes(); |
277 | music_sequence_recording = false; | 277 | music_sequence_recording = false; |
278 | music_sequence_playing = false; | 278 | music_sequence_playing = false; |
279 | return false; | 279 | return false; |
280 | } | 280 | } |
281 | |||
281 | if (keycode == KC_LGUI && record->event.pressed) { // Start playing | 282 | if (keycode == KC_LGUI && record->event.pressed) { // Start playing |
282 | stop_all_notes(); | 283 | stop_all_notes(); |
283 | music_sequence_recording = false; | 284 | music_sequence_recording = false; |
@@ -289,12 +290,13 @@ bool process_record_quantum(keyrecord_t *record) { | |||
289 | 290 | ||
290 | if (keycode == KC_UP) { | 291 | if (keycode == KC_UP) { |
291 | if (record->event.pressed) | 292 | if (record->event.pressed) |
292 | music_sequence_interval-=10; | 293 | music_sequence_interval-=10; |
293 | return false; | 294 | return false; |
294 | } | 295 | } |
296 | |||
295 | if (keycode == KC_DOWN) { | 297 | if (keycode == KC_DOWN) { |
296 | if (record->event.pressed) | 298 | if (record->event.pressed) |
297 | music_sequence_interval+=10; | 299 | music_sequence_interval+=10; |
298 | return false; | 300 | return false; |
299 | } | 301 | } |
300 | 302 | ||
@@ -459,5 +461,24 @@ void matrix_scan_quantum() { | |||
459 | } | 461 | } |
460 | 462 | ||
461 | #endif | 463 | #endif |
464 | |||
465 | //------------------------------------------------------------------------------ | ||
466 | // Override these functions in your keymap file to play different tunes on | ||
467 | // different events such as startup and bootloader jump | ||
468 | |||
469 | __attribute__ ((weak)) | ||
470 | void startup_user() {} | ||
471 | |||
472 | __attribute__ ((weak)) | ||
473 | void shutdown_user() {} | ||
474 | |||
462 | __attribute__ ((weak)) | 475 | __attribute__ ((weak)) |
463 | void music_on_user() {} | 476 | void music_on_user() {} |
477 | |||
478 | __attribute__ ((weak)) | ||
479 | void audio_on_user() {} | ||
480 | |||
481 | __attribute__ ((weak)) | ||
482 | void music_scale_user() {} | ||
483 | |||
484 | //------------------------------------------------------------------------------ \ No newline at end of file | ||
diff --git a/quantum/quantum.h b/quantum/quantum.h index d4da77289..69a0d8126 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
@@ -67,6 +67,10 @@ void music_toggle(void); | |||
67 | void music_on(void); | 67 | void music_on(void); |
68 | void music_off(void); | 68 | void music_off(void); |
69 | 69 | ||
70 | void startup_user(void); | ||
71 | void shutdown_user(void); | ||
72 | void audio_on_user(void); | ||
70 | void music_on_user(void); | 73 | void music_on_user(void); |
74 | void music_scale_user(void); | ||
71 | 75 | ||
72 | #endif \ No newline at end of file | 76 | #endif \ No newline at end of file |