diff options
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r-- | quantum/quantum.c | 69 |
1 files changed, 45 insertions, 24 deletions
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 | ||