diff options
Diffstat (limited to 'quantum/audio')
-rw-r--r-- | quantum/audio/audio.c | 8 | ||||
-rw-r--r-- | quantum/audio/audio.h | 3 | ||||
-rw-r--r-- | quantum/audio/audio_arm.c | 135 | ||||
-rw-r--r-- | quantum/audio/song_list.h | 30 |
4 files changed, 47 insertions, 129 deletions
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index c948a60d6c..6d6833ec11 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -223,7 +223,7 @@ void audio_init() TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10); TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER)); TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre); - #endif + #endif audio_initialized = true; } @@ -231,7 +231,7 @@ void audio_init() if (audio_config.enable) { PLAY_SONG(startup_song); } - + } void stop_all_notes() @@ -464,7 +464,7 @@ ISR(TIMER3_AUDIO_vect) note_position++; bool end_of_note = false; if (TIMER_3_PERIOD > 0) { - if (!note_resting) + if (!note_resting) end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF - 1)); else end_of_note = (note_position >= (note_length)); @@ -604,7 +604,7 @@ ISR(TIMER1_AUDIO_vect) note_position++; bool end_of_note = false; if (TIMER_1_PERIOD > 0) { - if (!note_resting) + if (!note_resting) end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1)); else end_of_note = (note_position >= (note_length)); diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index da09b2bcd2..8136c5b258 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -40,7 +40,8 @@ typedef union { uint8_t raw; struct { bool enable :1; - uint8_t level :7; + bool clicky_enable :1; + uint8_t level :6; }; } audio_config_t; diff --git a/quantum/audio/audio_arm.c b/quantum/audio/audio_arm.c index d38184f323..989f7a64be 100644 --- a/quantum/audio/audio_arm.c +++ b/quantum/audio/audio_arm.c @@ -80,6 +80,9 @@ float startup_song[][2] = STARTUP_SONG; static void gpt_cb8(GPTDriver *gptp); #define DAC_BUFFER_SIZE 720 +#ifndef DAC_SAMPLE_MAX +#define DAC_SAMPLE_MAX 65535U +#endif #define START_CHANNEL_1() gptStart(&GPTD6, &gpt6cfg1); \ gptStartContinuous(&GPTD6, 2U) @@ -202,132 +205,16 @@ GPTConfig gpt8cfg1 = { // squarewave static const dacsample_t dac_buffer[DAC_BUFFER_SIZE] = { - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 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 0, 0, 0, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, - 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047 + // opposite of dac_buffer above + [0 ... DAC_BUFFER_SIZE/2-1] = 0, + [DAC_BUFFER_SIZE/2 ... DAC_BUFFER_SIZE -1] = DAC_SAMPLE_MAX, }; /* @@ -363,7 +250,7 @@ static void error_cb1(DACDriver *dacp, dacerror_t err) { } static const DACConfig dac1cfg1 = { - .init = 2047U, + .init = DAC_SAMPLE_MAX, .datamode = DAC_DHRM_12BIT_RIGHT }; @@ -375,7 +262,7 @@ static const DACConversionGroup dacgrpcfg1 = { }; static const DACConfig dac1cfg2 = { - .init = 2047U, + .init = DAC_SAMPLE_MAX, .datamode = DAC_DHRM_12BIT_RIGHT }; diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h index e63616a994..9946084977 100644 --- a/quantum/audio/song_list.h +++ b/quantum/audio/song_list.h @@ -472,4 +472,34 @@ H__NOTE(_AS4), W__NOTE(_GS4), W__NOTE(_GS4), W__NOTE(_FS4), W__NOTE(_GS4), \ H__NOTE(_AS4), WD_NOTE(_DS4) +#define RICK_ROLL \ + Q__NOTE(_F4), \ + Q__NOTE(_G4), \ + Q__NOTE(_BF4), \ + Q__NOTE(_G4), \ + HD_NOTE(_D5), \ + HD_NOTE(_D5), \ + W__NOTE(_C5), \ + S__NOTE(_REST), \ + Q__NOTE(_F4), \ + Q__NOTE(_G4), \ + Q__NOTE(_BF4), \ + Q__NOTE(_G4), \ + HD_NOTE(_C5), \ + HD_NOTE(_C5), \ + W__NOTE(_BF4), \ + S__NOTE(_REST), \ + Q__NOTE(_F4), \ + Q__NOTE(_G4), \ + Q__NOTE(_BF4), \ + Q__NOTE(_G4), \ + W__NOTE(_BF4), \ + H__NOTE(_C5), \ + H__NOTE(_A4), \ + H__NOTE(_A4), \ + H__NOTE(_G4), \ + H__NOTE(_F4), \ + H__NOTE(_F4), \ + W__NOTE(_C5), \ + W__NOTE(_BF4), #endif |