diff options
author | Jack Humbert <jack.humb@gmail.com> | 2016-05-24 11:56:53 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2016-05-24 11:56:53 -0400 |
commit | 287eb7ad148abc8fe3fb014218d71e205fd9131d (patch) | |
tree | 59e800a739797cb86d9345d01f73fceee4c32030 /quantum/quantum.c | |
parent | 1ae6011cef2230826a9e6db6c5b638677bc640b7 (diff) | |
download | firmware-287eb7ad148abc8fe3fb014218d71e205fd9131d.tar.gz firmware-287eb7ad148abc8fe3fb014218d71e205fd9131d.tar.bz2 firmware-287eb7ad148abc8fe3fb014218d71e205fd9131d.zip |
Converted audio play functions to *_user (#349)
* Updated personal layouts
* tweaked personal
* Nightly - Audio Cleanup
Refactored the LUTs. Abstracted some of the registers out of audio to
use more functional names. Split audio into audio and audio_pwm. WIP
* nightly - collapsed code
* Added check for note playing to LEDs
* Usability tweaks
* TWEAE
* nightly
added extra kcs to keymap common
* turned on Plank audio
* Added backlight breathing to atomic
* reverted accidental merge
* Added music and audio toggles to Quantum.c
* Redid the audio callbacks
* Adjusted default planck layout to use the user tone naming
* tabs to spaces
* Rewrote the ALL recipe to allow for faster parallel make
* tabs to spaces
* Renamed custom event functions to be 'startup_user' and 'shutdown_user'. Also moved the prototypes around.
* Tweaked pvc atomic layout to work with the pvc planck.
* updates midi scale calling
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; #ifdef AUDIO_ENABLE bool music_activated = false; - float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); - // music sequencer - static bool music_sequence_recording = false; - static bool music_sequence_playing = false; - static float music_sequence[16] = {0}; - static uint8_t music_sequence_count = 0; - static uint8_t music_sequence_position = 0; +// music sequencer +static bool music_sequence_recording = false; +static bool music_sequence_playing = false; +static float music_sequence[16] = {0}; +static uint8_t music_sequence_count = 0; +static uint8_t music_sequence_position = 0; - static uint16_t music_sequence_timer = 0; - static uint16_t music_sequence_interval = 100; +static uint16_t music_sequence_timer = 0; +static uint16_t music_sequence_interval = 100; #endif @@ -133,7 +132,7 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef MIDI_ENABLE if (keycode == MI_ON && record->event.pressed) { midi_activated = true; - play_music_scale(); + music_scale_user(); return false; } @@ -230,37 +229,37 @@ bool process_record_quantum(keyrecord_t *record) { } if (keycode == MU_ON && record->event.pressed) { - music_on(); - return false; + music_on(); + return false; } if (keycode == MU_OFF && record->event.pressed) { - music_off(); - return false; + music_off(); + return false; } if (keycode == MU_TOG && record->event.pressed) { if (music_activated) { - music_off(); + music_off(); } else { - music_on(); + music_on(); } return false; } if (keycode == MUV_IN && record->event.pressed) { - voice_iterate(); - play_music_scale(); - return false; + voice_iterate(); + music_scale_user(); + return false; } if (keycode == MUV_DE && record->event.pressed) { - voice_deiterate(); - play_music_scale(); - return false; + voice_deiterate(); + music_scale_user(); + return false; } if (music_activated) { @@ -272,12 +271,14 @@ bool process_record_quantum(keyrecord_t *record) { music_sequence_count = 0; return false; } + if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing stop_all_notes(); music_sequence_recording = false; music_sequence_playing = false; return false; } + if (keycode == KC_LGUI && record->event.pressed) { // Start playing stop_all_notes(); music_sequence_recording = false; @@ -289,12 +290,13 @@ bool process_record_quantum(keyrecord_t *record) { if (keycode == KC_UP) { if (record->event.pressed) - music_sequence_interval-=10; + music_sequence_interval-=10; return false; } + if (keycode == KC_DOWN) { if (record->event.pressed) - music_sequence_interval+=10; + music_sequence_interval+=10; return false; } @@ -459,5 +461,24 @@ void matrix_scan_quantum() { } #endif + +//------------------------------------------------------------------------------ +// Override these functions in your keymap file to play different tunes on +// different events such as startup and bootloader jump + +__attribute__ ((weak)) +void startup_user() {} + +__attribute__ ((weak)) +void shutdown_user() {} + __attribute__ ((weak)) void music_on_user() {} + +__attribute__ ((weak)) +void audio_on_user() {} + +__attribute__ ((weak)) +void music_scale_user() {} + +//------------------------------------------------------------------------------
\ No newline at end of file |