From 6a3c66776cb10888b24400526241b46deeb051a8 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Thu, 20 Jul 2017 23:57:11 -0400 Subject: clean-up planck and preonic keymaps, move audio stuff around --- quantum/audio/audio.c | 14 ++++++++++++++ quantum/audio/audio.h | 2 +- quantum/audio/song_list.h | 42 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 52 insertions(+), 6 deletions(-) (limited to 'quantum/audio') diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index c924f2bd58..5b85630932 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 . */ + #include #include //#include @@ -119,9 +120,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 +178,11 @@ void audio_init() #endif audio_initialized = true; + + if (audio_config.enable) { + PLAY_NOTE_ARRAY(startup_song, false, LEGATO); + } + } void stop_all_notes() diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 27fdc2ab63..ad3abeb78a 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -99,7 +99,7 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) // 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(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style)); - +#define PLAY_SONG(song) PLAY_NOTE_ARRAY(song, false, STACCATO) bool is_playing_notes(void); diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h index db2d1a94cd..6960bee6da 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,18 @@ 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 CAPS_LOCK_ON_SOUND \ E__NOTE(_A3), \ E__NOTE(_B3), @@ -141,6 +163,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), -- cgit v1.2.3 From 92ccc9a7b8ac856966147be48e24ce652c160386 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 21 Jul 2017 12:58:48 -0400 Subject: use automatic rests with songs (no more rest styles) --- quantum/audio/audio.c | 39 +++++++++++++++++++++++++-------------- quantum/audio/audio.h | 8 +++++--- quantum/audio/musical_notes.h | 7 ------- 3 files changed, 30 insertions(+), 24 deletions(-) (limited to 'quantum/audio') diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 5b85630932..baa364eec2 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -99,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; @@ -180,7 +179,7 @@ void audio_init() audio_initialized = true; if (audio_config.enable) { - PLAY_NOTE_ARRAY(startup_song, false, LEGATO); + PLAY_SONG(startup_song); } } @@ -416,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) { @@ -433,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; @@ -548,9 +555,9 @@ 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)); + end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1)); } else { - end_of_note = (note_position >= (note_length * 0x7FF)); + end_of_note = (note_position >= (note_length)); } if (end_of_note) { @@ -565,11 +572,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; @@ -638,7 +650,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) { @@ -663,7 +675,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 ad3abeb78a..e29770e3b8 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(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style)); -#define PLAY_SONG(song) PLAY_NOTE_ARRAY(song, false, STACCATO) +#define PLAY_NOTE_ARRAY(note_array, note_repeat, deprecated_arg) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat)); \ + _Pragma ("message \"'PLAY_NOTE_ARRAY' macro is deprecated\"") +#define PLAY_SONG(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), false); +#define PLAY_LOOP(note_array) play_notes(¬e_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 -- cgit v1.2.3 From f407f3e8deea433ae4bca61f17d8ed8ed208bb27 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 21 Jul 2017 13:18:36 -0400 Subject: remove unneccesary headers --- quantum/audio/audio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'quantum/audio') diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index baa364eec2..8e8570d26c 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -555,7 +555,10 @@ 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 - 1)); + 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)); } -- cgit v1.2.3 From 415d38ba9ee20424ce354ed5f8e590fae58b863f Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 22 Jul 2017 00:14:26 -0400 Subject: adds music mode, music mode songs, music mask --- quantum/audio/audio.h | 4 ++-- quantum/audio/song_list.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'quantum/audio') diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index e29770e3b8..79e0da2295 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -100,8 +100,8 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat); #define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0])))) #define PLAY_NOTE_ARRAY(note_array, note_repeat, deprecated_arg) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat)); \ _Pragma ("message \"'PLAY_NOTE_ARRAY' macro is deprecated\"") -#define PLAY_SONG(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), false); -#define PLAY_LOOP(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), true); +#define PLAY_SONG(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), false) +#define PLAY_LOOP(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), true) bool is_playing_notes(void); diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h index 6960bee6da..f355d371bd 100644 --- a/quantum/audio/song_list.h +++ b/quantum/audio/song_list.h @@ -139,6 +139,38 @@ 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), -- cgit v1.2.3