From 0faa18eab996c2cfcc5da0b60b702f52335c5854 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 15 Apr 2016 23:38:21 -0400 Subject: audio enable stored in eeprom --- quantum/audio.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'quantum/audio.h') diff --git a/quantum/audio.h b/quantum/audio.h index 99203cea7a..58270015df 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -3,9 +3,21 @@ #include #include +typedef union { + uint8_t raw; + struct { + bool enable :1; + uint8_t level :7; + }; +} audio_config_t; + +void audio_toggle(void); +void audio_on(void); +void audio_off(void); + void play_sample(uint8_t * s, uint16_t l, bool r); void play_note(double freq, int vol); void stop_note(double freq); void stop_all_notes(); void init_notes(); -void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat); \ No newline at end of file +void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat); -- cgit v1.2.3 From 41cc35425ab32c9a9492006da8b667d01d32dfa6 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 16 Apr 2016 21:31:40 -0400 Subject: rests between notes as an argument --- quantum/audio.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'quantum/audio.h') diff --git a/quantum/audio.h b/quantum/audio.h index 58270015df..65a6f9434d 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -2,6 +2,7 @@ #include #include #include +#include "musical_notes.h" typedef union { uint8_t raw; @@ -20,4 +21,4 @@ void play_note(double freq, int vol); void stop_note(double freq); void stop_all_notes(); void init_notes(); -void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat); +void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat, float n_rest); -- cgit v1.2.3 From 45f10b4c4b308226fa1568277654a13853a03ab4 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Sat, 16 Apr 2016 22:10:18 -0500 Subject: Fixed how note arrays are used. --- quantum/audio.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'quantum/audio.h') diff --git a/quantum/audio.h b/quantum/audio.h index 65a6f9434d..762c980643 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -4,6 +4,9 @@ #include #include "musical_notes.h" +#ifndef AUDIO_H +#define AUDIO_H + typedef union { uint8_t raw; struct { @@ -19,6 +22,16 @@ void audio_off(void); void play_sample(uint8_t * s, uint16_t l, bool r); void play_note(double freq, int vol); void stop_note(double freq); -void stop_all_notes(); -void init_notes(); +void stop_all_notes(void); +void init_notes(void); void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat, float n_rest); + + +// These macros are used to allow play_notes to play an array of indeterminate +// 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) ((int)(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)); + + +#endif \ No newline at end of file -- cgit v1.2.3 From 29e495be2a57d1eb41699909b204c12ac6bc4c0e Mon Sep 17 00:00:00 2001 From: IBNobody Date: Sun, 17 Apr 2016 02:52:38 -0500 Subject: Added trimble and tempo adjustments! --- quantum/audio.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'quantum/audio.h') diff --git a/quantum/audio.h b/quantum/audio.h index 762c980643..8012aa6bf1 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -24,8 +24,12 @@ void play_note(double freq, int vol); void stop_note(double freq); void stop_all_notes(void); void init_notes(void); -void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat, float n_rest); +void play_notes(float (*np)[][2], uint8_t n_count, bool n_repeat, float n_rest); +void set_timbre(float timbre); +void set_tempo(float tempo); +void increase_tempo(uint8_t tempo_change); +void decrease_tempo(uint8_t tempo_change); // These macros are used to allow play_notes to play an array of indeterminate // length. This works around the limitation of C's sizeof operation on pointers. -- cgit v1.2.3 From 23231fa577f7c6c585124226a83f21a7668e62dd Mon Sep 17 00:00:00 2001 From: IBNobody Date: Sun, 17 Apr 2016 14:16:03 -0500 Subject: Converted goodbye to notes, fixed eighth dotted note macro --- quantum/audio.h | 1 + 1 file changed, 1 insertion(+) (limited to 'quantum/audio.h') diff --git a/quantum/audio.h b/quantum/audio.h index 3aba8370ac..05d314c940 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -3,6 +3,7 @@ #include #include #include "musical_notes.h" +#include "song_list.h" #ifndef AUDIO_H #define AUDIO_H -- cgit v1.2.3 From 5c98ad59606ee95b82c27bf2525383a9ec88542b Mon Sep 17 00:00:00 2001 From: IBNobody Date: Sun, 17 Apr 2016 20:14:37 -0500 Subject: Added extra songs, LED indicator notes --- quantum/audio.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'quantum/audio.h') diff --git a/quantum/audio.h b/quantum/audio.h index 05d314c940..44cafccd68 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -44,5 +44,7 @@ void decrease_tempo(uint8_t tempo_change); #define NOTE_ARRAY_SIZE(x) ((int)(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)); +void play_goodbye_tone(void); +void play_startup_tone(void); #endif \ No newline at end of file -- cgit v1.2.3 From a2f31c886ff13c5e7adeccccfe672698c1c7efb9 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Tue, 19 Apr 2016 12:58:13 -0400 Subject: getting ready for getters and setters --- quantum/audio.h | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'quantum/audio.h') diff --git a/quantum/audio.h b/quantum/audio.h index 44cafccd68..f705341d7f 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -47,4 +47,108 @@ void decrease_tempo(uint8_t tempo_change); void play_goodbye_tone(void); void play_startup_tone(void); +#define VIBRATO_LUT (float []) { \ +1.00090714186239, \ +1.00181152169061, \ +1.00270955652027, \ +1.00359767896099, \ +1.00447235162891, \ +1.00533008160601, \ +1.00616743486158, \ +1.00698105056935, \ +1.00776765525194, \ +1.00852407668313, \ +1.0092472574777, \ +1.00993426829815, \ +1.01058232060837, \ +1.01118877890462, \ +1.01175117235612, \ +1.01226720578933, \ +1.01273476995269, \ +1.01315195100182, \ +1.0135170391489, \ +1.01382853642434, \ +1.01408516350345, \ +1.01428586555648, \ +1.0144298170856, \ +1.0145164257189, \ +1.01454533493752, \ +1.0145164257189, \ +1.0144298170856, \ +1.01428586555648, \ +1.01408516350345, \ +1.01382853642434, \ +1.0135170391489, \ +1.01315195100182, \ +1.01273476995269, \ +1.01226720578933, \ +1.01175117235612, \ +1.01118877890462, \ +1.01058232060837, \ +1.00993426829815, \ +1.0092472574777, \ +1.00852407668313, \ +1.00776765525194, \ +1.00698105056935, \ +1.00616743486158, \ +1.00533008160601, \ +1.00447235162891, \ +1.00359767896099, \ +1.00270955652027, \ +1.00181152169061, \ +1.00090714186239, \ +1, \ +0.999093680298157, \ +0.998191753986265, \ +0.997297765337276, \ +0.996415217934032, \ +0.995547561242821, \ +0.99469817754036, \ +0.993870369236874, \ +0.993067346634376, \ +0.992292216155724, \ +0.991547969076588, \ +0.990837470789065, \ +0.990163450622494, \ +0.989528492243954, \ +0.988935024658062, \ +0.988385313823004, \ +0.98788145489731, \ +0.987425365129624, \ +0.987018777401739, \ +0.986663234433381, \ +0.986360083655655, \ +0.986110472758728, \ +0.985915345918143, \ +0.985775440703176, \ +0.985691285669809, \ +0.985663198640188, \ +0.985691285669809, \ +0.985775440703176, \ +0.985915345918143, \ +0.986110472758728, \ +0.986360083655655, \ +0.986663234433381, \ +0.987018777401739, \ +0.987425365129624, \ +0.98788145489731, \ +0.988385313823004, \ +0.988935024658062, \ +0.989528492243954, \ +0.990163450622494, \ +0.990837470789065, \ +0.991547969076588, \ +0.992292216155724, \ +0.993067346634376, \ +0.993870369236874, \ +0.99469817754036, \ +0.99554756124282, \ +0.996415217934032, \ +0.997297765337276, \ +0.998191753986265, \ +0.999093680298157, \ +1, \ +} +#define VIBRATO_LUT_LENGTH NOTE_ARRAY_SIZE(VIBRATO_LUT) + #endif \ No newline at end of file -- cgit v1.2.3 From fd49dfe5cb686f5966447c6b890800c9cd11d281 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Tue, 19 Apr 2016 17:00:45 -0400 Subject: vibrato and polyphony paratmeters --- quantum/audio.h | 140 +++++++++++++------------------------------------------- 1 file changed, 31 insertions(+), 109 deletions(-) (limited to 'quantum/audio.h') diff --git a/quantum/audio.h b/quantum/audio.h index f705341d7f..85756af9d4 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -8,6 +8,9 @@ #ifndef AUDIO_H #define AUDIO_H +// Enable vibrato strength/amplitude - slows down ISR too much +// #define VIBRATO_STRENGTH_ENABLE + typedef union { uint8_t raw; struct { @@ -20,6 +23,34 @@ void audio_toggle(void); void audio_on(void); void audio_off(void); +// Vibrato rate functions + +void set_vibrato_rate(float rate); +void increase_vibrato_rate(float change); +void decrease_vibrato_rate(float change); + +#ifdef VIBRATO_STRENGTH_ENABLE + +void set_vibrato_strength(float strength); +void increase_vibrato_strength(float change); +void decrease_vibrato_strength(float change); + +#endif + +// Polyphony functions + +void set_polyphony_rate(float rate); +void enable_polyphony(); +void disable_polyphony(); +void increase_polyphony_rate(float change); +void decrease_polyphony_rate(float change); + +void set_timbre(float timbre); +void set_tempo(float tempo); + +void increase_tempo(uint8_t tempo_change); +void decrease_tempo(uint8_t tempo_change); + void play_sample(uint8_t * s, uint16_t l, bool r); void play_note(double freq, int vol); void stop_note(double freq); @@ -27,11 +58,6 @@ void stop_all_notes(void); void init_notes(void); void play_notes(float (*np)[][2], uint8_t n_count, bool n_repeat, float n_rest); -void set_timbre(float timbre); -void set_tempo(float tempo); -void increase_tempo(uint8_t tempo_change); -void decrease_tempo(uint8_t tempo_change); - #define SCALE (int []){ 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), \ 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ @@ -47,108 +73,4 @@ void decrease_tempo(uint8_t tempo_change); void play_goodbye_tone(void); void play_startup_tone(void); -#define VIBRATO_LUT (float []) { \ -1.00090714186239, \ -1.00181152169061, \ -1.00270955652027, \ -1.00359767896099, \ -1.00447235162891, \ -1.00533008160601, \ -1.00616743486158, \ -1.00698105056935, \ -1.00776765525194, \ -1.00852407668313, \ -1.0092472574777, \ -1.00993426829815, \ -1.01058232060837, \ -1.01118877890462, \ -1.01175117235612, \ -1.01226720578933, \ -1.01273476995269, \ -1.01315195100182, \ -1.0135170391489, \ -1.01382853642434, \ -1.01408516350345, \ -1.01428586555648, \ -1.0144298170856, \ -1.0145164257189, \ -1.01454533493752, \ -1.0145164257189, \ -1.0144298170856, \ -1.01428586555648, \ -1.01408516350345, \ -1.01382853642434, \ -1.0135170391489, \ -1.01315195100182, \ -1.01273476995269, \ -1.01226720578933, \ -1.01175117235612, \ -1.01118877890462, \ -1.01058232060837, \ -1.00993426829815, \ -1.0092472574777, \ -1.00852407668313, \ -1.00776765525194, \ -1.00698105056935, \ -1.00616743486158, \ -1.00533008160601, \ -1.00447235162891, \ -1.00359767896099, \ -1.00270955652027, \ -1.00181152169061, \ -1.00090714186239, \ -1, \ -0.999093680298157, \ -0.998191753986265, \ -0.997297765337276, \ -0.996415217934032, \ -0.995547561242821, \ -0.99469817754036, \ -0.993870369236874, \ -0.993067346634376, \ -0.992292216155724, \ -0.991547969076588, \ -0.990837470789065, \ -0.990163450622494, \ -0.989528492243954, \ -0.988935024658062, \ -0.988385313823004, \ -0.98788145489731, \ -0.987425365129624, \ -0.987018777401739, \ -0.986663234433381, \ -0.986360083655655, \ -0.986110472758728, \ -0.985915345918143, \ -0.985775440703176, \ -0.985691285669809, \ -0.985663198640188, \ -0.985691285669809, \ -0.985775440703176, \ -0.985915345918143, \ -0.986110472758728, \ -0.986360083655655, \ -0.986663234433381, \ -0.987018777401739, \ -0.987425365129624, \ -0.98788145489731, \ -0.988385313823004, \ -0.988935024658062, \ -0.989528492243954, \ -0.990163450622494, \ -0.990837470789065, \ -0.991547969076588, \ -0.992292216155724, \ -0.993067346634376, \ -0.993870369236874, \ -0.99469817754036, \ -0.99554756124282, \ -0.996415217934032, \ -0.997297765337276, \ -0.998191753986265, \ -0.999093680298157, \ -1, \ -} -#define VIBRATO_LUT_LENGTH NOTE_ARRAY_SIZE(VIBRATO_LUT) - #endif \ No newline at end of file -- cgit v1.2.3 From 462601f5e8de3476963c6fef44a88653e19fc3fd Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Tue, 19 Apr 2016 21:25:48 -0400 Subject: breaking changes - restructuring audio.c a little --- quantum/audio.h | 1 - 1 file changed, 1 deletion(-) (limited to 'quantum/audio.h') diff --git a/quantum/audio.h b/quantum/audio.h index 85756af9d4..0fe3eac9af 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -55,7 +55,6 @@ void play_sample(uint8_t * s, uint16_t l, bool r); void play_note(double freq, int vol); void stop_note(double freq); void stop_all_notes(void); -void init_notes(void); void play_notes(float (*np)[][2], uint8_t n_count, bool n_repeat, float n_rest); #define SCALE (int []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ -- cgit v1.2.3 From de4690593cec908b19f97509f45c78534fd5440f Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Wed, 20 Apr 2016 01:08:17 -0400 Subject: fixed startup audio with a 500ms delay --- quantum/audio.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'quantum/audio.h') diff --git a/quantum/audio.h b/quantum/audio.h index 0fe3eac9af..2d4d303ced 100644 --- a/quantum/audio.h +++ b/quantum/audio.h @@ -8,6 +8,11 @@ #ifndef AUDIO_H #define AUDIO_H +// Largely untested PWM audio mode (doesn't sound as good) +// #define PWM_AUDIO + +// #define VIBRATO_ENABLE + // Enable vibrato strength/amplitude - slows down ISR too much // #define VIBRATO_STRENGTH_ENABLE @@ -25,6 +30,8 @@ void audio_off(void); // Vibrato rate functions +#ifdef VIBRATO_ENABLE + void set_vibrato_rate(float rate); void increase_vibrato_rate(float change); void decrease_vibrato_rate(float change); @@ -37,6 +44,8 @@ void decrease_vibrato_strength(float change); #endif +#endif + // Polyphony functions void set_polyphony_rate(float rate); @@ -51,11 +60,15 @@ void set_tempo(float tempo); void increase_tempo(uint8_t tempo_change); void decrease_tempo(uint8_t tempo_change); +void audio_init(); + +#ifdef PWM_AUDIO void play_sample(uint8_t * s, uint16_t l, bool r); -void play_note(double freq, int vol); -void stop_note(double freq); +#endif +void play_note(float freq, int vol); +void stop_note(float freq); void stop_all_notes(void); -void play_notes(float (*np)[][2], uint8_t n_count, bool n_repeat, float n_rest); +void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest); #define SCALE (int []){ 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), \ @@ -66,7 +79,7 @@ void play_notes(float (*np)[][2], uint8_t n_count, bool n_repeat, float n_rest); // These macros are used to allow play_notes to play an array of indeterminate // 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) ((int)(sizeof(x) / (sizeof(x[0])))) +#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)); void play_goodbye_tone(void); -- cgit v1.2.3 From 73228f5e5d1d4cd31a46e5e93aa893a8f727e3b9 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Thu, 21 Apr 2016 00:37:45 -0400 Subject: restructures audio, begins voicing --- quantum/audio.h | 88 --------------------------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 quantum/audio.h (limited to 'quantum/audio.h') diff --git a/quantum/audio.h b/quantum/audio.h deleted file mode 100644 index 2d4d303ced..0000000000 --- a/quantum/audio.h +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include -#include -#include -#include "musical_notes.h" -#include "song_list.h" - -#ifndef AUDIO_H -#define AUDIO_H - -// Largely untested PWM audio mode (doesn't sound as good) -// #define PWM_AUDIO - -// #define VIBRATO_ENABLE - -// Enable vibrato strength/amplitude - slows down ISR too much -// #define VIBRATO_STRENGTH_ENABLE - -typedef union { - uint8_t raw; - struct { - bool enable :1; - uint8_t level :7; - }; -} audio_config_t; - -void audio_toggle(void); -void audio_on(void); -void audio_off(void); - -// Vibrato rate functions - -#ifdef VIBRATO_ENABLE - -void set_vibrato_rate(float rate); -void increase_vibrato_rate(float change); -void decrease_vibrato_rate(float change); - -#ifdef VIBRATO_STRENGTH_ENABLE - -void set_vibrato_strength(float strength); -void increase_vibrato_strength(float change); -void decrease_vibrato_strength(float change); - -#endif - -#endif - -// Polyphony functions - -void set_polyphony_rate(float rate); -void enable_polyphony(); -void disable_polyphony(); -void increase_polyphony_rate(float change); -void decrease_polyphony_rate(float change); - -void set_timbre(float timbre); -void set_tempo(float tempo); - -void increase_tempo(uint8_t tempo_change); -void decrease_tempo(uint8_t tempo_change); - -void audio_init(); - -#ifdef PWM_AUDIO -void play_sample(uint8_t * s, uint16_t l, bool r); -#endif -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); - -#define SCALE (int []){ 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), \ - 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ - 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ - 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } - -// These macros are used to allow play_notes to play an array of indeterminate -// 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)); - -void play_goodbye_tone(void); -void play_startup_tone(void); - -#endif \ No newline at end of file -- cgit v1.2.3