diff options
| author | skullY <skullydazed@gmail.com> | 2019-08-30 11:19:03 -0700 |
|---|---|---|
| committer | skullydazed <skullydazed@users.noreply.github.com> | 2019-08-30 15:01:52 -0700 |
| commit | b624f32f944acdc59dcb130674c09090c5c404cb (patch) | |
| tree | bc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /quantum/audio | |
| parent | 61af76a10d00aba185b8338604171de490a13e3b (diff) | |
| download | qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.tar.gz qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.zip | |
clang-format changes
Diffstat (limited to 'quantum/audio')
| -rw-r--r-- | quantum/audio/audio.c | 740 | ||||
| -rw-r--r-- | quantum/audio/audio.h | 26 | ||||
| -rw-r--r-- | quantum/audio/audio_arm.c | 846 | ||||
| -rw-r--r-- | quantum/audio/audio_pwm.c | 637 | ||||
| -rw-r--r-- | quantum/audio/luts.c | 380 | ||||
| -rw-r--r-- | quantum/audio/luts.h | 18 | ||||
| -rw-r--r-- | quantum/audio/muse.c | 137 | ||||
| -rw-r--r-- | quantum/audio/musical_notes.h | 245 | ||||
| -rw-r--r-- | quantum/audio/song_list.h | 319 | ||||
| -rw-r--r-- | quantum/audio/voices.c | 250 | ||||
| -rw-r--r-- | quantum/audio/voices.h | 20 | ||||
| -rw-r--r-- | quantum/audio/wave.h | 273 |
12 files changed, 1423 insertions, 2468 deletions
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 3da164c73..781378788 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c | |||
| @@ -18,9 +18,9 @@ | |||
| 18 | #include <string.h> | 18 | #include <string.h> |
| 19 | //#include <math.h> | 19 | //#include <math.h> |
| 20 | #if defined(__AVR__) | 20 | #if defined(__AVR__) |
| 21 | #include <avr/pgmspace.h> | 21 | # include <avr/pgmspace.h> |
| 22 | #include <avr/interrupt.h> | 22 | # include <avr/interrupt.h> |
| 23 | #include <avr/io.h> | 23 | # include <avr/io.h> |
| 24 | #endif | 24 | #endif |
| 25 | #include "print.h" | 25 | #include "print.h" |
| 26 | #include "audio.h" | 26 | #include "audio.h" |
| @@ -35,119 +35,118 @@ | |||
| 35 | // Timer Abstractions | 35 | // Timer Abstractions |
| 36 | // ----------------------------------------------------------------------------- | 36 | // ----------------------------------------------------------------------------- |
| 37 | 37 | ||
| 38 | //Currently we support timers 1 and 3 used at the sime time, channels A-C, | 38 | // Currently we support timers 1 and 3 used at the sime time, channels A-C, |
| 39 | //pins PB5, PB6, PB7, PC4, PC5, and PC6 | 39 | // pins PB5, PB6, PB7, PC4, PC5, and PC6 |
| 40 | #if defined(C6_AUDIO) | 40 | #if defined(C6_AUDIO) |
| 41 | #define CPIN_AUDIO | 41 | # define CPIN_AUDIO |
| 42 | #define CPIN_SET_DIRECTION DDRC |= _BV(PORTC6); | 42 | # define CPIN_SET_DIRECTION DDRC |= _BV(PORTC6); |
| 43 | #define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); | 43 | # define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); |
| 44 | #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A) | 44 | # define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A) |
| 45 | #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A) | 45 | # define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A) |
| 46 | #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1); | 46 | # define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1); |
| 47 | #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)); | 47 | # define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)); |
| 48 | #define TIMER_3_PERIOD ICR3 | 48 | # define TIMER_3_PERIOD ICR3 |
| 49 | #define TIMER_3_DUTY_CYCLE OCR3A | 49 | # define TIMER_3_DUTY_CYCLE OCR3A |
| 50 | #define TIMER3_AUDIO_vect TIMER3_COMPA_vect | 50 | # define TIMER3_AUDIO_vect TIMER3_COMPA_vect |
| 51 | #endif | 51 | #endif |
| 52 | #if defined(C5_AUDIO) | 52 | #if defined(C5_AUDIO) |
| 53 | #define CPIN_AUDIO | 53 | # define CPIN_AUDIO |
| 54 | #define CPIN_SET_DIRECTION DDRC |= _BV(PORTC5); | 54 | # define CPIN_SET_DIRECTION DDRC |= _BV(PORTC5); |
| 55 | #define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3B1) | (0 << COM3B0) | (1 << WGM31) | (0 << WGM30); | 55 | # define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3B1) | (0 << COM3B0) | (1 << WGM31) | (0 << WGM30); |
| 56 | #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3B) | 56 | # define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3B) |
| 57 | #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3B) | 57 | # define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3B) |
| 58 | #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3B1); | 58 | # define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3B1); |
| 59 | #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3B1) | _BV(COM3B0)); | 59 | # define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3B1) | _BV(COM3B0)); |
| 60 | #define TIMER_3_PERIOD ICR3 | 60 | # define TIMER_3_PERIOD ICR3 |
| 61 | #define TIMER_3_DUTY_CYCLE OCR3B | 61 | # define TIMER_3_DUTY_CYCLE OCR3B |
| 62 | #define TIMER3_AUDIO_vect TIMER3_COMPB_vect | 62 | # define TIMER3_AUDIO_vect TIMER3_COMPB_vect |
| 63 | #endif | 63 | #endif |
| 64 | #if defined(C4_AUDIO) | 64 | #if defined(C4_AUDIO) |
| 65 | #define CPIN_AUDIO | 65 | # define CPIN_AUDIO |
| 66 | #define CPIN_SET_DIRECTION DDRC |= _BV(PORTC4); | 66 | # define CPIN_SET_DIRECTION DDRC |= _BV(PORTC4); |
| 67 | #define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3C1) | (0 << COM3C0) | (1 << WGM31) | (0 << WGM30); | 67 | # define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3C1) | (0 << COM3C0) | (1 << WGM31) | (0 << WGM30); |
| 68 | #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3C) | 68 | # define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3C) |
| 69 | #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3C) | 69 | # define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3C) |
| 70 | #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3C1); | 70 | # define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3C1); |
| 71 | #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3C1) | _BV(COM3C0)); | 71 | # define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3C1) | _BV(COM3C0)); |
| 72 | #define TIMER_3_PERIOD ICR3 | 72 | # define TIMER_3_PERIOD ICR3 |
| 73 | #define TIMER_3_DUTY_CYCLE OCR3C | 73 | # define TIMER_3_DUTY_CYCLE OCR3C |
| 74 | #define TIMER3_AUDIO_vect TIMER3_COMPC_vect | 74 | # define TIMER3_AUDIO_vect TIMER3_COMPC_vect |
| 75 | #endif | 75 | #endif |
| 76 | 76 | ||
| 77 | #if defined(B5_AUDIO) | 77 | #if defined(B5_AUDIO) |
| 78 | #define BPIN_AUDIO | 78 | # define BPIN_AUDIO |
| 79 | #define BPIN_SET_DIRECTION DDRB |= _BV(PORTB5); | 79 | # define BPIN_SET_DIRECTION DDRB |= _BV(PORTB5); |
| 80 | #define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (0 << WGM10); | 80 | # define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (0 << WGM10); |
| 81 | #define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1A) | 81 | # define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1A) |
| 82 | #define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1A) | 82 | # define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1A) |
| 83 | #define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1A1); | 83 | # define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1A1); |
| 84 | #define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1A1) | _BV(COM1A0)); | 84 | # define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1A1) | _BV(COM1A0)); |
| 85 | #define TIMER_1_PERIOD ICR1 | 85 | # define TIMER_1_PERIOD ICR1 |
| 86 | #define TIMER_1_DUTY_CYCLE OCR1A | 86 | # define TIMER_1_DUTY_CYCLE OCR1A |
| 87 | #define TIMER1_AUDIO_vect TIMER1_COMPA_vect | 87 | # define TIMER1_AUDIO_vect TIMER1_COMPA_vect |
| 88 | #endif | 88 | #endif |
| 89 | #if defined(B6_AUDIO) | 89 | #if defined(B6_AUDIO) |
| 90 | #define BPIN_AUDIO | 90 | # define BPIN_AUDIO |
| 91 | #define BPIN_SET_DIRECTION DDRB |= _BV(PORTB6); | 91 | # define BPIN_SET_DIRECTION DDRB |= _BV(PORTB6); |
| 92 | #define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1B1) | (0 << COM1B0) | (1 << WGM11) | (0 << WGM10); | 92 | # define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1B1) | (0 << COM1B0) | (1 << WGM11) | (0 << WGM10); |
| 93 | #define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1B) | 93 | # define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1B) |
| 94 | #define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1B) | 94 | # define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1B) |
| 95 | #define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1B1); | 95 | # define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1B1); |
| 96 | #define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1B1) | _BV(COM1B0)); | 96 | # define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1B1) | _BV(COM1B0)); |
| 97 | #define TIMER_1_PERIOD ICR1 | 97 | # define TIMER_1_PERIOD ICR1 |
| 98 | #define TIMER_1_DUTY_CYCLE OCR1B | 98 | # define TIMER_1_DUTY_CYCLE OCR1B |
| 99 | #define TIMER1_AUDIO_vect TIMER1_COMPB_vect | 99 | # define TIMER1_AUDIO_vect TIMER1_COMPB_vect |
| 100 | #endif | 100 | #endif |
| 101 | #if defined(B7_AUDIO) | 101 | #if defined(B7_AUDIO) |
| 102 | #define BPIN_AUDIO | 102 | # define BPIN_AUDIO |
| 103 | #define BPIN_SET_DIRECTION DDRB |= _BV(PORTB7); | 103 | # define BPIN_SET_DIRECTION DDRB |= _BV(PORTB7); |
| 104 | #define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1C1) | (0 << COM1C0) | (1 << WGM11) | (0 << WGM10); | 104 | # define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1C1) | (0 << COM1C0) | (1 << WGM11) | (0 << WGM10); |
| 105 | #define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1C) | 105 | # define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1C) |
| 106 | #define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1C) | 106 | # define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1C) |
| 107 | #define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1C1); | 107 | # define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1C1); |
| 108 | #define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1C1) | _BV(COM1C0)); | 108 | # define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1C1) | _BV(COM1C0)); |
| 109 | #define TIMER_1_PERIOD ICR1 | 109 | # define TIMER_1_PERIOD ICR1 |
| 110 | #define TIMER_1_DUTY_CYCLE OCR1C | 110 | # define TIMER_1_DUTY_CYCLE OCR1C |
| 111 | #define TIMER1_AUDIO_vect TIMER1_COMPC_vect | 111 | # define TIMER1_AUDIO_vect TIMER1_COMPC_vect |
| 112 | #endif | 112 | #endif |
| 113 | // ----------------------------------------------------------------------------- | 113 | // ----------------------------------------------------------------------------- |
| 114 | 114 | ||
| 115 | 115 | int voices = 0; | |
| 116 | int voices = 0; | 116 | int voice_place = 0; |
| 117 | int voice_place = 0; | 117 | float frequency = 0; |
| 118 | float frequency = 0; | ||
| 119 | float frequency_alt = 0; | 118 | float frequency_alt = 0; |
| 120 | int volume = 0; | 119 | int volume = 0; |
| 121 | long position = 0; | 120 | long position = 0; |
| 122 | 121 | ||
| 123 | float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | 122 | float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; |
| 124 | int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | 123 | int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0}; |
| 125 | bool sliding = false; | 124 | bool sliding = false; |
| 126 | 125 | ||
| 127 | float place = 0; | 126 | float place = 0; |
| 128 | 127 | ||
| 129 | uint8_t * sample; | 128 | uint8_t* sample; |
| 130 | uint16_t sample_length = 0; | 129 | uint16_t sample_length = 0; |
| 131 | 130 | ||
| 132 | bool playing_notes = false; | 131 | bool playing_notes = false; |
| 133 | bool playing_note = false; | 132 | bool playing_note = false; |
| 134 | float note_frequency = 0; | 133 | float note_frequency = 0; |
| 135 | float note_length = 0; | 134 | float note_length = 0; |
| 136 | uint8_t note_tempo = TEMPO_DEFAULT; | 135 | uint8_t note_tempo = TEMPO_DEFAULT; |
| 137 | float note_timbre = TIMBRE_DEFAULT; | 136 | float note_timbre = TIMBRE_DEFAULT; |
| 138 | uint16_t note_position = 0; | 137 | uint16_t note_position = 0; |
| 139 | float (* notes_pointer)[][2]; | 138 | float (*notes_pointer)[][2]; |
| 140 | uint16_t notes_count; | 139 | uint16_t notes_count; |
| 141 | bool notes_repeat; | 140 | bool notes_repeat; |
| 142 | bool note_resting = false; | 141 | bool note_resting = false; |
| 143 | 142 | ||
| 144 | uint16_t current_note = 0; | 143 | uint16_t current_note = 0; |
| 145 | uint8_t rest_counter = 0; | 144 | uint8_t rest_counter = 0; |
| 146 | 145 | ||
| 147 | #ifdef VIBRATO_ENABLE | 146 | #ifdef VIBRATO_ENABLE |
| 148 | float vibrato_counter = 0; | 147 | float vibrato_counter = 0; |
| 149 | float vibrato_strength = .5; | 148 | float vibrato_strength = .5; |
| 150 | float vibrato_rate = 0.125; | 149 | float vibrato_rate = 0.125; |
| 151 | #endif | 150 | #endif |
| 152 | 151 | ||
| 153 | float polyphony_rate = 0; | 152 | float polyphony_rate = 0; |
| @@ -157,73 +156,69 @@ static bool audio_initialized = false; | |||
| 157 | audio_config_t audio_config; | 156 | audio_config_t audio_config; |
| 158 | 157 | ||
| 159 | uint16_t envelope_index = 0; | 158 | uint16_t envelope_index = 0; |
| 160 | bool glissando = true; | 159 | bool glissando = true; |
| 161 | 160 | ||
| 162 | #ifndef STARTUP_SONG | 161 | #ifndef STARTUP_SONG |
| 163 | #define STARTUP_SONG SONG(STARTUP_SOUND) | 162 | # define STARTUP_SONG SONG(STARTUP_SOUND) |
| 164 | #endif | 163 | #endif |
| 165 | #ifndef AUDIO_ON_SONG | 164 | #ifndef AUDIO_ON_SONG |
| 166 | #define AUDIO_ON_SONG SONG(AUDIO_ON_SOUND) | 165 | # define AUDIO_ON_SONG SONG(AUDIO_ON_SOUND) |
| 167 | #endif | 166 | #endif |
| 168 | #ifndef AUDIO_OFF_SONG | 167 | #ifndef AUDIO_OFF_SONG |
| 169 | #define AUDIO_OFF_SONG SONG(AUDIO_OFF_SOUND) | 168 | # define AUDIO_OFF_SONG SONG(AUDIO_OFF_SOUND) |
| 170 | #endif | 169 | #endif |
| 171 | float startup_song[][2] = STARTUP_SONG; | 170 | float startup_song[][2] = STARTUP_SONG; |
| 172 | float audio_on_song[][2] = AUDIO_ON_SONG; | 171 | float audio_on_song[][2] = AUDIO_ON_SONG; |
| 173 | float audio_off_song[][2] = AUDIO_OFF_SONG; | 172 | float audio_off_song[][2] = AUDIO_OFF_SONG; |
| 174 | 173 | ||
| 175 | void audio_init() | 174 | void audio_init() { |
| 176 | { | ||
| 177 | |||
| 178 | // Check EEPROM | 175 | // Check EEPROM |
| 179 | if (!eeconfig_is_enabled()) | 176 | if (!eeconfig_is_enabled()) { |
| 180 | { | ||
| 181 | eeconfig_init(); | 177 | eeconfig_init(); |
| 182 | } | 178 | } |
| 183 | audio_config.raw = eeconfig_read_audio(); | 179 | audio_config.raw = eeconfig_read_audio(); |
| 184 | 180 | ||
| 185 | if (!audio_initialized) { | 181 | if (!audio_initialized) { |
| 182 | // Set audio ports as output | ||
| 183 | #ifdef CPIN_AUDIO | ||
| 184 | CPIN_SET_DIRECTION | ||
| 185 | DISABLE_AUDIO_COUNTER_3_ISR; | ||
| 186 | #endif | ||
| 187 | #ifdef BPIN_AUDIO | ||
| 188 | BPIN_SET_DIRECTION | ||
| 189 | DISABLE_AUDIO_COUNTER_1_ISR; | ||
| 190 | #endif | ||
| 186 | 191 | ||
| 187 | // Set audio ports as output | 192 | // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers TCCR3A/TCCR3B, TCCR1A/TCCR1B |
| 188 | #ifdef CPIN_AUDIO | 193 | // Compare Output Mode (COM3An and COM1An) = 0b00 = Normal port operation |
| 189 | CPIN_SET_DIRECTION | 194 | // OC3A -- PC6 |
| 190 | DISABLE_AUDIO_COUNTER_3_ISR; | 195 | // OC3B -- PC5 |
| 191 | #endif | 196 | // OC3C -- PC4 |
| 192 | #ifdef BPIN_AUDIO | 197 | // OC1A -- PB5 |
| 193 | BPIN_SET_DIRECTION | 198 | // OC1B -- PB6 |
| 194 | DISABLE_AUDIO_COUNTER_1_ISR; | 199 | // OC1C -- PB7 |
| 195 | #endif | 200 | |
| 196 | 201 | // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14. Period = ICR3, Duty Cycle OCR3A) | |
| 197 | // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers TCCR3A/TCCR3B, TCCR1A/TCCR1B | 202 | // OCR3A - PC6 |
| 198 | // Compare Output Mode (COM3An and COM1An) = 0b00 = Normal port operation | 203 | // OCR3B - PC5 |
| 199 | // OC3A -- PC6 | 204 | // OCR3C - PC4 |
| 200 | // OC3B -- PC5 | 205 | // OCR1A - PB5 |
| 201 | // OC3C -- PC4 | 206 | // OCR1B - PB6 |
| 202 | // OC1A -- PB5 | 207 | // OCR1C - PB7 |
| 203 | // OC1B -- PB6 | 208 | |
| 204 | // OC1C -- PB7 | 209 | // Clock Select (CS3n) = 0b010 = Clock / 8 |
| 205 | 210 | #ifdef CPIN_AUDIO | |
| 206 | // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14. Period = ICR3, Duty Cycle OCR3A) | 211 | INIT_AUDIO_COUNTER_3 |
| 207 | // OCR3A - PC6 | 212 | TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); |
| 208 | // OCR3B - PC5 | 213 | TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER)); |
| 209 | // OCR3C - PC4 | 214 | TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre); |
| 210 | // OCR1A - PB5 | 215 | #endif |
| 211 | // OCR1B - PB6 | 216 | #ifdef BPIN_AUDIO |
| 212 | // OCR1C - PB7 | 217 | INIT_AUDIO_COUNTER_1 |
| 213 | 218 | TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10); | |
| 214 | // Clock Select (CS3n) = 0b010 = Clock / 8 | 219 | TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER)); |
| 215 | #ifdef CPIN_AUDIO | 220 | TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre); |
| 216 | INIT_AUDIO_COUNTER_3 | 221 | #endif |
| 217 | TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); | ||
| 218 | TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER)); | ||
| 219 | TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre); | ||
| 220 | #endif | ||
| 221 | #ifdef BPIN_AUDIO | ||
| 222 | INIT_AUDIO_COUNTER_1 | ||
| 223 | TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10); | ||
| 224 | TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER)); | ||
| 225 | TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre); | ||
| 226 | #endif | ||
| 227 | 222 | ||
| 228 | audio_initialized = true; | 223 | audio_initialized = true; |
| 229 | } | 224 | } |
| @@ -231,11 +226,9 @@ void audio_init() | |||
| 231 | if (audio_config.enable) { | 226 | if (audio_config.enable) { |
| 232 | PLAY_SONG(startup_song); | 227 | PLAY_SONG(startup_song); |
| 233 | } | 228 | } |
| 234 | |||
| 235 | } | 229 | } |
| 236 | 230 | ||
| 237 | void stop_all_notes() | 231 | void stop_all_notes() { |
| 238 | { | ||
| 239 | dprintf("audio stop all notes"); | 232 | dprintf("audio stop all notes"); |
| 240 | 233 | ||
| 241 | if (!audio_initialized) { | 234 | if (!audio_initialized) { |
| @@ -243,31 +236,29 @@ void stop_all_notes() | |||
| 243 | } | 236 | } |
| 244 | voices = 0; | 237 | voices = 0; |
| 245 | 238 | ||
| 246 | #ifdef CPIN_AUDIO | 239 | #ifdef CPIN_AUDIO |
| 247 | DISABLE_AUDIO_COUNTER_3_ISR; | 240 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 248 | DISABLE_AUDIO_COUNTER_3_OUTPUT; | 241 | DISABLE_AUDIO_COUNTER_3_OUTPUT; |
| 249 | #endif | 242 | #endif |
| 250 | 243 | ||
| 251 | #ifdef BPIN_AUDIO | 244 | #ifdef BPIN_AUDIO |
| 252 | DISABLE_AUDIO_COUNTER_1_ISR; | 245 | DISABLE_AUDIO_COUNTER_1_ISR; |
| 253 | DISABLE_AUDIO_COUNTER_1_OUTPUT; | 246 | DISABLE_AUDIO_COUNTER_1_OUTPUT; |
| 254 | #endif | 247 | #endif |
| 255 | 248 | ||
| 256 | playing_notes = false; | 249 | playing_notes = false; |
| 257 | playing_note = false; | 250 | playing_note = false; |
| 258 | frequency = 0; | 251 | frequency = 0; |
| 259 | frequency_alt = 0; | 252 | frequency_alt = 0; |
| 260 | volume = 0; | 253 | volume = 0; |
| 261 | 254 | ||
| 262 | for (uint8_t i = 0; i < 8; i++) | 255 | for (uint8_t i = 0; i < 8; i++) { |
| 263 | { | ||
| 264 | frequencies[i] = 0; | 256 | frequencies[i] = 0; |
| 265 | volumes[i] = 0; | 257 | volumes[i] = 0; |
| 266 | } | 258 | } |
| 267 | } | 259 | } |
| 268 | 260 | ||
| 269 | void stop_note(float freq) | 261 | void stop_note(float freq) { |
| 270 | { | ||
| 271 | dprintf("audio stop note freq=%d", (int)freq); | 262 | dprintf("audio stop note freq=%d", (int)freq); |
| 272 | 263 | ||
| 273 | if (playing_note) { | 264 | if (playing_note) { |
| @@ -277,133 +268,129 @@ void stop_note(float freq) | |||
| 277 | for (int i = 7; i >= 0; i--) { | 268 | for (int i = 7; i >= 0; i--) { |
| 278 | if (frequencies[i] == freq) { | 269 | if (frequencies[i] == freq) { |
| 279 | frequencies[i] = 0; | 270 | frequencies[i] = 0; |
| 280 | volumes[i] = 0; | 271 | volumes[i] = 0; |
| 281 | for (int j = i; (j < 7); j++) { | 272 | for (int j = i; (j < 7); j++) { |
| 282 | frequencies[j] = frequencies[j+1]; | 273 | frequencies[j] = frequencies[j + 1]; |
| 283 | frequencies[j+1] = 0; | 274 | frequencies[j + 1] = 0; |
| 284 | volumes[j] = volumes[j+1]; | 275 | volumes[j] = volumes[j + 1]; |
| 285 | volumes[j+1] = 0; | 276 | volumes[j + 1] = 0; |
| 286 | } | 277 | } |
| 287 | break; | 278 | break; |
| 288 | } | 279 | } |
| 289 | } | 280 | } |
| 290 | voices--; | 281 | voices--; |
| 291 | if (voices < 0) | 282 | if (voices < 0) voices = 0; |
| 292 | voices = 0; | ||
| 293 | if (voice_place >= voices) { | 283 | if (voice_place >= voices) { |
| 294 | voice_place = 0; | 284 | voice_place = 0; |
| 295 | } | 285 | } |
| 296 | if (voices == 0) { | 286 | if (voices == 0) { |
| 297 | #ifdef CPIN_AUDIO | 287 | #ifdef CPIN_AUDIO |
| 298 | DISABLE_AUDIO_COUNTER_3_ISR; | 288 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 299 | DISABLE_AUDIO_COUNTER_3_OUTPUT; | 289 | DISABLE_AUDIO_COUNTER_3_OUTPUT; |
| 300 | #endif | 290 | #endif |
| 301 | #ifdef BPIN_AUDIO | 291 | #ifdef BPIN_AUDIO |
| 302 | DISABLE_AUDIO_COUNTER_1_ISR; | 292 | DISABLE_AUDIO_COUNTER_1_ISR; |
| 303 | DISABLE_AUDIO_COUNTER_1_OUTPUT; | 293 | DISABLE_AUDIO_COUNTER_1_OUTPUT; |
| 304 | #endif | 294 | #endif |
| 305 | frequency = 0; | 295 | frequency = 0; |
| 306 | frequency_alt = 0; | 296 | frequency_alt = 0; |
| 307 | volume = 0; | 297 | volume = 0; |
| 308 | playing_note = false; | 298 | playing_note = false; |
| 309 | } | 299 | } |
| 310 | } | 300 | } |
| 311 | } | 301 | } |
| 312 | 302 | ||
| 313 | #ifdef VIBRATO_ENABLE | 303 | #ifdef VIBRATO_ENABLE |
| 314 | 304 | ||
| 315 | float mod(float a, int b) | 305 | float mod(float a, int b) { |
| 316 | { | ||
| 317 | float r = fmod(a, b); | 306 | float r = fmod(a, b); |
| 318 | return r < 0 ? r + b : r; | 307 | return r < 0 ? r + b : r; |
| 319 | } | 308 | } |
| 320 | 309 | ||
| 321 | float vibrato(float average_freq) { | 310 | float vibrato(float average_freq) { |
| 322 | #ifdef VIBRATO_STRENGTH_ENABLE | 311 | # ifdef VIBRATO_STRENGTH_ENABLE |
| 323 | float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength); | 312 | float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength); |
| 324 | #else | 313 | # else |
| 325 | float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter]; | 314 | float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter]; |
| 326 | #endif | 315 | # endif |
| 327 | vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0/average_freq)), VIBRATO_LUT_LENGTH); | 316 | vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0 / average_freq)), VIBRATO_LUT_LENGTH); |
| 328 | return vibrated_freq; | 317 | return vibrated_freq; |
| 329 | } | 318 | } |
| 330 | 319 | ||
| 331 | #endif | 320 | #endif |
| 332 | 321 | ||
| 333 | #ifdef CPIN_AUDIO | 322 | #ifdef CPIN_AUDIO |
| 334 | ISR(TIMER3_AUDIO_vect) | 323 | ISR(TIMER3_AUDIO_vect) { |
| 335 | { | ||
| 336 | float freq; | 324 | float freq; |
| 337 | 325 | ||
| 338 | if (playing_note) { | 326 | if (playing_note) { |
| 339 | if (voices > 0) { | 327 | if (voices > 0) { |
| 340 | 328 | # ifdef BPIN_AUDIO | |
| 341 | #ifdef BPIN_AUDIO | ||
| 342 | float freq_alt = 0; | 329 | float freq_alt = 0; |
| 343 | if (voices > 1) { | 330 | if (voices > 1) { |
| 344 | if (polyphony_rate == 0) { | 331 | if (polyphony_rate == 0) { |
| 345 | if (glissando) { | 332 | if (glissando) { |
| 346 | if (frequency_alt != 0 && frequency_alt < frequencies[voices - 2] && frequency_alt < frequencies[voices - 2] * pow(2, -440/frequencies[voices - 2]/12/2)) { | 333 | if (frequency_alt != 0 && frequency_alt < frequencies[voices - 2] && frequency_alt < frequencies[voices - 2] * pow(2, -440 / frequencies[voices - 2] / 12 / 2)) { |
| 347 | frequency_alt = frequency_alt * pow(2, 440/frequency_alt/12/2); | 334 | frequency_alt = frequency_alt * pow(2, 440 / frequency_alt / 12 / 2); |
| 348 | } else if (frequency_alt != 0 && frequency_alt > frequencies[voices - 2] && frequency_alt > frequencies[voices - 2] * pow(2, 440/frequencies[voices - 2]/12/2)) { | 335 | } else if (frequency_alt != 0 && frequency_alt > frequencies[voices - 2] && frequency_alt > frequencies[voices - 2] * pow(2, 440 / frequencies[voices - 2] / 12 / 2)) { |
| 349 | frequency_alt = frequency_alt * pow(2, -440/frequency_alt/12/2); | 336 | frequency_alt = frequency_alt * pow(2, -440 / frequency_alt / 12 / 2); |
| 350 | } else { | ||
| 351 | frequency_alt = frequencies[voices - 2]; | ||
| 352 | } | ||
| 353 | } else { | 337 | } else { |
| 354 | frequency_alt = frequencies[voices - 2]; | 338 | frequency_alt = frequencies[voices - 2]; |
| 355 | } | 339 | } |
| 356 | 340 | } else { | |
| 357 | #ifdef VIBRATO_ENABLE | 341 | frequency_alt = frequencies[voices - 2]; |
| 358 | if (vibrato_strength > 0) { | ||
| 359 | freq_alt = vibrato(frequency_alt); | ||
| 360 | } else { | ||
| 361 | freq_alt = frequency_alt; | ||
| 362 | } | ||
| 363 | #else | ||
| 364 | freq_alt = frequency_alt; | ||
| 365 | #endif | ||
| 366 | } | 342 | } |
| 367 | 343 | ||
| 368 | if (envelope_index < 65535) { | 344 | # ifdef VIBRATO_ENABLE |
| 369 | envelope_index++; | 345 | if (vibrato_strength > 0) { |
| 346 | freq_alt = vibrato(frequency_alt); | ||
| 347 | } else { | ||
| 348 | freq_alt = frequency_alt; | ||
| 370 | } | 349 | } |
| 350 | # else | ||
| 351 | freq_alt = frequency_alt; | ||
| 352 | # endif | ||
| 353 | } | ||
| 371 | 354 | ||
| 372 | freq_alt = voice_envelope(freq_alt); | 355 | if (envelope_index < 65535) { |
| 356 | envelope_index++; | ||
| 357 | } | ||
| 373 | 358 | ||
| 374 | if (freq_alt < 30.517578125) { | 359 | freq_alt = voice_envelope(freq_alt); |
| 375 | freq_alt = 30.52; | ||
| 376 | } | ||
| 377 | 360 | ||
| 378 | TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq_alt * CPU_PRESCALER)); | 361 | if (freq_alt < 30.517578125) { |
| 379 | TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq_alt * CPU_PRESCALER)) * note_timbre); | 362 | freq_alt = 30.52; |
| 380 | } | 363 | } |
| 381 | #endif | 364 | |
| 365 | TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq_alt * CPU_PRESCALER)); | ||
| 366 | TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq_alt * CPU_PRESCALER)) * note_timbre); | ||
| 367 | } | ||
| 368 | # endif | ||
| 382 | 369 | ||
| 383 | if (polyphony_rate > 0) { | 370 | if (polyphony_rate > 0) { |
| 384 | if (voices > 1) { | 371 | if (voices > 1) { |
| 385 | voice_place %= voices; | 372 | voice_place %= voices; |
| 386 | if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { | 373 | if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { |
| 387 | voice_place = (voice_place + 1) % voices; | 374 | voice_place = (voice_place + 1) % voices; |
| 388 | place = 0.0; | 375 | place = 0.0; |
| 389 | } | 376 | } |
| 390 | } | 377 | } |
| 391 | 378 | ||
| 392 | #ifdef VIBRATO_ENABLE | 379 | # ifdef VIBRATO_ENABLE |
| 393 | if (vibrato_strength > 0) { | 380 | if (vibrato_strength > 0) { |
| 394 | freq = vibrato(frequencies[voice_place]); | 381 | freq = vibrato(frequencies[voice_place]); |
| 395 | } else { | 382 | } else { |
| 396 | freq = frequencies[voice_place]; | ||
| 397 | } | ||
| 398 | #else | ||
| 399 | freq = frequencies[voice_place]; | 383 | freq = frequencies[voice_place]; |
| 400 | #endif | 384 | } |
| 385 | # else | ||
| 386 | freq = frequencies[voice_place]; | ||
| 387 | # endif | ||
| 401 | } else { | 388 | } else { |
| 402 | if (glissando) { | 389 | if (glissando) { |
| 403 | if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) { | 390 | if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440 / frequencies[voices - 1] / 12 / 2)) { |
| 404 | frequency = frequency * pow(2, 440/frequency/12/2); | 391 | frequency = frequency * pow(2, 440 / frequency / 12 / 2); |
| 405 | } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) { | 392 | } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440 / frequencies[voices - 1] / 12 / 2)) { |
| 406 | frequency = frequency * pow(2, -440/frequency/12/2); | 393 | frequency = frequency * pow(2, -440 / frequency / 12 / 2); |
| 407 | } else { | 394 | } else { |
| 408 | frequency = frequencies[voices - 1]; | 395 | frequency = frequencies[voices - 1]; |
| 409 | } | 396 | } |
| @@ -411,15 +398,15 @@ ISR(TIMER3_AUDIO_vect) | |||
| 411 | frequency = frequencies[voices - 1]; | 398 | frequency = frequencies[voices - 1]; |
| 412 | } | 399 | } |
| 413 | 400 | ||
| 414 | #ifdef VIBRATO_ENABLE | 401 | # ifdef VIBRATO_ENABLE |
| 415 | if (vibrato_strength > 0) { | 402 | if (vibrato_strength > 0) { |
| 416 | freq = vibrato(frequency); | 403 | freq = vibrato(frequency); |
| 417 | } else { | 404 | } else { |
| 418 | freq = frequency; | ||
| 419 | } | ||
| 420 | #else | ||
| 421 | freq = frequency; | 405 | freq = frequency; |
| 422 | #endif | 406 | } |
| 407 | # else | ||
| 408 | freq = frequency; | ||
| 409 | # endif | ||
| 423 | } | 410 | } |
| 424 | 411 | ||
| 425 | if (envelope_index < 65535) { | 412 | if (envelope_index < 65535) { |
| @@ -432,32 +419,32 @@ ISR(TIMER3_AUDIO_vect) | |||
| 432 | freq = 30.52; | 419 | freq = 30.52; |
| 433 | } | 420 | } |
| 434 | 421 | ||
| 435 | TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); | 422 | TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); |
| 436 | TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); | 423 | TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); |
| 437 | } | 424 | } |
| 438 | } | 425 | } |
| 439 | 426 | ||
| 440 | if (playing_notes) { | 427 | if (playing_notes) { |
| 441 | if (note_frequency > 0) { | 428 | if (note_frequency > 0) { |
| 442 | #ifdef VIBRATO_ENABLE | 429 | # ifdef VIBRATO_ENABLE |
| 443 | if (vibrato_strength > 0) { | 430 | if (vibrato_strength > 0) { |
| 444 | freq = vibrato(note_frequency); | 431 | freq = vibrato(note_frequency); |
| 445 | } else { | 432 | } else { |
| 446 | freq = note_frequency; | 433 | freq = note_frequency; |
| 447 | } | 434 | } |
| 448 | #else | 435 | # else |
| 449 | freq = note_frequency; | 436 | freq = note_frequency; |
| 450 | #endif | 437 | # endif |
| 451 | 438 | ||
| 452 | if (envelope_index < 65535) { | 439 | if (envelope_index < 65535) { |
| 453 | envelope_index++; | 440 | envelope_index++; |
| 454 | } | 441 | } |
| 455 | freq = voice_envelope(freq); | 442 | freq = voice_envelope(freq); |
| 456 | 443 | ||
| 457 | TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); | 444 | TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); |
| 458 | TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); | 445 | TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); |
| 459 | } else { | 446 | } else { |
| 460 | TIMER_3_PERIOD = 0; | 447 | TIMER_3_PERIOD = 0; |
| 461 | TIMER_3_DUTY_CYCLE = 0; | 448 | TIMER_3_DUTY_CYCLE = 0; |
| 462 | } | 449 | } |
| 463 | 450 | ||
| @@ -489,16 +476,16 @@ ISR(TIMER3_AUDIO_vect) | |||
| 489 | current_note--; | 476 | current_note--; |
| 490 | if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) { | 477 | if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) { |
| 491 | note_frequency = 0; | 478 | note_frequency = 0; |
| 492 | note_length = 1; | 479 | note_length = 1; |
| 493 | } else { | 480 | } else { |
| 494 | note_frequency = (*notes_pointer)[current_note][0]; | 481 | note_frequency = (*notes_pointer)[current_note][0]; |
| 495 | note_length = 1; | 482 | note_length = 1; |
| 496 | } | 483 | } |
| 497 | } else { | 484 | } else { |
| 498 | note_resting = false; | 485 | note_resting = false; |
| 499 | envelope_index = 0; | 486 | envelope_index = 0; |
| 500 | note_frequency = (*notes_pointer)[current_note][0]; | 487 | note_frequency = (*notes_pointer)[current_note][0]; |
| 501 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); | 488 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); |
| 502 | } | 489 | } |
| 503 | 490 | ||
| 504 | note_position = 0; | 491 | note_position = 0; |
| @@ -507,15 +494,14 @@ ISR(TIMER3_AUDIO_vect) | |||
| 507 | 494 | ||
| 508 | if (!audio_config.enable) { | 495 | if (!audio_config.enable) { |
| 509 | playing_notes = false; | 496 | playing_notes = false; |
| 510 | playing_note = false; | 497 | playing_note = false; |
| 511 | } | 498 | } |
| 512 | } | 499 | } |
| 513 | #endif | 500 | #endif |
| 514 | 501 | ||
| 515 | #ifdef BPIN_AUDIO | 502 | #ifdef BPIN_AUDIO |
| 516 | ISR(TIMER1_AUDIO_vect) | 503 | ISR(TIMER1_AUDIO_vect) { |
| 517 | { | 504 | # if defined(BPIN_AUDIO) && !defined(CPIN_AUDIO) |
| 518 | #if defined(BPIN_AUDIO) && !defined(CPIN_AUDIO) | ||
| 519 | float freq = 0; | 505 | float freq = 0; |
| 520 | 506 | ||
| 521 | if (playing_note) { | 507 | if (playing_note) { |
| @@ -525,25 +511,25 @@ ISR(TIMER1_AUDIO_vect) | |||
| 525 | voice_place %= voices; | 511 | voice_place %= voices; |
| 526 | if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { | 512 | if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { |
| 527 | voice_place = (voice_place + 1) % voices; | 513 | voice_place = (voice_place + 1) % voices; |
| 528 | place = 0.0; | 514 | place = 0.0; |
| 529 | } | 515 | } |
| 530 | } | 516 | } |
| 531 | 517 | ||
| 532 | #ifdef VIBRATO_ENABLE | 518 | # ifdef VIBRATO_ENABLE |
| 533 | if (vibrato_strength > 0) { | 519 | if (vibrato_strength > 0) { |
| 534 | freq = vibrato(frequencies[voice_place]); | 520 | freq = vibrato(frequencies[voice_place]); |
| 535 | } else { | 521 | } else { |
| 536 | freq = frequencies[voice_place]; | ||
| 537 | } | ||
| 538 | #else | ||
| 539 | freq = frequencies[voice_place]; | 522 | freq = frequencies[voice_place]; |
| 540 | #endif | 523 | } |
| 524 | # else | ||
| 525 | freq = frequencies[voice_place]; | ||
| 526 | # endif | ||
| 541 | } else { | 527 | } else { |
| 542 | if (glissando) { | 528 | if (glissando) { |
| 543 | if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) { | 529 | if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440 / frequencies[voices - 1] / 12 / 2)) { |
| 544 | frequency = frequency * pow(2, 440/frequency/12/2); | 530 | frequency = frequency * pow(2, 440 / frequency / 12 / 2); |
| 545 | } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) { | 531 | } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440 / frequencies[voices - 1] / 12 / 2)) { |
| 546 | frequency = frequency * pow(2, -440/frequency/12/2); | 532 | frequency = frequency * pow(2, -440 / frequency / 12 / 2); |
| 547 | } else { | 533 | } else { |
| 548 | frequency = frequencies[voices - 1]; | 534 | frequency = frequencies[voices - 1]; |
| 549 | } | 535 | } |
| @@ -551,15 +537,15 @@ ISR(TIMER1_AUDIO_vect) | |||
| 551 | frequency = frequencies[voices - 1]; | 537 | frequency = frequencies[voices - 1]; |
| 552 | } | 538 | } |
| 553 | 539 | ||
| 554 | #ifdef VIBRATO_ENABLE | 540 | # ifdef VIBRATO_ENABLE |
| 555 | if (vibrato_strength > 0) { | 541 | if (vibrato_strength > 0) { |
| 556 | freq = vibrato(frequency); | 542 | freq = vibrato(frequency); |
| 557 | } else { | 543 | } else { |
| 558 | freq = frequency; | ||
| 559 | } | ||
| 560 | #else | ||
| 561 | freq = frequency; | 544 | freq = frequency; |
| 562 | #endif | 545 | } |
| 546 | # else | ||
| 547 | freq = frequency; | ||
| 548 | # endif | ||
| 563 | } | 549 | } |
| 564 | 550 | ||
| 565 | if (envelope_index < 65535) { | 551 | if (envelope_index < 65535) { |
| @@ -572,32 +558,32 @@ ISR(TIMER1_AUDIO_vect) | |||
| 572 | freq = 30.52; | 558 | freq = 30.52; |
| 573 | } | 559 | } |
| 574 | 560 | ||
| 575 | TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); | 561 | TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); |
| 576 | TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); | 562 | TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); |
| 577 | } | 563 | } |
| 578 | } | 564 | } |
| 579 | 565 | ||
| 580 | if (playing_notes) { | 566 | if (playing_notes) { |
| 581 | if (note_frequency > 0) { | 567 | if (note_frequency > 0) { |
| 582 | #ifdef VIBRATO_ENABLE | 568 | # ifdef VIBRATO_ENABLE |
| 583 | if (vibrato_strength > 0) { | 569 | if (vibrato_strength > 0) { |
| 584 | freq = vibrato(note_frequency); | 570 | freq = vibrato(note_frequency); |
| 585 | } else { | 571 | } else { |
| 586 | freq = note_frequency; | 572 | freq = note_frequency; |
| 587 | } | 573 | } |
| 588 | #else | 574 | # else |
| 589 | freq = note_frequency; | 575 | freq = note_frequency; |
| 590 | #endif | 576 | # endif |
| 591 | 577 | ||
| 592 | if (envelope_index < 65535) { | 578 | if (envelope_index < 65535) { |
| 593 | envelope_index++; | 579 | envelope_index++; |
| 594 | } | 580 | } |
| 595 | freq = voice_envelope(freq); | 581 | freq = voice_envelope(freq); |
| 596 | 582 | ||
| 597 | TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); | 583 | TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); |
| 598 | TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); | 584 | TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); |
| 599 | } else { | 585 | } else { |
| 600 | TIMER_1_PERIOD = 0; | 586 | TIMER_1_PERIOD = 0; |
| 601 | TIMER_1_DUTY_CYCLE = 0; | 587 | TIMER_1_DUTY_CYCLE = 0; |
| 602 | } | 588 | } |
| 603 | 589 | ||
| @@ -629,16 +615,16 @@ ISR(TIMER1_AUDIO_vect) | |||
| 629 | current_note--; | 615 | current_note--; |
| 630 | if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) { | 616 | if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) { |
| 631 | note_frequency = 0; | 617 | note_frequency = 0; |
| 632 | note_length = 1; | 618 | note_length = 1; |
| 633 | } else { | 619 | } else { |
| 634 | note_frequency = (*notes_pointer)[current_note][0]; | 620 | note_frequency = (*notes_pointer)[current_note][0]; |
| 635 | note_length = 1; | 621 | note_length = 1; |
| 636 | } | 622 | } |
| 637 | } else { | 623 | } else { |
| 638 | note_resting = false; | 624 | note_resting = false; |
| 639 | envelope_index = 0; | 625 | envelope_index = 0; |
| 640 | note_frequency = (*notes_pointer)[current_note][0]; | 626 | note_frequency = (*notes_pointer)[current_note][0]; |
| 641 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); | 627 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); |
| 642 | } | 628 | } |
| 643 | 629 | ||
| 644 | note_position = 0; | 630 | note_position = 0; |
| @@ -647,14 +633,13 @@ ISR(TIMER1_AUDIO_vect) | |||
| 647 | 633 | ||
| 648 | if (!audio_config.enable) { | 634 | if (!audio_config.enable) { |
| 649 | playing_notes = false; | 635 | playing_notes = false; |
| 650 | playing_note = false; | 636 | playing_note = false; |
| 651 | } | 637 | } |
| 652 | #endif | 638 | # endif |
| 653 | } | 639 | } |
| 654 | #endif | 640 | #endif |
| 655 | 641 | ||
| 656 | void play_note(float freq, int vol) { | 642 | void play_note(float freq, int vol) { |
| 657 | |||
| 658 | dprintf("audio play note freq=%d vol=%d", (int)freq, vol); | 643 | dprintf("audio play note freq=%d vol=%d", (int)freq, vol); |
| 659 | 644 | ||
| 660 | if (!audio_initialized) { | 645 | if (!audio_initialized) { |
| @@ -662,16 +647,15 @@ void play_note(float freq, int vol) { | |||
| 662 | } | 647 | } |
| 663 | 648 | ||
| 664 | if (audio_config.enable && voices < 8) { | 649 | if (audio_config.enable && voices < 8) { |
| 665 | #ifdef CPIN_AUDIO | 650 | #ifdef CPIN_AUDIO |
| 666 | DISABLE_AUDIO_COUNTER_3_ISR; | 651 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 667 | #endif | 652 | #endif |
| 668 | #ifdef BPIN_AUDIO | 653 | #ifdef BPIN_AUDIO |
| 669 | DISABLE_AUDIO_COUNTER_1_ISR; | 654 | DISABLE_AUDIO_COUNTER_1_ISR; |
| 670 | #endif | 655 | #endif |
| 671 | 656 | ||
| 672 | // Cancel notes if notes are playing | 657 | // Cancel notes if notes are playing |
| 673 | if (playing_notes) | 658 | if (playing_notes) stop_all_notes(); |
| 674 | stop_all_notes(); | ||
| 675 | 659 | ||
| 676 | playing_note = true; | 660 | playing_note = true; |
| 677 | 661 | ||
| @@ -679,90 +663,78 @@ void play_note(float freq, int vol) { | |||
| 679 | 663 | ||
| 680 | if (freq > 0) { | 664 | if (freq > 0) { |
| 681 | frequencies[voices] = freq; | 665 | frequencies[voices] = freq; |
| 682 | volumes[voices] = vol; | 666 | volumes[voices] = vol; |
| 683 | voices++; | 667 | voices++; |
| 684 | } | 668 | } |
| 685 | 669 | ||
| 686 | #ifdef CPIN_AUDIO | 670 | #ifdef CPIN_AUDIO |
| 687 | ENABLE_AUDIO_COUNTER_3_ISR; | 671 | ENABLE_AUDIO_COUNTER_3_ISR; |
| 688 | ENABLE_AUDIO_COUNTER_3_OUTPUT; | 672 | ENABLE_AUDIO_COUNTER_3_OUTPUT; |
| 689 | #endif | 673 | #endif |
| 690 | #ifdef BPIN_AUDIO | 674 | #ifdef BPIN_AUDIO |
| 691 | #ifdef CPIN_AUDIO | 675 | # ifdef CPIN_AUDIO |
| 692 | if (voices > 1) { | 676 | if (voices > 1) { |
| 693 | ENABLE_AUDIO_COUNTER_1_ISR; | ||
| 694 | ENABLE_AUDIO_COUNTER_1_OUTPUT; | ||
| 695 | } | ||
| 696 | #else | ||
| 697 | ENABLE_AUDIO_COUNTER_1_ISR; | 677 | ENABLE_AUDIO_COUNTER_1_ISR; |
| 698 | ENABLE_AUDIO_COUNTER_1_OUTPUT; | 678 | ENABLE_AUDIO_COUNTER_1_OUTPUT; |
| 699 | #endif | 679 | } |
| 700 | #endif | 680 | # else |
| 681 | ENABLE_AUDIO_COUNTER_1_ISR; | ||
| 682 | ENABLE_AUDIO_COUNTER_1_OUTPUT; | ||
| 683 | # endif | ||
| 684 | #endif | ||
| 701 | } | 685 | } |
| 702 | |||
| 703 | } | 686 | } |
| 704 | 687 | ||
| 705 | void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat) | 688 | void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat) { |
| 706 | { | ||
| 707 | |||
| 708 | if (!audio_initialized) { | 689 | if (!audio_initialized) { |
| 709 | audio_init(); | 690 | audio_init(); |
| 710 | } | 691 | } |
| 711 | 692 | ||
| 712 | if (audio_config.enable) { | 693 | if (audio_config.enable) { |
| 713 | 694 | #ifdef CPIN_AUDIO | |
| 714 | #ifdef CPIN_AUDIO | 695 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 715 | DISABLE_AUDIO_COUNTER_3_ISR; | 696 | #endif |
| 716 | #endif | 697 | #ifdef BPIN_AUDIO |
| 717 | #ifdef BPIN_AUDIO | 698 | DISABLE_AUDIO_COUNTER_1_ISR; |
| 718 | DISABLE_AUDIO_COUNTER_1_ISR; | 699 | #endif |
| 719 | #endif | ||
| 720 | 700 | ||
| 721 | // Cancel note if a note is playing | 701 | // Cancel note if a note is playing |
| 722 | if (playing_note) | 702 | if (playing_note) stop_all_notes(); |
| 723 | stop_all_notes(); | ||
| 724 | 703 | ||
| 725 | playing_notes = true; | 704 | playing_notes = true; |
| 726 | 705 | ||
| 727 | notes_pointer = np; | 706 | notes_pointer = np; |
| 728 | notes_count = n_count; | 707 | notes_count = n_count; |
| 729 | notes_repeat = n_repeat; | 708 | notes_repeat = n_repeat; |
| 730 | 709 | ||
| 731 | place = 0; | 710 | place = 0; |
| 732 | current_note = 0; | 711 | current_note = 0; |
| 733 | 712 | ||
| 734 | note_frequency = (*notes_pointer)[current_note][0]; | 713 | note_frequency = (*notes_pointer)[current_note][0]; |
| 735 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); | 714 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); |
| 736 | note_position = 0; | 715 | note_position = 0; |
| 737 | 716 | ||
| 738 | 717 | #ifdef CPIN_AUDIO | |
| 739 | #ifdef CPIN_AUDIO | 718 | ENABLE_AUDIO_COUNTER_3_ISR; |
| 740 | ENABLE_AUDIO_COUNTER_3_ISR; | 719 | ENABLE_AUDIO_COUNTER_3_OUTPUT; |
| 741 | ENABLE_AUDIO_COUNTER_3_OUTPUT; | 720 | #endif |
| 742 | #endif | 721 | #ifdef BPIN_AUDIO |
| 743 | #ifdef BPIN_AUDIO | 722 | # ifndef CPIN_AUDIO |
| 744 | #ifndef CPIN_AUDIO | 723 | ENABLE_AUDIO_COUNTER_1_ISR; |
| 745 | ENABLE_AUDIO_COUNTER_1_ISR; | 724 | ENABLE_AUDIO_COUNTER_1_OUTPUT; |
| 746 | ENABLE_AUDIO_COUNTER_1_OUTPUT; | 725 | # endif |
| 747 | #endif | 726 | #endif |
| 748 | #endif | ||
| 749 | } | 727 | } |
| 750 | |||
| 751 | } | 728 | } |
| 752 | 729 | ||
| 753 | bool is_playing_notes(void) { | 730 | bool is_playing_notes(void) { return playing_notes; } |
| 754 | return playing_notes; | ||
| 755 | } | ||
| 756 | 731 | ||
| 757 | bool is_audio_on(void) { | 732 | bool is_audio_on(void) { return (audio_config.enable != 0); } |
| 758 | return (audio_config.enable != 0); | ||
| 759 | } | ||
| 760 | 733 | ||
| 761 | void audio_toggle(void) { | 734 | void audio_toggle(void) { |
| 762 | audio_config.enable ^= 1; | 735 | audio_config.enable ^= 1; |
| 763 | eeconfig_update_audio(audio_config.raw); | 736 | eeconfig_update_audio(audio_config.raw); |
| 764 | if (audio_config.enable) | 737 | if (audio_config.enable) audio_on_user(); |
| 765 | audio_on_user(); | ||
| 766 | } | 738 | } |
| 767 | 739 | ||
| 768 | void audio_on(void) { | 740 | void audio_on(void) { |
| @@ -784,73 +756,45 @@ void audio_off(void) { | |||
| 784 | 756 | ||
| 785 | // Vibrato rate functions | 757 | // Vibrato rate functions |
| 786 | 758 | ||
| 787 | void set_vibrato_rate(float rate) { | 759 | void set_vibrato_rate(float rate) { vibrato_rate = rate; } |
| 788 | vibrato_rate = rate; | ||
| 789 | } | ||
| 790 | 760 | ||
| 791 | void increase_vibrato_rate(float change) { | 761 | void increase_vibrato_rate(float change) { vibrato_rate *= change; } |
| 792 | vibrato_rate *= change; | ||
| 793 | } | ||
| 794 | 762 | ||
| 795 | void decrease_vibrato_rate(float change) { | 763 | void decrease_vibrato_rate(float change) { vibrato_rate /= change; } |
| 796 | vibrato_rate /= change; | ||
| 797 | } | ||
| 798 | 764 | ||
| 799 | #ifdef VIBRATO_STRENGTH_ENABLE | 765 | # ifdef VIBRATO_STRENGTH_ENABLE |
| 800 | 766 | ||
| 801 | void set_vibrato_strength(float strength) { | 767 | void set_vibrato_strength(float strength) { vibrato_strength = strength; } |
| 802 | vibrato_strength = strength; | ||
| 803 | } | ||
| 804 | 768 | ||
| 805 | void increase_vibrato_strength(float change) { | 769 | void increase_vibrato_strength(float change) { vibrato_strength *= change; } |
| 806 | vibrato_strength *= change; | ||
| 807 | } | ||
| 808 | 770 | ||
| 809 | void decrease_vibrato_strength(float change) { | 771 | void decrease_vibrato_strength(float change) { vibrato_strength /= change; } |
| 810 | vibrato_strength /= change; | ||
| 811 | } | ||
| 812 | 772 | ||
| 813 | #endif /* VIBRATO_STRENGTH_ENABLE */ | 773 | # endif /* VIBRATO_STRENGTH_ENABLE */ |
| 814 | 774 | ||
| 815 | #endif /* VIBRATO_ENABLE */ | 775 | #endif /* VIBRATO_ENABLE */ |
| 816 | 776 | ||
| 817 | // Polyphony functions | 777 | // Polyphony functions |
| 818 | 778 | ||
| 819 | void set_polyphony_rate(float rate) { | 779 | void set_polyphony_rate(float rate) { polyphony_rate = rate; } |
| 820 | polyphony_rate = rate; | ||
| 821 | } | ||
| 822 | 780 | ||
| 823 | void enable_polyphony() { | 781 | void enable_polyphony() { polyphony_rate = 5; } |
| 824 | polyphony_rate = 5; | ||
| 825 | } | ||
| 826 | 782 | ||
| 827 | void disable_polyphony() { | 783 | void disable_polyphony() { polyphony_rate = 0; } |
| 828 | polyphony_rate = 0; | ||
| 829 | } | ||
| 830 | 784 | ||
| 831 | void increase_polyphony_rate(float change) { | 785 | void increase_polyphony_rate(float change) { polyphony_rate *= change; } |
| 832 | polyphony_rate *= change; | ||
| 833 | } | ||
| 834 | 786 | ||
| 835 | void decrease_polyphony_rate(float change) { | 787 | void decrease_polyphony_rate(float change) { polyphony_rate /= change; } |
| 836 | polyphony_rate /= change; | ||
| 837 | } | ||
| 838 | 788 | ||
| 839 | // Timbre function | 789 | // Timbre function |
| 840 | 790 | ||
| 841 | void set_timbre(float timbre) { | 791 | void set_timbre(float timbre) { note_timbre = timbre; } |
| 842 | note_timbre = timbre; | ||
| 843 | } | ||
| 844 | 792 | ||
| 845 | // Tempo functions | 793 | // Tempo functions |
| 846 | 794 | ||
| 847 | void set_tempo(uint8_t tempo) { | 795 | void set_tempo(uint8_t tempo) { note_tempo = tempo; } |
| 848 | note_tempo = tempo; | ||
| 849 | } | ||
| 850 | 796 | ||
| 851 | void decrease_tempo(uint8_t tempo_change) { | 797 | void decrease_tempo(uint8_t tempo_change) { note_tempo += tempo_change; } |
| 852 | note_tempo += tempo_change; | ||
| 853 | } | ||
| 854 | 798 | ||
| 855 | void increase_tempo(uint8_t tempo_change) { | 799 | void increase_tempo(uint8_t tempo_change) { |
| 856 | if (note_tempo - tempo_change < 10) { | 800 | if (note_tempo - tempo_change < 10) { |
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 8136c5b25..2bcc27b4a 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h | |||
| @@ -19,7 +19,7 @@ | |||
| 19 | #include <stdint.h> | 19 | #include <stdint.h> |
| 20 | #include <stdbool.h> | 20 | #include <stdbool.h> |
| 21 | #if defined(__AVR__) | 21 | #if defined(__AVR__) |
| 22 | #include <avr/io.h> | 22 | # include <avr/io.h> |
| 23 | #endif | 23 | #endif |
| 24 | #include "wait.h" | 24 | #include "wait.h" |
| 25 | #include "musical_notes.h" | 25 | #include "musical_notes.h" |
| @@ -39,9 +39,9 @@ | |||
| 39 | typedef union { | 39 | typedef union { |
| 40 | uint8_t raw; | 40 | uint8_t raw; |
| 41 | struct { | 41 | struct { |
| 42 | bool enable :1; | 42 | bool enable : 1; |
| 43 | bool clicky_enable :1; | 43 | bool clicky_enable : 1; |
| 44 | uint8_t level :6; | 44 | uint8_t level : 6; |
| 45 | }; | 45 | }; |
| 46 | } audio_config_t; | 46 | } audio_config_t; |
| 47 | 47 | ||
| @@ -58,13 +58,13 @@ void set_vibrato_rate(float rate); | |||
| 58 | void increase_vibrato_rate(float change); | 58 | void increase_vibrato_rate(float change); |
| 59 | void decrease_vibrato_rate(float change); | 59 | void decrease_vibrato_rate(float change); |
| 60 | 60 | ||
| 61 | #ifdef VIBRATO_STRENGTH_ENABLE | 61 | # ifdef VIBRATO_STRENGTH_ENABLE |
| 62 | 62 | ||
| 63 | void set_vibrato_strength(float strength); | 63 | void set_vibrato_strength(float strength); |
| 64 | void increase_vibrato_strength(float change); | 64 | void increase_vibrato_strength(float change); |
| 65 | void decrease_vibrato_strength(float change); | 65 | void decrease_vibrato_strength(float change); |
| 66 | 66 | ||
| 67 | #endif | 67 | # endif |
| 68 | 68 | ||
| 69 | #endif | 69 | #endif |
| 70 | 70 | ||
| @@ -85,25 +85,23 @@ void decrease_tempo(uint8_t tempo_change); | |||
| 85 | void audio_init(void); | 85 | void audio_init(void); |
| 86 | 86 | ||
| 87 | #ifdef PWM_AUDIO | 87 | #ifdef PWM_AUDIO |
| 88 | void play_sample(uint8_t * s, uint16_t l, bool r); | 88 | void play_sample(uint8_t* s, uint16_t l, bool r); |
| 89 | #endif | 89 | #endif |
| 90 | void play_note(float freq, int vol); | 90 | void play_note(float freq, int vol); |
| 91 | void stop_note(float freq); | 91 | void stop_note(float freq); |
| 92 | void stop_all_notes(void); | 92 | void stop_all_notes(void); |
| 93 | void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat); | 93 | void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat); |
| 94 | 94 | ||
| 95 | #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), \ | 95 | #define SCALE \ |
| 96 | 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ | 96 | (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), 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), } |
| 97 | 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ | ||
| 98 | 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ | ||
| 99 | 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } | ||
| 100 | 97 | ||
| 101 | // These macros are used to allow play_notes to play an array of indeterminate | 98 | // These macros are used to allow play_notes to play an array of indeterminate |
| 102 | // length. This works around the limitation of C's sizeof operation on pointers. | 99 | // length. This works around the limitation of C's sizeof operation on pointers. |
| 103 | // The global float array for the song must be used here. | 100 | // The global float array for the song must be used here. |
| 104 | #define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0])))) | 101 | #define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0])))) |
| 105 | #define PLAY_NOTE_ARRAY(note_array, note_repeat, deprecated_arg) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat)); \ | 102 | #define PLAY_NOTE_ARRAY(note_array, note_repeat, deprecated_arg) \ |
| 106 | _Pragma ("message \"'PLAY_NOTE_ARRAY' macro is deprecated\"") | 103 | play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat)); \ |
| 104 | _Pragma("message \"'PLAY_NOTE_ARRAY' macro is deprecated\"") | ||
| 107 | #define PLAY_SONG(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), false) | 105 | #define PLAY_SONG(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), false) |
| 108 | #define PLAY_LOOP(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), true) | 106 | #define PLAY_LOOP(note_array) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), true) |
| 109 | 107 | ||
diff --git a/quantum/audio/audio_arm.c b/quantum/audio/audio_arm.c index de0cd15c5..87d625301 100644 --- a/quantum/audio/audio_arm.c +++ b/quantum/audio/audio_arm.c | |||
| @@ -26,41 +26,41 @@ | |||
| 26 | 26 | ||
| 27 | // ----------------------------------------------------------------------------- | 27 | // ----------------------------------------------------------------------------- |
| 28 | 28 | ||
| 29 | int voices = 0; | 29 | int voices = 0; |
| 30 | int voice_place = 0; | 30 | int voice_place = 0; |
| 31 | float frequency = 0; | 31 | float frequency = 0; |
| 32 | float frequency_alt = 0; | 32 | float frequency_alt = 0; |
| 33 | int volume = 0; | 33 | int volume = 0; |
| 34 | long position = 0; | 34 | long position = 0; |
| 35 | 35 | ||
| 36 | float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | 36 | float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; |
| 37 | int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | 37 | int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0}; |
| 38 | bool sliding = false; | 38 | bool sliding = false; |
| 39 | 39 | ||
| 40 | float place = 0; | 40 | float place = 0; |
| 41 | 41 | ||
| 42 | uint8_t * sample; | 42 | uint8_t *sample; |
| 43 | uint16_t sample_length = 0; | 43 | uint16_t sample_length = 0; |
| 44 | 44 | ||
| 45 | bool playing_notes = false; | 45 | bool playing_notes = false; |
| 46 | bool playing_note = false; | 46 | bool playing_note = false; |
| 47 | float note_frequency = 0; | 47 | float note_frequency = 0; |
| 48 | float note_length = 0; | 48 | float note_length = 0; |
| 49 | uint8_t note_tempo = TEMPO_DEFAULT; | 49 | uint8_t note_tempo = TEMPO_DEFAULT; |
| 50 | float note_timbre = TIMBRE_DEFAULT; | 50 | float note_timbre = TIMBRE_DEFAULT; |
| 51 | uint16_t note_position = 0; | 51 | uint16_t note_position = 0; |
| 52 | float (* notes_pointer)[][2]; | 52 | float (*notes_pointer)[][2]; |
| 53 | uint16_t notes_count; | 53 | uint16_t notes_count; |
| 54 | bool notes_repeat; | 54 | bool notes_repeat; |
| 55 | bool note_resting = false; | 55 | bool note_resting = false; |
| 56 | 56 | ||
| 57 | uint16_t current_note = 0; | 57 | uint16_t current_note = 0; |
| 58 | uint8_t rest_counter = 0; | 58 | uint8_t rest_counter = 0; |
| 59 | 59 | ||
| 60 | #ifdef VIBRATO_ENABLE | 60 | #ifdef VIBRATO_ENABLE |
| 61 | float vibrato_counter = 0; | 61 | float vibrato_counter = 0; |
| 62 | float vibrato_strength = .5; | 62 | float vibrato_strength = .5; |
| 63 | float vibrato_rate = 0.125; | 63 | float vibrato_rate = 0.125; |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | float polyphony_rate = 0; | 66 | float polyphony_rate = 0; |
| @@ -70,10 +70,10 @@ static bool audio_initialized = false; | |||
| 70 | audio_config_t audio_config; | 70 | audio_config_t audio_config; |
| 71 | 71 | ||
| 72 | uint16_t envelope_index = 0; | 72 | uint16_t envelope_index = 0; |
| 73 | bool glissando = true; | 73 | bool glissando = true; |
| 74 | 74 | ||
| 75 | #ifndef STARTUP_SONG | 75 | #ifndef STARTUP_SONG |
| 76 | #define STARTUP_SONG SONG(STARTUP_SOUND) | 76 | # define STARTUP_SONG SONG(STARTUP_SOUND) |
| 77 | #endif | 77 | #endif |
| 78 | float startup_song[][2] = STARTUP_SONG; | 78 | float startup_song[][2] = STARTUP_SONG; |
| 79 | 79 | ||
| @@ -81,27 +81,32 @@ static void gpt_cb8(GPTDriver *gptp); | |||
| 81 | 81 | ||
| 82 | #define DAC_BUFFER_SIZE 100 | 82 | #define DAC_BUFFER_SIZE 100 |
| 83 | #ifndef DAC_SAMPLE_MAX | 83 | #ifndef DAC_SAMPLE_MAX |
| 84 | #define DAC_SAMPLE_MAX 65535U | 84 | # define DAC_SAMPLE_MAX 65535U |
| 85 | #endif | 85 | #endif |
| 86 | 86 | ||
| 87 | #define START_CHANNEL_1() gptStart(&GPTD6, &gpt6cfg1); \ | 87 | #define START_CHANNEL_1() \ |
| 88 | gptStart(&GPTD6, &gpt6cfg1); \ | ||
| 88 | gptStartContinuous(&GPTD6, 2U) | 89 | gptStartContinuous(&GPTD6, 2U) |
| 89 | #define START_CHANNEL_2() gptStart(&GPTD7, &gpt7cfg1); \ | 90 | #define START_CHANNEL_2() \ |
| 91 | gptStart(&GPTD7, &gpt7cfg1); \ | ||
| 90 | gptStartContinuous(&GPTD7, 2U) | 92 | gptStartContinuous(&GPTD7, 2U) |
| 91 | #define STOP_CHANNEL_1() gptStopTimer(&GPTD6) | 93 | #define STOP_CHANNEL_1() gptStopTimer(&GPTD6) |
| 92 | #define STOP_CHANNEL_2() gptStopTimer(&GPTD7) | 94 | #define STOP_CHANNEL_2() gptStopTimer(&GPTD7) |
| 93 | #define RESTART_CHANNEL_1() STOP_CHANNEL_1(); \ | 95 | #define RESTART_CHANNEL_1() \ |
| 96 | STOP_CHANNEL_1(); \ | ||
| 94 | START_CHANNEL_1() | 97 | START_CHANNEL_1() |
| 95 | #define RESTART_CHANNEL_2() STOP_CHANNEL_2(); \ | 98 | #define RESTART_CHANNEL_2() \ |
| 99 | STOP_CHANNEL_2(); \ | ||
| 96 | START_CHANNEL_2() | 100 | START_CHANNEL_2() |
| 97 | #define UPDATE_CHANNEL_1_FREQ(freq) gpt6cfg1.frequency = freq * DAC_BUFFER_SIZE; \ | 101 | #define UPDATE_CHANNEL_1_FREQ(freq) \ |
| 102 | gpt6cfg1.frequency = freq * DAC_BUFFER_SIZE; \ | ||
| 98 | RESTART_CHANNEL_1() | 103 | RESTART_CHANNEL_1() |
| 99 | #define UPDATE_CHANNEL_2_FREQ(freq) gpt7cfg1.frequency = freq * DAC_BUFFER_SIZE; \ | 104 | #define UPDATE_CHANNEL_2_FREQ(freq) \ |
| 105 | gpt7cfg1.frequency = freq * DAC_BUFFER_SIZE; \ | ||
| 100 | RESTART_CHANNEL_2() | 106 | RESTART_CHANNEL_2() |
| 101 | #define GET_CHANNEL_1_FREQ (uint16_t)(gpt6cfg1.frequency * DAC_BUFFER_SIZE) | 107 | #define GET_CHANNEL_1_FREQ (uint16_t)(gpt6cfg1.frequency * DAC_BUFFER_SIZE) |
| 102 | #define GET_CHANNEL_2_FREQ (uint16_t)(gpt7cfg1.frequency * DAC_BUFFER_SIZE) | 108 | #define GET_CHANNEL_2_FREQ (uint16_t)(gpt7cfg1.frequency * DAC_BUFFER_SIZE) |
| 103 | 109 | ||
| 104 | |||
| 105 | /* | 110 | /* |
| 106 | * GPT6 configuration. | 111 | * GPT6 configuration. |
| 107 | */ | 112 | */ |
| @@ -112,27 +117,20 @@ static void gpt_cb8(GPTDriver *gptp); | |||
| 112 | // .dier = 0U | 117 | // .dier = 0U |
| 113 | // }; | 118 | // }; |
| 114 | 119 | ||
| 115 | GPTConfig gpt6cfg1 = { | 120 | GPTConfig gpt6cfg1 = {.frequency = 440U * DAC_BUFFER_SIZE, |
| 116 | .frequency = 440U*DAC_BUFFER_SIZE, | 121 | .callback = NULL, |
| 117 | .callback = NULL, | 122 | .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */ |
| 118 | .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */ | 123 | .dier = 0U}; |
| 119 | .dier = 0U | ||
| 120 | }; | ||
| 121 | 124 | ||
| 122 | GPTConfig gpt7cfg1 = { | 125 | GPTConfig gpt7cfg1 = {.frequency = 440U * DAC_BUFFER_SIZE, |
| 123 | .frequency = 440U*DAC_BUFFER_SIZE, | 126 | .callback = NULL, |
| 124 | .callback = NULL, | 127 | .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */ |
| 125 | .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */ | 128 | .dier = 0U}; |
| 126 | .dier = 0U | ||
| 127 | }; | ||
| 128 | |||
| 129 | GPTConfig gpt8cfg1 = { | ||
| 130 | .frequency = 10, | ||
| 131 | .callback = gpt_cb8, | ||
| 132 | .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */ | ||
| 133 | .dier = 0U | ||
| 134 | }; | ||
| 135 | 129 | ||
| 130 | GPTConfig gpt8cfg1 = {.frequency = 10, | ||
| 131 | .callback = gpt_cb8, | ||
| 132 | .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */ | ||
| 133 | .dier = 0U}; | ||
| 136 | 134 | ||
| 137 | /* | 135 | /* |
| 138 | * DAC test buffer (sine wave). | 136 | * DAC test buffer (sine wave). |
| @@ -205,122 +203,101 @@ GPTConfig gpt8cfg1 = { | |||
| 205 | 203 | ||
| 206 | // squarewave | 204 | // squarewave |
| 207 | static const dacsample_t dac_buffer[DAC_BUFFER_SIZE] = { | 205 | static const dacsample_t dac_buffer[DAC_BUFFER_SIZE] = { |
| 208 | // First half is max, second half is 0 | 206 | // First half is max, second half is 0 |
| 209 | [0 ... DAC_BUFFER_SIZE/2-1] = DAC_SAMPLE_MAX, | 207 | [0 ... DAC_BUFFER_SIZE / 2 - 1] = DAC_SAMPLE_MAX, |
| 210 | [DAC_BUFFER_SIZE/2 ... DAC_BUFFER_SIZE -1] = 0, | 208 | [DAC_BUFFER_SIZE / 2 ... DAC_BUFFER_SIZE - 1] = 0, |
| 211 | }; | 209 | }; |
| 212 | 210 | ||
| 213 | // squarewave | 211 | // squarewave |
| 214 | static const dacsample_t dac_buffer_2[DAC_BUFFER_SIZE] = { | 212 | static const dacsample_t dac_buffer_2[DAC_BUFFER_SIZE] = { |
| 215 | // opposite of dac_buffer above | 213 | // opposite of dac_buffer above |
| 216 | [0 ... DAC_BUFFER_SIZE/2-1] = 0, | 214 | [0 ... DAC_BUFFER_SIZE / 2 - 1] = 0, |
| 217 | [DAC_BUFFER_SIZE/2 ... DAC_BUFFER_SIZE -1] = DAC_SAMPLE_MAX, | 215 | [DAC_BUFFER_SIZE / 2 ... DAC_BUFFER_SIZE - 1] = DAC_SAMPLE_MAX, |
| 218 | }; | 216 | }; |
| 219 | 217 | ||
| 220 | /* | 218 | /* |
| 221 | * DAC streaming callback. | 219 | * DAC streaming callback. |
| 222 | */ | 220 | */ |
| 223 | size_t nx = 0, ny = 0, nz = 0; | 221 | size_t nx = 0, ny = 0, nz = 0; |
| 224 | static void end_cb1(DACDriver *dacp, dacsample_t *buffer, size_t n) { | 222 | static void end_cb1(DACDriver *dacp, dacsample_t *buffer, size_t n) { |
| 223 | (void)dacp; | ||
| 225 | 224 | ||
| 226 | (void)dacp; | 225 | nz++; |
| 227 | 226 | if (dac_buffer == buffer) { | |
| 228 | nz++; | 227 | nx += n; |
| 229 | if (dac_buffer == buffer) { | 228 | } else { |
| 230 | nx += n; | 229 | ny += n; |
| 231 | } | 230 | } |
| 232 | else { | ||
| 233 | ny += n; | ||
| 234 | } | ||
| 235 | 231 | ||
| 236 | if ((nz % 1000) == 0) { | 232 | if ((nz % 1000) == 0) { |
| 237 | // palTogglePad(GPIOD, GPIOD_LED3); | 233 | // palTogglePad(GPIOD, GPIOD_LED3); |
| 238 | } | 234 | } |
| 239 | } | 235 | } |
| 240 | 236 | ||
| 241 | /* | 237 | /* |
| 242 | * DAC error callback. | 238 | * DAC error callback. |
| 243 | */ | 239 | */ |
| 244 | static void error_cb1(DACDriver *dacp, dacerror_t err) { | 240 | static void error_cb1(DACDriver *dacp, dacerror_t err) { |
| 241 | (void)dacp; | ||
| 242 | (void)err; | ||
| 245 | 243 | ||
| 246 | (void)dacp; | 244 | chSysHalt("DAC failure"); |
| 247 | (void)err; | ||
| 248 | |||
| 249 | chSysHalt("DAC failure"); | ||
| 250 | } | 245 | } |
| 251 | 246 | ||
| 252 | static const DACConfig dac1cfg1 = { | 247 | static const DACConfig dac1cfg1 = {.init = DAC_SAMPLE_MAX, .datamode = DAC_DHRM_12BIT_RIGHT}; |
| 253 | .init = DAC_SAMPLE_MAX, | ||
| 254 | .datamode = DAC_DHRM_12BIT_RIGHT | ||
| 255 | }; | ||
| 256 | 248 | ||
| 257 | static const DACConversionGroup dacgrpcfg1 = { | 249 | static const DACConversionGroup dacgrpcfg1 = {.num_channels = 1U, .end_cb = end_cb1, .error_cb = error_cb1, .trigger = DAC_TRG(0)}; |
| 258 | .num_channels = 1U, | ||
| 259 | .end_cb = end_cb1, | ||
| 260 | .error_cb = error_cb1, | ||
| 261 | .trigger = DAC_TRG(0) | ||
| 262 | }; | ||
| 263 | 250 | ||
| 264 | static const DACConfig dac1cfg2 = { | 251 | static const DACConfig dac1cfg2 = {.init = DAC_SAMPLE_MAX, .datamode = DAC_DHRM_12BIT_RIGHT}; |
| 265 | .init = DAC_SAMPLE_MAX, | ||
| 266 | .datamode = DAC_DHRM_12BIT_RIGHT | ||
| 267 | }; | ||
| 268 | 252 | ||
| 269 | static const DACConversionGroup dacgrpcfg2 = { | 253 | static const DACConversionGroup dacgrpcfg2 = {.num_channels = 1U, .end_cb = end_cb1, .error_cb = error_cb1, .trigger = DAC_TRG(0)}; |
| 270 | .num_channels = 1U, | ||
| 271 | .end_cb = end_cb1, | ||
| 272 | .error_cb = error_cb1, | ||
| 273 | .trigger = DAC_TRG(0) | ||
| 274 | }; | ||
| 275 | 254 | ||
| 276 | void audio_init() { | 255 | void audio_init() { |
| 256 | if (audio_initialized) { | ||
| 257 | return; | ||
| 258 | } | ||
| 277 | 259 | ||
| 278 | if (audio_initialized) { | 260 | // Check EEPROM |
| 279 | return; | 261 | #if defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE) |
| 280 | } | ||
| 281 | |||
| 282 | // Check EEPROM | ||
| 283 | #if defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE) | ||
| 284 | if (!eeconfig_is_enabled()) { | 262 | if (!eeconfig_is_enabled()) { |
| 285 | eeconfig_init(); | 263 | eeconfig_init(); |
| 286 | } | 264 | } |
| 287 | audio_config.raw = eeconfig_read_audio(); | 265 | audio_config.raw = eeconfig_read_audio(); |
| 288 | #else // ARM EEPROM | 266 | #else // ARM EEPROM |
| 289 | audio_config.enable = true; | 267 | audio_config.enable = true; |
| 290 | #ifdef AUDIO_CLICKY_ON | 268 | # ifdef AUDIO_CLICKY_ON |
| 291 | audio_config.clicky_enable = true; | 269 | audio_config.clicky_enable = true; |
| 292 | #endif | 270 | # endif |
| 293 | #endif // ARM EEPROM | 271 | #endif // ARM EEPROM |
| 294 | 272 | ||
| 295 | /* | 273 | /* |
| 296 | * Starting DAC1 driver, setting up the output pin as analog as suggested | 274 | * Starting DAC1 driver, setting up the output pin as analog as suggested |
| 297 | * by the Reference Manual. | 275 | * by the Reference Manual. |
| 298 | */ | 276 | */ |
| 299 | palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG); | 277 | palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG); |
| 300 | palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG); | 278 | palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG); |
| 301 | dacStart(&DACD1, &dac1cfg1); | 279 | dacStart(&DACD1, &dac1cfg1); |
| 302 | dacStart(&DACD2, &dac1cfg2); | 280 | dacStart(&DACD2, &dac1cfg2); |
| 303 | 281 | ||
| 304 | /* | 282 | /* |
| 305 | * Starting GPT6/7 driver, it is used for triggering the DAC. | 283 | * Starting GPT6/7 driver, it is used for triggering the DAC. |
| 306 | */ | 284 | */ |
| 307 | START_CHANNEL_1(); | 285 | START_CHANNEL_1(); |
| 308 | START_CHANNEL_2(); | 286 | START_CHANNEL_2(); |
| 309 | 287 | ||
| 310 | /* | 288 | /* |
| 311 | * Starting a continuous conversion. | 289 | * Starting a continuous conversion. |
| 312 | */ | 290 | */ |
| 313 | dacStartConversion(&DACD1, &dacgrpcfg1, (dacsample_t *)dac_buffer, DAC_BUFFER_SIZE); | 291 | dacStartConversion(&DACD1, &dacgrpcfg1, (dacsample_t *)dac_buffer, DAC_BUFFER_SIZE); |
| 314 | dacStartConversion(&DACD2, &dacgrpcfg2, (dacsample_t *)dac_buffer_2, DAC_BUFFER_SIZE); | 292 | dacStartConversion(&DACD2, &dacgrpcfg2, (dacsample_t *)dac_buffer_2, DAC_BUFFER_SIZE); |
| 315 | 293 | ||
| 316 | audio_initialized = true; | 294 | audio_initialized = true; |
| 317 | 295 | ||
| 318 | if (audio_config.enable) { | 296 | if (audio_config.enable) { |
| 319 | PLAY_SONG(startup_song); | 297 | PLAY_SONG(startup_song); |
| 320 | } else { | 298 | } else { |
| 321 | stop_all_notes(); | 299 | stop_all_notes(); |
| 322 | } | 300 | } |
| 323 | |||
| 324 | } | 301 | } |
| 325 | 302 | ||
| 326 | void stop_all_notes() { | 303 | void stop_all_notes() { |
| @@ -336,437 +313,396 @@ void stop_all_notes() { | |||
| 336 | gptStopTimer(&GPTD8); | 313 | gptStopTimer(&GPTD8); |
| 337 | 314 | ||
| 338 | playing_notes = false; | 315 | playing_notes = false; |
| 339 | playing_note = false; | 316 | playing_note = false; |
| 340 | frequency = 0; | 317 | frequency = 0; |
| 341 | frequency_alt = 0; | 318 | frequency_alt = 0; |
| 342 | volume = 0; | 319 | volume = 0; |
| 343 | 320 | ||
| 344 | for (uint8_t i = 0; i < 8; i++) | 321 | for (uint8_t i = 0; i < 8; i++) { |
| 345 | { | ||
| 346 | frequencies[i] = 0; | 322 | frequencies[i] = 0; |
| 347 | volumes[i] = 0; | 323 | volumes[i] = 0; |
| 348 | } | 324 | } |
| 349 | } | 325 | } |
| 350 | 326 | ||
| 351 | void stop_note(float freq) { | 327 | void stop_note(float freq) { |
| 352 | dprintf("audio stop note freq=%d", (int)freq); | 328 | dprintf("audio stop note freq=%d", (int)freq); |
| 353 | 329 | ||
| 354 | if (playing_note) { | 330 | if (playing_note) { |
| 355 | if (!audio_initialized) { | 331 | if (!audio_initialized) { |
| 356 | audio_init(); | 332 | audio_init(); |
| 357 | } | 333 | } |
| 358 | for (int i = 7; i >= 0; i--) { | 334 | for (int i = 7; i >= 0; i--) { |
| 359 | if (frequencies[i] == freq) { | 335 | if (frequencies[i] == freq) { |
| 360 | frequencies[i] = 0; | 336 | frequencies[i] = 0; |
| 361 | volumes[i] = 0; | 337 | volumes[i] = 0; |
| 362 | for (int j = i; (j < 7); j++) { | 338 | for (int j = i; (j < 7); j++) { |
| 363 | frequencies[j] = frequencies[j+1]; | 339 | frequencies[j] = frequencies[j + 1]; |
| 364 | frequencies[j+1] = 0; | 340 | frequencies[j + 1] = 0; |
| 365 | volumes[j] = volumes[j+1]; | 341 | volumes[j] = volumes[j + 1]; |
| 366 | volumes[j+1] = 0; | 342 | volumes[j + 1] = 0; |
| 343 | } | ||
| 344 | break; | ||
| 345 | } | ||
| 346 | } | ||
| 347 | voices--; | ||
| 348 | if (voices < 0) { | ||
| 349 | voices = 0; | ||
| 350 | } | ||
| 351 | if (voice_place >= voices) { | ||
| 352 | voice_place = 0; | ||
| 353 | } | ||
| 354 | if (voices == 0) { | ||
| 355 | STOP_CHANNEL_1(); | ||
| 356 | STOP_CHANNEL_2(); | ||
| 357 | gptStopTimer(&GPTD8); | ||
| 358 | frequency = 0; | ||
| 359 | frequency_alt = 0; | ||
| 360 | volume = 0; | ||
| 361 | playing_note = false; | ||
| 367 | } | 362 | } |
| 368 | break; | ||
| 369 | } | ||
| 370 | } | ||
| 371 | voices--; | ||
| 372 | if (voices < 0) { | ||
| 373 | voices = 0; | ||
| 374 | } | ||
| 375 | if (voice_place >= voices) { | ||
| 376 | voice_place = 0; | ||
| 377 | } | ||
| 378 | if (voices == 0) { | ||
| 379 | STOP_CHANNEL_1(); | ||
| 380 | STOP_CHANNEL_2(); | ||
| 381 | gptStopTimer(&GPTD8); | ||
| 382 | frequency = 0; | ||
| 383 | frequency_alt = 0; | ||
| 384 | volume = 0; | ||
| 385 | playing_note = false; | ||
| 386 | } | 363 | } |
| 387 | } | ||
| 388 | } | 364 | } |
| 389 | 365 | ||
| 390 | #ifdef VIBRATO_ENABLE | 366 | #ifdef VIBRATO_ENABLE |
| 391 | 367 | ||
| 392 | float mod(float a, int b) { | 368 | float mod(float a, int b) { |
| 393 | float r = fmod(a, b); | 369 | float r = fmod(a, b); |
| 394 | return r < 0 ? r + b : r; | 370 | return r < 0 ? r + b : r; |
| 395 | } | 371 | } |
| 396 | 372 | ||
| 397 | float vibrato(float average_freq) { | 373 | float vibrato(float average_freq) { |
| 398 | #ifdef VIBRATO_STRENGTH_ENABLE | 374 | # ifdef VIBRATO_STRENGTH_ENABLE |
| 399 | float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength); | 375 | float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength); |
| 400 | #else | 376 | # else |
| 401 | float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter]; | 377 | float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter]; |
| 402 | #endif | 378 | # endif |
| 403 | vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0/average_freq)), VIBRATO_LUT_LENGTH); | 379 | vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0 / average_freq)), VIBRATO_LUT_LENGTH); |
| 404 | return vibrated_freq; | 380 | return vibrated_freq; |
| 405 | } | 381 | } |
| 406 | 382 | ||
| 407 | #endif | 383 | #endif |
| 408 | 384 | ||
| 409 | static void gpt_cb8(GPTDriver *gptp) { | 385 | static void gpt_cb8(GPTDriver *gptp) { |
| 410 | float freq; | 386 | float freq; |
| 411 | |||
| 412 | if (playing_note) { | ||
| 413 | if (voices > 0) { | ||
| 414 | |||
| 415 | float freq_alt = 0; | ||
| 416 | if (voices > 1) { | ||
| 417 | if (polyphony_rate == 0) { | ||
| 418 | if (glissando) { | ||
| 419 | if (frequency_alt != 0 && frequency_alt < frequencies[voices - 2] && frequency_alt < frequencies[voices - 2] * pow(2, -440/frequencies[voices - 2]/12/2)) { | ||
| 420 | frequency_alt = frequency_alt * pow(2, 440/frequency_alt/12/2); | ||
| 421 | } else if (frequency_alt != 0 && frequency_alt > frequencies[voices - 2] && frequency_alt > frequencies[voices - 2] * pow(2, 440/frequencies[voices - 2]/12/2)) { | ||
| 422 | frequency_alt = frequency_alt * pow(2, -440/frequency_alt/12/2); | ||
| 423 | } else { | ||
| 424 | frequency_alt = frequencies[voices - 2]; | ||
| 425 | } | ||
| 426 | } else { | ||
| 427 | frequency_alt = frequencies[voices - 2]; | ||
| 428 | } | ||
| 429 | 387 | ||
| 430 | #ifdef VIBRATO_ENABLE | 388 | if (playing_note) { |
| 431 | if (vibrato_strength > 0) { | 389 | if (voices > 0) { |
| 432 | freq_alt = vibrato(frequency_alt); | 390 | float freq_alt = 0; |
| 433 | } else { | 391 | if (voices > 1) { |
| 434 | freq_alt = frequency_alt; | 392 | if (polyphony_rate == 0) { |
| 435 | } | 393 | if (glissando) { |
| 436 | #else | 394 | if (frequency_alt != 0 && frequency_alt < frequencies[voices - 2] && frequency_alt < frequencies[voices - 2] * pow(2, -440 / frequencies[voices - 2] / 12 / 2)) { |
| 437 | freq_alt = frequency_alt; | 395 | frequency_alt = frequency_alt * pow(2, 440 / frequency_alt / 12 / 2); |
| 438 | #endif | 396 | } else if (frequency_alt != 0 && frequency_alt > frequencies[voices - 2] && frequency_alt > frequencies[voices - 2] * pow(2, 440 / frequencies[voices - 2] / 12 / 2)) { |
| 439 | } | 397 | frequency_alt = frequency_alt * pow(2, -440 / frequency_alt / 12 / 2); |
| 398 | } else { | ||
| 399 | frequency_alt = frequencies[voices - 2]; | ||
| 400 | } | ||
| 401 | } else { | ||
| 402 | frequency_alt = frequencies[voices - 2]; | ||
| 403 | } | ||
| 440 | 404 | ||
| 441 | if (envelope_index < 65535) { | 405 | #ifdef VIBRATO_ENABLE |
| 442 | envelope_index++; | 406 | if (vibrato_strength > 0) { |
| 443 | } | 407 | freq_alt = vibrato(frequency_alt); |
| 408 | } else { | ||
| 409 | freq_alt = frequency_alt; | ||
| 410 | } | ||
| 411 | #else | ||
| 412 | freq_alt = frequency_alt; | ||
| 413 | #endif | ||
| 414 | } | ||
| 444 | 415 | ||
| 445 | freq_alt = voice_envelope(freq_alt); | 416 | if (envelope_index < 65535) { |
| 417 | envelope_index++; | ||
| 418 | } | ||
| 446 | 419 | ||
| 447 | if (freq_alt < 30.517578125) { | 420 | freq_alt = voice_envelope(freq_alt); |
| 448 | freq_alt = 30.52; | ||
| 449 | } | ||
| 450 | 421 | ||
| 451 | if (GET_CHANNEL_2_FREQ != (uint16_t)freq_alt) { | 422 | if (freq_alt < 30.517578125) { |
| 452 | UPDATE_CHANNEL_2_FREQ(freq_alt); | 423 | freq_alt = 30.52; |
| 453 | } else { | 424 | } |
| 454 | RESTART_CHANNEL_2(); | ||
| 455 | } | ||
| 456 | //note_timbre; | ||
| 457 | } | ||
| 458 | |||
| 459 | if (polyphony_rate > 0) { | ||
| 460 | if (voices > 1) { | ||
| 461 | voice_place %= voices; | ||
| 462 | if (place++ > (frequencies[voice_place] / polyphony_rate)) { | ||
| 463 | voice_place = (voice_place + 1) % voices; | ||
| 464 | place = 0.0; | ||
| 465 | } | ||
| 466 | } | ||
| 467 | 425 | ||
| 468 | #ifdef VIBRATO_ENABLE | 426 | if (GET_CHANNEL_2_FREQ != (uint16_t)freq_alt) { |
| 469 | if (vibrato_strength > 0) { | 427 | UPDATE_CHANNEL_2_FREQ(freq_alt); |
| 470 | freq = vibrato(frequencies[voice_place]); | 428 | } else { |
| 471 | } else { | 429 | RESTART_CHANNEL_2(); |
| 472 | freq = frequencies[voice_place]; | 430 | } |
| 473 | } | 431 | // note_timbre; |
| 474 | #else | 432 | } |
| 475 | freq = frequencies[voice_place]; | ||
| 476 | #endif | ||
| 477 | } else { | ||
| 478 | if (glissando) { | ||
| 479 | if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) { | ||
| 480 | frequency = frequency * pow(2, 440/frequency/12/2); | ||
| 481 | } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) { | ||
| 482 | frequency = frequency * pow(2, -440/frequency/12/2); | ||
| 483 | } else { | ||
| 484 | frequency = frequencies[voices - 1]; | ||
| 485 | } | ||
| 486 | } else { | ||
| 487 | frequency = frequencies[voices - 1]; | ||
| 488 | } | ||
| 489 | 433 | ||
| 490 | #ifdef VIBRATO_ENABLE | 434 | if (polyphony_rate > 0) { |
| 491 | if (vibrato_strength > 0) { | 435 | if (voices > 1) { |
| 492 | freq = vibrato(frequency); | 436 | voice_place %= voices; |
| 493 | } else { | 437 | if (place++ > (frequencies[voice_place] / polyphony_rate)) { |
| 494 | freq = frequency; | 438 | voice_place = (voice_place + 1) % voices; |
| 495 | } | 439 | place = 0.0; |
| 496 | #else | 440 | } |
| 497 | freq = frequency; | 441 | } |
| 498 | #endif | ||
| 499 | } | ||
| 500 | 442 | ||
| 501 | if (envelope_index < 65535) { | 443 | #ifdef VIBRATO_ENABLE |
| 502 | envelope_index++; | 444 | if (vibrato_strength > 0) { |
| 503 | } | 445 | freq = vibrato(frequencies[voice_place]); |
| 446 | } else { | ||
| 447 | freq = frequencies[voice_place]; | ||
| 448 | } | ||
| 449 | #else | ||
| 450 | freq = frequencies[voice_place]; | ||
| 451 | #endif | ||
| 452 | } else { | ||
| 453 | if (glissando) { | ||
| 454 | if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440 / frequencies[voices - 1] / 12 / 2)) { | ||
| 455 | frequency = frequency * pow(2, 440 / frequency / 12 / 2); | ||
| 456 | } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440 / frequencies[voices - 1] / 12 / 2)) { | ||
| 457 | frequency = frequency * pow(2, -440 / frequency / 12 / 2); | ||
| 458 | } else { | ||
| 459 | frequency = frequencies[voices - 1]; | ||
| 460 | } | ||
| 461 | } else { | ||
| 462 | frequency = frequencies[voices - 1]; | ||
| 463 | } | ||
| 504 | 464 | ||
| 505 | freq = voice_envelope(freq); | 465 | #ifdef VIBRATO_ENABLE |
| 466 | if (vibrato_strength > 0) { | ||
| 467 | freq = vibrato(frequency); | ||
| 468 | } else { | ||
| 469 | freq = frequency; | ||
| 470 | } | ||
| 471 | #else | ||
| 472 | freq = frequency; | ||
| 473 | #endif | ||
| 474 | } | ||
| 506 | 475 | ||
| 507 | if (freq < 30.517578125) { | 476 | if (envelope_index < 65535) { |
| 508 | freq = 30.52; | 477 | envelope_index++; |
| 509 | } | 478 | } |
| 510 | 479 | ||
| 480 | freq = voice_envelope(freq); | ||
| 511 | 481 | ||
| 512 | if (GET_CHANNEL_1_FREQ != (uint16_t)freq) { | 482 | if (freq < 30.517578125) { |
| 513 | UPDATE_CHANNEL_1_FREQ(freq); | 483 | freq = 30.52; |
| 514 | } else { | 484 | } |
| 515 | RESTART_CHANNEL_1(); | ||
| 516 | } | ||
| 517 | //note_timbre; | ||
| 518 | } | ||
| 519 | } | ||
| 520 | 485 | ||
| 521 | if (playing_notes) { | 486 | if (GET_CHANNEL_1_FREQ != (uint16_t)freq) { |
| 522 | if (note_frequency > 0) { | 487 | UPDATE_CHANNEL_1_FREQ(freq); |
| 523 | #ifdef VIBRATO_ENABLE | 488 | } else { |
| 524 | if (vibrato_strength > 0) { | 489 | RESTART_CHANNEL_1(); |
| 525 | freq = vibrato(note_frequency); | 490 | } |
| 526 | } else { | 491 | // note_timbre; |
| 527 | freq = note_frequency; | ||
| 528 | } | 492 | } |
| 529 | #else | ||
| 530 | freq = note_frequency; | ||
| 531 | #endif | ||
| 532 | |||
| 533 | if (envelope_index < 65535) { | ||
| 534 | envelope_index++; | ||
| 535 | } | ||
| 536 | freq = voice_envelope(freq); | ||
| 537 | |||
| 538 | |||
| 539 | if (GET_CHANNEL_1_FREQ != (uint16_t)freq) { | ||
| 540 | UPDATE_CHANNEL_1_FREQ(freq); | ||
| 541 | UPDATE_CHANNEL_2_FREQ(freq); | ||
| 542 | } | ||
| 543 | //note_timbre; | ||
| 544 | } else { | ||
| 545 | // gptStopTimer(&GPTD6); | ||
| 546 | // gptStopTimer(&GPTD7); | ||
| 547 | } | 493 | } |
| 548 | 494 | ||
| 549 | note_position++; | 495 | if (playing_notes) { |
| 550 | bool end_of_note = false; | 496 | if (note_frequency > 0) { |
| 551 | if (GET_CHANNEL_1_FREQ > 0) { | 497 | #ifdef VIBRATO_ENABLE |
| 552 | if (!note_resting) | 498 | if (vibrato_strength > 0) { |
| 553 | end_of_note = (note_position >= (note_length*8 - 1)); | 499 | freq = vibrato(note_frequency); |
| 554 | else | 500 | } else { |
| 555 | end_of_note = (note_position >= (note_length*8)); | 501 | freq = note_frequency; |
| 556 | } else { | 502 | } |
| 557 | end_of_note = (note_position >= (note_length*8)); | 503 | #else |
| 558 | } | 504 | freq = note_frequency; |
| 505 | #endif | ||
| 559 | 506 | ||
| 560 | if (end_of_note) { | 507 | if (envelope_index < 65535) { |
| 561 | current_note++; | 508 | envelope_index++; |
| 562 | if (current_note >= notes_count) { | 509 | } |
| 563 | if (notes_repeat) { | 510 | freq = voice_envelope(freq); |
| 564 | current_note = 0; | 511 | |
| 512 | if (GET_CHANNEL_1_FREQ != (uint16_t)freq) { | ||
| 513 | UPDATE_CHANNEL_1_FREQ(freq); | ||
| 514 | UPDATE_CHANNEL_2_FREQ(freq); | ||
| 515 | } | ||
| 516 | // note_timbre; | ||
| 565 | } else { | 517 | } else { |
| 566 | STOP_CHANNEL_1(); | 518 | // gptStopTimer(&GPTD6); |
| 567 | STOP_CHANNEL_2(); | 519 | // gptStopTimer(&GPTD7); |
| 568 | // gptStopTimer(&GPTD8); | ||
| 569 | playing_notes = false; | ||
| 570 | return; | ||
| 571 | } | 520 | } |
| 572 | } | 521 | |
| 573 | if (!note_resting) { | 522 | note_position++; |
| 574 | note_resting = true; | 523 | bool end_of_note = false; |
| 575 | current_note--; | 524 | if (GET_CHANNEL_1_FREQ > 0) { |
| 576 | if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) { | 525 | if (!note_resting) |
| 577 | note_frequency = 0; | 526 | end_of_note = (note_position >= (note_length * 8 - 1)); |
| 578 | note_length = 1; | 527 | else |
| 528 | end_of_note = (note_position >= (note_length * 8)); | ||
| 579 | } else { | 529 | } else { |
| 580 | note_frequency = (*notes_pointer)[current_note][0]; | 530 | end_of_note = (note_position >= (note_length * 8)); |
| 581 | note_length = 1; | ||
| 582 | } | 531 | } |
| 583 | } else { | ||
| 584 | note_resting = false; | ||
| 585 | envelope_index = 0; | ||
| 586 | note_frequency = (*notes_pointer)[current_note][0]; | ||
| 587 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); | ||
| 588 | } | ||
| 589 | 532 | ||
| 590 | note_position = 0; | 533 | if (end_of_note) { |
| 534 | current_note++; | ||
| 535 | if (current_note >= notes_count) { | ||
| 536 | if (notes_repeat) { | ||
| 537 | current_note = 0; | ||
| 538 | } else { | ||
| 539 | STOP_CHANNEL_1(); | ||
| 540 | STOP_CHANNEL_2(); | ||
| 541 | // gptStopTimer(&GPTD8); | ||
| 542 | playing_notes = false; | ||
| 543 | return; | ||
| 544 | } | ||
| 545 | } | ||
| 546 | if (!note_resting) { | ||
| 547 | note_resting = true; | ||
| 548 | current_note--; | ||
| 549 | if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) { | ||
| 550 | note_frequency = 0; | ||
| 551 | note_length = 1; | ||
| 552 | } else { | ||
| 553 | note_frequency = (*notes_pointer)[current_note][0]; | ||
| 554 | note_length = 1; | ||
| 555 | } | ||
| 556 | } else { | ||
| 557 | note_resting = false; | ||
| 558 | envelope_index = 0; | ||
| 559 | note_frequency = (*notes_pointer)[current_note][0]; | ||
| 560 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); | ||
| 561 | } | ||
| 562 | |||
| 563 | note_position = 0; | ||
| 564 | } | ||
| 591 | } | 565 | } |
| 592 | } | ||
| 593 | 566 | ||
| 594 | if (!audio_config.enable) { | 567 | if (!audio_config.enable) { |
| 595 | playing_notes = false; | 568 | playing_notes = false; |
| 596 | playing_note = false; | 569 | playing_note = false; |
| 597 | } | 570 | } |
| 598 | } | 571 | } |
| 599 | 572 | ||
| 600 | void play_note(float freq, int vol) { | 573 | void play_note(float freq, int vol) { |
| 574 | dprintf("audio play note freq=%d vol=%d", (int)freq, vol); | ||
| 601 | 575 | ||
| 602 | dprintf("audio play note freq=%d vol=%d", (int)freq, vol); | 576 | if (!audio_initialized) { |
| 603 | 577 | audio_init(); | |
| 604 | if (!audio_initialized) { | ||
| 605 | audio_init(); | ||
| 606 | } | ||
| 607 | |||
| 608 | if (audio_config.enable && voices < 8) { | ||
| 609 | |||
| 610 | // Cancel notes if notes are playing | ||
| 611 | if (playing_notes) { | ||
| 612 | stop_all_notes(); | ||
| 613 | } | 578 | } |
| 614 | 579 | ||
| 615 | playing_note = true; | 580 | if (audio_config.enable && voices < 8) { |
| 581 | // Cancel notes if notes are playing | ||
| 582 | if (playing_notes) { | ||
| 583 | stop_all_notes(); | ||
| 584 | } | ||
| 616 | 585 | ||
| 617 | envelope_index = 0; | 586 | playing_note = true; |
| 618 | 587 | ||
| 619 | if (freq > 0) { | 588 | envelope_index = 0; |
| 620 | frequencies[voices] = freq; | ||
| 621 | volumes[voices] = vol; | ||
| 622 | voices++; | ||
| 623 | } | ||
| 624 | 589 | ||
| 625 | gptStart(&GPTD8, &gpt8cfg1); | 590 | if (freq > 0) { |
| 626 | gptStartContinuous(&GPTD8, 2U); | 591 | frequencies[voices] = freq; |
| 627 | RESTART_CHANNEL_1(); | 592 | volumes[voices] = vol; |
| 628 | RESTART_CHANNEL_2(); | 593 | voices++; |
| 629 | } | 594 | } |
| 630 | 595 | ||
| 596 | gptStart(&GPTD8, &gpt8cfg1); | ||
| 597 | gptStartContinuous(&GPTD8, 2U); | ||
| 598 | RESTART_CHANNEL_1(); | ||
| 599 | RESTART_CHANNEL_2(); | ||
| 600 | } | ||
| 631 | } | 601 | } |
| 632 | 602 | ||
| 633 | void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat) { | 603 | void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat) { |
| 634 | 604 | if (!audio_initialized) { | |
| 635 | if (!audio_initialized) { | 605 | audio_init(); |
| 636 | audio_init(); | ||
| 637 | } | ||
| 638 | |||
| 639 | if (audio_config.enable) { | ||
| 640 | |||
| 641 | // Cancel note if a note is playing | ||
| 642 | if (playing_note) { | ||
| 643 | stop_all_notes(); | ||
| 644 | } | 606 | } |
| 645 | 607 | ||
| 646 | playing_notes = true; | 608 | if (audio_config.enable) { |
| 609 | // Cancel note if a note is playing | ||
| 610 | if (playing_note) { | ||
| 611 | stop_all_notes(); | ||
| 612 | } | ||
| 647 | 613 | ||
| 648 | notes_pointer = np; | 614 | playing_notes = true; |
| 649 | notes_count = n_count; | ||
| 650 | notes_repeat = n_repeat; | ||
| 651 | 615 | ||
| 652 | place = 0; | 616 | notes_pointer = np; |
| 653 | current_note = 0; | 617 | notes_count = n_count; |
| 618 | notes_repeat = n_repeat; | ||
| 654 | 619 | ||
| 655 | note_frequency = (*notes_pointer)[current_note][0]; | 620 | place = 0; |
| 656 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); | 621 | current_note = 0; |
| 657 | note_position = 0; | ||
| 658 | 622 | ||
| 659 | gptStart(&GPTD8, &gpt8cfg1); | 623 | note_frequency = (*notes_pointer)[current_note][0]; |
| 660 | gptStartContinuous(&GPTD8, 2U); | 624 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); |
| 661 | RESTART_CHANNEL_1(); | 625 | note_position = 0; |
| 662 | RESTART_CHANNEL_2(); | ||
| 663 | } | ||
| 664 | } | ||
| 665 | 626 | ||
| 666 | bool is_playing_notes(void) { | 627 | gptStart(&GPTD8, &gpt8cfg1); |
| 667 | return playing_notes; | 628 | gptStartContinuous(&GPTD8, 2U); |
| 629 | RESTART_CHANNEL_1(); | ||
| 630 | RESTART_CHANNEL_2(); | ||
| 631 | } | ||
| 668 | } | 632 | } |
| 669 | 633 | ||
| 670 | bool is_audio_on(void) { | 634 | bool is_playing_notes(void) { return playing_notes; } |
| 671 | return (audio_config.enable != 0); | 635 | |
| 672 | } | 636 | bool is_audio_on(void) { return (audio_config.enable != 0); } |
| 673 | 637 | ||
| 674 | void audio_toggle(void) { | 638 | void audio_toggle(void) { |
| 675 | audio_config.enable ^= 1; | 639 | audio_config.enable ^= 1; |
| 676 | eeconfig_update_audio(audio_config.raw); | 640 | eeconfig_update_audio(audio_config.raw); |
| 677 | if (audio_config.enable) { | 641 | if (audio_config.enable) { |
| 678 | audio_on_user(); | 642 | audio_on_user(); |
| 679 | } | 643 | } |
| 680 | } | 644 | } |
| 681 | 645 | ||
| 682 | void audio_on(void) { | 646 | void audio_on(void) { |
| 683 | audio_config.enable = 1; | 647 | audio_config.enable = 1; |
| 684 | eeconfig_update_audio(audio_config.raw); | 648 | eeconfig_update_audio(audio_config.raw); |
| 685 | audio_on_user(); | 649 | audio_on_user(); |
| 686 | } | 650 | } |
| 687 | 651 | ||
| 688 | void audio_off(void) { | 652 | void audio_off(void) { |
| 689 | stop_all_notes(); | 653 | stop_all_notes(); |
| 690 | audio_config.enable = 0; | 654 | audio_config.enable = 0; |
| 691 | eeconfig_update_audio(audio_config.raw); | 655 | eeconfig_update_audio(audio_config.raw); |
| 692 | } | 656 | } |
| 693 | 657 | ||
| 694 | #ifdef VIBRATO_ENABLE | 658 | #ifdef VIBRATO_ENABLE |
| 695 | 659 | ||
| 696 | // Vibrato rate functions | 660 | // Vibrato rate functions |
| 697 | 661 | ||
| 698 | void set_vibrato_rate(float rate) { | 662 | void set_vibrato_rate(float rate) { vibrato_rate = rate; } |
| 699 | vibrato_rate = rate; | ||
| 700 | } | ||
| 701 | 663 | ||
| 702 | void increase_vibrato_rate(float change) { | 664 | void increase_vibrato_rate(float change) { vibrato_rate *= change; } |
| 703 | vibrato_rate *= change; | ||
| 704 | } | ||
| 705 | 665 | ||
| 706 | void decrease_vibrato_rate(float change) { | 666 | void decrease_vibrato_rate(float change) { vibrato_rate /= change; } |
| 707 | vibrato_rate /= change; | ||
| 708 | } | ||
| 709 | 667 | ||
| 710 | #ifdef VIBRATO_STRENGTH_ENABLE | 668 | # ifdef VIBRATO_STRENGTH_ENABLE |
| 711 | 669 | ||
| 712 | void set_vibrato_strength(float strength) { | 670 | void set_vibrato_strength(float strength) { vibrato_strength = strength; } |
| 713 | vibrato_strength = strength; | ||
| 714 | } | ||
| 715 | 671 | ||
| 716 | void increase_vibrato_strength(float change) { | 672 | void increase_vibrato_strength(float change) { vibrato_strength *= change; } |
| 717 | vibrato_strength *= change; | ||
| 718 | } | ||
| 719 | 673 | ||
| 720 | void decrease_vibrato_strength(float change) { | 674 | void decrease_vibrato_strength(float change) { vibrato_strength /= change; } |
| 721 | vibrato_strength /= change; | ||
| 722 | } | ||
| 723 | 675 | ||
| 724 | #endif /* VIBRATO_STRENGTH_ENABLE */ | 676 | # endif /* VIBRATO_STRENGTH_ENABLE */ |
| 725 | 677 | ||
| 726 | #endif /* VIBRATO_ENABLE */ | 678 | #endif /* VIBRATO_ENABLE */ |
| 727 | 679 | ||
| 728 | // Polyphony functions | 680 | // Polyphony functions |
| 729 | 681 | ||
| 730 | void set_polyphony_rate(float rate) { | 682 | void set_polyphony_rate(float rate) { polyphony_rate = rate; } |
| 731 | polyphony_rate = rate; | ||
| 732 | } | ||
| 733 | 683 | ||
| 734 | void enable_polyphony() { | 684 | void enable_polyphony() { polyphony_rate = 5; } |
| 735 | polyphony_rate = 5; | ||
| 736 | } | ||
| 737 | 685 | ||
| 738 | void disable_polyphony() { | 686 | void disable_polyphony() { polyphony_rate = 0; } |
| 739 | polyphony_rate = 0; | ||
| 740 | } | ||
| 741 | 687 | ||
| 742 | void increase_polyphony_rate(float change) { | 688 | void increase_polyphony_rate(float change) { polyphony_rate *= change; } |
| 743 | polyphony_rate *= change; | ||
| 744 | } | ||
| 745 | 689 | ||
| 746 | void decrease_polyphony_rate(float change) { | 690 | void decrease_polyphony_rate(float change) { polyphony_rate /= change; } |
| 747 | polyphony_rate /= change; | ||
| 748 | } | ||
| 749 | 691 | ||
| 750 | // Timbre function | 692 | // Timbre function |
| 751 | 693 | ||
| 752 | void set_timbre(float timbre) { | 694 | void set_timbre(float timbre) { note_timbre = timbre; } |
| 753 | note_timbre = timbre; | ||
| 754 | } | ||
| 755 | 695 | ||
| 756 | // Tempo functions | 696 | // Tempo functions |
| 757 | 697 | ||
| 758 | void set_tempo(uint8_t tempo) { | 698 | void set_tempo(uint8_t tempo) { note_tempo = tempo; } |
| 759 | note_tempo = tempo; | ||
| 760 | } | ||
| 761 | 699 | ||
| 762 | void decrease_tempo(uint8_t tempo_change) { | 700 | void decrease_tempo(uint8_t tempo_change) { note_tempo += tempo_change; } |
| 763 | note_tempo += tempo_change; | ||
| 764 | } | ||
| 765 | 701 | ||
| 766 | void increase_tempo(uint8_t tempo_change) { | 702 | void increase_tempo(uint8_t tempo_change) { |
| 767 | if (note_tempo - tempo_change < 10) { | 703 | if (note_tempo - tempo_change < 10) { |
| 768 | note_tempo = 10; | 704 | note_tempo = 10; |
| 769 | } else { | 705 | } else { |
| 770 | note_tempo -= tempo_change; | 706 | note_tempo -= tempo_change; |
| 771 | } | 707 | } |
| 772 | } | 708 | } |
diff --git a/quantum/audio/audio_pwm.c b/quantum/audio/audio_pwm.c index ed6713609..545aef6dd 100644 --- a/quantum/audio/audio_pwm.c +++ b/quantum/audio/audio_pwm.c | |||
| @@ -29,7 +29,6 @@ | |||
| 29 | 29 | ||
| 30 | #define CPU_PRESCALER 8 | 30 | #define CPU_PRESCALER 8 |
| 31 | 31 | ||
| 32 | |||
| 33 | // Timer Abstractions | 32 | // Timer Abstractions |
| 34 | 33 | ||
| 35 | // TIMSK3 - Timer/Counter #3 Interrupt Mask Register | 34 | // TIMSK3 - Timer/Counter #3 Interrupt Mask Register |
| @@ -37,70 +36,67 @@ | |||
| 37 | #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A) | 36 | #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A) |
| 38 | #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A) | 37 | #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A) |
| 39 | 38 | ||
| 40 | |||
| 41 | // TCCR3A: Timer/Counter #3 Control Register | 39 | // TCCR3A: Timer/Counter #3 Control Register |
| 42 | // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 | 40 | // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 |
| 43 | #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1); | 41 | #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1); |
| 44 | #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)); | 42 | #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)); |
| 45 | 43 | ||
| 46 | |||
| 47 | #define NOTE_PERIOD ICR3 | 44 | #define NOTE_PERIOD ICR3 |
| 48 | #define NOTE_DUTY_CYCLE OCR3A | 45 | #define NOTE_DUTY_CYCLE OCR3A |
| 49 | 46 | ||
| 50 | |||
| 51 | #ifdef PWM_AUDIO | 47 | #ifdef PWM_AUDIO |
| 52 | #include "wave.h" | 48 | # include "wave.h" |
| 53 | #define SAMPLE_DIVIDER 39 | 49 | # define SAMPLE_DIVIDER 39 |
| 54 | #define SAMPLE_RATE (2000000.0/SAMPLE_DIVIDER/2048) | 50 | # define SAMPLE_RATE (2000000.0 / SAMPLE_DIVIDER / 2048) |
| 55 | // Resistor value of 1/ (2 * PI * 10nF * (2000000 hertz / SAMPLE_DIVIDER / 10)) for 10nF cap | 51 | // Resistor value of 1/ (2 * PI * 10nF * (2000000 hertz / SAMPLE_DIVIDER / 10)) for 10nF cap |
| 56 | 52 | ||
| 57 | float places[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | 53 | float places[8] = {0, 0, 0, 0, 0, 0, 0, 0}; |
| 58 | uint16_t place_int = 0; | 54 | uint16_t place_int = 0; |
| 59 | bool repeat = true; | 55 | bool repeat = true; |
| 60 | #endif | 56 | #endif |
| 61 | 57 | ||
| 62 | void delay_us(int count) { | 58 | void delay_us(int count) { |
| 63 | while(count--) { | 59 | while (count--) { |
| 64 | _delay_us(1); | 60 | _delay_us(1); |
| 65 | } | 61 | } |
| 66 | } | 62 | } |
| 67 | 63 | ||
| 68 | int voices = 0; | 64 | int voices = 0; |
| 69 | int voice_place = 0; | 65 | int voice_place = 0; |
| 70 | float frequency = 0; | 66 | float frequency = 0; |
| 71 | int volume = 0; | 67 | int volume = 0; |
| 72 | long position = 0; | 68 | long position = 0; |
| 73 | 69 | ||
| 74 | float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | 70 | float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; |
| 75 | int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | 71 | int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0}; |
| 76 | bool sliding = false; | 72 | bool sliding = false; |
| 77 | 73 | ||
| 78 | float place = 0; | 74 | float place = 0; |
| 79 | 75 | ||
| 80 | uint8_t * sample; | 76 | uint8_t* sample; |
| 81 | uint16_t sample_length = 0; | 77 | uint16_t sample_length = 0; |
| 82 | // float freq = 0; | 78 | // float freq = 0; |
| 83 | 79 | ||
| 84 | bool playing_notes = false; | 80 | bool playing_notes = false; |
| 85 | bool playing_note = false; | 81 | bool playing_note = false; |
| 86 | float note_frequency = 0; | 82 | float note_frequency = 0; |
| 87 | float note_length = 0; | 83 | float note_length = 0; |
| 88 | uint8_t note_tempo = TEMPO_DEFAULT; | 84 | uint8_t note_tempo = TEMPO_DEFAULT; |
| 89 | float note_timbre = TIMBRE_DEFAULT; | 85 | float note_timbre = TIMBRE_DEFAULT; |
| 90 | uint16_t note_position = 0; | 86 | uint16_t note_position = 0; |
| 91 | float (* notes_pointer)[][2]; | 87 | float (*notes_pointer)[][2]; |
| 92 | uint16_t notes_count; | 88 | uint16_t notes_count; |
| 93 | bool notes_repeat; | 89 | bool notes_repeat; |
| 94 | float notes_rest; | 90 | float notes_rest; |
| 95 | bool note_resting = false; | 91 | bool note_resting = false; |
| 96 | 92 | ||
| 97 | uint16_t current_note = 0; | 93 | uint16_t current_note = 0; |
| 98 | uint8_t rest_counter = 0; | 94 | uint8_t rest_counter = 0; |
| 99 | 95 | ||
| 100 | #ifdef VIBRATO_ENABLE | 96 | #ifdef VIBRATO_ENABLE |
| 101 | float vibrato_counter = 0; | 97 | float vibrato_counter = 0; |
| 102 | float vibrato_strength = .5; | 98 | float vibrato_strength = .5; |
| 103 | float vibrato_rate = 0.125; | 99 | float vibrato_rate = 0.125; |
| 104 | #endif | 100 | #endif |
| 105 | 101 | ||
| 106 | float polyphony_rate = 0; | 102 | float polyphony_rate = 0; |
| @@ -112,50 +108,49 @@ audio_config_t audio_config; | |||
| 112 | uint16_t envelope_index = 0; | 108 | uint16_t envelope_index = 0; |
| 113 | 109 | ||
| 114 | void audio_init() { | 110 | void audio_init() { |
| 115 | |||
| 116 | // Check EEPROM | 111 | // Check EEPROM |
| 117 | if (!eeconfig_is_enabled()) | 112 | if (!eeconfig_is_enabled()) { |
| 118 | { | ||
| 119 | eeconfig_init(); | 113 | eeconfig_init(); |
| 120 | } | 114 | } |
| 121 | audio_config.raw = eeconfig_read_audio(); | 115 | audio_config.raw = eeconfig_read_audio(); |
| 122 | 116 | ||
| 123 | #ifdef PWM_AUDIO | 117 | #ifdef PWM_AUDIO |
| 124 | 118 | ||
| 125 | PLLFRQ = _BV(PDIV2); | 119 | PLLFRQ = _BV(PDIV2); |
| 126 | PLLCSR = _BV(PLLE); | 120 | PLLCSR = _BV(PLLE); |
| 127 | while(!(PLLCSR & _BV(PLOCK))); | 121 | while (!(PLLCSR & _BV(PLOCK))) |
| 128 | PLLFRQ |= _BV(PLLTM0); /* PCK 48MHz */ | 122 | ; |
| 123 | PLLFRQ |= _BV(PLLTM0); /* PCK 48MHz */ | ||
| 129 | 124 | ||
| 130 | /* Init a fast PWM on Timer4 */ | 125 | /* Init a fast PWM on Timer4 */ |
| 131 | TCCR4A = _BV(COM4A0) | _BV(PWM4A); /* Clear OC4A on Compare Match */ | 126 | TCCR4A = _BV(COM4A0) | _BV(PWM4A); /* Clear OC4A on Compare Match */ |
| 132 | TCCR4B = _BV(CS40); /* No prescaling => f = PCK/256 = 187500Hz */ | 127 | TCCR4B = _BV(CS40); /* No prescaling => f = PCK/256 = 187500Hz */ |
| 133 | OCR4A = 0; | 128 | OCR4A = 0; |
| 134 | 129 | ||
| 135 | /* Enable the OC4A output */ | 130 | /* Enable the OC4A output */ |
| 136 | DDRC |= _BV(PORTC6); | 131 | DDRC |= _BV(PORTC6); |
| 137 | 132 | ||
| 138 | DISABLE_AUDIO_COUNTER_3_ISR; // Turn off 3A interputs | 133 | DISABLE_AUDIO_COUNTER_3_ISR; // Turn off 3A interputs |
| 139 | 134 | ||
| 140 | TCCR3A = 0x0; // Options not needed | 135 | TCCR3A = 0x0; // Options not needed |
| 141 | TCCR3B = _BV(CS31) | _BV(CS30) | _BV(WGM32); // 64th prescaling and CTC | 136 | TCCR3B = _BV(CS31) | _BV(CS30) | _BV(WGM32); // 64th prescaling and CTC |
| 142 | OCR3A = SAMPLE_DIVIDER - 1; // Correct count/compare, related to sample playback | 137 | OCR3A = SAMPLE_DIVIDER - 1; // Correct count/compare, related to sample playback |
| 143 | 138 | ||
| 144 | #else | 139 | #else |
| 145 | 140 | ||
| 146 | // Set port PC6 (OC3A and /OC4A) as output | 141 | // Set port PC6 (OC3A and /OC4A) as output |
| 147 | DDRC |= _BV(PORTC6); | 142 | DDRC |= _BV(PORTC6); |
| 148 | 143 | ||
| 149 | DISABLE_AUDIO_COUNTER_3_ISR; | 144 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 150 | 145 | ||
| 151 | // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers | 146 | // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers |
| 152 | // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 | 147 | // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 |
| 153 | // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A) | 148 | // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A) |
| 154 | // Clock Select (CS3n) = 0b010 = Clock / 8 | 149 | // Clock Select (CS3n) = 0b010 = Clock / 8 |
| 155 | TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); | 150 | TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); |
| 156 | TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); | 151 | TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); |
| 157 | 152 | ||
| 158 | #endif | 153 | #endif |
| 159 | 154 | ||
| 160 | audio_initialized = true; | 155 | audio_initialized = true; |
| 161 | } | 156 | } |
| @@ -165,62 +160,59 @@ void stop_all_notes() { | |||
| 165 | audio_init(); | 160 | audio_init(); |
| 166 | } | 161 | } |
| 167 | voices = 0; | 162 | voices = 0; |
| 168 | #ifdef PWM_AUDIO | 163 | #ifdef PWM_AUDIO |
| 169 | DISABLE_AUDIO_COUNTER_3_ISR; | 164 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 170 | #else | 165 | #else |
| 171 | DISABLE_AUDIO_COUNTER_3_ISR; | 166 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 172 | DISABLE_AUDIO_COUNTER_3_OUTPUT; | 167 | DISABLE_AUDIO_COUNTER_3_OUTPUT; |
| 173 | #endif | 168 | #endif |
| 174 | 169 | ||
| 175 | playing_notes = false; | 170 | playing_notes = false; |
| 176 | playing_note = false; | 171 | playing_note = false; |
| 177 | frequency = 0; | 172 | frequency = 0; |
| 178 | volume = 0; | 173 | volume = 0; |
| 179 | 174 | ||
| 180 | for (uint8_t i = 0; i < 8; i++) | 175 | for (uint8_t i = 0; i < 8; i++) { |
| 181 | { | ||
| 182 | frequencies[i] = 0; | 176 | frequencies[i] = 0; |
| 183 | volumes[i] = 0; | 177 | volumes[i] = 0; |
| 184 | } | 178 | } |
| 185 | } | 179 | } |
| 186 | 180 | ||
| 187 | void stop_note(float freq) | 181 | void stop_note(float freq) { |
| 188 | { | ||
| 189 | if (playing_note) { | 182 | if (playing_note) { |
| 190 | if (!audio_initialized) { | 183 | if (!audio_initialized) { |
| 191 | audio_init(); | 184 | audio_init(); |
| 192 | } | 185 | } |
| 193 | #ifdef PWM_AUDIO | 186 | #ifdef PWM_AUDIO |
| 194 | freq = freq / SAMPLE_RATE; | 187 | freq = freq / SAMPLE_RATE; |
| 195 | #endif | 188 | #endif |
| 196 | for (int i = 7; i >= 0; i--) { | 189 | for (int i = 7; i >= 0; i--) { |
| 197 | if (frequencies[i] == freq) { | 190 | if (frequencies[i] == freq) { |
| 198 | frequencies[i] = 0; | 191 | frequencies[i] = 0; |
| 199 | volumes[i] = 0; | 192 | volumes[i] = 0; |
| 200 | for (int j = i; (j < 7); j++) { | 193 | for (int j = i; (j < 7); j++) { |
| 201 | frequencies[j] = frequencies[j+1]; | 194 | frequencies[j] = frequencies[j + 1]; |
| 202 | frequencies[j+1] = 0; | 195 | frequencies[j + 1] = 0; |
| 203 | volumes[j] = volumes[j+1]; | 196 | volumes[j] = volumes[j + 1]; |
| 204 | volumes[j+1] = 0; | 197 | volumes[j + 1] = 0; |
| 205 | } | 198 | } |
| 206 | break; | 199 | break; |
| 207 | } | 200 | } |
| 208 | } | 201 | } |
| 209 | voices--; | 202 | voices--; |
| 210 | if (voices < 0) | 203 | if (voices < 0) voices = 0; |
| 211 | voices = 0; | ||
| 212 | if (voice_place >= voices) { | 204 | if (voice_place >= voices) { |
| 213 | voice_place = 0; | 205 | voice_place = 0; |
| 214 | } | 206 | } |
| 215 | if (voices == 0) { | 207 | if (voices == 0) { |
| 216 | #ifdef PWM_AUDIO | 208 | #ifdef PWM_AUDIO |
| 217 | DISABLE_AUDIO_COUNTER_3_ISR; | 209 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 218 | #else | 210 | #else |
| 219 | DISABLE_AUDIO_COUNTER_3_ISR; | 211 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 220 | DISABLE_AUDIO_COUNTER_3_OUTPUT; | 212 | DISABLE_AUDIO_COUNTER_3_OUTPUT; |
| 221 | #endif | 213 | #endif |
| 222 | frequency = 0; | 214 | frequency = 0; |
| 223 | volume = 0; | 215 | volume = 0; |
| 224 | playing_note = false; | 216 | playing_note = false; |
| 225 | } | 217 | } |
| 226 | } | 218 | } |
| @@ -228,126 +220,120 @@ void stop_note(float freq) | |||
| 228 | 220 | ||
| 229 | #ifdef VIBRATO_ENABLE | 221 | #ifdef VIBRATO_ENABLE |
| 230 | 222 | ||
| 231 | float mod(float a, int b) | 223 | float mod(float a, int b) { |
| 232 | { | ||
| 233 | float r = fmod(a, b); | 224 | float r = fmod(a, b); |
| 234 | return r < 0 ? r + b : r; | 225 | return r < 0 ? r + b : r; |
| 235 | } | 226 | } |
| 236 | 227 | ||
| 237 | float vibrato(float average_freq) { | 228 | float vibrato(float average_freq) { |
| 238 | #ifdef VIBRATO_STRENGTH_ENABLE | 229 | # ifdef VIBRATO_STRENGTH_ENABLE |
| 239 | float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength); | 230 | float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength); |
| 240 | #else | 231 | # else |
| 241 | float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter]; | 232 | float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter]; |
| 242 | #endif | 233 | # endif |
| 243 | vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0/average_freq)), VIBRATO_LUT_LENGTH); | 234 | vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0 / average_freq)), VIBRATO_LUT_LENGTH); |
| 244 | return vibrated_freq; | 235 | return vibrated_freq; |
| 245 | } | 236 | } |
| 246 | 237 | ||
| 247 | #endif | 238 | #endif |
| 248 | 239 | ||
| 249 | ISR(TIMER3_COMPA_vect) | 240 | ISR(TIMER3_COMPA_vect) { |
| 250 | { | ||
| 251 | if (playing_note) { | 241 | if (playing_note) { |
| 252 | #ifdef PWM_AUDIO | 242 | #ifdef PWM_AUDIO |
| 253 | if (voices == 1) { | 243 | if (voices == 1) { |
| 244 | // SINE | ||
| 245 | OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 2; | ||
| 246 | |||
| 247 | // SQUARE | ||
| 248 | // if (((int)place) >= 1024){ | ||
| 249 | // OCR4A = 0xFF >> 2; | ||
| 250 | // } else { | ||
| 251 | // OCR4A = 0x00; | ||
| 252 | // } | ||
| 253 | |||
| 254 | // SAWTOOTH | ||
| 255 | // OCR4A = (int)place / 4; | ||
| 256 | |||
| 257 | // TRIANGLE | ||
| 258 | // if (((int)place) >= 1024) { | ||
| 259 | // OCR4A = (int)place / 2; | ||
| 260 | // } else { | ||
| 261 | // OCR4A = 2048 - (int)place / 2; | ||
| 262 | // } | ||
| 263 | |||
| 264 | place += frequency; | ||
| 265 | |||
| 266 | if (place >= SINE_LENGTH) place -= SINE_LENGTH; | ||
| 267 | |||
| 268 | } else { | ||
| 269 | int sum = 0; | ||
| 270 | for (int i = 0; i < voices; i++) { | ||
| 254 | // SINE | 271 | // SINE |
| 255 | OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 2; | 272 | sum += pgm_read_byte(&sinewave[(uint16_t)places[i]]) >> 2; |
| 256 | 273 | ||
| 257 | // SQUARE | 274 | // SQUARE |
| 258 | // if (((int)place) >= 1024){ | 275 | // if (((int)places[i]) >= 1024){ |
| 259 | // OCR4A = 0xFF >> 2; | 276 | // sum += 0xFF >> 2; |
| 260 | // } else { | 277 | // } else { |
| 261 | // OCR4A = 0x00; | 278 | // sum += 0x00; |
| 262 | // } | 279 | // } |
| 263 | 280 | ||
| 264 | // SAWTOOTH | 281 | places[i] += frequencies[i]; |
| 265 | // OCR4A = (int)place / 4; | ||
| 266 | |||
| 267 | // TRIANGLE | ||
| 268 | // if (((int)place) >= 1024) { | ||
| 269 | // OCR4A = (int)place / 2; | ||
| 270 | // } else { | ||
| 271 | // OCR4A = 2048 - (int)place / 2; | ||
| 272 | // } | ||
| 273 | 282 | ||
| 274 | place += frequency; | 283 | if (places[i] >= SINE_LENGTH) places[i] -= SINE_LENGTH; |
| 275 | |||
| 276 | if (place >= SINE_LENGTH) | ||
| 277 | place -= SINE_LENGTH; | ||
| 278 | |||
| 279 | } else { | ||
| 280 | int sum = 0; | ||
| 281 | for (int i = 0; i < voices; i++) { | ||
| 282 | // SINE | ||
| 283 | sum += pgm_read_byte(&sinewave[(uint16_t)places[i]]) >> 2; | ||
| 284 | |||
| 285 | // SQUARE | ||
| 286 | // if (((int)places[i]) >= 1024){ | ||
| 287 | // sum += 0xFF >> 2; | ||
| 288 | // } else { | ||
| 289 | // sum += 0x00; | ||
| 290 | // } | ||
| 291 | |||
| 292 | places[i] += frequencies[i]; | ||
| 293 | |||
| 294 | if (places[i] >= SINE_LENGTH) | ||
| 295 | places[i] -= SINE_LENGTH; | ||
| 296 | } | ||
| 297 | OCR4A = sum; | ||
| 298 | } | 284 | } |
| 299 | #else | 285 | OCR4A = sum; |
| 300 | if (voices > 0) { | 286 | } |
| 301 | float freq; | 287 | #else |
| 302 | if (polyphony_rate > 0) { | 288 | if (voices > 0) { |
| 303 | if (voices > 1) { | 289 | float freq; |
| 304 | voice_place %= voices; | 290 | if (polyphony_rate > 0) { |
| 305 | if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { | 291 | if (voices > 1) { |
| 306 | voice_place = (voice_place + 1) % voices; | 292 | voice_place %= voices; |
| 307 | place = 0.0; | 293 | if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { |
| 308 | } | 294 | voice_place = (voice_place + 1) % voices; |
| 309 | } | 295 | place = 0.0; |
| 310 | #ifdef VIBRATO_ENABLE | ||
| 311 | if (vibrato_strength > 0) { | ||
| 312 | freq = vibrato(frequencies[voice_place]); | ||
| 313 | } else { | ||
| 314 | #else | ||
| 315 | { | ||
| 316 | #endif | ||
| 317 | freq = frequencies[voice_place]; | ||
| 318 | } | 296 | } |
| 297 | } | ||
| 298 | # ifdef VIBRATO_ENABLE | ||
| 299 | if (vibrato_strength > 0) { | ||
| 300 | freq = vibrato(frequencies[voice_place]); | ||
| 319 | } else { | 301 | } else { |
| 320 | if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) { | 302 | # else |
| 321 | frequency = frequency * pow(2, 440/frequency/12/2); | 303 | { |
| 322 | } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) { | 304 | # endif |
| 323 | frequency = frequency * pow(2, -440/frequency/12/2); | 305 | freq = frequencies[voice_place]; |
| 324 | } else { | 306 | } |
| 325 | frequency = frequencies[voices - 1]; | 307 | } else { |
| 326 | } | 308 | if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440 / frequencies[voices - 1] / 12 / 2)) { |
| 327 | 309 | frequency = frequency * pow(2, 440 / frequency / 12 / 2); | |
| 328 | 310 | } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440 / frequencies[voices - 1] / 12 / 2)) { | |
| 329 | #ifdef VIBRATO_ENABLE | 311 | frequency = frequency * pow(2, -440 / frequency / 12 / 2); |
| 330 | if (vibrato_strength > 0) { | 312 | } else { |
| 331 | freq = vibrato(frequency); | 313 | frequency = frequencies[voices - 1]; |
| 332 | } else { | ||
| 333 | #else | ||
| 334 | { | ||
| 335 | #endif | ||
| 336 | freq = frequency; | ||
| 337 | } | ||
| 338 | } | 314 | } |
| 339 | 315 | ||
| 340 | if (envelope_index < 65535) { | 316 | # ifdef VIBRATO_ENABLE |
| 341 | envelope_index++; | 317 | if (vibrato_strength > 0) { |
| 318 | freq = vibrato(frequency); | ||
| 319 | } else { | ||
| 320 | # else | ||
| 321 | { | ||
| 322 | # endif | ||
| 323 | freq = frequency; | ||
| 342 | } | 324 | } |
| 343 | freq = voice_envelope(freq); | 325 | } |
| 344 | 326 | ||
| 345 | if (freq < 30.517578125) | 327 | if (envelope_index < 65535) { |
| 346 | freq = 30.52; | 328 | envelope_index++; |
| 347 | NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period | ||
| 348 | NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period | ||
| 349 | } | 329 | } |
| 350 | #endif | 330 | freq = voice_envelope(freq); |
| 331 | |||
| 332 | if (freq < 30.517578125) freq = 30.52; | ||
| 333 | NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period | ||
| 334 | NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period | ||
| 335 | } | ||
| 336 | #endif | ||
| 351 | } | 337 | } |
| 352 | 338 | ||
| 353 | // SAMPLE | 339 | // SAMPLE |
| @@ -361,41 +347,38 @@ ISR(TIMER3_COMPA_vect) | |||
| 361 | // else | 347 | // else |
| 362 | // DISABLE_AUDIO_COUNTER_3_ISR; | 348 | // DISABLE_AUDIO_COUNTER_3_ISR; |
| 363 | 349 | ||
| 364 | |||
| 365 | if (playing_notes) { | 350 | if (playing_notes) { |
| 366 | #ifdef PWM_AUDIO | 351 | #ifdef PWM_AUDIO |
| 367 | OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 0; | 352 | OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 0; |
| 368 | |||
| 369 | place += note_frequency; | ||
| 370 | if (place >= SINE_LENGTH) | ||
| 371 | place -= SINE_LENGTH; | ||
| 372 | #else | ||
| 373 | if (note_frequency > 0) { | ||
| 374 | float freq; | ||
| 375 | |||
| 376 | #ifdef VIBRATO_ENABLE | ||
| 377 | if (vibrato_strength > 0) { | ||
| 378 | freq = vibrato(note_frequency); | ||
| 379 | } else { | ||
| 380 | #else | ||
| 381 | { | ||
| 382 | #endif | ||
| 383 | freq = note_frequency; | ||
| 384 | } | ||
| 385 | 353 | ||
| 386 | if (envelope_index < 65535) { | 354 | place += note_frequency; |
| 387 | envelope_index++; | 355 | if (place >= SINE_LENGTH) place -= SINE_LENGTH; |
| 388 | } | 356 | #else |
| 389 | freq = voice_envelope(freq); | 357 | if (note_frequency > 0) { |
| 358 | float freq; | ||
| 390 | 359 | ||
| 391 | NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period | 360 | # ifdef VIBRATO_ENABLE |
| 392 | NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period | 361 | if (vibrato_strength > 0) { |
| 362 | freq = vibrato(note_frequency); | ||
| 393 | } else { | 363 | } else { |
| 394 | NOTE_PERIOD = 0; | 364 | # else |
| 395 | NOTE_DUTY_CYCLE = 0; | 365 | { |
| 366 | # endif | ||
| 367 | freq = note_frequency; | ||
| 396 | } | 368 | } |
| 397 | #endif | ||
| 398 | 369 | ||
| 370 | if (envelope_index < 65535) { | ||
| 371 | envelope_index++; | ||
| 372 | } | ||
| 373 | freq = voice_envelope(freq); | ||
| 374 | |||
| 375 | NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period | ||
| 376 | NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period | ||
| 377 | } else { | ||
| 378 | NOTE_PERIOD = 0; | ||
| 379 | NOTE_DUTY_CYCLE = 0; | ||
| 380 | } | ||
| 381 | #endif | ||
| 399 | 382 | ||
| 400 | note_position++; | 383 | note_position++; |
| 401 | bool end_of_note = false; | 384 | bool end_of_note = false; |
| @@ -409,126 +392,116 @@ ISR(TIMER3_COMPA_vect) | |||
| 409 | if (notes_repeat) { | 392 | if (notes_repeat) { |
| 410 | current_note = 0; | 393 | current_note = 0; |
| 411 | } else { | 394 | } else { |
| 412 | #ifdef PWM_AUDIO | 395 | #ifdef PWM_AUDIO |
| 413 | DISABLE_AUDIO_COUNTER_3_ISR; | 396 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 414 | #else | 397 | #else |
| 415 | DISABLE_AUDIO_COUNTER_3_ISR; | 398 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 416 | DISABLE_AUDIO_COUNTER_3_OUTPUT; | 399 | DISABLE_AUDIO_COUNTER_3_OUTPUT; |
| 417 | #endif | 400 | #endif |
| 418 | playing_notes = false; | 401 | playing_notes = false; |
| 419 | return; | 402 | return; |
| 420 | } | 403 | } |
| 421 | } | 404 | } |
| 422 | if (!note_resting && (notes_rest > 0)) { | 405 | if (!note_resting && (notes_rest > 0)) { |
| 423 | note_resting = true; | 406 | note_resting = true; |
| 424 | note_frequency = 0; | 407 | note_frequency = 0; |
| 425 | note_length = notes_rest; | 408 | note_length = notes_rest; |
| 426 | current_note--; | 409 | current_note--; |
| 427 | } else { | 410 | } else { |
| 428 | note_resting = false; | 411 | note_resting = false; |
| 429 | #ifdef PWM_AUDIO | 412 | #ifdef PWM_AUDIO |
| 430 | note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE; | 413 | note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE; |
| 431 | note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100); | 414 | note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100); |
| 432 | #else | 415 | #else |
| 433 | envelope_index = 0; | 416 | envelope_index = 0; |
| 434 | note_frequency = (*notes_pointer)[current_note][0]; | 417 | note_frequency = (*notes_pointer)[current_note][0]; |
| 435 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); | 418 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); |
| 436 | #endif | 419 | #endif |
| 437 | } | 420 | } |
| 438 | note_position = 0; | 421 | note_position = 0; |
| 439 | } | 422 | } |
| 440 | |||
| 441 | } | 423 | } |
| 442 | 424 | ||
| 443 | if (!audio_config.enable) { | 425 | if (!audio_config.enable) { |
| 444 | playing_notes = false; | 426 | playing_notes = false; |
| 445 | playing_note = false; | 427 | playing_note = false; |
| 446 | } | 428 | } |
| 447 | } | 429 | } |
| 448 | 430 | ||
| 449 | void play_note(float freq, int vol) { | 431 | void play_note(float freq, int vol) { |
| 450 | |||
| 451 | if (!audio_initialized) { | 432 | if (!audio_initialized) { |
| 452 | audio_init(); | 433 | audio_init(); |
| 453 | } | 434 | } |
| 454 | 435 | ||
| 455 | if (audio_config.enable && voices < 8) { | 436 | if (audio_config.enable && voices < 8) { |
| 456 | DISABLE_AUDIO_COUNTER_3_ISR; | 437 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 457 | |||
| 458 | // Cancel notes if notes are playing | ||
| 459 | if (playing_notes) | ||
| 460 | stop_all_notes(); | ||
| 461 | 438 | ||
| 462 | playing_note = true; | 439 | // Cancel notes if notes are playing |
| 440 | if (playing_notes) stop_all_notes(); | ||
| 463 | 441 | ||
| 464 | envelope_index = 0; | 442 | playing_note = true; |
| 465 | 443 | ||
| 466 | #ifdef PWM_AUDIO | 444 | envelope_index = 0; |
| 467 | freq = freq / SAMPLE_RATE; | ||
| 468 | #endif | ||
| 469 | if (freq > 0) { | ||
| 470 | frequencies[voices] = freq; | ||
| 471 | volumes[voices] = vol; | ||
| 472 | voices++; | ||
| 473 | } | ||
| 474 | 445 | ||
| 475 | #ifdef PWM_AUDIO | 446 | #ifdef PWM_AUDIO |
| 476 | ENABLE_AUDIO_COUNTER_3_ISR; | 447 | freq = freq / SAMPLE_RATE; |
| 477 | #else | 448 | #endif |
| 478 | ENABLE_AUDIO_COUNTER_3_ISR; | 449 | if (freq > 0) { |
| 479 | ENABLE_AUDIO_COUNTER_3_OUTPUT; | 450 | frequencies[voices] = freq; |
| 480 | #endif | 451 | volumes[voices] = vol; |
| 481 | } | 452 | voices++; |
| 453 | } | ||
| 482 | 454 | ||
| 455 | #ifdef PWM_AUDIO | ||
| 456 | ENABLE_AUDIO_COUNTER_3_ISR; | ||
| 457 | #else | ||
| 458 | ENABLE_AUDIO_COUNTER_3_ISR; | ||
| 459 | ENABLE_AUDIO_COUNTER_3_OUTPUT; | ||
| 460 | #endif | ||
| 461 | } | ||
| 483 | } | 462 | } |
| 484 | 463 | ||
| 485 | void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) | 464 | void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) { |
| 486 | { | ||
| 487 | |||
| 488 | if (!audio_initialized) { | 465 | if (!audio_initialized) { |
| 489 | audio_init(); | 466 | audio_init(); |
| 490 | } | 467 | } |
| 491 | 468 | ||
| 492 | if (audio_config.enable) { | 469 | if (audio_config.enable) { |
| 493 | 470 | DISABLE_AUDIO_COUNTER_3_ISR; | |
| 494 | DISABLE_AUDIO_COUNTER_3_ISR; | ||
| 495 | |||
| 496 | // Cancel note if a note is playing | ||
| 497 | if (playing_note) | ||
| 498 | stop_all_notes(); | ||
| 499 | |||
| 500 | playing_notes = true; | ||
| 501 | 471 | ||
| 502 | notes_pointer = np; | 472 | // Cancel note if a note is playing |
| 503 | notes_count = n_count; | 473 | if (playing_note) stop_all_notes(); |
| 504 | notes_repeat = n_repeat; | ||
| 505 | notes_rest = n_rest; | ||
| 506 | 474 | ||
| 507 | place = 0; | 475 | playing_notes = true; |
| 508 | current_note = 0; | ||
| 509 | 476 | ||
| 510 | #ifdef PWM_AUDIO | 477 | notes_pointer = np; |
| 511 | note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE; | 478 | notes_count = n_count; |
| 512 | note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100); | 479 | notes_repeat = n_repeat; |
| 513 | #else | 480 | notes_rest = n_rest; |
| 514 | note_frequency = (*notes_pointer)[current_note][0]; | ||
| 515 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); | ||
| 516 | #endif | ||
| 517 | note_position = 0; | ||
| 518 | 481 | ||
| 482 | place = 0; | ||
| 483 | current_note = 0; | ||
| 519 | 484 | ||
| 520 | #ifdef PWM_AUDIO | 485 | #ifdef PWM_AUDIO |
| 521 | ENABLE_AUDIO_COUNTER_3_ISR; | 486 | note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE; |
| 522 | #else | 487 | note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100); |
| 523 | ENABLE_AUDIO_COUNTER_3_ISR; | 488 | #else |
| 524 | ENABLE_AUDIO_COUNTER_3_OUTPUT; | 489 | note_frequency = (*notes_pointer)[current_note][0]; |
| 525 | #endif | 490 | note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); |
| 526 | } | 491 | #endif |
| 492 | note_position = 0; | ||
| 527 | 493 | ||
| 494 | #ifdef PWM_AUDIO | ||
| 495 | ENABLE_AUDIO_COUNTER_3_ISR; | ||
| 496 | #else | ||
| 497 | ENABLE_AUDIO_COUNTER_3_ISR; | ||
| 498 | ENABLE_AUDIO_COUNTER_3_OUTPUT; | ||
| 499 | #endif | ||
| 500 | } | ||
| 528 | } | 501 | } |
| 529 | 502 | ||
| 530 | #ifdef PWM_AUDIO | 503 | #ifdef PWM_AUDIO |
| 531 | void play_sample(uint8_t * s, uint16_t l, bool r) { | 504 | void play_sample(uint8_t* s, uint16_t l, bool r) { |
| 532 | if (!audio_initialized) { | 505 | if (!audio_initialized) { |
| 533 | audio_init(); | 506 | audio_init(); |
| 534 | } | 507 | } |
| @@ -536,17 +509,16 @@ void play_sample(uint8_t * s, uint16_t l, bool r) { | |||
| 536 | if (audio_config.enable) { | 509 | if (audio_config.enable) { |
| 537 | DISABLE_AUDIO_COUNTER_3_ISR; | 510 | DISABLE_AUDIO_COUNTER_3_ISR; |
| 538 | stop_all_notes(); | 511 | stop_all_notes(); |
| 539 | place_int = 0; | 512 | place_int = 0; |
| 540 | sample = s; | 513 | sample = s; |
| 541 | sample_length = l; | 514 | sample_length = l; |
| 542 | repeat = r; | 515 | repeat = r; |
| 543 | 516 | ||
| 544 | ENABLE_AUDIO_COUNTER_3_ISR; | 517 | ENABLE_AUDIO_COUNTER_3_ISR; |
| 545 | } | 518 | } |
| 546 | } | 519 | } |
| 547 | #endif | 520 | #endif |
| 548 | 521 | ||
| 549 | |||
| 550 | void audio_toggle(void) { | 522 | void audio_toggle(void) { |
| 551 | audio_config.enable ^= 1; | 523 | audio_config.enable ^= 1; |
| 552 | eeconfig_update_audio(audio_config.raw); | 524 | eeconfig_update_audio(audio_config.raw); |
| @@ -566,73 +538,45 @@ void audio_off(void) { | |||
| 566 | 538 | ||
| 567 | // Vibrato rate functions | 539 | // Vibrato rate functions |
| 568 | 540 | ||
| 569 | void set_vibrato_rate(float rate) { | 541 | void set_vibrato_rate(float rate) { vibrato_rate = rate; } |
| 570 | vibrato_rate = rate; | ||
| 571 | } | ||
| 572 | 542 | ||
| 573 | void increase_vibrato_rate(float change) { | 543 | void increase_vibrato_rate(float change) { vibrato_rate *= change; } |
| 574 | vibrato_rate *= change; | ||
| 575 | } | ||
| 576 | 544 | ||
| 577 | void decrease_vibrato_rate(float change) { | 545 | void decrease_vibrato_rate(float change) { vibrato_rate /= change; } |
| 578 | vibrato_rate /= change; | ||
| 579 | } | ||
| 580 | 546 | ||
| 581 | #ifdef VIBRATO_STRENGTH_ENABLE | 547 | # ifdef VIBRATO_STRENGTH_ENABLE |
| 582 | 548 | ||
| 583 | void set_vibrato_strength(float strength) { | 549 | void set_vibrato_strength(float strength) { vibrato_strength = strength; } |
| 584 | vibrato_strength = strength; | ||
| 585 | } | ||
| 586 | 550 | ||
| 587 | void increase_vibrato_strength(float change) { | 551 | void increase_vibrato_strength(float change) { vibrato_strength *= change; } |
| 588 | vibrato_strength *= change; | ||
| 589 | } | ||
| 590 | 552 | ||
| 591 | void decrease_vibrato_strength(float change) { | 553 | void decrease_vibrato_strength(float change) { vibrato_strength /= change; } |
| 592 | vibrato_strength /= change; | ||
| 593 | } | ||
| 594 | 554 | ||
| 595 | #endif /* VIBRATO_STRENGTH_ENABLE */ | 555 | # endif /* VIBRATO_STRENGTH_ENABLE */ |
| 596 | 556 | ||
| 597 | #endif /* VIBRATO_ENABLE */ | 557 | #endif /* VIBRATO_ENABLE */ |
| 598 | 558 | ||
| 599 | // Polyphony functions | 559 | // Polyphony functions |
| 600 | 560 | ||
| 601 | void set_polyphony_rate(float rate) { | 561 | void set_polyphony_rate(float rate) { polyphony_rate = rate; } |
| 602 | polyphony_rate = rate; | ||
| 603 | } | ||
| 604 | 562 | ||
| 605 | void enable_polyphony() { | 563 | void enable_polyphony() { polyphony_rate = 5; } |
| 606 | polyphony_rate = 5; | ||
| 607 | } | ||
| 608 | 564 | ||
| 609 | void disable_polyphony() { | 565 | void disable_polyphony() { polyphony_rate = 0; } |
| 610 | polyphony_rate = 0; | ||
| 611 | } | ||
| 612 | 566 | ||
| 613 | void increase_polyphony_rate(float change) { | 567 | void increase_polyphony_rate(float change) { polyphony_rate *= change; } |
| 614 | polyphony_rate *= change; | ||
| 615 | } | ||
| 616 | 568 | ||
| 617 | void decrease_polyphony_rate(float change) { | 569 | void decrease_polyphony_rate(float change) { polyphony_rate /= change; } |
| 618 | polyphony_rate /= change; | ||
| 619 | } | ||
| 620 | 570 | ||
| 621 | // Timbre function | 571 | // Timbre function |
| 622 | 572 | ||
| 623 | void set_timbre(float timbre) { | 573 | void set_timbre(float timbre) { note_timbre = timbre; } |
| 624 | note_timbre = timbre; | ||
| 625 | } | ||
| 626 | 574 | ||
| 627 | // Tempo functions | 575 | // Tempo functions |
| 628 | 576 | ||
| 629 | void set_tempo(uint8_t tempo) { | 577 | void set_tempo(uint8_t tempo) { note_tempo = tempo; } |
| 630 | note_tempo = tempo; | ||
| 631 | } | ||
| 632 | 578 | ||
| 633 | void decrease_tempo(uint8_t tempo_change) { | 579 | void decrease_tempo(uint8_t tempo_change) { note_tempo += tempo_change; } |
| 634 | note_tempo += tempo_change; | ||
| 635 | } | ||
| 636 | 580 | ||
| 637 | void increase_tempo(uint8_t tempo_change) { | 581 | void increase_tempo(uint8_t tempo_change) { |
| 638 | if (note_tempo - tempo_change < 10) { | 582 | if (note_tempo - tempo_change < 10) { |
| @@ -642,17 +586,10 @@ void increase_tempo(uint8_t tempo_change) { | |||
| 642 | } | 586 | } |
| 643 | } | 587 | } |
| 644 | 588 | ||
| 645 | |||
| 646 | //------------------------------------------------------------------------------ | 589 | //------------------------------------------------------------------------------ |
| 647 | // Override these functions in your keymap file to play different tunes on | 590 | // Override these functions in your keymap file to play different tunes on |
| 648 | // startup and bootloader jump | 591 | // startup and bootloader jump |
| 649 | __attribute__ ((weak)) | 592 | __attribute__((weak)) void play_startup_tone() {} |
| 650 | void play_startup_tone() | ||
| 651 | { | ||
| 652 | } | ||
| 653 | 593 | ||
| 654 | __attribute__ ((weak)) | 594 | __attribute__((weak)) void play_goodbye_tone() {} |
| 655 | void play_goodbye_tone() | ||
| 656 | { | ||
| 657 | } | ||
| 658 | //------------------------------------------------------------------------------ | 595 | //------------------------------------------------------------------------------ |
diff --git a/quantum/audio/luts.c b/quantum/audio/luts.c index 4404aff43..e8f77a0f3 100644 --- a/quantum/audio/luts.c +++ b/quantum/audio/luts.c | |||
| @@ -16,380 +16,12 @@ | |||
| 16 | 16 | ||
| 17 | #include "luts.h" | 17 | #include "luts.h" |
| 18 | 18 | ||
| 19 | const float vibrato_lut[VIBRATO_LUT_LENGTH] = | 19 | const float vibrato_lut[VIBRATO_LUT_LENGTH] = { |
| 20 | { | 20 | 1.0022336811487, 1.0042529943610, 1.0058584256028, 1.0068905285205, 1.0072464122237, 1.0068905285205, 1.0058584256028, 1.0042529943610, 1.0022336811487, 1.0000000000000, 0.9977712970630, 0.9957650169978, 0.9941756956510, 0.9931566259436, 0.9928057204913, 0.9931566259436, 0.9941756956510, 0.9957650169978, 0.9977712970630, 1.0000000000000, |
| 21 | 1.0022336811487, | ||
| 22 | 1.0042529943610, | ||
| 23 | 1.0058584256028, | ||
| 24 | 1.0068905285205, | ||
| 25 | 1.0072464122237, | ||
| 26 | 1.0068905285205, | ||
| 27 | 1.0058584256028, | ||
| 28 | 1.0042529943610, | ||
| 29 | 1.0022336811487, | ||
| 30 | 1.0000000000000, | ||
| 31 | 0.9977712970630, | ||
| 32 | 0.9957650169978, | ||
| 33 | 0.9941756956510, | ||
| 34 | 0.9931566259436, | ||
| 35 | 0.9928057204913, | ||
| 36 | 0.9931566259436, | ||
| 37 | 0.9941756956510, | ||
| 38 | 0.9957650169978, | ||
| 39 | 0.9977712970630, | ||
| 40 | 1.0000000000000, | ||
| 41 | }; | 21 | }; |
| 42 | 22 | ||
| 43 | const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH] = | 23 | const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH] = { |
| 44 | { | 24 | 0x8E0B, 0x8C02, 0x8A00, 0x8805, 0x8612, 0x8426, 0x8241, 0x8063, 0x7E8C, 0x7CBB, 0x7AF2, 0x792E, 0x7772, 0x75BB, 0x740B, 0x7261, 0x70BD, 0x6F20, 0x6D88, 0x6BF6, 0x6A69, 0x68E3, 0x6762, 0x65E6, 0x6470, 0x6300, 0x6194, 0x602E, 0x5ECD, 0x5D71, 0x5C1A, 0x5AC8, 0x597B, 0x5833, 0x56EF, 0x55B0, 0x5475, 0x533F, 0x520E, 0x50E1, 0x4FB8, 0x4E93, 0x4D73, 0x4C57, 0x4B3E, 0x4A2A, 0x491A, 0x480E, 0x4705, 0x4601, 0x4500, 0x4402, 0x4309, 0x4213, 0x4120, 0x4031, 0x3F46, 0x3E5D, 0x3D79, 0x3C97, 0x3BB9, 0x3ADD, 0x3A05, 0x3930, 0x385E, 0x3790, 0x36C4, 0x35FB, 0x3534, 0x3471, 0x33B1, 0x32F3, 0x3238, 0x3180, 0x30CA, 0x3017, 0x2F66, 0x2EB8, 0x2E0D, 0x2D64, 0x2CBD, 0x2C19, 0x2B77, 0x2AD8, 0x2A3A, 0x299F, 0x2907, 0x2870, 0x27DC, 0x2749, 0x26B9, 0x262B, 0x259F, 0x2515, 0x248D, 0x2407, 0x2382, 0x2300, 0x2280, 0x2201, 0x2184, 0x2109, 0x2090, 0x2018, 0x1FA3, 0x1F2E, 0x1EBC, 0x1E4B, 0x1DDC, 0x1D6E, 0x1D02, 0x1C98, 0x1C2F, 0x1BC8, 0x1B62, 0x1AFD, 0x1A9A, |
| 45 | 0x8E0B, | 25 | 0x1A38, 0x19D8, 0x1979, 0x191C, 0x18C0, 0x1865, 0x180B, 0x17B3, 0x175C, 0x1706, 0x16B2, 0x165E, 0x160C, 0x15BB, 0x156C, 0x151D, 0x14CF, 0x1483, 0x1438, 0x13EE, 0x13A4, 0x135C, 0x1315, 0x12CF, 0x128A, 0x1246, 0x1203, 0x11C1, 0x1180, 0x1140, 0x1100, 0x10C2, 0x1084, 0x1048, 0x100C, 0xFD1, 0xF97, 0xF5E, 0xF25, 0xEEE, 0xEB7, 0xE81, 0xE4C, 0xE17, 0xDE4, 0xDB1, 0xD7E, 0xD4D, 0xD1C, 0xCEC, 0xCBC, 0xC8E, 0xC60, 0xC32, 0xC05, 0xBD9, 0xBAE, 0xB83, 0xB59, 0xB2F, 0xB06, 0xADD, 0xAB6, 0xA8E, 0xA67, 0xA41, 0xA1C, 0x9F7, 0x9D2, 0x9AE, 0x98A, 0x967, 0x945, 0x923, 0x901, 0x8E0, 0x8C0, 0x8A0, 0x880, 0x861, 0x842, 0x824, 0x806, 0x7E8, 0x7CB, 0x7AF, 0x792, 0x777, 0x75B, 0x740, 0x726, 0x70B, 0x6F2, 0x6D8, 0x6BF, 0x6A6, 0x68E, 0x676, 0x65E, 0x647, 0x630, 0x619, 0x602, 0x5EC, 0x5D7, 0x5C1, 0x5AC, 0x597, 0x583, 0x56E, 0x55B, 0x547, 0x533, 0x520, 0x50E, 0x4FB, 0x4E9, |
| 46 | 0x8C02, | 26 | 0x4D7, 0x4C5, 0x4B3, 0x4A2, 0x491, 0x480, 0x470, 0x460, 0x450, 0x440, 0x430, 0x421, 0x412, 0x403, 0x3F4, 0x3E5, 0x3D7, 0x3C9, 0x3BB, 0x3AD, 0x3A0, 0x393, 0x385, 0x379, 0x36C, 0x35F, 0x353, 0x347, 0x33B, 0x32F, 0x323, 0x318, 0x30C, 0x301, 0x2F6, 0x2EB, 0x2E0, 0x2D6, 0x2CB, 0x2C1, 0x2B7, 0x2AD, 0x2A3, 0x299, 0x290, 0x287, 0x27D, 0x274, 0x26B, 0x262, 0x259, 0x251, 0x248, 0x240, 0x238, 0x230, 0x228, 0x220, 0x218, 0x210, 0x209, 0x201, 0x1FA, 0x1F2, 0x1EB, 0x1E4, 0x1DD, 0x1D6, 0x1D0, 0x1C9, 0x1C2, 0x1BC, 0x1B6, 0x1AF, 0x1A9, 0x1A3, 0x19D, 0x197, 0x191, 0x18C, 0x186, 0x180, 0x17B, 0x175, 0x170, 0x16B, 0x165, 0x160, 0x15B, 0x156, 0x151, 0x14C, 0x148, 0x143, 0x13E, 0x13A, 0x135, 0x131, 0x12C, 0x128, 0x124, 0x120, 0x11C, 0x118, 0x114, 0x110, 0x10C, 0x108, 0x104, 0x100, 0xFD, 0xF9, 0xF5, 0xF2, 0xEE, |
| 47 | 0x8A00, | ||
| 48 | 0x8805, | ||
| 49 | 0x8612, | ||
| 50 | 0x8426, | ||
| 51 | 0x8241, | ||
| 52 | 0x8063, | ||
| 53 | 0x7E8C, | ||
| 54 | 0x7CBB, | ||
| 55 | 0x7AF2, | ||
| 56 | 0x792E, | ||
| 57 | 0x7772, | ||
| 58 | 0x75BB, | ||
| 59 | 0x740B, | ||
| 60 | 0x7261, | ||
| 61 | 0x70BD, | ||
| 62 | 0x6F20, | ||
| 63 | 0x6D88, | ||
| 64 | 0x6BF6, | ||
| 65 | 0x6A69, | ||
| 66 | 0x68E3, | ||
| 67 | 0x6762, | ||
| 68 | 0x65E6, | ||
| 69 | 0x6470, | ||
| 70 | 0x6300, | ||
| 71 | 0x6194, | ||
| 72 | 0x602E, | ||
| 73 | 0x5ECD, | ||
| 74 | 0x5D71, | ||
| 75 | 0x5C1A, | ||
| 76 | 0x5AC8, | ||
| 77 | 0x597B, | ||
| 78 | 0x5833, | ||
| 79 | 0x56EF, | ||
| 80 | 0x55B0, | ||
| 81 | 0x5475, | ||
| 82 | 0x533F, | ||
| 83 | 0x520E, | ||
| 84 | 0x50E1, | ||
| 85 | 0x4FB8, | ||
| 86 | 0x4E93, | ||
| 87 | 0x4D73, | ||
| 88 | 0x4C57, | ||
| 89 | 0x4B3E, | ||
| 90 | 0x4A2A, | ||
| 91 | 0x491A, | ||
| 92 | 0x480E, | ||
| 93 | 0x4705, | ||
| 94 | 0x4601, | ||
| 95 | 0x4500, | ||
| 96 | 0x4402, | ||
| 97 | 0x4309, | ||
| 98 | 0x4213, | ||
| 99 | 0x4120, | ||
| 100 | 0x4031, | ||
| 101 | 0x3F46, | ||
| 102 | 0x3E5D, | ||
| 103 | 0x3D79, | ||
| 104 | 0x3C97, | ||
| 105 | 0x3BB9, | ||
| 106 | 0x3ADD, | ||
| 107 | 0x3A05, | ||
| 108 | 0x3930, | ||
| 109 | 0x385E, | ||
| 110 | 0x3790, | ||
| 111 | 0x36C4, | ||
| 112 | 0x35FB, | ||
| 113 | 0x3534, | ||
| 114 | 0x3471, | ||
| 115 | 0x33B1, | ||
| 116 | 0x32F3, | ||
| 117 | 0x3238, | ||
| 118 | 0x3180, | ||
| 119 | 0x30CA, | ||
| 120 | 0x3017, | ||
| 121 | 0x2F66, | ||
| 122 | 0x2EB8, | ||
| 123 | 0x2E0D, | ||
| 124 | 0x2D64, | ||
| 125 | 0x2CBD, | ||
| 126 | 0x2C19, | ||
| 127 | 0x2B77, | ||
| 128 | 0x2AD8, | ||
| 129 | 0x2A3A, | ||
| 130 | 0x299F, | ||
| 131 | 0x2907, | ||
| 132 | 0x2870, | ||
| 133 | 0x27DC, | ||
| 134 | 0x2749, | ||
| 135 | 0x26B9, | ||
| 136 | 0x262B, | ||
| 137 | 0x259F, | ||
| 138 | 0x2515, | ||
| 139 | 0x248D, | ||
| 140 | 0x2407, | ||
| 141 | 0x2382, | ||
| 142 | 0x2300, | ||
| 143 | 0x2280, | ||
| 144 | 0x2201, | ||
| 145 | 0x2184, | ||
| 146 | 0x2109, | ||
| 147 | 0x2090, | ||
| 148 | 0x2018, | ||
| 149 | 0x1FA3, | ||
| 150 | 0x1F2E, | ||
| 151 | 0x1EBC, | ||
| 152 | 0x1E4B, | ||
| 153 | 0x1DDC, | ||
| 154 | 0x1D6E, | ||
| 155 | 0x1D02, | ||
| 156 | 0x1C98, | ||
| 157 | 0x1C2F, | ||
| 158 | 0x1BC8, | ||
| 159 | 0x1B62, | ||
| 160 | 0x1AFD, | ||
| 161 | 0x1A9A, | ||
| 162 | 0x1A38, | ||
| 163 | 0x19D8, | ||
| 164 | 0x1979, | ||
| 165 | 0x191C, | ||
| 166 | 0x18C0, | ||
| 167 | 0x1865, | ||
| 168 | 0x180B, | ||
| 169 | 0x17B3, | ||
| 170 | 0x175C, | ||
| 171 | 0x1706, | ||
| 172 | 0x16B2, | ||
| 173 | 0x165E, | ||
| 174 | 0x160C, | ||
| 175 | 0x15BB, | ||
| 176 | 0x156C, | ||
| 177 | 0x151D, | ||
| 178 | 0x14CF, | ||
| 179 | 0x1483, | ||
| 180 | 0x1438, | ||
| 181 | 0x13EE, | ||
| 182 | 0x13A4, | ||
| 183 | 0x135C, | ||
| 184 | 0x1315, | ||
| 185 | 0x12CF, | ||
| 186 | 0x128A, | ||
| 187 | 0x1246, | ||
| 188 | 0x1203, | ||
| 189 | 0x11C1, | ||
| 190 | 0x1180, | ||
| 191 | 0x1140, | ||
| 192 | 0x1100, | ||
| 193 | 0x10C2, | ||
| 194 | 0x1084, | ||
| 195 | 0x1048, | ||
| 196 | 0x100C, | ||
| 197 | 0xFD1, | ||
| 198 | 0xF97, | ||
| 199 | 0xF5E, | ||
| 200 | 0xF25, | ||
| 201 | 0xEEE, | ||
| 202 | 0xEB7, | ||
| 203 | 0xE81, | ||
| 204 | 0xE4C, | ||
| 205 | 0xE17, | ||
| 206 | 0xDE4, | ||
| 207 | 0xDB1, | ||
| 208 | 0xD7E, | ||
| 209 | 0xD4D, | ||
| 210 | 0xD1C, | ||
| 211 | 0xCEC, | ||
| 212 | 0xCBC, | ||
| 213 | 0xC8E, | ||
| 214 | 0xC60, | ||
| 215 | 0xC32, | ||
| 216 | 0xC05, | ||
| 217 | 0xBD9, | ||
| 218 | 0xBAE, | ||
| 219 | 0xB83, | ||
| 220 | 0xB59, | ||
| 221 | 0xB2F, | ||
| 222 | 0xB06, | ||
| 223 | 0xADD, | ||
| 224 | 0xAB6, | ||
| 225 | 0xA8E, | ||
| 226 | 0xA67, | ||
| 227 | 0xA41, | ||
| 228 | 0xA1C, | ||
| 229 | 0x9F7, | ||
| 230 | 0x9D2, | ||
| 231 | 0x9AE, | ||
| 232 | 0x98A, | ||
| 233 | 0x967, | ||
| 234 | 0x945, | ||
| 235 | 0x923, | ||
| 236 | 0x901, | ||
| 237 | 0x8E0, | ||
| 238 | 0x8C0, | ||
| 239 | 0x8A0, | ||
| 240 | 0x880, | ||
| 241 | 0x861, | ||
| 242 | 0x842, | ||
| 243 | 0x824, | ||
| 244 | 0x806, | ||
| 245 | 0x7E8, | ||
| 246 | 0x7CB, | ||
| 247 | 0x7AF, | ||
| 248 | 0x792, | ||
| 249 | 0x777, | ||
| 250 | 0x75B, | ||
| 251 | 0x740, | ||
| 252 | 0x726, | ||
| 253 | 0x70B, | ||
| 254 | 0x6F2, | ||
| 255 | 0x6D8, | ||
| 256 | 0x6BF, | ||
| 257 | 0x6A6, | ||
| 258 | 0x68E, | ||
| 259 | 0x676, | ||
| 260 | 0x65E, | ||
| 261 | 0x647, | ||
| 262 | 0x630, | ||
| 263 | 0x619, | ||
| 264 | 0x602, | ||
| 265 | 0x5EC, | ||
| 266 | 0x5D7, | ||
| 267 | 0x5C1, | ||
| 268 | 0x5AC, | ||
| 269 | 0x597, | ||
| 270 | 0x583, | ||
| 271 | 0x56E, | ||
| 272 | 0x55B, | ||
| 273 | 0x547, | ||
| 274 | 0x533, | ||
| 275 | 0x520, | ||
| 276 | 0x50E, | ||
| 277 | 0x4FB, | ||
| 278 | 0x4E9, | ||
| 279 | 0x4D7, | ||
| 280 | 0x4C5, | ||
| 281 | 0x4B3, | ||
| 282 | 0x4A2, | ||
| 283 | 0x491, | ||
| 284 | 0x480, | ||
| 285 | 0x470, | ||
| 286 | 0x460, | ||
| 287 | 0x450, | ||
| 288 | 0x440, | ||
| 289 | 0x430, | ||
| 290 | 0x421, | ||
| 291 | 0x412, | ||
| 292 | 0x403, | ||
| 293 | 0x3F4, | ||
| 294 | 0x3E5, | ||
| 295 | 0x3D7, | ||
| 296 | 0x3C9, | ||
| 297 | 0x3BB, | ||
| 298 | 0x3AD, | ||
| 299 | 0x3A0, | ||
| 300 | 0x393, | ||
| 301 | 0x385, | ||
| 302 | 0x379, | ||
| 303 | 0x36C, | ||
| 304 | 0x35F, | ||
| 305 | 0x353, | ||
| 306 | 0x347, | ||
| 307 | 0x33B, | ||
| 308 | 0x32F, | ||
| 309 | 0x323, | ||
| 310 | 0x318, | ||
| 311 | 0x30C, | ||
| 312 | 0x301, | ||
| 313 | 0x2F6, | ||
| 314 | 0x2EB, | ||
| 315 | 0x2E0, | ||
| 316 | 0x2D6, | ||
| 317 | 0x2CB, | ||
| 318 | 0x2C1, | ||
| 319 | 0x2B7, | ||
| 320 | 0x2AD, | ||
| 321 | 0x2A3, | ||
| 322 | 0x299, | ||
| 323 | 0x290, | ||
| 324 | 0x287, | ||
| 325 | 0x27D, | ||
| 326 | 0x274, | ||
| 327 | 0x26B, | ||
| 328 | 0x262, | ||
| 329 | 0x259, | ||
| 330 | 0x251, | ||
| 331 | 0x248, | ||
| 332 | 0x240, | ||
| 333 | 0x238, | ||
| 334 | 0x230, | ||
| 335 | 0x228, | ||
| 336 | 0x220, | ||
| 337 | 0x218, | ||
| 338 | 0x210, | ||
| 339 | 0x209, | ||
| 340 | 0x201, | ||
| 341 | 0x1FA, | ||
| 342 | 0x1F2, | ||
| 343 | 0x1EB, | ||
| 344 | 0x1E4, | ||
| 345 | 0x1DD, | ||
| 346 | 0x1D6, | ||
| 347 | 0x1D0, | ||
| 348 | 0x1C9, | ||
| 349 | 0x1C2, | ||
| 350 | 0x1BC, | ||
| 351 | 0x1B6, | ||
| 352 | 0x1AF, | ||
| 353 | 0x1A9, | ||
| 354 | 0x1A3, | ||
| 355 | 0x19D, | ||
| 356 | 0x197, | ||
| 357 | 0x191, | ||
| 358 | 0x18C, | ||
| 359 | 0x186, | ||
| 360 | 0x180, | ||
| 361 | 0x17B, | ||
| 362 | 0x175, | ||
| 363 | 0x170, | ||
| 364 | 0x16B, | ||
| 365 | 0x165, | ||
| 366 | 0x160, | ||
| 367 | 0x15B, | ||
| 368 | 0x156, | ||
| 369 | 0x151, | ||
| 370 | 0x14C, | ||
| 371 | 0x148, | ||
| 372 | 0x143, | ||
| 373 | 0x13E, | ||
| 374 | 0x13A, | ||
| 375 | 0x135, | ||
| 376 | 0x131, | ||
| 377 | 0x12C, | ||
| 378 | 0x128, | ||
| 379 | 0x124, | ||
| 380 | 0x120, | ||
| 381 | 0x11C, | ||
| 382 | 0x118, | ||
| 383 | 0x114, | ||
| 384 | 0x110, | ||
| 385 | 0x10C, | ||
| 386 | 0x108, | ||
| 387 | 0x104, | ||
| 388 | 0x100, | ||
| 389 | 0xFD, | ||
| 390 | 0xF9, | ||
| 391 | 0xF5, | ||
| 392 | 0xF2, | ||
| 393 | 0xEE, | ||
| 394 | }; | 27 | }; |
| 395 | |||
diff --git a/quantum/audio/luts.h b/quantum/audio/luts.h index a377a6c87..117d74cd0 100644 --- a/quantum/audio/luts.h +++ b/quantum/audio/luts.h | |||
| @@ -15,22 +15,22 @@ | |||
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #if defined(__AVR__) | 17 | #if defined(__AVR__) |
| 18 | #include <avr/io.h> | 18 | # include <avr/io.h> |
| 19 | #include <avr/interrupt.h> | 19 | # include <avr/interrupt.h> |
| 20 | #include <avr/pgmspace.h> | 20 | # include <avr/pgmspace.h> |
| 21 | #else | 21 | #else |
| 22 | #include "ch.h" | 22 | # include "ch.h" |
| 23 | #include "hal.h" | 23 | # include "hal.h" |
| 24 | #endif | 24 | #endif |
| 25 | 25 | ||
| 26 | #ifndef LUTS_H | 26 | #ifndef LUTS_H |
| 27 | #define LUTS_H | 27 | # define LUTS_H |
| 28 | 28 | ||
| 29 | #define VIBRATO_LUT_LENGTH 20 | 29 | # define VIBRATO_LUT_LENGTH 20 |
| 30 | 30 | ||
| 31 | #define FREQUENCY_LUT_LENGTH 349 | 31 | # define FREQUENCY_LUT_LENGTH 349 |
| 32 | 32 | ||
| 33 | extern const float vibrato_lut[VIBRATO_LUT_LENGTH]; | 33 | extern const float vibrato_lut[VIBRATO_LUT_LENGTH]; |
| 34 | extern const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH]; | 34 | extern const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH]; |
| 35 | 35 | ||
| 36 | #endif /* LUTS_H */ | 36 | #endif /* LUTS_H */ |
diff --git a/quantum/audio/muse.c b/quantum/audio/muse.c index f3cb592d8..01b95671f 100644 --- a/quantum/audio/muse.c +++ b/quantum/audio/muse.c | |||
| @@ -1,111 +1,56 @@ | |||
| 1 | #include "muse.h" | 1 | #include "muse.h" |
| 2 | 2 | ||
| 3 | enum { | 3 | enum { MUSE_OFF, MUSE_ON, MUSE_C_1_2, MUSE_C1, MUSE_C2, MUSE_C4, MUSE_C8, MUSE_C3, MUSE_C6, MUSE_B1, MUSE_B2, MUSE_B3, MUSE_B4, MUSE_B5, MUSE_B6, MUSE_B7, MUSE_B8, MUSE_B9, MUSE_B10, MUSE_B11, MUSE_B12, MUSE_B13, MUSE_B14, MUSE_B15, MUSE_B16, MUSE_B17, MUSE_B18, MUSE_B19, MUSE_B20, MUSE_B21, MUSE_B22, MUSE_B23, MUSE_B24, MUSE_B25, MUSE_B26, MUSE_B27, MUSE_B28, MUSE_B29, MUSE_B30, MUSE_B31 }; |
| 4 | MUSE_OFF, | ||
| 5 | MUSE_ON, | ||
| 6 | MUSE_C_1_2, | ||
| 7 | MUSE_C1, | ||
| 8 | MUSE_C2, | ||
| 9 | MUSE_C4, | ||
| 10 | MUSE_C8, | ||
| 11 | MUSE_C3, | ||
| 12 | MUSE_C6, | ||
| 13 | MUSE_B1, | ||
| 14 | MUSE_B2, | ||
| 15 | MUSE_B3, | ||
| 16 | MUSE_B4, | ||
| 17 | MUSE_B5, | ||
| 18 | MUSE_B6, | ||
| 19 | MUSE_B7, | ||
| 20 | MUSE_B8, | ||
| 21 | MUSE_B9, | ||
| 22 | MUSE_B10, | ||
| 23 | MUSE_B11, | ||
| 24 | MUSE_B12, | ||
| 25 | MUSE_B13, | ||
| 26 | MUSE_B14, | ||
| 27 | MUSE_B15, | ||
| 28 | MUSE_B16, | ||
| 29 | MUSE_B17, | ||
| 30 | MUSE_B18, | ||
| 31 | MUSE_B19, | ||
| 32 | MUSE_B20, | ||
| 33 | MUSE_B21, | ||
| 34 | MUSE_B22, | ||
| 35 | MUSE_B23, | ||
| 36 | MUSE_B24, | ||
| 37 | MUSE_B25, | ||
| 38 | MUSE_B26, | ||
| 39 | MUSE_B27, | ||
| 40 | MUSE_B28, | ||
| 41 | MUSE_B29, | ||
| 42 | MUSE_B30, | ||
| 43 | MUSE_B31 | ||
| 44 | }; | ||
| 45 | 4 | ||
| 46 | bool number_of_ones_to_bool[16] = { | 5 | bool number_of_ones_to_bool[16] = {1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1}; |
| 47 | 1, 0, 0, 1, 0, 1, 1, 0, | ||
| 48 | 0, 1, 1, 0, 1, 0, 0, 1 | ||
| 49 | }; | ||
| 50 | 6 | ||
| 51 | uint8_t muse_interval[4] = {MUSE_B7, MUSE_B19, MUSE_B3, MUSE_B28}; | 7 | uint8_t muse_interval[4] = {MUSE_B7, MUSE_B19, MUSE_B3, MUSE_B28}; |
| 52 | uint8_t muse_theme[4] = {MUSE_B8, MUSE_B23, MUSE_B18, MUSE_B17}; | 8 | uint8_t muse_theme[4] = {MUSE_B8, MUSE_B23, MUSE_B18, MUSE_B17}; |
| 53 | 9 | ||
| 54 | bool muse_timer_1bit = 0; | 10 | bool muse_timer_1bit = 0; |
| 55 | uint8_t muse_timer_2bit = 0; | 11 | uint8_t muse_timer_2bit = 0; |
| 56 | uint8_t muse_timer_2bit_counter = 0; | 12 | uint8_t muse_timer_2bit_counter = 0; |
| 57 | uint8_t muse_timer_4bit = 0; | 13 | uint8_t muse_timer_4bit = 0; |
| 58 | uint32_t muse_timer_31bit = 0; | 14 | uint32_t muse_timer_31bit = 0; |
| 59 | 15 | ||
| 60 | bool bit_for_value(uint8_t value) { | 16 | bool bit_for_value(uint8_t value) { |
| 61 | switch (value) { | 17 | switch (value) { |
| 62 | case MUSE_OFF: | 18 | case MUSE_OFF: |
| 63 | return 0; | 19 | return 0; |
| 64 | case MUSE_ON: | 20 | case MUSE_ON: |
| 65 | return 1; | 21 | return 1; |
| 66 | case MUSE_C_1_2: | 22 | case MUSE_C_1_2: |
| 67 | return muse_timer_1bit; | 23 | return muse_timer_1bit; |
| 68 | case MUSE_C1: | 24 | case MUSE_C1: |
| 69 | return (muse_timer_4bit & 1); | 25 | return (muse_timer_4bit & 1); |
| 70 | case MUSE_C2: | 26 | case MUSE_C2: |
| 71 | return (muse_timer_4bit & 2); | 27 | return (muse_timer_4bit & 2); |
| 72 | case MUSE_C4: | 28 | case MUSE_C4: |
| 73 | return (muse_timer_4bit & 4); | 29 | return (muse_timer_4bit & 4); |
| 74 | case MUSE_C8: | 30 | case MUSE_C8: |
| 75 | return (muse_timer_4bit & 8); | 31 | return (muse_timer_4bit & 8); |
| 76 | case MUSE_C3: | 32 | case MUSE_C3: |
| 77 | return (muse_timer_2bit & 1); | 33 | return (muse_timer_2bit & 1); |
| 78 | case MUSE_C6: | 34 | case MUSE_C6: |
| 79 | return (muse_timer_2bit & 2); | 35 | return (muse_timer_2bit & 2); |
| 80 | default: | 36 | default: |
| 81 | return muse_timer_31bit & (1UL << (value - MUSE_B1)); | 37 | return muse_timer_31bit & (1UL << (value - MUSE_B1)); |
| 82 | } | 38 | } |
| 83 | } | 39 | } |
| 84 | 40 | ||
| 85 | uint8_t muse_clock_pulse(void) { | 41 | uint8_t muse_clock_pulse(void) { |
| 86 | 42 | bool top = number_of_ones_to_bool[bit_for_value(muse_theme[0]) + (bit_for_value(muse_theme[1]) << 1) + (bit_for_value(muse_theme[2]) << 2) + (bit_for_value(muse_theme[3]) << 3)]; | |
| 87 | bool top = number_of_ones_to_bool[ | 43 | |
| 88 | bit_for_value(muse_theme[0]) + | 44 | if (muse_timer_1bit == 0) { |
| 89 | (bit_for_value(muse_theme[1]) << 1) + | 45 | if (muse_timer_2bit_counter == 0) { |
| 90 | (bit_for_value(muse_theme[2]) << 2) + | 46 | muse_timer_2bit = (muse_timer_2bit + 1) % 4; |
| 91 | (bit_for_value(muse_theme[3]) << 3) | 47 | } |
| 92 | ]; | 48 | muse_timer_2bit_counter = (muse_timer_2bit_counter + 1) % 3; |
| 93 | 49 | muse_timer_4bit = (muse_timer_4bit + 1) % 16; | |
| 94 | if (muse_timer_1bit == 0) { | 50 | muse_timer_31bit = (muse_timer_31bit << 1) + top; |
| 95 | if (muse_timer_2bit_counter == 0) { | ||
| 96 | muse_timer_2bit = (muse_timer_2bit + 1) % 4; | ||
| 97 | } | 51 | } |
| 98 | muse_timer_2bit_counter = (muse_timer_2bit_counter + 1) % 3; | ||
| 99 | muse_timer_4bit = (muse_timer_4bit + 1) % 16; | ||
| 100 | muse_timer_31bit = (muse_timer_31bit << 1) + top; | ||
| 101 | } | ||
| 102 | |||
| 103 | muse_timer_1bit = (muse_timer_1bit + 1) % 2; | ||
| 104 | 52 | ||
| 105 | return | 53 | muse_timer_1bit = (muse_timer_1bit + 1) % 2; |
| 106 | bit_for_value(muse_interval[0]) + | ||
| 107 | (bit_for_value(muse_interval[1]) << 1) + | ||
| 108 | (bit_for_value(muse_interval[2]) << 2) + | ||
| 109 | (bit_for_value(muse_interval[3]) << 3); | ||
| 110 | 54 | ||
| 55 | return bit_for_value(muse_interval[0]) + (bit_for_value(muse_interval[1]) << 1) + (bit_for_value(muse_interval[2]) << 2) + (bit_for_value(muse_interval[3]) << 3); | ||
| 111 | } | 56 | } |
diff --git a/quantum/audio/musical_notes.h b/quantum/audio/musical_notes.h index cd54af38d..9742e19c4 100644 --- a/quantum/audio/musical_notes.h +++ b/quantum/audio/musical_notes.h | |||
| @@ -20,55 +20,55 @@ | |||
| 20 | // Tempo Placeholder | 20 | // Tempo Placeholder |
| 21 | #define TEMPO_DEFAULT 100 | 21 | #define TEMPO_DEFAULT 100 |
| 22 | 22 | ||
| 23 | 23 | #define SONG(notes...) \ | |
| 24 | #define SONG(notes...) { notes } | 24 | { notes } |
| 25 | |||
| 26 | 25 | ||
| 27 | // Note Types | 26 | // Note Types |
| 28 | #define MUSICAL_NOTE(note, duration) {(NOTE##note), duration} | 27 | #define MUSICAL_NOTE(note, duration) \ |
| 29 | #define BREVE_NOTE(note) MUSICAL_NOTE(note, 128) | 28 | { (NOTE##note), duration } |
| 30 | #define WHOLE_NOTE(note) MUSICAL_NOTE(note, 64) | 29 | #define BREVE_NOTE(note) MUSICAL_NOTE(note, 128) |
| 31 | #define HALF_NOTE(note) MUSICAL_NOTE(note, 32) | 30 | #define WHOLE_NOTE(note) MUSICAL_NOTE(note, 64) |
| 32 | #define QUARTER_NOTE(note) MUSICAL_NOTE(note, 16) | 31 | #define HALF_NOTE(note) MUSICAL_NOTE(note, 32) |
| 33 | #define EIGHTH_NOTE(note) MUSICAL_NOTE(note, 8) | 32 | #define QUARTER_NOTE(note) MUSICAL_NOTE(note, 16) |
| 34 | #define SIXTEENTH_NOTE(note) MUSICAL_NOTE(note, 4) | 33 | #define EIGHTH_NOTE(note) MUSICAL_NOTE(note, 8) |
| 35 | 34 | #define SIXTEENTH_NOTE(note) MUSICAL_NOTE(note, 4) | |
| 36 | #define BREVE_DOT_NOTE(note) MUSICAL_NOTE(note, 128+64) | 35 | |
| 37 | #define WHOLE_DOT_NOTE(note) MUSICAL_NOTE(note, 64+32) | 36 | #define BREVE_DOT_NOTE(note) MUSICAL_NOTE(note, 128 + 64) |
| 38 | #define HALF_DOT_NOTE(note) MUSICAL_NOTE(note, 32+16) | 37 | #define WHOLE_DOT_NOTE(note) MUSICAL_NOTE(note, 64 + 32) |
| 39 | #define QUARTER_DOT_NOTE(note) MUSICAL_NOTE(note, 16+8) | 38 | #define HALF_DOT_NOTE(note) MUSICAL_NOTE(note, 32 + 16) |
| 40 | #define EIGHTH_DOT_NOTE(note) MUSICAL_NOTE(note, 8+4) | 39 | #define QUARTER_DOT_NOTE(note) MUSICAL_NOTE(note, 16 + 8) |
| 41 | #define SIXTEENTH_DOT_NOTE(note) MUSICAL_NOTE(note, 4+2) | 40 | #define EIGHTH_DOT_NOTE(note) MUSICAL_NOTE(note, 8 + 4) |
| 41 | #define SIXTEENTH_DOT_NOTE(note) MUSICAL_NOTE(note, 4 + 2) | ||
| 42 | 42 | ||
| 43 | // Note Type Shortcuts | 43 | // Note Type Shortcuts |
| 44 | #define M__NOTE(note, duration) MUSICAL_NOTE(note, duration) | 44 | #define M__NOTE(note, duration) MUSICAL_NOTE(note, duration) |
| 45 | #define B__NOTE(n) BREVE_NOTE(n) | 45 | #define B__NOTE(n) BREVE_NOTE(n) |
| 46 | #define W__NOTE(n) WHOLE_NOTE(n) | 46 | #define W__NOTE(n) WHOLE_NOTE(n) |
| 47 | #define H__NOTE(n) HALF_NOTE(n) | 47 | #define H__NOTE(n) HALF_NOTE(n) |
| 48 | #define Q__NOTE(n) QUARTER_NOTE(n) | 48 | #define Q__NOTE(n) QUARTER_NOTE(n) |
| 49 | #define E__NOTE(n) EIGHTH_NOTE(n) | 49 | #define E__NOTE(n) EIGHTH_NOTE(n) |
| 50 | #define S__NOTE(n) SIXTEENTH_NOTE(n) | 50 | #define S__NOTE(n) SIXTEENTH_NOTE(n) |
| 51 | #define BD_NOTE(n) BREVE_DOT_NOTE(n) | 51 | #define BD_NOTE(n) BREVE_DOT_NOTE(n) |
| 52 | #define WD_NOTE(n) WHOLE_DOT_NOTE(n) | 52 | #define WD_NOTE(n) WHOLE_DOT_NOTE(n) |
| 53 | #define HD_NOTE(n) HALF_DOT_NOTE(n) | 53 | #define HD_NOTE(n) HALF_DOT_NOTE(n) |
| 54 | #define QD_NOTE(n) QUARTER_DOT_NOTE(n) | 54 | #define QD_NOTE(n) QUARTER_DOT_NOTE(n) |
| 55 | #define ED_NOTE(n) EIGHTH_DOT_NOTE(n) | 55 | #define ED_NOTE(n) EIGHTH_DOT_NOTE(n) |
| 56 | #define SD_NOTE(n) SIXTEENTH_DOT_NOTE(n) | 56 | #define SD_NOTE(n) SIXTEENTH_DOT_NOTE(n) |
| 57 | 57 | ||
| 58 | // Note Timbre | 58 | // Note Timbre |
| 59 | // Changes how the notes sound | 59 | // Changes how the notes sound |
| 60 | #define TIMBRE_12 0.125f | 60 | #define TIMBRE_12 0.125f |
| 61 | #define TIMBRE_25 0.250f | 61 | #define TIMBRE_25 0.250f |
| 62 | #define TIMBRE_50 0.500f | 62 | #define TIMBRE_50 0.500f |
| 63 | #define TIMBRE_75 0.750f | 63 | #define TIMBRE_75 0.750f |
| 64 | #define TIMBRE_DEFAULT TIMBRE_50 | 64 | #define TIMBRE_DEFAULT TIMBRE_50 |
| 65 | 65 | ||
| 66 | // Notes - # = Octave | 66 | // Notes - # = Octave |
| 67 | 67 | ||
| 68 | #ifdef __arm__ | 68 | #ifdef __arm__ |
| 69 | #define NOTE_REST 1.00f | 69 | # define NOTE_REST 1.00f |
| 70 | #else | 70 | #else |
| 71 | #define NOTE_REST 0.00f | 71 | # define NOTE_REST 0.00f |
| 72 | #endif | 72 | #endif |
| 73 | 73 | ||
| 74 | /* These notes are currently bugged | 74 | /* These notes are currently bugged |
| @@ -97,91 +97,91 @@ | |||
| 97 | #define NOTE_AS1 58.27f | 97 | #define NOTE_AS1 58.27f |
| 98 | */ | 98 | */ |
| 99 | 99 | ||
| 100 | #define NOTE_B1 61.74f | 100 | #define NOTE_B1 61.74f |
| 101 | #define NOTE_C2 65.41f | 101 | #define NOTE_C2 65.41f |
| 102 | #define NOTE_CS2 69.30f | 102 | #define NOTE_CS2 69.30f |
| 103 | #define NOTE_D2 73.42f | 103 | #define NOTE_D2 73.42f |
| 104 | #define NOTE_DS2 77.78f | 104 | #define NOTE_DS2 77.78f |
| 105 | #define NOTE_E2 82.41f | 105 | #define NOTE_E2 82.41f |
| 106 | #define NOTE_F2 87.31f | 106 | #define NOTE_F2 87.31f |
| 107 | #define NOTE_FS2 92.50f | 107 | #define NOTE_FS2 92.50f |
| 108 | #define NOTE_G2 98.00f | 108 | #define NOTE_G2 98.00f |
| 109 | #define NOTE_GS2 103.83f | 109 | #define NOTE_GS2 103.83f |
| 110 | #define NOTE_A2 110.00f | 110 | #define NOTE_A2 110.00f |
| 111 | #define NOTE_AS2 116.54f | 111 | #define NOTE_AS2 116.54f |
| 112 | #define NOTE_B2 123.47f | 112 | #define NOTE_B2 123.47f |
| 113 | #define NOTE_C3 130.81f | 113 | #define NOTE_C3 130.81f |
| 114 | #define NOTE_CS3 138.59f | 114 | #define NOTE_CS3 138.59f |
| 115 | #define NOTE_D3 146.83f | 115 | #define NOTE_D3 146.83f |
| 116 | #define NOTE_DS3 155.56f | 116 | #define NOTE_DS3 155.56f |
| 117 | #define NOTE_E3 164.81f | 117 | #define NOTE_E3 164.81f |
| 118 | #define NOTE_F3 174.61f | 118 | #define NOTE_F3 174.61f |
| 119 | #define NOTE_FS3 185.00f | 119 | #define NOTE_FS3 185.00f |
| 120 | #define NOTE_G3 196.00f | 120 | #define NOTE_G3 196.00f |
| 121 | #define NOTE_GS3 207.65f | 121 | #define NOTE_GS3 207.65f |
| 122 | #define NOTE_A3 220.00f | 122 | #define NOTE_A3 220.00f |
| 123 | #define NOTE_AS3 233.08f | 123 | #define NOTE_AS3 233.08f |
| 124 | #define NOTE_B3 246.94f | 124 | #define NOTE_B3 246.94f |
| 125 | #define NOTE_C4 261.63f | 125 | #define NOTE_C4 261.63f |
| 126 | #define NOTE_CS4 277.18f | 126 | #define NOTE_CS4 277.18f |
| 127 | #define NOTE_D4 293.66f | 127 | #define NOTE_D4 293.66f |
| 128 | #define NOTE_DS4 311.13f | 128 | #define NOTE_DS4 311.13f |
| 129 | #define NOTE_E4 329.63f | 129 | #define NOTE_E4 329.63f |
| 130 | #define NOTE_F4 349.23f | 130 | #define NOTE_F4 349.23f |
| 131 | #define NOTE_FS4 369.99f | 131 | #define NOTE_FS4 369.99f |
| 132 | #define NOTE_G4 392.00f | 132 | #define NOTE_G4 392.00f |
| 133 | #define NOTE_GS4 415.30f | 133 | #define NOTE_GS4 415.30f |
| 134 | #define NOTE_A4 440.00f | 134 | #define NOTE_A4 440.00f |
| 135 | #define NOTE_AS4 466.16f | 135 | #define NOTE_AS4 466.16f |
| 136 | #define NOTE_B4 493.88f | 136 | #define NOTE_B4 493.88f |
| 137 | #define NOTE_C5 523.25f | 137 | #define NOTE_C5 523.25f |
| 138 | #define NOTE_CS5 554.37f | 138 | #define NOTE_CS5 554.37f |
| 139 | #define NOTE_D5 587.33f | 139 | #define NOTE_D5 587.33f |
| 140 | #define NOTE_DS5 622.25f | 140 | #define NOTE_DS5 622.25f |
| 141 | #define NOTE_E5 659.26f | 141 | #define NOTE_E5 659.26f |
| 142 | #define NOTE_F5 698.46f | 142 | #define NOTE_F5 698.46f |
| 143 | #define NOTE_FS5 739.99f | 143 | #define NOTE_FS5 739.99f |
| 144 | #define NOTE_G5 783.99f | 144 | #define NOTE_G5 783.99f |
| 145 | #define NOTE_GS5 830.61f | 145 | #define NOTE_GS5 830.61f |
| 146 | #define NOTE_A5 880.00f | 146 | #define NOTE_A5 880.00f |
| 147 | #define NOTE_AS5 932.33f | 147 | #define NOTE_AS5 932.33f |
| 148 | #define NOTE_B5 987.77f | 148 | #define NOTE_B5 987.77f |
| 149 | #define NOTE_C6 1046.50f | 149 | #define NOTE_C6 1046.50f |
| 150 | #define NOTE_CS6 1108.73f | 150 | #define NOTE_CS6 1108.73f |
| 151 | #define NOTE_D6 1174.66f | 151 | #define NOTE_D6 1174.66f |
| 152 | #define NOTE_DS6 1244.51f | 152 | #define NOTE_DS6 1244.51f |
| 153 | #define NOTE_E6 1318.51f | 153 | #define NOTE_E6 1318.51f |
| 154 | #define NOTE_F6 1396.91f | 154 | #define NOTE_F6 1396.91f |
| 155 | #define NOTE_FS6 1479.98f | 155 | #define NOTE_FS6 1479.98f |
| 156 | #define NOTE_G6 1567.98f | 156 | #define NOTE_G6 1567.98f |
| 157 | #define NOTE_GS6 1661.22f | 157 | #define NOTE_GS6 1661.22f |
| 158 | #define NOTE_A6 1760.00f | 158 | #define NOTE_A6 1760.00f |
| 159 | #define NOTE_AS6 1864.66f | 159 | #define NOTE_AS6 1864.66f |
| 160 | #define NOTE_B6 1975.53f | 160 | #define NOTE_B6 1975.53f |
| 161 | #define NOTE_C7 2093.00f | 161 | #define NOTE_C7 2093.00f |
| 162 | #define NOTE_CS7 2217.46f | 162 | #define NOTE_CS7 2217.46f |
| 163 | #define NOTE_D7 2349.32f | 163 | #define NOTE_D7 2349.32f |
| 164 | #define NOTE_DS7 2489.02f | 164 | #define NOTE_DS7 2489.02f |
| 165 | #define NOTE_E7 2637.02f | 165 | #define NOTE_E7 2637.02f |
| 166 | #define NOTE_F7 2793.83f | 166 | #define NOTE_F7 2793.83f |
| 167 | #define NOTE_FS7 2959.96f | 167 | #define NOTE_FS7 2959.96f |
| 168 | #define NOTE_G7 3135.96f | 168 | #define NOTE_G7 3135.96f |
| 169 | #define NOTE_GS7 3322.44f | 169 | #define NOTE_GS7 3322.44f |
| 170 | #define NOTE_A7 3520.00f | 170 | #define NOTE_A7 3520.00f |
| 171 | #define NOTE_AS7 3729.31f | 171 | #define NOTE_AS7 3729.31f |
| 172 | #define NOTE_B7 3951.07f | 172 | #define NOTE_B7 3951.07f |
| 173 | #define NOTE_C8 4186.01f | 173 | #define NOTE_C8 4186.01f |
| 174 | #define NOTE_CS8 4434.92f | 174 | #define NOTE_CS8 4434.92f |
| 175 | #define NOTE_D8 4698.64f | 175 | #define NOTE_D8 4698.64f |
| 176 | #define NOTE_DS8 4978.03f | 176 | #define NOTE_DS8 4978.03f |
| 177 | #define NOTE_E8 5274.04f | 177 | #define NOTE_E8 5274.04f |
| 178 | #define NOTE_F8 5587.65f | 178 | #define NOTE_F8 5587.65f |
| 179 | #define NOTE_FS8 5919.91f | 179 | #define NOTE_FS8 5919.91f |
| 180 | #define NOTE_G8 6271.93f | 180 | #define NOTE_G8 6271.93f |
| 181 | #define NOTE_GS8 6644.88f | 181 | #define NOTE_GS8 6644.88f |
| 182 | #define NOTE_A8 7040.00f | 182 | #define NOTE_A8 7040.00f |
| 183 | #define NOTE_AS8 7458.62f | 183 | #define NOTE_AS8 7458.62f |
| 184 | #define NOTE_B8 7902.13f | 184 | #define NOTE_B8 7902.13f |
| 185 | 185 | ||
| 186 | // Flat Aliases | 186 | // Flat Aliases |
| 187 | #define NOTE_DF0 NOTE_CS0 | 187 | #define NOTE_DF0 NOTE_CS0 |
| @@ -230,5 +230,4 @@ | |||
| 230 | #define NOTE_AF8 NOTE_GS8 | 230 | #define NOTE_AF8 NOTE_GS8 |
| 231 | #define NOTE_BF8 NOTE_AS8 | 231 | #define NOTE_BF8 NOTE_AS8 |
| 232 | 232 | ||
| 233 | |||
| 234 | #endif | 233 | #endif |
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h index 33dbcfcb1..3d0e0e51e 100644 --- a/quantum/audio/song_list.h +++ b/quantum/audio/song_list.h | |||
| @@ -26,25 +26,15 @@ | |||
| 26 | * Author: Friedrich Schiller | 26 | * Author: Friedrich Schiller |
| 27 | + License: Public Domain | 27 | + License: Public Domain |
| 28 | */ | 28 | */ |
| 29 | #define ODE_TO_JOY \ | 29 | #define ODE_TO_JOY Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), Q__NOTE(_G4), Q__NOTE(_F4), Q__NOTE(_E4), Q__NOTE(_D4), Q__NOTE(_C4), Q__NOTE(_C4), Q__NOTE(_D4), Q__NOTE(_E4), QD_NOTE(_E4), E__NOTE(_D4), H__NOTE(_D4), |
| 30 | Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \ | ||
| 31 | Q__NOTE(_G4), Q__NOTE(_F4), Q__NOTE(_E4), Q__NOTE(_D4), \ | ||
| 32 | Q__NOTE(_C4), Q__NOTE(_C4), Q__NOTE(_D4), Q__NOTE(_E4), \ | ||
| 33 | QD_NOTE(_E4), E__NOTE(_D4), H__NOTE(_D4), | ||
| 34 | 30 | ||
| 35 | /* Rock-a-bye Baby | 31 | /* Rock-a-bye Baby |
| 36 | * Author: Unknown | 32 | * Author: Unknown |
| 37 | + License: Public Domain | 33 | + License: Public Domain |
| 38 | */ | 34 | */ |
| 39 | #define ROCK_A_BYE_BABY \ | 35 | #define ROCK_A_BYE_BABY QD_NOTE(_B4), E__NOTE(_D4), Q__NOTE(_B5), H__NOTE(_A5), Q__NOTE(_G5), QD_NOTE(_B4), E__NOTE(_D5), Q__NOTE(_G5), H__NOTE(_FS5), |
| 40 | QD_NOTE(_B4), E__NOTE(_D4), Q__NOTE(_B5), \ | ||
| 41 | H__NOTE(_A5), Q__NOTE(_G5), \ | ||
| 42 | QD_NOTE(_B4), E__NOTE(_D5), Q__NOTE(_G5), \ | ||
| 43 | H__NOTE(_FS5), | ||
| 44 | 36 | ||
| 45 | 37 | #define CLUEBOARD_SOUND HD_NOTE(_C3), HD_NOTE(_D3), HD_NOTE(_E3), HD_NOTE(_F3), HD_NOTE(_G3), HD_NOTE(_A4), HD_NOTE(_B4), HD_NOTE(_C4) | |
| 46 | #define CLUEBOARD_SOUND \ | ||
| 47 | HD_NOTE(_C3), HD_NOTE(_D3), HD_NOTE(_E3), HD_NOTE(_F3), HD_NOTE(_G3), HD_NOTE(_A4), HD_NOTE(_B4), HD_NOTE(_C4) | ||
| 48 | /* | 38 | /* |
| 49 | HD_NOTE(_G3), HD_NOTE(_E3), HD_NOTE(_C3), \ | 39 | HD_NOTE(_G3), HD_NOTE(_E3), HD_NOTE(_C3), \ |
| 50 | Q__NOTE(_E3), Q__NOTE(_C3), Q__NOTE(_G3), \ | 40 | Q__NOTE(_E3), Q__NOTE(_C3), Q__NOTE(_G3), \ |
| @@ -56,258 +46,93 @@ | |||
| 56 | Q__NOTE(_F3) | 46 | Q__NOTE(_F3) |
| 57 | */ | 47 | */ |
| 58 | 48 | ||
| 59 | #define STARTUP_SOUND \ | 49 | #define STARTUP_SOUND E__NOTE(_E6), E__NOTE(_A6), ED_NOTE(_E7), |
| 60 | E__NOTE(_E6), \ | 50 | |
| 61 | E__NOTE(_A6), \ | 51 | #define GOODBYE_SOUND E__NOTE(_E7), E__NOTE(_A6), ED_NOTE(_E6), |
| 62 | ED_NOTE(_E7), | 52 | |
| 63 | 53 | #define PLANCK_SOUND ED_NOTE(_E7), E__NOTE(_CS7), E__NOTE(_E6), E__NOTE(_A6), M__NOTE(_CS7, 20), | |
| 64 | #define GOODBYE_SOUND \ | 54 | |
| 65 | E__NOTE(_E7), \ | 55 | #define PREONIC_SOUND M__NOTE(_B5, 20), E__NOTE(_B6), M__NOTE(_DS6, 20), E__NOTE(_B6), |
| 66 | E__NOTE(_A6), \ | 56 | |
| 67 | ED_NOTE(_E6), | 57 | #define QWERTY_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), Q__NOTE(_E7), |
| 68 | 58 | ||
| 69 | #define PLANCK_SOUND \ | 59 | #define COLEMAK_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), ED_NOTE(_E7), S__NOTE(_REST), ED_NOTE(_GS7), |
| 70 | ED_NOTE(_E7 ), \ | 60 | |
| 71 | E__NOTE(_CS7), \ | 61 | #define DVORAK_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), E__NOTE(_E7), S__NOTE(_REST), E__NOTE(_FS7), S__NOTE(_REST), E__NOTE(_E7), |
| 72 | E__NOTE(_E6 ), \ | 62 | |
| 73 | E__NOTE(_A6 ), \ | 63 | #define WORKMAN_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), ED_NOTE(_FS7), S__NOTE(_REST), ED_NOTE(_A7), |
| 74 | M__NOTE(_CS7, 20), | 64 | |
| 75 | 65 | #define PLOVER_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), ED_NOTE(_E7), S__NOTE(_REST), ED_NOTE(_A7), | |
| 76 | #define PREONIC_SOUND \ | 66 | |
| 77 | M__NOTE(_B5, 20), \ | 67 | #define PLOVER_GOODBYE_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), ED_NOTE(_A7), S__NOTE(_REST), ED_NOTE(_E7), |
| 78 | E__NOTE(_B6), \ | 68 | |
| 79 | M__NOTE(_DS6, 20), \ | 69 | #define MUSIC_ON_SOUND E__NOTE(_A5), E__NOTE(_B5), E__NOTE(_CS6), E__NOTE(_D6), E__NOTE(_E6), E__NOTE(_FS6), E__NOTE(_GS6), E__NOTE(_A6), |
| 80 | E__NOTE(_B6), | 70 | |
| 81 | 71 | #define AUDIO_ON_SOUND E__NOTE(_A5), E__NOTE(_A6), | |
| 82 | #define QWERTY_SOUND \ | 72 | |
| 83 | E__NOTE(_GS6 ), \ | 73 | #define AUDIO_OFF_SOUND E__NOTE(_A6), E__NOTE(_A5), |
| 84 | E__NOTE(_A6 ), \ | ||
| 85 | S__NOTE(_REST), \ | ||
| 86 | Q__NOTE(_E7 ), | ||
| 87 | |||
| 88 | #define COLEMAK_SOUND \ | ||
| 89 | E__NOTE(_GS6 ), \ | ||
| 90 | E__NOTE(_A6 ), \ | ||
| 91 | S__NOTE(_REST), \ | ||
| 92 | ED_NOTE(_E7 ), \ | ||
| 93 | S__NOTE(_REST), \ | ||
| 94 | ED_NOTE(_GS7 ), | ||
| 95 | |||
| 96 | #define DVORAK_SOUND \ | ||
| 97 | E__NOTE(_GS6 ), \ | ||
| 98 | E__NOTE(_A6 ), \ | ||
| 99 | S__NOTE(_REST), \ | ||
| 100 | E__NOTE(_E7 ), \ | ||
| 101 | S__NOTE(_REST), \ | ||
| 102 | E__NOTE(_FS7 ), \ | ||
| 103 | S__NOTE(_REST), \ | ||
| 104 | E__NOTE(_E7 ), | ||
| 105 | |||
| 106 | #define WORKMAN_SOUND \ | ||
| 107 | E__NOTE(_GS6 ), \ | ||
| 108 | E__NOTE(_A6 ), \ | ||
| 109 | S__NOTE(_REST), \ | ||
| 110 | E__NOTE(_GS6 ), \ | ||
| 111 | E__NOTE(_A6 ), \ | ||
| 112 | S__NOTE(_REST), \ | ||
| 113 | ED_NOTE(_FS7 ), \ | ||
| 114 | S__NOTE(_REST), \ | ||
| 115 | ED_NOTE(_A7 ), | ||
| 116 | |||
| 117 | #define PLOVER_SOUND \ | ||
| 118 | E__NOTE(_GS6 ), \ | ||
| 119 | E__NOTE(_A6 ), \ | ||
| 120 | S__NOTE(_REST), \ | ||
| 121 | ED_NOTE(_E7 ), \ | ||
| 122 | S__NOTE(_REST), \ | ||
| 123 | ED_NOTE(_A7 ), | ||
| 124 | |||
| 125 | #define PLOVER_GOODBYE_SOUND \ | ||
| 126 | E__NOTE(_GS6 ), \ | ||
| 127 | E__NOTE(_A6 ), \ | ||
| 128 | S__NOTE(_REST), \ | ||
| 129 | ED_NOTE(_A7 ), \ | ||
| 130 | S__NOTE(_REST), \ | ||
| 131 | ED_NOTE(_E7 ), | ||
| 132 | |||
| 133 | #define MUSIC_ON_SOUND \ | ||
| 134 | E__NOTE(_A5 ), \ | ||
| 135 | E__NOTE(_B5 ), \ | ||
| 136 | E__NOTE(_CS6), \ | ||
| 137 | E__NOTE(_D6 ), \ | ||
| 138 | E__NOTE(_E6 ), \ | ||
| 139 | E__NOTE(_FS6), \ | ||
| 140 | E__NOTE(_GS6), \ | ||
| 141 | E__NOTE(_A6 ), | ||
| 142 | |||
| 143 | #define AUDIO_ON_SOUND \ | ||
| 144 | E__NOTE(_A5 ), \ | ||
| 145 | E__NOTE(_A6 ), | ||
| 146 | |||
| 147 | #define AUDIO_OFF_SOUND \ | ||
| 148 | E__NOTE(_A6 ), \ | ||
| 149 | E__NOTE(_A5 ), | ||
| 150 | 74 | ||
| 151 | #define MUSIC_SCALE_SOUND MUSIC_ON_SOUND | 75 | #define MUSIC_SCALE_SOUND MUSIC_ON_SOUND |
| 152 | 76 | ||
| 153 | #define MUSIC_OFF_SOUND \ | 77 | #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), |
| 154 | E__NOTE(_A6 ), \ | 78 | |
| 155 | E__NOTE(_GS6 ), \ | 79 | #define VOICE_CHANGE_SOUND Q__NOTE(_A5), Q__NOTE(_CS6), Q__NOTE(_E6), Q__NOTE(_A6), |
| 156 | E__NOTE(_FS6), \ | 80 | |
| 157 | E__NOTE(_E6 ), \ | 81 | #define CHROMATIC_SOUND Q__NOTE(_A5), Q__NOTE(_AS5), Q__NOTE(_B5), Q__NOTE(_C6), Q__NOTE(_CS6), |
| 158 | E__NOTE(_D6 ), \ | 82 | |
| 159 | E__NOTE(_CS6), \ | 83 | #define MAJOR_SOUND Q__NOTE(_A5), Q__NOTE(_B5), Q__NOTE(_CS6), Q__NOTE(_D6), Q__NOTE(_E6), |
| 160 | E__NOTE(_B5), \ | 84 | |
| 161 | E__NOTE(_A5 ), | 85 | #define MINOR_SOUND Q__NOTE(_A5), Q__NOTE(_B5), Q__NOTE(_C6), Q__NOTE(_D6), Q__NOTE(_E6), |
| 162 | 86 | ||
| 163 | #define VOICE_CHANGE_SOUND \ | 87 | #define GUITAR_SOUND Q__NOTE(_E5), Q__NOTE(_A5), Q__NOTE(_D6), Q__NOTE(_G6), |
| 164 | Q__NOTE(_A5 ), \ | ||
| 165 | Q__NOTE(_CS6), \ | ||
| 166 | Q__NOTE(_E6 ), \ | ||
| 167 | Q__NOTE(_A6 ), | ||
| 168 | |||
| 169 | #define CHROMATIC_SOUND \ | ||
| 170 | Q__NOTE(_A5 ), \ | ||
| 171 | Q__NOTE(_AS5 ), \ | ||
| 172 | Q__NOTE(_B5), \ | ||
| 173 | Q__NOTE(_C6 ), \ | ||
| 174 | Q__NOTE(_CS6 ), | ||
| 175 | |||
| 176 | #define MAJOR_SOUND \ | ||
| 177 | Q__NOTE(_A5 ), \ | ||
| 178 | Q__NOTE(_B5 ), \ | ||
| 179 | Q__NOTE(_CS6), \ | ||
| 180 | Q__NOTE(_D6 ), \ | ||
| 181 | Q__NOTE(_E6 ), | ||
| 182 | |||
| 183 | #define MINOR_SOUND \ | ||
| 184 | Q__NOTE(_A5 ), \ | ||
| 185 | Q__NOTE(_B5 ), \ | ||
| 186 | Q__NOTE(_C6 ), \ | ||
| 187 | Q__NOTE(_D6 ), \ | ||
| 188 | Q__NOTE(_E6 ), | ||
| 189 | |||
| 190 | #define GUITAR_SOUND \ | ||
| 191 | Q__NOTE(_E5 ), \ | ||
| 192 | Q__NOTE(_A5), \ | ||
| 193 | Q__NOTE(_D6 ), \ | ||
| 194 | Q__NOTE(_G6 ), | ||
| 195 | |||
| 196 | #define VIOLIN_SOUND \ | ||
| 197 | Q__NOTE(_G5 ), \ | ||
| 198 | Q__NOTE(_D6), \ | ||
| 199 | Q__NOTE(_A6 ), \ | ||
| 200 | Q__NOTE(_E7 ), | ||
| 201 | |||
| 202 | #define CAPS_LOCK_ON_SOUND \ | ||
| 203 | E__NOTE(_A3), \ | ||
| 204 | E__NOTE(_B3), | ||
| 205 | |||
| 206 | #define CAPS_LOCK_OFF_SOUND \ | ||
| 207 | E__NOTE(_B3), \ | ||
| 208 | E__NOTE(_A3), | ||
| 209 | |||
| 210 | #define SCROLL_LOCK_ON_SOUND \ | ||
| 211 | E__NOTE(_D4), \ | ||
| 212 | E__NOTE(_E4), | ||
| 213 | |||
| 214 | #define SCROLL_LOCK_OFF_SOUND \ | ||
| 215 | E__NOTE(_E4), \ | ||
| 216 | E__NOTE(_D4), | ||
| 217 | |||
| 218 | #define NUM_LOCK_ON_SOUND \ | ||
| 219 | E__NOTE(_D5), \ | ||
| 220 | E__NOTE(_E5), | ||
| 221 | |||
| 222 | #define NUM_LOCK_OFF_SOUND \ | ||
| 223 | E__NOTE(_E5), \ | ||
| 224 | E__NOTE(_D5), | ||
| 225 | |||
| 226 | #define AG_NORM_SOUND \ | ||
| 227 | E__NOTE(_A5), \ | ||
| 228 | E__NOTE(_A5), | ||
| 229 | |||
| 230 | #define AG_SWAP_SOUND \ | ||
| 231 | SD_NOTE(_B5), \ | ||
| 232 | SD_NOTE(_A5), \ | ||
| 233 | SD_NOTE(_B5), \ | ||
| 234 | SD_NOTE(_A5), | ||
| 235 | |||
| 236 | #define UNICODE_WINDOWS \ | ||
| 237 | E__NOTE(_B5), \ | ||
| 238 | S__NOTE(_E6), | ||
| 239 | |||
| 240 | #define UNICODE_LINUX \ | ||
| 241 | E__NOTE(_E6), \ | ||
| 242 | S__NOTE(_B5), | ||
| 243 | |||
| 244 | |||
| 245 | #define TERMINAL_SOUND \ | ||
| 246 | E__NOTE(_C5 ) | ||
| 247 | 88 | ||
| 89 | #define VIOLIN_SOUND Q__NOTE(_G5), Q__NOTE(_D6), Q__NOTE(_A6), Q__NOTE(_E7), | ||
| 90 | |||
| 91 | #define CAPS_LOCK_ON_SOUND E__NOTE(_A3), E__NOTE(_B3), | ||
| 92 | |||
| 93 | #define CAPS_LOCK_OFF_SOUND E__NOTE(_B3), E__NOTE(_A3), | ||
| 94 | |||
| 95 | #define SCROLL_LOCK_ON_SOUND E__NOTE(_D4), E__NOTE(_E4), | ||
| 96 | |||
| 97 | #define SCROLL_LOCK_OFF_SOUND E__NOTE(_E4), E__NOTE(_D4), | ||
| 98 | |||
| 99 | #define NUM_LOCK_ON_SOUND E__NOTE(_D5), E__NOTE(_E5), | ||
| 100 | |||
| 101 | #define NUM_LOCK_OFF_SOUND E__NOTE(_E5), E__NOTE(_D5), | ||
| 102 | |||
| 103 | #define AG_NORM_SOUND E__NOTE(_A5), E__NOTE(_A5), | ||
| 104 | |||
| 105 | #define AG_SWAP_SOUND SD_NOTE(_B5), SD_NOTE(_A5), SD_NOTE(_B5), SD_NOTE(_A5), | ||
| 106 | |||
| 107 | #define UNICODE_WINDOWS E__NOTE(_B5), S__NOTE(_E6), | ||
| 108 | |||
| 109 | #define UNICODE_LINUX E__NOTE(_E6), S__NOTE(_B5), | ||
| 110 | |||
| 111 | #define TERMINAL_SOUND E__NOTE(_C5) | ||
| 248 | 112 | ||
| 249 | /* Title: La Campanella | 113 | /* Title: La Campanella |
| 250 | * Author/Composer: Frank Lizst | 114 | * Author/Composer: Frank Lizst |
| 251 | + License: Public Domain | 115 | + License: Public Domain |
| 252 | */ | 116 | */ |
| 253 | #define CAMPANELLA \ | 117 | #define CAMPANELLA \ |
| 254 | Q__NOTE(_DS4), E__NOTE(_DS4), E__NOTE(_DS5), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_DS5), E__NOTE(_DS5), \ | 118 | Q__NOTE(_DS4), E__NOTE(_DS4), E__NOTE(_DS5), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_CS5), E__NOTE(_CS5), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_GS4), E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_G4), E__NOTE(_G4), E__NOTE(_DS6), Q__NOTE(_GS4), E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_DS4), E__NOTE(_DS4), E__NOTE(_DS6), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_E5), E__NOTE(_E5), E__NOTE(_DS6), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_CS5), E__NOTE(_CS5), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_GS4), E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_G4), E__NOTE(_G4), E__NOTE(_DS6), Q__NOTE(_GS4), E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_AS4), \ |
| 255 | E__NOTE(_DS6), Q__NOTE(_CS5), E__NOTE(_CS5), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), \ | 119 | E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_DS4), E__NOTE(_DS4), E__NOTE(_DS5), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_DS6), E__NOTE(_DS6), E__NOTE(_DS7), Q__NOTE(_DS6), E__NOTE(_DS6), E__NOTE(_DS7), Q__NOTE(_CS6), E__NOTE(_CS6), E__NOTE(_DS7), Q__NOTE(_B5), E__NOTE(_B5), E__NOTE(_DS7), Q__NOTE(_B5), E__NOTE(_B5), E__NOTE(_DS7), Q__NOTE(_AS5), E__NOTE(_AS5), E__NOTE(_DS7), Q__NOTE(_GS5), E__NOTE(_GS5), E__NOTE(_DS7), Q__NOTE(_G5), E__NOTE(_G5), E__NOTE(_DS7), Q__NOTE(_GS5), E__NOTE(_GS5), E__NOTE(_DS7), Q__NOTE(_AS5), E__NOTE(_AS5), E__NOTE(_DS7), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS7), W__NOTE(_DS6), W__NOTE(_GS5), |
| 256 | Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_GS4), \ | ||
| 257 | E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_G4), E__NOTE(_G4), E__NOTE(_DS6), Q__NOTE(_GS4), E__NOTE(_GS4), \ | ||
| 258 | E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_DS4), E__NOTE(_DS4), E__NOTE(_DS6), \ | ||
| 259 | Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_E5), E__NOTE(_E5), E__NOTE(_DS6), Q__NOTE(_DS5), \ | ||
| 260 | E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_CS5), E__NOTE(_CS5), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), \ | ||
| 261 | E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), \ | ||
| 262 | Q__NOTE(_GS4), E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_G4), E__NOTE(_G4), E__NOTE(_DS6), Q__NOTE(_GS4), \ | ||
| 263 | E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_DS4), E__NOTE(_DS4), \ | ||
| 264 | E__NOTE(_DS5), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_DS6), E__NOTE(_DS6), E__NOTE(_DS7), \ | ||
| 265 | Q__NOTE(_DS6), E__NOTE(_DS6), E__NOTE(_DS7), Q__NOTE(_CS6), E__NOTE(_CS6), E__NOTE(_DS7), Q__NOTE(_B5), \ | ||
| 266 | E__NOTE(_B5), E__NOTE(_DS7), Q__NOTE(_B5), E__NOTE(_B5), E__NOTE(_DS7), Q__NOTE(_AS5), E__NOTE(_AS5), \ | ||
| 267 | E__NOTE(_DS7), Q__NOTE(_GS5), E__NOTE(_GS5), E__NOTE(_DS7), Q__NOTE(_G5), E__NOTE(_G5), E__NOTE(_DS7), \ | ||
| 268 | Q__NOTE(_GS5), E__NOTE(_GS5), E__NOTE(_DS7), Q__NOTE(_AS5), E__NOTE(_AS5), E__NOTE(_DS7), Q__NOTE(_DS5), \ | ||
| 269 | E__NOTE(_DS5), E__NOTE(_DS7), W__NOTE(_DS6), W__NOTE(_GS5), | ||
| 270 | |||
| 271 | |||
| 272 | |||
| 273 | 120 | ||
| 274 | /* Title: Fantaisie-Impromptu | 121 | /* Title: Fantaisie-Impromptu |
| 275 | * Author/Composer: Chopin | 122 | * Author/Composer: Chopin |
| 276 | * License: Public Domain | 123 | * License: Public Domain |
| 277 | */ | 124 | */ |
| 278 | #define FANTASIE_IMPROMPTU \ | 125 | #define FANTASIE_IMPROMPTU \ |
| 279 | E__NOTE(_GS4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), \ | 126 | E__NOTE(_GS4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_GS4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_A4), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_FS5), E__NOTE(_A5), E__NOTE(_CS6), E__NOTE(_DS6), E__NOTE(_B6), E__NOTE(_A6), E__NOTE(_GS6), E__NOTE(_FS6), E__NOTE(_E6), E__NOTE(_DS6), E__NOTE(_FS6), E__NOTE(_CS6), E__NOTE(_C5), E__NOTE(_DS6), E__NOTE(_A5), E__NOTE(_GS5), E__NOTE(_FS5), E__NOTE(_A5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_FS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_DS5), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_B4), E__NOTE(_A4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), \ |
| 280 | E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_GS4), E__NOTE(_A4), \ | 127 | E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_GS4), E__NOTE(_AS4), E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_DS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_REST), E__NOTE(_DS5), E__NOTE(_B5), E__NOTE(_AS5), E__NOTE(_GS5), E__NOTE(_REST), E__NOTE(_E6), E__NOTE(_DS6), E__NOTE(_CS6), E__NOTE(_B5), E__NOTE(_AS5), E__NOTE(_GS5), E__NOTE(_REST), E__NOTE(_AS5), WD_NOTE(_GS5), |
| 281 | E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), \ | ||
| 282 | E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_A4), E__NOTE(_CS5), E__NOTE(_DS5), \ | ||
| 283 | E__NOTE(_FS5), E__NOTE(_A5), E__NOTE(_CS6), E__NOTE(_DS6), E__NOTE(_B6), E__NOTE(_A6), E__NOTE(_GS6), E__NOTE(_FS6), \ | ||
| 284 | E__NOTE(_E6), E__NOTE(_DS6), E__NOTE(_FS6), E__NOTE(_CS6), E__NOTE(_C5), E__NOTE(_DS6), E__NOTE(_A5), E__NOTE(_GS5), \ | ||
| 285 | E__NOTE(_FS5), E__NOTE(_A5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_FS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_DS5), \ | ||
| 286 | E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_B4), E__NOTE(_A4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_A4), E__NOTE(_GS4), \ | ||
| 287 | E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), \ | ||
| 288 | E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_GS4), E__NOTE(_AS4), E__NOTE(_GS4), E__NOTE(_REST), \ | ||
| 289 | E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), \ | ||
| 290 | E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_DS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_REST), E__NOTE(_DS5), \ | ||
| 291 | E__NOTE(_B5), E__NOTE(_AS5), E__NOTE(_GS5), E__NOTE(_REST), E__NOTE(_E6), E__NOTE(_DS6), E__NOTE(_CS6), E__NOTE(_B5), \ | ||
| 292 | E__NOTE(_AS5), E__NOTE(_GS5), E__NOTE(_REST), E__NOTE(_AS5), WD_NOTE(_GS5), | ||
| 293 | |||
| 294 | 128 | ||
| 295 | /* Title: Nocturne Op. 9 No. 1 in B flat minor | 129 | /* Title: Nocturne Op. 9 No. 1 in B flat minor |
| 296 | * Author/Composer: Chopin | 130 | * Author/Composer: Chopin |
| 297 | License: Public Domain | 131 | License: Public Domain |
| 298 | */ | 132 | */ |
| 299 | #define NOCTURNE_OP_9_NO_1 \ | 133 | #define NOCTURNE_OP_9_NO_1 \ |
| 300 | H__NOTE(_BF5), H__NOTE(_C6), H__NOTE(_DF6), H__NOTE(_A5), H__NOTE(_BF5), H__NOTE(_GF5), W__NOTE(_F5), W__NOTE(_F5), W__NOTE(_F5), \ | 134 | H__NOTE(_BF5), H__NOTE(_C6), H__NOTE(_DF6), H__NOTE(_A5), H__NOTE(_BF5), H__NOTE(_GF5), W__NOTE(_F5), W__NOTE(_F5), W__NOTE(_F5), W__NOTE(_F5), H__NOTE(_GF5), H__NOTE(_F5), H__NOTE(_EF5), H__NOTE(_C5), B__NOTE(_DF5), W__NOTE(_BF4), Q__NOTE(_BF5), Q__NOTE(_C6), Q__NOTE(_DF6), Q__NOTE(_A5), Q__NOTE(_BF5), Q__NOTE(_A5), Q__NOTE(_GS5), Q__NOTE(_A5), Q__NOTE(_C6), Q__NOTE(_BF5), Q__NOTE(_GF5), Q__NOTE(_F5), Q__NOTE(_GF5), Q__NOTE(_E5), Q__NOTE(_F5), Q__NOTE(_BF5), Q__NOTE(_A5), Q__NOTE(_AF5), Q__NOTE(_G5), Q__NOTE(_GF5), Q__NOTE(_F5), Q__NOTE(_E5), Q__NOTE(_EF5), Q__NOTE(_D5), Q__NOTE(_DF5), Q__NOTE(_C5), Q__NOTE(_DF5), Q__NOTE(_C5), Q__NOTE(_B4), Q__NOTE(_C5), Q__NOTE(_F5), Q__NOTE(_E5), Q__NOTE(_EF5), B__NOTE(_DF5), W__NOTE(_BF4), W__NOTE(_BF5), W__NOTE(_BF5), W__NOTE(_BF5), BD_NOTE(_AF5), W__NOTE(_DF5), H__NOTE(_BF4), H__NOTE(_C5), H__NOTE(_DF5), H__NOTE(_GF5), H__NOTE(_GF5), BD_NOTE(_F5), W__NOTE(_EF5), H__NOTE(_F5), H__NOTE(_EF5), H__NOTE(_DF5), H__NOTE(_A4), B__NOTE(_AF4), \ |
| 301 | W__NOTE(_F5), H__NOTE(_GF5), H__NOTE(_F5), H__NOTE(_EF5), H__NOTE(_C5), B__NOTE(_DF5), W__NOTE(_BF4), Q__NOTE(_BF5), \ | 135 | W__NOTE(_DF5), W__NOTE(_EF5), H__NOTE(_F5), H__NOTE(_EF5), H__NOTE(_DF5), H__NOTE(_EF5), BD_NOTE(_F5), |
| 302 | Q__NOTE(_C6), Q__NOTE(_DF6), Q__NOTE(_A5), Q__NOTE(_BF5), Q__NOTE(_A5), Q__NOTE(_GS5), Q__NOTE(_A5), Q__NOTE(_C6), \ | ||
| 303 | Q__NOTE(_BF5), Q__NOTE(_GF5), Q__NOTE(_F5), Q__NOTE(_GF5), Q__NOTE(_E5), Q__NOTE(_F5), Q__NOTE(_BF5), Q__NOTE(_A5), \ | ||
| 304 | Q__NOTE(_AF5), Q__NOTE(_G5), Q__NOTE(_GF5), Q__NOTE(_F5), Q__NOTE(_E5), Q__NOTE(_EF5), Q__NOTE(_D5), Q__NOTE(_DF5), \ | ||
| 305 | Q__NOTE(_C5), Q__NOTE(_DF5), Q__NOTE(_C5), Q__NOTE(_B4), Q__NOTE(_C5), Q__NOTE(_F5), Q__NOTE(_E5), Q__NOTE(_EF5), \ | ||
| 306 | B__NOTE(_DF5), W__NOTE(_BF4), W__NOTE(_BF5), W__NOTE(_BF5), W__NOTE(_BF5), BD_NOTE(_AF5), W__NOTE(_DF5), H__NOTE(_BF4), \ | ||
| 307 | H__NOTE(_C5), H__NOTE(_DF5), H__NOTE(_GF5), H__NOTE(_GF5), BD_NOTE(_F5), W__NOTE(_EF5), H__NOTE(_F5), H__NOTE(_EF5), \ | ||
| 308 | H__NOTE(_DF5), H__NOTE(_A4), B__NOTE(_AF4), W__NOTE(_DF5), W__NOTE(_EF5), H__NOTE(_F5), H__NOTE(_EF5), H__NOTE(_DF5), \ | ||
| 309 | H__NOTE(_EF5), BD_NOTE(_F5), | ||
| 310 | |||
| 311 | 136 | ||
| 312 | /* Removed sounds | 137 | /* Removed sounds |
| 313 | + This list is here solely for compatibility, so that removed songs don't just break things | 138 | + This list is here solely for compatibility, so that removed songs don't just break things |
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c index 94147ccb6..53a65e4e3 100644 --- a/quantum/audio/voices.c +++ b/quantum/audio/voices.c | |||
| @@ -19,40 +19,33 @@ | |||
| 19 | 19 | ||
| 20 | // these are imported from audio.c | 20 | // these are imported from audio.c |
| 21 | extern uint16_t envelope_index; | 21 | extern uint16_t envelope_index; |
| 22 | extern float note_timbre; | 22 | extern float note_timbre; |
| 23 | extern float polyphony_rate; | 23 | extern float polyphony_rate; |
| 24 | extern bool glissando; | 24 | extern bool glissando; |
| 25 | 25 | ||
| 26 | voice_type voice = default_voice; | 26 | voice_type voice = default_voice; |
| 27 | 27 | ||
| 28 | void set_voice(voice_type v) { | 28 | void set_voice(voice_type v) { voice = v; } |
| 29 | voice = v; | ||
| 30 | } | ||
| 31 | 29 | ||
| 32 | void voice_iterate() { | 30 | void voice_iterate() { voice = (voice + 1) % number_of_voices; } |
| 33 | voice = (voice + 1) % number_of_voices; | ||
| 34 | } | ||
| 35 | 31 | ||
| 36 | void voice_deiterate() { | 32 | void voice_deiterate() { voice = (voice - 1 + number_of_voices) % number_of_voices; } |
| 37 | voice = (voice - 1 + number_of_voices) % number_of_voices; | ||
| 38 | } | ||
| 39 | 33 | ||
| 40 | float voice_envelope(float frequency) { | 34 | float voice_envelope(float frequency) { |
| 41 | // envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz | 35 | // envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz |
| 42 | __attribute__ ((unused)) | 36 | __attribute__((unused)) uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency)); |
| 43 | uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency)); | ||
| 44 | 37 | ||
| 45 | switch (voice) { | 38 | switch (voice) { |
| 46 | case default_voice: | 39 | case default_voice: |
| 47 | glissando = false; | 40 | glissando = false; |
| 48 | note_timbre = TIMBRE_50; | 41 | note_timbre = TIMBRE_50; |
| 49 | polyphony_rate = 0; | 42 | polyphony_rate = 0; |
| 50 | break; | 43 | break; |
| 51 | 44 | ||
| 52 | #ifdef AUDIO_VOICES | 45 | #ifdef AUDIO_VOICES |
| 53 | 46 | ||
| 54 | case something: | 47 | case something: |
| 55 | glissando = false; | 48 | glissando = false; |
| 56 | polyphony_rate = 0; | 49 | polyphony_rate = 0; |
| 57 | switch (compensated_index) { | 50 | switch (compensated_index) { |
| 58 | case 0 ... 9: | 51 | case 0 ... 9: |
| @@ -74,25 +67,23 @@ float voice_envelope(float frequency) { | |||
| 74 | break; | 67 | break; |
| 75 | 68 | ||
| 76 | case drums: | 69 | case drums: |
| 77 | glissando = false; | 70 | glissando = false; |
| 78 | polyphony_rate = 0; | 71 | polyphony_rate = 0; |
| 79 | // switch (compensated_index) { | 72 | // switch (compensated_index) { |
| 80 | // case 0 ... 10: | 73 | // case 0 ... 10: |
| 81 | // note_timbre = 0.5; | 74 | // note_timbre = 0.5; |
| 82 | // break; | 75 | // break; |
| 83 | // case 11 ... 20: | 76 | // case 11 ... 20: |
| 84 | // note_timbre = 0.5 * (21 - compensated_index) / 10; | 77 | // note_timbre = 0.5 * (21 - compensated_index) / 10; |
| 85 | // break; | 78 | // break; |
| 86 | // default: | 79 | // default: |
| 87 | // note_timbre = 0; | 80 | // note_timbre = 0; |
| 88 | // break; | 81 | // break; |
| 89 | // } | 82 | // } |
| 90 | // frequency = (rand() % (int)(frequency * 1.2 - frequency)) + (frequency * 0.8); | 83 | // frequency = (rand() % (int)(frequency * 1.2 - frequency)) + (frequency * 0.8); |
| 91 | 84 | ||
| 92 | if (frequency < 80.0) { | 85 | if (frequency < 80.0) { |
| 93 | |||
| 94 | } else if (frequency < 160.0) { | 86 | } else if (frequency < 160.0) { |
| 95 | |||
| 96 | // Bass drum: 60 - 100 Hz | 87 | // Bass drum: 60 - 100 Hz |
| 97 | frequency = (rand() % (int)(40)) + 60; | 88 | frequency = (rand() % (int)(40)) + 60; |
| 98 | switch (envelope_index) { | 89 | switch (envelope_index) { |
| @@ -108,8 +99,6 @@ float voice_envelope(float frequency) { | |||
| 108 | } | 99 | } |
| 109 | 100 | ||
| 110 | } else if (frequency < 320.0) { | 101 | } else if (frequency < 320.0) { |
| 111 | |||
| 112 | |||
| 113 | // Snare drum: 1 - 2 KHz | 102 | // Snare drum: 1 - 2 KHz |
| 114 | frequency = (rand() % (int)(1000)) + 1000; | 103 | frequency = (rand() % (int)(1000)) + 1000; |
| 115 | switch (envelope_index) { | 104 | switch (envelope_index) { |
| @@ -125,7 +114,6 @@ float voice_envelope(float frequency) { | |||
| 125 | } | 114 | } |
| 126 | 115 | ||
| 127 | } else if (frequency < 640.0) { | 116 | } else if (frequency < 640.0) { |
| 128 | |||
| 129 | // Closed Hi-hat: 3 - 5 KHz | 117 | // Closed Hi-hat: 3 - 5 KHz |
| 130 | frequency = (rand() % (int)(2000)) + 3000; | 118 | frequency = (rand() % (int)(2000)) + 3000; |
| 131 | switch (envelope_index) { | 119 | switch (envelope_index) { |
| @@ -141,7 +129,6 @@ float voice_envelope(float frequency) { | |||
| 141 | } | 129 | } |
| 142 | 130 | ||
| 143 | } else if (frequency < 1280.0) { | 131 | } else if (frequency < 1280.0) { |
| 144 | |||
| 145 | // Open Hi-hat: 3 - 5 KHz | 132 | // Open Hi-hat: 3 - 5 KHz |
| 146 | frequency = (rand() % (int)(2000)) + 3000; | 133 | frequency = (rand() % (int)(2000)) + 3000; |
| 147 | switch (envelope_index) { | 134 | switch (envelope_index) { |
| @@ -155,141 +142,138 @@ float voice_envelope(float frequency) { | |||
| 155 | note_timbre = 0; | 142 | note_timbre = 0; |
| 156 | break; | 143 | break; |
| 157 | } | 144 | } |
| 158 | |||
| 159 | } | 145 | } |
| 160 | break; | 146 | break; |
| 161 | case butts_fader: | 147 | case butts_fader: |
| 162 | glissando = true; | 148 | glissando = true; |
| 163 | polyphony_rate = 0; | 149 | polyphony_rate = 0; |
| 164 | switch (compensated_index) { | 150 | switch (compensated_index) { |
| 165 | case 0 ... 9: | 151 | case 0 ... 9: |
| 166 | frequency = frequency / 4; | 152 | frequency = frequency / 4; |
| 167 | note_timbre = TIMBRE_12; | 153 | note_timbre = TIMBRE_12; |
| 168 | break; | 154 | break; |
| 169 | 155 | ||
| 170 | case 10 ... 19: | 156 | case 10 ... 19: |
| 171 | frequency = frequency / 2; | 157 | frequency = frequency / 2; |
| 172 | note_timbre = TIMBRE_12; | 158 | note_timbre = TIMBRE_12; |
| 173 | break; | 159 | break; |
| 174 | 160 | ||
| 175 | case 20 ... 200: | 161 | case 20 ... 200: |
| 176 | note_timbre = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2)*.125; | 162 | note_timbre = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2) * .125; |
| 177 | break; | 163 | break; |
| 178 | 164 | ||
| 179 | default: | 165 | default: |
| 180 | note_timbre = 0; | 166 | note_timbre = 0; |
| 181 | break; | 167 | break; |
| 182 | } | 168 | } |
| 183 | break; | 169 | break; |
| 184 | |||
| 185 | // case octave_crunch: | ||
| 186 | // polyphony_rate = 0; | ||
| 187 | // switch (compensated_index) { | ||
| 188 | // case 0 ... 9: | ||
| 189 | // case 20 ... 24: | ||
| 190 | // case 30 ... 32: | ||
| 191 | // frequency = frequency / 2; | ||
| 192 | // note_timbre = TIMBRE_12; | ||
| 193 | // break; | ||
| 194 | |||
| 195 | // case 10 ... 19: | ||
| 196 | // case 25 ... 29: | ||
| 197 | // case 33 ... 35: | ||
| 198 | // frequency = frequency * 2; | ||
| 199 | // note_timbre = TIMBRE_12; | ||
| 200 | // break; | ||
| 201 | 170 | ||
| 202 | // default: | 171 | // case octave_crunch: |
| 203 | // note_timbre = TIMBRE_12; | 172 | // polyphony_rate = 0; |
| 204 | // break; | 173 | // switch (compensated_index) { |
| 205 | // } | 174 | // case 0 ... 9: |
| 206 | // break; | 175 | // case 20 ... 24: |
| 176 | // case 30 ... 32: | ||
| 177 | // frequency = frequency / 2; | ||
| 178 | // note_timbre = TIMBRE_12; | ||
| 179 | // break; | ||
| 180 | |||
| 181 | // case 10 ... 19: | ||
| 182 | // case 25 ... 29: | ||
| 183 | // case 33 ... 35: | ||
| 184 | // frequency = frequency * 2; | ||
| 185 | // note_timbre = TIMBRE_12; | ||
| 186 | // break; | ||
| 187 | |||
| 188 | // default: | ||
| 189 | // note_timbre = TIMBRE_12; | ||
| 190 | // break; | ||
| 191 | // } | ||
| 192 | // break; | ||
| 207 | 193 | ||
| 208 | case duty_osc: | 194 | case duty_osc: |
| 209 | // This slows the loop down a substantial amount, so higher notes may freeze | 195 | // This slows the loop down a substantial amount, so higher notes may freeze |
| 210 | glissando = true; | 196 | glissando = true; |
| 211 | polyphony_rate = 0; | 197 | polyphony_rate = 0; |
| 212 | switch (compensated_index) { | 198 | switch (compensated_index) { |
| 213 | default: | 199 | default: |
| 214 | #define OCS_SPEED 10 | 200 | # define OCS_SPEED 10 |
| 215 | #define OCS_AMP .25 | 201 | # define OCS_AMP .25 |
| 216 | // sine wave is slow | 202 | // sine wave is slow |
| 217 | // note_timbre = (sin((float)compensated_index/10000*OCS_SPEED) * OCS_AMP / 2) + .5; | 203 | // note_timbre = (sin((float)compensated_index/10000*OCS_SPEED) * OCS_AMP / 2) + .5; |
| 218 | // triangle wave is a bit faster | 204 | // triangle wave is a bit faster |
| 219 | note_timbre = (float)abs((compensated_index*OCS_SPEED % 3000) - 1500) * ( OCS_AMP / 1500 ) + (1 - OCS_AMP) / 2; | 205 | note_timbre = (float)abs((compensated_index * OCS_SPEED % 3000) - 1500) * (OCS_AMP / 1500) + (1 - OCS_AMP) / 2; |
| 220 | break; | 206 | break; |
| 221 | } | 207 | } |
| 222 | break; | 208 | break; |
| 223 | 209 | ||
| 224 | case duty_octave_down: | 210 | case duty_octave_down: |
| 225 | glissando = true; | 211 | glissando = true; |
| 226 | polyphony_rate = 0; | 212 | polyphony_rate = 0; |
| 227 | note_timbre = (envelope_index % 2) * .125 + .375 * 2; | 213 | note_timbre = (envelope_index % 2) * .125 + .375 * 2; |
| 228 | if ((envelope_index % 4) == 0) | 214 | if ((envelope_index % 4) == 0) note_timbre = 0.5; |
| 229 | note_timbre = 0.5; | 215 | if ((envelope_index % 8) == 0) note_timbre = 0; |
| 230 | if ((envelope_index % 8) == 0) | ||
| 231 | note_timbre = 0; | ||
| 232 | break; | 216 | break; |
| 233 | case delayed_vibrato: | 217 | case delayed_vibrato: |
| 234 | glissando = true; | 218 | glissando = true; |
| 235 | polyphony_rate = 0; | 219 | polyphony_rate = 0; |
| 236 | note_timbre = TIMBRE_50; | 220 | note_timbre = TIMBRE_50; |
| 237 | #define VOICE_VIBRATO_DELAY 150 | 221 | # define VOICE_VIBRATO_DELAY 150 |
| 238 | #define VOICE_VIBRATO_SPEED 50 | 222 | # define VOICE_VIBRATO_SPEED 50 |
| 239 | switch (compensated_index) { | 223 | switch (compensated_index) { |
| 240 | case 0 ... VOICE_VIBRATO_DELAY: | 224 | case 0 ... VOICE_VIBRATO_DELAY: |
| 241 | break; | 225 | break; |
| 242 | default: | 226 | default: |
| 243 | frequency = frequency * vibrato_lut[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1))/1000*VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)]; | 227 | frequency = frequency * vibrato_lut[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1)) / 1000 * VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)]; |
| 244 | break; | 228 | break; |
| 245 | } | 229 | } |
| 246 | break; | 230 | break; |
| 247 | // case delayed_vibrato_octave: | 231 | // case delayed_vibrato_octave: |
| 248 | // polyphony_rate = 0; | 232 | // polyphony_rate = 0; |
| 249 | // if ((envelope_index % 2) == 1) { | 233 | // if ((envelope_index % 2) == 1) { |
| 250 | // note_timbre = 0.55; | 234 | // note_timbre = 0.55; |
| 251 | // } else { | 235 | // } else { |
| 252 | // note_timbre = 0.45; | 236 | // note_timbre = 0.45; |
| 253 | // } | 237 | // } |
| 254 | // #define VOICE_VIBRATO_DELAY 150 | 238 | // #define VOICE_VIBRATO_DELAY 150 |
| 255 | // #define VOICE_VIBRATO_SPEED 50 | 239 | // #define VOICE_VIBRATO_SPEED 50 |
| 256 | // switch (compensated_index) { | 240 | // switch (compensated_index) { |
| 257 | // case 0 ... VOICE_VIBRATO_DELAY: | 241 | // case 0 ... VOICE_VIBRATO_DELAY: |
| 258 | // break; | 242 | // break; |
| 259 | // default: | 243 | // default: |
| 260 | // frequency = frequency * VIBRATO_LUT[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1))/1000*VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)]; | 244 | // frequency = frequency * VIBRATO_LUT[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1))/1000*VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)]; |
| 261 | // break; | 245 | // break; |
| 262 | // } | 246 | // } |
| 263 | // break; | 247 | // break; |
| 264 | // case duty_fifth_down: | 248 | // case duty_fifth_down: |
| 265 | // note_timbre = 0.5; | 249 | // note_timbre = 0.5; |
| 266 | // if ((envelope_index % 3) == 0) | 250 | // if ((envelope_index % 3) == 0) |
| 267 | // note_timbre = 0.75; | 251 | // note_timbre = 0.75; |
| 268 | // break; | 252 | // break; |
| 269 | // case duty_fourth_down: | 253 | // case duty_fourth_down: |
| 270 | // note_timbre = 0.0; | 254 | // note_timbre = 0.0; |
| 271 | // if ((envelope_index % 12) == 0) | 255 | // if ((envelope_index % 12) == 0) |
| 272 | // note_timbre = 0.75; | 256 | // note_timbre = 0.75; |
| 273 | // if (((envelope_index % 12) % 4) != 1) | 257 | // if (((envelope_index % 12) % 4) != 1) |
| 274 | // note_timbre = 0.75; | 258 | // note_timbre = 0.75; |
| 275 | // break; | 259 | // break; |
| 276 | // case duty_third_down: | 260 | // case duty_third_down: |
| 277 | // note_timbre = 0.5; | 261 | // note_timbre = 0.5; |
| 278 | // if ((envelope_index % 5) == 0) | 262 | // if ((envelope_index % 5) == 0) |
| 279 | // note_timbre = 0.75; | 263 | // note_timbre = 0.75; |
| 280 | // break; | 264 | // break; |
| 281 | // case duty_fifth_third_down: | 265 | // case duty_fifth_third_down: |
| 282 | // note_timbre = 0.5; | 266 | // note_timbre = 0.5; |
| 283 | // if ((envelope_index % 5) == 0) | 267 | // if ((envelope_index % 5) == 0) |
| 284 | // note_timbre = 0.75; | 268 | // note_timbre = 0.75; |
| 285 | // if ((envelope_index % 3) == 0) | 269 | // if ((envelope_index % 3) == 0) |
| 286 | // note_timbre = 0.25; | 270 | // note_timbre = 0.25; |
| 287 | // break; | 271 | // break; |
| 288 | 272 | ||
| 289 | #endif | 273 | #endif |
| 290 | 274 | ||
| 291 | default: | 275 | default: |
| 292 | break; | 276 | break; |
| 293 | } | 277 | } |
| 294 | 278 | ||
| 295 | return frequency; | 279 | return frequency; |
diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h index 1cf33095a..0c45b0720 100644 --- a/quantum/audio/voices.h +++ b/quantum/audio/voices.h | |||
| @@ -16,19 +16,19 @@ | |||
| 16 | #include <stdint.h> | 16 | #include <stdint.h> |
| 17 | #include <stdbool.h> | 17 | #include <stdbool.h> |
| 18 | #if defined(__AVR__) | 18 | #if defined(__AVR__) |
| 19 | #include <avr/io.h> | 19 | # include <avr/io.h> |
| 20 | #endif | 20 | #endif |
| 21 | #include "wait.h" | 21 | #include "wait.h" |
| 22 | #include "luts.h" | 22 | #include "luts.h" |
| 23 | 23 | ||
| 24 | #ifndef VOICES_H | 24 | #ifndef VOICES_H |
| 25 | #define VOICES_H | 25 | # define VOICES_H |
| 26 | 26 | ||
| 27 | float voice_envelope(float frequency); | 27 | float voice_envelope(float frequency); |
| 28 | 28 | ||
| 29 | typedef enum { | 29 | typedef enum { |
| 30 | default_voice, | 30 | default_voice, |
| 31 | #ifdef AUDIO_VOICES | 31 | # ifdef AUDIO_VOICES |
| 32 | something, | 32 | something, |
| 33 | drums, | 33 | drums, |
| 34 | butts_fader, | 34 | butts_fader, |
| @@ -36,13 +36,13 @@ typedef enum { | |||
| 36 | duty_osc, | 36 | duty_osc, |
| 37 | duty_octave_down, | 37 | duty_octave_down, |
| 38 | delayed_vibrato, | 38 | delayed_vibrato, |
| 39 | // delayed_vibrato_octave, | 39 | // delayed_vibrato_octave, |
| 40 | // duty_fifth_down, | 40 | // duty_fifth_down, |
| 41 | // duty_fourth_down, | 41 | // duty_fourth_down, |
| 42 | // duty_third_down, | 42 | // duty_third_down, |
| 43 | // duty_fifth_third_down, | 43 | // duty_fifth_third_down, |
| 44 | #endif | 44 | # endif |
| 45 | number_of_voices // important that this is last | 45 | number_of_voices // important that this is last |
| 46 | } voice_type; | 46 | } voice_type; |
| 47 | 47 | ||
| 48 | void set_voice(voice_type v); | 48 | void set_voice(voice_type v); |
diff --git a/quantum/audio/wave.h b/quantum/audio/wave.h index f15615dd1..48210a944 100644 --- a/quantum/audio/wave.h +++ b/quantum/audio/wave.h | |||
| @@ -20,262 +20,17 @@ | |||
| 20 | 20 | ||
| 21 | #define SINE_LENGTH 2048 | 21 | #define SINE_LENGTH 2048 |
| 22 | 22 | ||
| 23 | const uint8_t sinewave[] PROGMEM= //2048 values | 23 | const uint8_t sinewave[] PROGMEM = // 2048 values |
| 24 | { | 24 | {0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x82, 0x82, 0x83, 0x83, 0x83, 0x84, 0x84, 0x85, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x87, 0x88, 0x88, 0x88, 0x89, 0x89, 0x8a, 0x8a, 0x8a, 0x8b, 0x8b, 0x8c, 0x8c, 0x8c, 0x8d, 0x8d, 0x8e, 0x8e, 0x8e, 0x8f, 0x8f, 0x8f, 0x90, 0x90, 0x91, 0x91, 0x91, 0x92, 0x92, 0x93, 0x93, 0x93, 0x94, 0x94, 0x95, 0x95, 0x95, 0x96, 0x96, 0x96, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99, 0x9a, 0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f, 0xa0, 0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa5, 0xa6, 0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0xa9, 0xa9, 0xa9, 0xaa, 0xaa, 0xaa, 0xab, 0xab, 0xac, 0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae, 0xaf, 0xaf, 0xb0, 0xb0, 0xb0, 0xb1, 0xb1, 0xb1, 0xb2, 0xb2, 0xb2, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4, 0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7, 0xb7, 0xb8, 0xb8, 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xba, 0xbb, |
| 25 | 0x80,0x80,0x80,0x81,0x81,0x81,0x82,0x82, | 25 | 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0, 0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3, 0xc3, 0xc4, 0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6, 0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9, 0xc9, 0xca, 0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc, 0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf, 0xcf, 0xcf, 0xd0, 0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2, 0xd2, 0xd3, 0xd3, 0xd3, 0xd4, 0xd4, 0xd4, 0xd5, 0xd5, 0xd5, 0xd5, 0xd6, 0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8, 0xd9, 0xd9, 0xd9, 0xd9, 0xda, 0xda, 0xda, 0xda, 0xdb, 0xdb, 0xdb, 0xdc, 0xdc, 0xdc, 0xdc, 0xdd, 0xdd, 0xdd, 0xdd, 0xde, 0xde, 0xde, 0xde, 0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe0, 0xe1, 0xe1, 0xe1, 0xe1, 0xe2, 0xe2, 0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe5, 0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7, 0xe7, 0xe7, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, |
| 26 | 0x83,0x83,0x83,0x84,0x84,0x85,0x85,0x85, | 26 | 0xe9, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea, 0xea, 0xea, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xec, 0xec, 0xed, 0xed, 0xed, 0xed, 0xed, 0xee, 0xee, 0xee, 0xee, 0xee, 0xef, 0xef, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, |
| 27 | 0x86,0x86,0x87,0x87,0x87,0x88,0x88,0x88, | 27 | 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, |
| 28 | 0x89,0x89,0x8a,0x8a,0x8a,0x8b,0x8b,0x8c, | 28 | 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xef, 0xef, 0xef, 0xef, 0xef, 0xee, 0xee, 0xee, 0xee, 0xee, 0xed, 0xed, 0xed, 0xed, 0xed, 0xec, 0xec, 0xec, 0xec, 0xec, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xea, 0xea, 0xea, 0xea, 0xea, 0xe9, 0xe9, 0xe9, 0xe9, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe7, 0xe7, 0xe7, 0xe7, 0xe6, 0xe6, 0xe6, 0xe6, 0xe5, 0xe5, 0xe5, 0xe5, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe3, 0xe3, 0xe3, 0xe3, 0xe2, 0xe2, 0xe2, 0xe2, 0xe1, 0xe1, 0xe1, 0xe1, 0xe0, 0xe0, 0xe0, 0xe0, 0xdf, 0xdf, 0xdf, 0xde, 0xde, 0xde, 0xde, 0xdd, 0xdd, 0xdd, 0xdd, 0xdc, 0xdc, 0xdc, 0xdc, 0xdb, 0xdb, 0xdb, 0xda, 0xda, 0xda, 0xda, 0xd9, 0xd9, 0xd9, 0xd9, 0xd8, 0xd8, 0xd8, 0xd7, 0xd7, 0xd7, 0xd7, 0xd6, 0xd6, 0xd6, 0xd5, 0xd5, 0xd5, 0xd5, 0xd4, 0xd4, 0xd4, |
| 29 | 0x8c,0x8c,0x8d,0x8d,0x8e,0x8e,0x8e,0x8f, | 29 | 0xd3, 0xd3, 0xd3, 0xd2, 0xd2, 0xd2, 0xd2, 0xd1, 0xd1, 0xd1, 0xd0, 0xd0, 0xd0, 0xcf, 0xcf, 0xcf, 0xcf, 0xce, 0xce, 0xce, 0xcd, 0xcd, 0xcd, 0xcc, 0xcc, 0xcc, 0xcb, 0xcb, 0xcb, 0xcb, 0xca, 0xca, 0xca, 0xc9, 0xc9, 0xc9, 0xc8, 0xc8, 0xc8, 0xc7, 0xc7, 0xc7, 0xc6, 0xc6, 0xc6, 0xc5, 0xc5, 0xc5, 0xc4, 0xc4, 0xc4, 0xc3, 0xc3, 0xc3, 0xc2, 0xc2, 0xc2, 0xc1, 0xc1, 0xc1, 0xc0, 0xc0, 0xc0, 0xbf, 0xbf, 0xbf, 0xbe, 0xbe, 0xbe, 0xbd, 0xbd, 0xbd, 0xbc, 0xbc, 0xbc, 0xbb, 0xbb, 0xbb, 0xba, 0xba, 0xba, 0xb9, 0xb9, 0xb8, 0xb8, 0xb8, 0xb7, 0xb7, 0xb7, 0xb6, 0xb6, 0xb6, 0xb5, 0xb5, 0xb5, 0xb4, 0xb4, 0xb4, 0xb3, 0xb3, 0xb2, 0xb2, 0xb2, 0xb1, 0xb1, 0xb1, 0xb0, 0xb0, 0xb0, 0xaf, 0xaf, 0xae, 0xae, 0xae, 0xad, 0xad, 0xad, 0xac, 0xac, 0xac, 0xab, 0xab, 0xaa, 0xaa, 0xaa, 0xa9, 0xa9, 0xa9, 0xa8, 0xa8, 0xa7, 0xa7, 0xa7, 0xa6, 0xa6, 0xa6, 0xa5, 0xa5, 0xa5, 0xa4, 0xa4, 0xa3, 0xa3, 0xa3, 0xa2, 0xa2, 0xa2, 0xa1, 0xa1, 0xa0, 0xa0, 0xa0, 0x9f, 0x9f, 0x9e, 0x9e, 0x9e, 0x9d, |
| 30 | 0x8f,0x8f,0x90,0x90,0x91,0x91,0x91,0x92, | 30 | 0x9d, 0x9d, 0x9c, 0x9c, 0x9b, 0x9b, 0x9b, 0x9a, 0x9a, 0x9a, 0x99, 0x99, 0x98, 0x98, 0x98, 0x97, 0x97, 0x96, 0x96, 0x96, 0x95, 0x95, 0x95, 0x94, 0x94, 0x93, 0x93, 0x93, 0x92, 0x92, 0x91, 0x91, 0x91, 0x90, 0x90, 0x8f, 0x8f, 0x8f, 0x8e, 0x8e, 0x8e, 0x8d, 0x8d, 0x8c, 0x8c, 0x8c, 0x8b, 0x8b, 0x8a, 0x8a, 0x8a, 0x89, 0x89, 0x88, 0x88, 0x88, 0x87, 0x87, 0x87, 0x86, 0x86, 0x85, 0x85, 0x85, 0x84, 0x84, 0x83, 0x83, 0x83, 0x82, 0x82, 0x81, 0x81, 0x81, 0x80, 0x80, 0x80, 0x7f, 0x7f, 0x7e, 0x7e, 0x7e, 0x7d, 0x7d, 0x7c, 0x7c, 0x7c, 0x7b, 0x7b, 0x7a, 0x7a, 0x7a, 0x79, 0x79, 0x78, 0x78, 0x78, 0x77, 0x77, 0x77, 0x76, 0x76, 0x75, 0x75, 0x75, 0x74, 0x74, 0x73, 0x73, 0x73, 0x72, 0x72, 0x71, 0x71, 0x71, 0x70, 0x70, 0x70, 0x6f, 0x6f, 0x6e, 0x6e, 0x6e, 0x6d, 0x6d, 0x6c, 0x6c, 0x6c, 0x6b, 0x6b, 0x6a, 0x6a, 0x6a, 0x69, 0x69, 0x69, 0x68, 0x68, 0x67, 0x67, 0x67, 0x66, 0x66, 0x65, 0x65, 0x65, 0x64, 0x64, 0x64, 0x63, 0x63, 0x62, 0x62, 0x62, 0x61, 0x61, 0x61, 0x60, |
| 31 | 0x92,0x93,0x93,0x93,0x94,0x94,0x95,0x95, | 31 | 0x60, 0x5f, 0x5f, 0x5f, 0x5e, 0x5e, 0x5d, 0x5d, 0x5d, 0x5c, 0x5c, 0x5c, 0x5b, 0x5b, 0x5a, 0x5a, 0x5a, 0x59, 0x59, 0x59, 0x58, 0x58, 0x58, 0x57, 0x57, 0x56, 0x56, 0x56, 0x55, 0x55, 0x55, 0x54, 0x54, 0x53, 0x53, 0x53, 0x52, 0x52, 0x52, 0x51, 0x51, 0x51, 0x50, 0x50, 0x4f, 0x4f, 0x4f, 0x4e, 0x4e, 0x4e, 0x4d, 0x4d, 0x4d, 0x4c, 0x4c, 0x4b, 0x4b, 0x4b, 0x4a, 0x4a, 0x4a, 0x49, 0x49, 0x49, 0x48, 0x48, 0x48, 0x47, 0x47, 0x47, 0x46, 0x46, 0x45, 0x45, 0x45, 0x44, 0x44, 0x44, 0x43, 0x43, 0x43, 0x42, 0x42, 0x42, 0x41, 0x41, 0x41, 0x40, 0x40, 0x40, 0x3f, 0x3f, 0x3f, 0x3e, 0x3e, 0x3e, 0x3d, 0x3d, 0x3d, 0x3c, 0x3c, 0x3c, 0x3b, 0x3b, 0x3b, 0x3a, 0x3a, 0x3a, 0x39, 0x39, 0x39, 0x38, 0x38, 0x38, 0x37, 0x37, 0x37, 0x36, 0x36, 0x36, 0x35, 0x35, 0x35, 0x34, 0x34, 0x34, 0x34, 0x33, 0x33, 0x33, 0x32, 0x32, 0x32, 0x31, 0x31, 0x31, 0x30, 0x30, 0x30, 0x30, 0x2f, 0x2f, 0x2f, 0x2e, 0x2e, 0x2e, 0x2d, 0x2d, 0x2d, 0x2d, 0x2c, 0x2c, 0x2c, 0x2b, 0x2b, 0x2b, 0x2a, 0x2a, |
| 32 | 0x95,0x96,0x96,0x96,0x97,0x97,0x98,0x98, | 32 | 0x2a, 0x2a, 0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x27, 0x27, 0x27, 0x26, 0x26, 0x26, 0x26, 0x25, 0x25, 0x25, 0x25, 0x24, 0x24, 0x24, 0x23, 0x23, 0x23, 0x23, 0x22, 0x22, 0x22, 0x22, 0x21, 0x21, 0x21, 0x21, 0x20, 0x20, 0x20, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e, 0x1e, 0x1e, 0x1e, 0x1d, 0x1d, 0x1d, 0x1d, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1a, 0x1a, 0x1a, 0x1a, 0x19, 0x19, 0x19, 0x19, 0x18, 0x18, 0x18, 0x18, 0x17, 0x17, 0x17, 0x17, 0x17, 0x16, 0x16, 0x16, 0x16, 0x15, 0x15, 0x15, 0x15, 0x15, 0x14, 0x14, 0x14, 0x14, 0x14, 0x13, 0x13, 0x13, 0x13, 0x13, 0x12, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x10, 0x10, 0x10, 0x10, 0x10, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xe, 0xe, 0xe, 0xe, 0xe, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xc, 0xc, 0xc, 0xc, 0xc, 0xc, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0x8, 0x8, 0x8, 0x8, 0x8, |
| 33 | 0x98,0x99,0x99,0x9a,0x9a,0x9a,0x9b,0x9b, | 33 | 0x8, 0x8, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, |
| 34 | 0x9b,0x9c,0x9c,0x9d,0x9d,0x9d,0x9e,0x9e, | 34 | 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xc, 0xc, 0xc, 0xc, 0xc, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xe, 0xe, 0xe, 0xe, 0xe, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17, |
| 35 | 0x9e,0x9f,0x9f,0xa0,0xa0,0xa0,0xa1,0xa1, | 35 | 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a, 0x1a, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d, 0x1d, 0x1d, 0x1e, 0x1e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24, 0x25, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x2a, 0x2a, 0x2a, 0x2a, 0x2b, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x2f, 0x30, 0x30, 0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32, 0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x34, 0x35, 0x35, 0x35, 0x36, 0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38, 0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b, 0x3b, 0x3c, 0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e, 0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x46, |
| 36 | 0xa2,0xa2,0xa2,0xa3,0xa3,0xa3,0xa4,0xa4, | 36 | 0x46, 0x47, 0x47, 0x47, 0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a, 0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x4e, 0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59, 0x59, 0x5a, 0x5a, 0x5a, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c, 0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5f, 0x5f, 0x5f, 0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65, 0x65, 0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b, 0x6c, 0x6c, 0x6c, 0x6d, 0x6d, 0x6e, 0x6e, 0x6e, 0x6f, 0x6f, 0x70, 0x70, 0x70, 0x71, 0x71, 0x71, 0x72, 0x72, 0x73, 0x73, 0x73, 0x74, 0x74, 0x75, 0x75, 0x75, 0x76, 0x76, 0x77, 0x77, 0x77, 0x78, 0x78, 0x78, 0x79, 0x79, 0x7a, 0x7a, 0x7a, 0x7b, 0x7b, 0x7c, 0x7c, 0x7c, 0x7d, 0x7d, 0x7e, 0x7e, 0x7e, 0x7f, 0x7f}; |
| 37 | 0xa5,0xa5,0xa5,0xa6,0xa6,0xa6,0xa7,0xa7, | ||
| 38 | 0xa7,0xa8,0xa8,0xa9,0xa9,0xa9,0xaa,0xaa, | ||
| 39 | 0xaa,0xab,0xab,0xac,0xac,0xac,0xad,0xad, | ||
| 40 | 0xad,0xae,0xae,0xae,0xaf,0xaf,0xb0,0xb0, | ||
| 41 | 0xb0,0xb1,0xb1,0xb1,0xb2,0xb2,0xb2,0xb3, | ||
| 42 | 0xb3,0xb4,0xb4,0xb4,0xb5,0xb5,0xb5,0xb6, | ||
| 43 | 0xb6,0xb6,0xb7,0xb7,0xb7,0xb8,0xb8,0xb8, | ||
| 44 | 0xb9,0xb9,0xba,0xba,0xba,0xbb,0xbb,0xbb, | ||
| 45 | 0xbc,0xbc,0xbc,0xbd,0xbd,0xbd,0xbe,0xbe, | ||
| 46 | 0xbe,0xbf,0xbf,0xbf,0xc0,0xc0,0xc0,0xc1, | ||
| 47 | 0xc1,0xc1,0xc2,0xc2,0xc2,0xc3,0xc3,0xc3, | ||
| 48 | 0xc4,0xc4,0xc4,0xc5,0xc5,0xc5,0xc6,0xc6, | ||
| 49 | 0xc6,0xc7,0xc7,0xc7,0xc8,0xc8,0xc8,0xc9, | ||
| 50 | 0xc9,0xc9,0xca,0xca,0xca,0xcb,0xcb,0xcb, | ||
| 51 | 0xcb,0xcc,0xcc,0xcc,0xcd,0xcd,0xcd,0xce, | ||
| 52 | 0xce,0xce,0xcf,0xcf,0xcf,0xcf,0xd0,0xd0, | ||
| 53 | 0xd0,0xd1,0xd1,0xd1,0xd2,0xd2,0xd2,0xd2, | ||
| 54 | 0xd3,0xd3,0xd3,0xd4,0xd4,0xd4,0xd5,0xd5, | ||
| 55 | 0xd5,0xd5,0xd6,0xd6,0xd6,0xd7,0xd7,0xd7, | ||
| 56 | 0xd7,0xd8,0xd8,0xd8,0xd9,0xd9,0xd9,0xd9, | ||
| 57 | 0xda,0xda,0xda,0xda,0xdb,0xdb,0xdb,0xdc, | ||
| 58 | 0xdc,0xdc,0xdc,0xdd,0xdd,0xdd,0xdd,0xde, | ||
| 59 | 0xde,0xde,0xde,0xdf,0xdf,0xdf,0xe0,0xe0, | ||
| 60 | 0xe0,0xe0,0xe1,0xe1,0xe1,0xe1,0xe2,0xe2, | ||
| 61 | 0xe2,0xe2,0xe3,0xe3,0xe3,0xe3,0xe4,0xe4, | ||
| 62 | 0xe4,0xe4,0xe4,0xe5,0xe5,0xe5,0xe5,0xe6, | ||
| 63 | 0xe6,0xe6,0xe6,0xe7,0xe7,0xe7,0xe7,0xe8, | ||
| 64 | 0xe8,0xe8,0xe8,0xe8,0xe9,0xe9,0xe9,0xe9, | ||
| 65 | 0xea,0xea,0xea,0xea,0xea,0xeb,0xeb,0xeb, | ||
| 66 | 0xeb,0xeb,0xec,0xec,0xec,0xec,0xec,0xed, | ||
| 67 | 0xed,0xed,0xed,0xed,0xee,0xee,0xee,0xee, | ||
| 68 | 0xee,0xef,0xef,0xef,0xef,0xef,0xf0,0xf0, | ||
| 69 | 0xf0,0xf0,0xf0,0xf0,0xf1,0xf1,0xf1,0xf1, | ||
| 70 | 0xf1,0xf2,0xf2,0xf2,0xf2,0xf2,0xf2,0xf3, | ||
| 71 | 0xf3,0xf3,0xf3,0xf3,0xf3,0xf4,0xf4,0xf4, | ||
| 72 | 0xf4,0xf4,0xf4,0xf5,0xf5,0xf5,0xf5,0xf5, | ||
| 73 | 0xf5,0xf5,0xf6,0xf6,0xf6,0xf6,0xf6,0xf6, | ||
| 74 | 0xf6,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7, | ||
| 75 | 0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8, | ||
| 76 | 0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9, | ||
| 77 | 0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa, | ||
| 78 | 0xfa,0xfa,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb, | ||
| 79 | 0xfb,0xfb,0xfb,0xfb,0xfc,0xfc,0xfc,0xfc, | ||
| 80 | 0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc, | ||
| 81 | 0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd, | ||
| 82 | 0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfe,0xfe, | ||
| 83 | 0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe, | ||
| 84 | 0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe, | ||
| 85 | 0xfe,0xfe,0xfe,0xfe,0xff,0xff,0xff,0xff, | ||
| 86 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 87 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 88 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 89 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 90 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 91 | 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, | ||
| 92 | 0xff,0xff,0xff,0xff,0xff,0xfe,0xfe,0xfe, | ||
| 93 | 0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe, | ||
| 94 | 0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe, | ||
| 95 | 0xfe,0xfe,0xfe,0xfd,0xfd,0xfd,0xfd,0xfd, | ||
| 96 | 0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd, | ||
| 97 | 0xfd,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc, | ||
| 98 | 0xfc,0xfc,0xfc,0xfc,0xfc,0xfb,0xfb,0xfb, | ||
| 99 | 0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfa, | ||
| 100 | 0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa, | ||
| 101 | 0xfa,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9, | ||
| 102 | 0xf9,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8, | ||
| 103 | 0xf8,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7, | ||
| 104 | 0xf6,0xf6,0xf6,0xf6,0xf6,0xf6,0xf6,0xf5, | ||
| 105 | 0xf5,0xf5,0xf5,0xf5,0xf5,0xf5,0xf4,0xf4, | ||
| 106 | 0xf4,0xf4,0xf4,0xf4,0xf3,0xf3,0xf3,0xf3, | ||
| 107 | 0xf3,0xf3,0xf2,0xf2,0xf2,0xf2,0xf2,0xf2, | ||
| 108 | 0xf1,0xf1,0xf1,0xf1,0xf1,0xf0,0xf0,0xf0, | ||
| 109 | 0xf0,0xf0,0xf0,0xef,0xef,0xef,0xef,0xef, | ||
| 110 | 0xee,0xee,0xee,0xee,0xee,0xed,0xed,0xed, | ||
| 111 | 0xed,0xed,0xec,0xec,0xec,0xec,0xec,0xeb, | ||
| 112 | 0xeb,0xeb,0xeb,0xeb,0xea,0xea,0xea,0xea, | ||
| 113 | 0xea,0xe9,0xe9,0xe9,0xe9,0xe8,0xe8,0xe8, | ||
| 114 | 0xe8,0xe8,0xe7,0xe7,0xe7,0xe7,0xe6,0xe6, | ||
| 115 | 0xe6,0xe6,0xe5,0xe5,0xe5,0xe5,0xe4,0xe4, | ||
| 116 | 0xe4,0xe4,0xe4,0xe3,0xe3,0xe3,0xe3,0xe2, | ||
| 117 | 0xe2,0xe2,0xe2,0xe1,0xe1,0xe1,0xe1,0xe0, | ||
| 118 | 0xe0,0xe0,0xe0,0xdf,0xdf,0xdf,0xde,0xde, | ||
| 119 | 0xde,0xde,0xdd,0xdd,0xdd,0xdd,0xdc,0xdc, | ||
| 120 | 0xdc,0xdc,0xdb,0xdb,0xdb,0xda,0xda,0xda, | ||
| 121 | 0xda,0xd9,0xd9,0xd9,0xd9,0xd8,0xd8,0xd8, | ||
| 122 | 0xd7,0xd7,0xd7,0xd7,0xd6,0xd6,0xd6,0xd5, | ||
| 123 | 0xd5,0xd5,0xd5,0xd4,0xd4,0xd4,0xd3,0xd3, | ||
| 124 | 0xd3,0xd2,0xd2,0xd2,0xd2,0xd1,0xd1,0xd1, | ||
| 125 | 0xd0,0xd0,0xd0,0xcf,0xcf,0xcf,0xcf,0xce, | ||
| 126 | 0xce,0xce,0xcd,0xcd,0xcd,0xcc,0xcc,0xcc, | ||
| 127 | 0xcb,0xcb,0xcb,0xcb,0xca,0xca,0xca,0xc9, | ||
| 128 | 0xc9,0xc9,0xc8,0xc8,0xc8,0xc7,0xc7,0xc7, | ||
| 129 | 0xc6,0xc6,0xc6,0xc5,0xc5,0xc5,0xc4,0xc4, | ||
| 130 | 0xc4,0xc3,0xc3,0xc3,0xc2,0xc2,0xc2,0xc1, | ||
| 131 | 0xc1,0xc1,0xc0,0xc0,0xc0,0xbf,0xbf,0xbf, | ||
| 132 | 0xbe,0xbe,0xbe,0xbd,0xbd,0xbd,0xbc,0xbc, | ||
| 133 | 0xbc,0xbb,0xbb,0xbb,0xba,0xba,0xba,0xb9, | ||
| 134 | 0xb9,0xb8,0xb8,0xb8,0xb7,0xb7,0xb7,0xb6, | ||
| 135 | 0xb6,0xb6,0xb5,0xb5,0xb5,0xb4,0xb4,0xb4, | ||
| 136 | 0xb3,0xb3,0xb2,0xb2,0xb2,0xb1,0xb1,0xb1, | ||
| 137 | 0xb0,0xb0,0xb0,0xaf,0xaf,0xae,0xae,0xae, | ||
| 138 | 0xad,0xad,0xad,0xac,0xac,0xac,0xab,0xab, | ||
| 139 | 0xaa,0xaa,0xaa,0xa9,0xa9,0xa9,0xa8,0xa8, | ||
| 140 | 0xa7,0xa7,0xa7,0xa6,0xa6,0xa6,0xa5,0xa5, | ||
| 141 | 0xa5,0xa4,0xa4,0xa3,0xa3,0xa3,0xa2,0xa2, | ||
| 142 | 0xa2,0xa1,0xa1,0xa0,0xa0,0xa0,0x9f,0x9f, | ||
| 143 | 0x9e,0x9e,0x9e,0x9d,0x9d,0x9d,0x9c,0x9c, | ||
| 144 | 0x9b,0x9b,0x9b,0x9a,0x9a,0x9a,0x99,0x99, | ||
| 145 | 0x98,0x98,0x98,0x97,0x97,0x96,0x96,0x96, | ||
| 146 | 0x95,0x95,0x95,0x94,0x94,0x93,0x93,0x93, | ||
| 147 | 0x92,0x92,0x91,0x91,0x91,0x90,0x90,0x8f, | ||
| 148 | 0x8f,0x8f,0x8e,0x8e,0x8e,0x8d,0x8d,0x8c, | ||
| 149 | 0x8c,0x8c,0x8b,0x8b,0x8a,0x8a,0x8a,0x89, | ||
| 150 | 0x89,0x88,0x88,0x88,0x87,0x87,0x87,0x86, | ||
| 151 | 0x86,0x85,0x85,0x85,0x84,0x84,0x83,0x83, | ||
| 152 | 0x83,0x82,0x82,0x81,0x81,0x81,0x80,0x80, | ||
| 153 | 0x80,0x7f,0x7f,0x7e,0x7e,0x7e,0x7d,0x7d, | ||
| 154 | 0x7c,0x7c,0x7c,0x7b,0x7b,0x7a,0x7a,0x7a, | ||
| 155 | 0x79,0x79,0x78,0x78,0x78,0x77,0x77,0x77, | ||
| 156 | 0x76,0x76,0x75,0x75,0x75,0x74,0x74,0x73, | ||
| 157 | 0x73,0x73,0x72,0x72,0x71,0x71,0x71,0x70, | ||
| 158 | 0x70,0x70,0x6f,0x6f,0x6e,0x6e,0x6e,0x6d, | ||
| 159 | 0x6d,0x6c,0x6c,0x6c,0x6b,0x6b,0x6a,0x6a, | ||
| 160 | 0x6a,0x69,0x69,0x69,0x68,0x68,0x67,0x67, | ||
| 161 | 0x67,0x66,0x66,0x65,0x65,0x65,0x64,0x64, | ||
| 162 | 0x64,0x63,0x63,0x62,0x62,0x62,0x61,0x61, | ||
| 163 | 0x61,0x60,0x60,0x5f,0x5f,0x5f,0x5e,0x5e, | ||
| 164 | 0x5d,0x5d,0x5d,0x5c,0x5c,0x5c,0x5b,0x5b, | ||
| 165 | 0x5a,0x5a,0x5a,0x59,0x59,0x59,0x58,0x58, | ||
| 166 | 0x58,0x57,0x57,0x56,0x56,0x56,0x55,0x55, | ||
| 167 | 0x55,0x54,0x54,0x53,0x53,0x53,0x52,0x52, | ||
| 168 | 0x52,0x51,0x51,0x51,0x50,0x50,0x4f,0x4f, | ||
| 169 | 0x4f,0x4e,0x4e,0x4e,0x4d,0x4d,0x4d,0x4c, | ||
| 170 | 0x4c,0x4b,0x4b,0x4b,0x4a,0x4a,0x4a,0x49, | ||
| 171 | 0x49,0x49,0x48,0x48,0x48,0x47,0x47,0x47, | ||
| 172 | 0x46,0x46,0x45,0x45,0x45,0x44,0x44,0x44, | ||
| 173 | 0x43,0x43,0x43,0x42,0x42,0x42,0x41,0x41, | ||
| 174 | 0x41,0x40,0x40,0x40,0x3f,0x3f,0x3f,0x3e, | ||
| 175 | 0x3e,0x3e,0x3d,0x3d,0x3d,0x3c,0x3c,0x3c, | ||
| 176 | 0x3b,0x3b,0x3b,0x3a,0x3a,0x3a,0x39,0x39, | ||
| 177 | 0x39,0x38,0x38,0x38,0x37,0x37,0x37,0x36, | ||
| 178 | 0x36,0x36,0x35,0x35,0x35,0x34,0x34,0x34, | ||
| 179 | 0x34,0x33,0x33,0x33,0x32,0x32,0x32,0x31, | ||
| 180 | 0x31,0x31,0x30,0x30,0x30,0x30,0x2f,0x2f, | ||
| 181 | 0x2f,0x2e,0x2e,0x2e,0x2d,0x2d,0x2d,0x2d, | ||
| 182 | 0x2c,0x2c,0x2c,0x2b,0x2b,0x2b,0x2a,0x2a, | ||
| 183 | 0x2a,0x2a,0x29,0x29,0x29,0x28,0x28,0x28, | ||
| 184 | 0x28,0x27,0x27,0x27,0x26,0x26,0x26,0x26, | ||
| 185 | 0x25,0x25,0x25,0x25,0x24,0x24,0x24,0x23, | ||
| 186 | 0x23,0x23,0x23,0x22,0x22,0x22,0x22,0x21, | ||
| 187 | 0x21,0x21,0x21,0x20,0x20,0x20,0x1f,0x1f, | ||
| 188 | 0x1f,0x1f,0x1e,0x1e,0x1e,0x1e,0x1d,0x1d, | ||
| 189 | 0x1d,0x1d,0x1c,0x1c,0x1c,0x1c,0x1b,0x1b, | ||
| 190 | 0x1b,0x1b,0x1b,0x1a,0x1a,0x1a,0x1a,0x19, | ||
| 191 | 0x19,0x19,0x19,0x18,0x18,0x18,0x18,0x17, | ||
| 192 | 0x17,0x17,0x17,0x17,0x16,0x16,0x16,0x16, | ||
| 193 | 0x15,0x15,0x15,0x15,0x15,0x14,0x14,0x14, | ||
| 194 | 0x14,0x14,0x13,0x13,0x13,0x13,0x13,0x12, | ||
| 195 | 0x12,0x12,0x12,0x12,0x11,0x11,0x11,0x11, | ||
| 196 | 0x11,0x10,0x10,0x10,0x10,0x10,0xf,0xf, | ||
| 197 | 0xf,0xf,0xf,0xf,0xe,0xe,0xe,0xe, | ||
| 198 | 0xe,0xd,0xd,0xd,0xd,0xd,0xd,0xc, | ||
| 199 | 0xc,0xc,0xc,0xc,0xc,0xb,0xb,0xb, | ||
| 200 | 0xb,0xb,0xb,0xa,0xa,0xa,0xa,0xa, | ||
| 201 | 0xa,0xa,0x9,0x9,0x9,0x9,0x9,0x9, | ||
| 202 | 0x9,0x8,0x8,0x8,0x8,0x8,0x8,0x8, | ||
| 203 | 0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7, | ||
| 204 | 0x6,0x6,0x6,0x6,0x6,0x6,0x6,0x6, | ||
| 205 | 0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5, | ||
| 206 | 0x5,0x5,0x4,0x4,0x4,0x4,0x4,0x4, | ||
| 207 | 0x4,0x4,0x4,0x4,0x3,0x3,0x3,0x3, | ||
| 208 | 0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3, | ||
| 209 | 0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2, | ||
| 210 | 0x2,0x2,0x2,0x2,0x2,0x2,0x1,0x1, | ||
| 211 | 0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1, | ||
| 212 | 0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1, | ||
| 213 | 0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0, | ||
| 214 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 215 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 216 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 217 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 218 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 219 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | ||
| 220 | 0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x1, | ||
| 221 | 0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1, | ||
| 222 | 0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1, | ||
| 223 | 0x1,0x1,0x1,0x2,0x2,0x2,0x2,0x2, | ||
| 224 | 0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2, | ||
| 225 | 0x2,0x3,0x3,0x3,0x3,0x3,0x3,0x3, | ||
| 226 | 0x3,0x3,0x3,0x3,0x3,0x4,0x4,0x4, | ||
| 227 | 0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x5, | ||
| 228 | 0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5, | ||
| 229 | 0x5,0x6,0x6,0x6,0x6,0x6,0x6,0x6, | ||
| 230 | 0x6,0x7,0x7,0x7,0x7,0x7,0x7,0x7, | ||
| 231 | 0x7,0x8,0x8,0x8,0x8,0x8,0x8,0x8, | ||
| 232 | 0x9,0x9,0x9,0x9,0x9,0x9,0x9,0xa, | ||
| 233 | 0xa,0xa,0xa,0xa,0xa,0xa,0xb,0xb, | ||
| 234 | 0xb,0xb,0xb,0xb,0xc,0xc,0xc,0xc, | ||
| 235 | 0xc,0xc,0xd,0xd,0xd,0xd,0xd,0xd, | ||
| 236 | 0xe,0xe,0xe,0xe,0xe,0xf,0xf,0xf, | ||
| 237 | 0xf,0xf,0xf,0x10,0x10,0x10,0x10,0x10, | ||
| 238 | 0x11,0x11,0x11,0x11,0x11,0x12,0x12,0x12, | ||
| 239 | 0x12,0x12,0x13,0x13,0x13,0x13,0x13,0x14, | ||
| 240 | 0x14,0x14,0x14,0x14,0x15,0x15,0x15,0x15, | ||
| 241 | 0x15,0x16,0x16,0x16,0x16,0x17,0x17,0x17, | ||
| 242 | 0x17,0x17,0x18,0x18,0x18,0x18,0x19,0x19, | ||
| 243 | 0x19,0x19,0x1a,0x1a,0x1a,0x1a,0x1b,0x1b, | ||
| 244 | 0x1b,0x1b,0x1b,0x1c,0x1c,0x1c,0x1c,0x1d, | ||
| 245 | 0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1e,0x1f, | ||
| 246 | 0x1f,0x1f,0x1f,0x20,0x20,0x20,0x21,0x21, | ||
| 247 | 0x21,0x21,0x22,0x22,0x22,0x22,0x23,0x23, | ||
| 248 | 0x23,0x23,0x24,0x24,0x24,0x25,0x25,0x25, | ||
| 249 | 0x25,0x26,0x26,0x26,0x26,0x27,0x27,0x27, | ||
| 250 | 0x28,0x28,0x28,0x28,0x29,0x29,0x29,0x2a, | ||
| 251 | 0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2c,0x2c, | ||
| 252 | 0x2c,0x2d,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e, | ||
| 253 | 0x2f,0x2f,0x2f,0x30,0x30,0x30,0x30,0x31, | ||
| 254 | 0x31,0x31,0x32,0x32,0x32,0x33,0x33,0x33, | ||
| 255 | 0x34,0x34,0x34,0x34,0x35,0x35,0x35,0x36, | ||
| 256 | 0x36,0x36,0x37,0x37,0x37,0x38,0x38,0x38, | ||
| 257 | 0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3b,0x3b, | ||
| 258 | 0x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3e, | ||
| 259 | 0x3e,0x3e,0x3f,0x3f,0x3f,0x40,0x40,0x40, | ||
| 260 | 0x41,0x41,0x41,0x42,0x42,0x42,0x43,0x43, | ||
| 261 | 0x43,0x44,0x44,0x44,0x45,0x45,0x45,0x46, | ||
| 262 | 0x46,0x47,0x47,0x47,0x48,0x48,0x48,0x49, | ||
| 263 | 0x49,0x49,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b, | ||
| 264 | 0x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e, | ||
| 265 | 0x4f,0x4f,0x4f,0x50,0x50,0x51,0x51,0x51, | ||
| 266 | 0x52,0x52,0x52,0x53,0x53,0x53,0x54,0x54, | ||
| 267 | 0x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57, | ||
| 268 | 0x58,0x58,0x58,0x59,0x59,0x59,0x5a,0x5a, | ||
| 269 | 0x5a,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d, | ||
| 270 | 0x5d,0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60, | ||
| 271 | 0x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63, | ||
| 272 | 0x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66, | ||
| 273 | 0x67,0x67,0x67,0x68,0x68,0x69,0x69,0x69, | ||
| 274 | 0x6a,0x6a,0x6a,0x6b,0x6b,0x6c,0x6c,0x6c, | ||
| 275 | 0x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x70, | ||
| 276 | 0x70,0x70,0x71,0x71,0x71,0x72,0x72,0x73, | ||
| 277 | 0x73,0x73,0x74,0x74,0x75,0x75,0x75,0x76, | ||
| 278 | 0x76,0x77,0x77,0x77,0x78,0x78,0x78,0x79, | ||
| 279 | 0x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7c,0x7c, | ||
| 280 | 0x7c,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f | ||
| 281 | }; | ||
