summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/audio/audio.c54
-rw-r--r--quantum/audio/audio.h8
-rw-r--r--quantum/audio/musical_notes.h7
-rw-r--r--quantum/audio/song_list.h74
-rw-r--r--quantum/config_common.h2
-rw-r--r--quantum/process_keycode/process_audio.c22
-rw-r--r--quantum/process_keycode/process_music.c153
-rw-r--r--quantum/process_keycode/process_music.h9
-rw-r--r--quantum/quantum.c44
-rw-r--r--quantum/quantum.h3
-rw-r--r--quantum/quantum_keycodes.h7
11 files changed, 294 insertions, 89 deletions
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c
index c924f2bd58..8e8570d26c 100644
--- a/quantum/audio/audio.c
+++ b/quantum/audio/audio.c
@@ -13,6 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
#include <stdio.h>
#include <string.h>
//#include <math.h>
@@ -98,7 +99,6 @@ uint16_t note_position = 0;
float (* notes_pointer)[][2];
uint16_t notes_count;
bool notes_repeat;
-float notes_rest;
bool note_resting = false;
uint8_t current_note = 0;
@@ -119,9 +119,17 @@ audio_config_t audio_config;
uint16_t envelope_index = 0;
bool glissando = true;
+#ifndef STARTUP_SONG
+ #define STARTUP_SONG SONG(STARTUP_SOUND)
+#endif
+float startup_song[][2] = STARTUP_SONG;
+
void audio_init()
{
+ if (audio_initialized)
+ return;
+
// Check EEPROM
if (!eeconfig_is_enabled())
{
@@ -169,6 +177,11 @@ void audio_init()
#endif
audio_initialized = true;
+
+ if (audio_config.enable) {
+ PLAY_SONG(startup_song);
+ }
+
}
void stop_all_notes()
@@ -402,9 +415,12 @@ ISR(TIMER3_COMPA_vect)
note_position++;
bool end_of_note = false;
if (TIMER_3_PERIOD > 0) {
- end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF));
+ if (!note_resting)
+ end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF - 1));
+ else
+ end_of_note = (note_position >= (note_length));
} else {
- end_of_note = (note_position >= (note_length * 0x7FF));
+ end_of_note = (note_position >= (note_length));
}
if (end_of_note) {
@@ -419,11 +435,16 @@ ISR(TIMER3_COMPA_vect)
return;
}
}
- if (!note_resting && (notes_rest > 0)) {
+ if (!note_resting) {
note_resting = true;
- note_frequency = 0;
- note_length = notes_rest;
current_note--;
+ if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) {
+ note_frequency = 0;
+ note_length = 1;
+ } else {
+ note_frequency = (*notes_pointer)[current_note][0];
+ note_length = 1;
+ }
} else {
note_resting = false;
envelope_index = 0;
@@ -534,9 +555,12 @@ ISR(TIMER1_COMPA_vect)
note_position++;
bool end_of_note = false;
if (TIMER_1_PERIOD > 0) {
- end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF));
+ if (!note_resting)
+ end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1));
+ else
+ end_of_note = (note_position >= (note_length));
} else {
- end_of_note = (note_position >= (note_length * 0x7FF));
+ end_of_note = (note_position >= (note_length));
}
if (end_of_note) {
@@ -551,11 +575,16 @@ ISR(TIMER1_COMPA_vect)
return;
}
}
- if (!note_resting && (notes_rest > 0)) {
+ if (!note_resting) {
note_resting = true;
- note_frequency = 0;
- note_length = notes_rest;
current_note--;
+ if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) {
+ note_frequency = 0;
+ note_length = 1;
+ } else {
+ note_frequency = (*notes_pointer)[current_note][0];
+ note_length = 1;
+ }
} else {
note_resting = false;
envelope_index = 0;
@@ -624,7 +653,7 @@ void play_note(float freq, int vol) {
}
-void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest)
+void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat)
{
if (!audio_initialized) {
@@ -649,7 +678,6 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest)
notes_pointer = np;
notes_count = n_count;
notes_repeat = n_repeat;
- notes_rest = n_rest;
place = 0;
current_note = 0;
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h
index 27fdc2ab63..79e0da2295 100644
--- a/quantum/audio/audio.h
+++ b/quantum/audio/audio.h
@@ -86,7 +86,7 @@ void play_sample(uint8_t * s, uint16_t l, bool r);
void play_note(float freq, int vol);
void stop_note(float freq);
void stop_all_notes(void);
-void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest);
+void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat);
#define SCALE (int8_t []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \
0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \
@@ -98,8 +98,10 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest)
// length. This works around the limitation of C's sizeof operation on pointers.
// The global float array for the song must be used here.
#define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0]))))
-#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));
-
+#define PLAY_NOTE_ARRAY(note_array, note_repeat, deprecated_arg) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat)); \
+ _Pragma ("message \"'PLAY_NOTE_ARRAY' macro is deprecated\"")
+#define PLAY_SONG(note_array) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), false)
+#define PLAY_LOOP(note_array) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), true)
bool is_playing_notes(void);
diff --git a/quantum/audio/musical_notes.h b/quantum/audio/musical_notes.h
index a3aaa2f199..647b695640 100644
--- a/quantum/audio/musical_notes.h
+++ b/quantum/audio/musical_notes.h
@@ -51,12 +51,6 @@
#define ED_NOTE(n) EIGHTH_DOT_NOTE(n)
#define SD_NOTE(n) SIXTEENTH_DOT_NOTE(n)
-// Note Styles
-// Staccato makes sure there is a rest between each note. Think: TA TA TA
-// Legato makes notes flow together. Think: TAAA
-#define STACCATO 0.01
-#define LEGATO 0
-
// Note Timbre
// Changes how the notes sound
#define TIMBRE_12 0.125
@@ -65,7 +59,6 @@
#define TIMBRE_75 0.750
#define TIMBRE_DEFAULT TIMBRE_50
-
// Notes - # = Octave
#define NOTE_REST 0.00
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h
index db2d1a94cd..f355d371bd 100644
--- a/quantum/audio/song_list.h
+++ b/quantum/audio/song_list.h
@@ -18,9 +18,7 @@
#ifndef SONG_LIST_H
#define SONG_LIST_H
-#define COIN_SOUND \
- E__NOTE(_A5 ),\
- HD_NOTE(_E6 ),
+#define NO_SOUND
#define ODE_TO_JOY \
Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \
@@ -55,18 +53,29 @@
E__NOTE(_CS4), E__NOTE(_B4), QD_NOTE(_AS4), \
E__NOTE(_AS4), E__NOTE(_AS4), QD_NOTE(_B4),
+#define STARTUP_SOUND \
+ E__NOTE(_E6), \
+ E__NOTE(_A6), \
+ ED_NOTE(_E7),
+
#define GOODBYE_SOUND \
E__NOTE(_E7), \
E__NOTE(_A6), \
ED_NOTE(_E6),
-#define STARTUP_SOUND \
+#define PLANCK_SOUND \
ED_NOTE(_E7 ), \
E__NOTE(_CS7), \
E__NOTE(_E6 ), \
E__NOTE(_A6 ), \
M__NOTE(_CS7, 20),
+#define PREONIC_SOUND \
+ M__NOTE(_B5, 20), \
+ E__NOTE(_B6), \
+ M__NOTE(_DS6, 20), \
+ E__NOTE(_B6),
+
#define QWERTY_SOUND \
E__NOTE(_GS6 ), \
E__NOTE(_A6 ), \
@@ -107,7 +116,8 @@
S__NOTE(_REST), \
ED_NOTE(_E7 ),
-#define MUSIC_SCALE_SOUND \
+
+#define MUSIC_ON_SOUND \
E__NOTE(_A5 ), \
E__NOTE(_B5 ), \
E__NOTE(_CS6), \
@@ -117,6 +127,50 @@
E__NOTE(_GS6), \
E__NOTE(_A6 ),
+#define MUSIC_SCALE_SOUND MUSIC_ON_SOUND
+
+#define MUSIC_OFF_SOUND \
+ E__NOTE(_A6 ), \
+ E__NOTE(_GS6 ), \
+ E__NOTE(_FS6), \
+ E__NOTE(_E6 ), \
+ E__NOTE(_D6 ), \
+ E__NOTE(_CS6), \
+ E__NOTE(_B5), \
+ E__NOTE(_A5 ),
+
+#define VOICE_CHANGE_SOUND \
+ Q__NOTE(_A5 ), \
+ Q__NOTE(_CS6), \
+ Q__NOTE(_E6 ), \
+ Q__NOTE(_A6 ),
+
+#define CHROMATIC_SOUND \
+ Q__NOTE(_A5 ), \
+ Q__NOTE(_AS5 ), \
+ Q__NOTE(_B5), \
+ Q__NOTE(_C6 ), \
+ Q__NOTE(_CS6 ),
+
+#define MAJOR_SOUND \
+ Q__NOTE(_A5 ), \
+ Q__NOTE(_B5 ), \
+ Q__NOTE(_CS6), \
+ Q__NOTE(_D6 ), \
+ Q__NOTE(_E6 ),
+
+#define GUITAR_SOUND \
+ Q__NOTE(_E5 ), \
+ Q__NOTE(_A5), \
+ Q__NOTE(_D6 ), \
+ Q__NOTE(_G6 ),
+
+#define VIOLIN_SOUND \
+ Q__NOTE(_G5 ), \
+ Q__NOTE(_D6), \
+ Q__NOTE(_A6 ), \
+ Q__NOTE(_E7 ),
+
#define CAPS_LOCK_ON_SOUND \
E__NOTE(_A3), \
E__NOTE(_B3),
@@ -141,6 +195,16 @@
E__NOTE(_E5), \
E__NOTE(_D5),
+#define AG_NORM_SOUND \
+ E__NOTE(_A5), \
+ E__NOTE(_A5),
+
+#define AG_SWAP_SOUND \
+ SD_NOTE(_B5), \
+ SD_NOTE(_A5), \
+ SD_NOTE(_B5), \
+ SD_NOTE(_A5),
+
#define UNICODE_WINDOWS \
E__NOTE(_B5), \
S__NOTE(_E6),
diff --git a/quantum/config_common.h b/quantum/config_common.h
index c88e02d918..4c6a702af4 100644
--- a/quantum/config_common.h
+++ b/quantum/config_common.h
@@ -100,4 +100,6 @@
#define API_SYSEX_MAX_SIZE 32
+#include "song_list.h"
+
#endif
diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c
index 0b6380ed39..32057ae8dc 100644
--- a/quantum/process_keycode/process_audio.c
+++ b/quantum/process_keycode/process_audio.c
@@ -1,10 +1,19 @@
#include "audio.h"
#include "process_audio.h"
+#ifndef VOICE_CHANGE_SONG
+ #define VOICE_CHANGE_SONG SONG(VOICE_CHANGE_SOUND)
+#endif
+float voice_change_song[][2] = VOICE_CHANGE_SONG;
+
+#ifndef PITCH_STANDARD_A
+ #define PITCH_STANDARD_A 440.0f
+#endif
+
static float compute_freq_for_midi_note(uint8_t note)
{
// https://en.wikipedia.org/wiki/MIDI_tuning_standard
- return pow(2.0, (note - 69) / 12.0) * 440.0f;
+ return pow(2.0, (note - 69) / 12.0) * PITCH_STANDARD_A;
}
bool process_audio(uint16_t keycode, keyrecord_t *record) {
@@ -20,12 +29,9 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) {
}
if (keycode == AU_TOG && record->event.pressed) {
- if (is_audio_on())
- {
+ if (is_audio_on()) {
audio_off();
- }
- else
- {
+ } else {
audio_on();
}
return false;
@@ -33,13 +39,13 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) {
if (keycode == MUV_IN && record->event.pressed) {
voice_iterate();
- music_scale_user();
+ PLAY_SONG(voice_change_song);
return false;
}
if (keycode == MUV_DE && record->event.pressed) {
voice_deiterate();
- music_scale_user();
+ PLAY_SONG(voice_change_song);
return false;
}
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c
index 217dca2807..63841d1e87 100644
--- a/quantum/process_keycode/process_music.c
+++ b/quantum/process_keycode/process_music.c
@@ -27,6 +27,7 @@
bool music_activated = false;
uint8_t music_starting_note = 0x0C;
int music_offset = 7;
+uint8_t music_mode = MUSIC_MODE_CHROMATIC;
// music sequencer
static bool music_sequence_recording = false;
@@ -39,6 +40,39 @@ static uint8_t music_sequence_position = 0;
static uint16_t music_sequence_timer = 0;
static uint16_t music_sequence_interval = 100;
+#ifdef AUDIO_ENABLE
+ #ifndef MUSIC_ON_SONG
+ #define MUSIC_ON_SONG SONG(MUSIC_ON_SOUND)
+ #endif
+ #ifndef MUSIC_OFF_SONG
+ #define MUSIC_OFF_SONG SONG(MUSIC_OFF_SOUND)
+ #endif
+ #ifndef CHROMATIC_SONG
+ #define CHROMATIC_SONG SONG(CHROMATIC_SOUND)
+ #endif
+ #ifndef GUITAR_SONG
+ #define GUITAR_SONG SONG(GUITAR_SOUND)
+ #endif
+ #ifndef VIOLIN_SONG
+ #define VIOLIN_SONG SONG(VIOLIN_SOUND)
+ #endif
+ #ifndef MAJOR_SONG
+ #define MAJOR_SONG SONG(MAJOR_SOUND)
+ #endif
+ float music_mode_songs[NUMBER_OF_MODES][5][2] = {
+ CHROMATIC_SONG,
+ GUITAR_SONG,
+ VIOLIN_SONG,
+ MAJOR_SONG
+ };
+ float music_on_song[][2] = MUSIC_ON_SONG;
+ float music_off_song[][2] = MUSIC_OFF_SONG;
+#endif
+
+#ifndef MUSIC_MASK
+ #define MUSIC_MASK keycode < 0xFF
+#endif
+
static void music_noteon(uint8_t note) {
#ifdef AUDIO_ENABLE
process_audio_noteon(note);
@@ -79,70 +113,71 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
}
if (keycode == MU_TOG && record->event.pressed) {
- if (music_activated)
- {
+ if (music_activated) {
music_off();
- }
- else
- {
+ } else {
music_on();
}
return false;
}
- if (music_activated) {
+ if (keycode == MU_MOD && record->event.pressed) {
+ music_mode_cycle();
+ return false;
+ }
- if (keycode == KC_LCTL && record->event.pressed) { // Start recording
- music_all_notes_off();
- music_sequence_recording = true;
- music_sequence_recorded = false;
- music_sequence_playing = false;
- music_sequence_count = 0;
- return false;
- }
+ if (music_activated) {
+ if (record->event.pressed) {
+ if (keycode == KC_LCTL) { // Start recording
+ music_all_notes_off();
+ music_sequence_recording = true;
+ music_sequence_recorded = false;
+ music_sequence_playing = false;
+ music_sequence_count = 0;
+ return false;
+ }
- if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing
- music_all_notes_off();
- if (music_sequence_recording) { // was recording
- music_sequence_recorded = true;
+ if (keycode == KC_LALT) { // Stop recording/playing
+ music_all_notes_off();
+ if (music_sequence_recording) { // was recording
+ music_sequence_recorded = true;
+ }
+ music_sequence_recording = false;
+ music_sequence_playing = false;
+ return false;
}
- music_sequence_recording = false;
- music_sequence_playing = false;
- return false;
- }
- if (keycode == KC_LGUI && record->event.pressed && music_sequence_recorded) { // Start playing
- music_all_notes_off();
- music_sequence_recording = false;
- music_sequence_playing = true;
- music_sequence_position = 0;
- music_sequence_timer = 0;
- return false;
- }
+ if (keycode == KC_LGUI && music_sequence_recorded) { // Start playing
+ music_all_notes_off();
+ music_sequence_recording = false;
+ music_sequence_playing = true;
+ music_sequence_position = 0;
+ music_sequence_timer = 0;
+ return false;
+ }
- if (keycode == KC_UP) {
- if (record->event.pressed)
- music_sequence_interval-=10;
- return false;
- }
+ if (keycode == KC_UP) {
+ music_sequence_interval-=10;
+ return false;
+ }
- if (keycode == KC_DOWN) {
- if (record->event.pressed)
- music_sequence_interval+=10;
- return false;
+ if (keycode == KC_DOWN) {
+ music_sequence_interval+=10;
+ return false;
+ }
}
- #define MUSIC_MODE_GUITAR
-
- #ifdef MUSIC_MODE_CHROMATIC
- uint8_t note = (music_starting_note + record->event.key.col + music_offset - 3)+12*(MATRIX_ROWS - record->event.key.row);
- #elif defined(MUSIC_MODE_GUITAR)
- uint8_t note = (music_starting_note + record->event.key.col + music_offset + 32)+5*(MATRIX_ROWS - record->event.key.row);
- #elif defined(MUSIC_MODE_VIOLIN)
- uint8_t note = (music_starting_note + record->event.key.col + music_offset + 32)+7*(MATRIX_ROWS - record->event.key.row);
- #else
- uint8_t note = (music_starting_note + SCALE[record->event.key.col + music_offset] - 3)+12*(MATRIX_ROWS - record->event.key.row);
- #endif
+ uint8_t note;
+ if (music_mode == MUSIC_MODE_CHROMATIC)
+ note = (music_starting_note + record->event.key.col + music_offset - 3)+12*(MATRIX_ROWS - record->event.key.row);
+ else if (music_mode == MUSIC_MODE_GUITAR)
+ note = (music_starting_note + record->event.key.col + music_offset + 32)+5*(MATRIX_ROWS - record->event.key.row);
+ else if (music_mode == MUSIC_MODE_VIOLIN)
+ note = (music_starting_note + record->event.key.col + music_offset + 32)+7*(MATRIX_ROWS - record->event.key.row);
+ else if (music_mode == MUSIC_MODE_MAJOR)
+ note = (music_starting_note + SCALE[record->event.key.col + music_offset] - 3)+12*(MATRIX_ROWS - record->event.key.row);
+ else
+ note = music_starting_note;
if (record->event.pressed) {
music_noteon(note);
@@ -154,7 +189,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
music_noteoff(note);
}
- if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through
+ if (MUSIC_MASK)
return false;
}
@@ -175,12 +210,26 @@ void music_toggle(void) {
void music_on(void) {
music_activated = 1;
+ #ifdef AUDIO_ENABLE
+ PLAY_SONG(music_on_song);
+ #endif
music_on_user();
}
void music_off(void) {
- music_activated = 0;
music_all_notes_off();
+ music_activated = 0;
+ #ifdef AUDIO_ENABLE
+ PLAY_SONG(music_off_song);
+ #endif
+}
+
+void music_mode_cycle(void) {
+ music_all_notes_off();
+ music_mode = (music_mode + 1) % NUMBER_OF_MODES;
+ #ifdef AUDIO_ENABLE
+ PLAY_SONG(music_mode_songs[music_mode]);
+ #endif
}
void matrix_scan_music(void) {
diff --git a/quantum/process_keycode/process_music.h b/quantum/process_keycode/process_music.h
index 8dfbf041f4..ee027197c2 100644
--- a/quantum/process_keycode/process_music.h
+++ b/quantum/process_keycode/process_music.h
@@ -21,6 +21,14 @@
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
+enum music_modes {
+ MUSIC_MODE_CHROMATIC,
+ MUSIC_MODE_GUITAR,
+ MUSIC_MODE_VIOLIN,
+ MUSIC_MODE_MAJOR,
+ NUMBER_OF_MODES
+};
+
bool process_music(uint16_t keycode, keyrecord_t *record);
bool is_music_on(void);
@@ -31,6 +39,7 @@ void music_off(void);
void music_on_user(void);
void music_scale_user(void);
void music_all_notes_off(void);
+void music_mode_cycle(void);
void matrix_scan_music(void);
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 36e586d316..b76a114186 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -30,6 +30,25 @@ extern backlight_config_t backlight_config;
#include "fauxclicky.h"
#endif
+#ifdef AUDIO_ENABLE
+ #ifndef GOODBYE_SONG
+ #define GOODBYE_SONG SONG(GOODBYE_SOUND)
+ #endif
+ #ifndef AG_NORM_SONG
+ #define AG_NORM_SONG SONG(AG_NORM_SOUND)
+ #endif
+ #ifndef AG_SWAP_SONG
+ #define AG_SWAP_SONG SONG(AG_SWAP_SOUND)
+ #endif
+ #ifndef DEFAULT_LAYER_SONGS
+ #define DEFAULT_LAYER_SONGS { }
+ #endif
+ float goodbye_song[][2] = GOODBYE_SONG;
+ float ag_norm_song[][2] = AG_NORM_SONG;
+ float ag_swap_song[][2] = AG_SWAP_SONG;
+ float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
+#endif
+
static void do_code16 (uint16_t code, void (*f) (uint8_t)) {
switch (code) {
case QK_MODS ... QK_MODS_MAX:
@@ -116,9 +135,15 @@ void reset_keyboard(void) {
clear_keyboard();
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC))
music_all_notes_off();
+ uint16_t timer_start = timer_read();
+ PLAY_SONG(goodbye_song);
shutdown_user();
-#endif
+ while(timer_elapsed(timer_start) < 250)
+ wait_ms(1);
+ stop_all_notes();
+#else
wait_ms(250);
+#endif
#ifdef CATERINA_BOOTLOADER
*(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
#endif
@@ -351,6 +376,9 @@ bool process_record_quantum(keyrecord_t *record) {
case MAGIC_SWAP_ALT_GUI:
keymap_config.swap_lalt_lgui = true;
keymap_config.swap_ralt_rgui = true;
+ #ifdef AUDIO_ENABLE
+ PLAY_SONG(ag_swap_song);
+ #endif
break;
case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
keymap_config.swap_control_capslock = false;
@@ -379,6 +407,9 @@ bool process_record_quantum(keyrecord_t *record) {
case MAGIC_UNSWAP_ALT_GUI:
keymap_config.swap_lalt_lgui = false;
keymap_config.swap_ralt_rgui = false;
+ #ifdef AUDIO_ENABLE
+ PLAY_SONG(ag_norm_song);
+ #endif
break;
case MAGIC_TOGGLE_NKRO:
keymap_config.nkro = !keymap_config.nkro;
@@ -521,6 +552,14 @@ void send_string_with_delay(const char *str, uint8_t interval) {
}
}
+void set_single_persistent_default_layer(uint8_t default_layer) {
+ #ifdef AUDIO_ENABLE
+ PLAY_SONG(default_layer_songs[default_layer]);
+ #endif
+ eeconfig_update_default_layer(1U<<default_layer);
+ default_layer_set(1U<<default_layer);
+}
+
void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
layer_on(layer3);
@@ -571,6 +610,9 @@ void matrix_init_quantum() {
#ifdef BACKLIGHT_ENABLE
backlight_init_ports();
#endif
+ #ifdef AUDIO_ENABLE
+ audio_init();
+ #endif
matrix_init_kb();
}
diff --git a/quantum/quantum.h b/quantum/quantum.h
index e00fe23464..6c0e465732 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -56,6 +56,7 @@ extern uint32_t default_layer_state;
#endif // MIDI_ENABLE
#ifdef AUDIO_ENABLE
+ #include "audio.h"
#include "process_audio.h"
#endif
@@ -103,6 +104,8 @@ void send_string_with_delay(const char *str, uint8_t interval);
// For tri-layer
void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
+void set_single_persistent_default_layer(uint8_t default_layer);
+
void tap_random_base64(void);
#define IS_LAYER_ON(layer) (layer_state & (1UL << (layer)))
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index 6038e31c46..06ab6d18db 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -26,6 +26,10 @@
#endif
#endif
+// Fillers to make layering more clear
+#define _______ KC_TRNS
+#define XXXXXXX KC_NO
+
enum quantum_keycodes {
// Ranges used in shortucuts - not to be used directly
QK_TMK = 0x0000,
@@ -128,6 +132,9 @@ enum quantum_keycodes {
MU_OFF,
MU_TOG,
+ // Music mode cycle
+ MU_MOD,
+
// Music voice iterate
MUV_IN,
MUV_DE,