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 | |
parent | 1ae6011cef2230826a9e6db6c5b638677bc640b7 (diff) |
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')
-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 32f64417ed..3ca249fdf5 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -475,20 +475,3 @@ void increase_tempo(uint8_t tempo_change) { note_tempo -= tempo_change; } } - - -//------------------------------------------------------------------------------ -// Override these functions in your keymap file to play different tunes on -// startup and bootloader jump -__attribute__ ((weak)) -void play_startup_tone() {} - -__attribute__ ((weak)) -void play_goodbye_tone() {} - -__attribute__ ((weak)) -void audio_on_user() {} - -__attribute__ ((weak)) -void play_music_scale() {} -//------------------------------------------------------------------------------ diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index b46f587bb4..00d45f7ac1 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -5,6 +5,7 @@ #include "musical_notes.h" #include "song_list.h" #include "voices.h" +#include "quantum.h" #ifndef AUDIO_H #define AUDIO_H @@ -87,9 +88,4 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) bool is_playing_notes(void); -void play_goodbye_tone(void); -void play_startup_tone(void); -void audio_on_user(void); -void play_music_scale(void); - #endif
\ No newline at end of file diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 1d9ab2e05c..ba7269388b 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/>. #include "backlight.h" #include "bootloader.h" #include "eeconfig.h" +#include "quantum.h" #ifdef MIDI_ENABLE #include "keymap_midi.h" @@ -190,7 +191,7 @@ static action_t keycode_to_action(uint16_t keycode) clear_keyboard(); #ifdef AUDIO_ENABLE stop_all_notes(); - play_goodbye_tone(); + shutdown_user(); #endif _delay_ms(250); #ifdef ATREUS_ASTAR diff --git a/quantum/quantum.c b/quantum/quantum.c index 34c575af42..eb64a99a4d 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 diff --git a/quantum/quantum.h b/quantum/quantum.h index d4da772890..69a0d8126a 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -67,6 +67,10 @@ void music_toggle(void); void music_on(void); void music_off(void); +void startup_user(void); +void shutdown_user(void); +void audio_on_user(void); void music_on_user(void); +void music_scale_user(void); #endif
\ No newline at end of file |