aboutsummaryrefslogtreecommitdiff
path: root/quantum/audio
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/audio')
-rw-r--r--quantum/audio/audio.c607
-rw-r--r--quantum/audio/audio.h89
-rw-r--r--quantum/audio/musical_notes.h217
-rw-r--r--quantum/audio/song_list.h117
-rw-r--r--quantum/audio/vibrato_lut.h28
-rw-r--r--quantum/audio/voices.c60
-rw-r--r--quantum/audio/voices.h21
-rw-r--r--quantum/audio/wave.h265
8 files changed, 1404 insertions, 0 deletions
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c
new file mode 100644
index 000000000..3225557ba
--- /dev/null
+++ b/quantum/audio/audio.c
@@ -0,0 +1,607 @@
1#include <stdio.h>
2#include <string.h>
3#include <math.h>
4#include <avr/pgmspace.h>
5#include <avr/interrupt.h>
6#include <avr/io.h>
7#include "print.h"
8#include "audio.h"
9#include "keymap_common.h"
10
11#include "eeconfig.h"
12
13#ifdef VIBRATO_ENABLE
14 #include "vibrato_lut.h"
15#endif
16
17#define PI 3.14159265
18
19#define CPU_PRESCALER 8
20
21#ifdef PWM_AUDIO
22 #include "wave.h"
23 #define SAMPLE_DIVIDER 39
24 #define SAMPLE_RATE (2000000.0/SAMPLE_DIVIDER/2048)
25 // Resistor value of 1/ (2 * PI * 10nF * (2000000 hertz / SAMPLE_DIVIDER / 10)) for 10nF cap
26
27 float places[8] = {0, 0, 0, 0, 0, 0, 0, 0};
28 uint16_t place_int = 0;
29 bool repeat = true;
30#endif
31
32void delay_us(int count) {
33 while(count--) {
34 _delay_us(1);
35 }
36}
37
38int voices = 0;
39int voice_place = 0;
40float frequency = 0;
41int volume = 0;
42long position = 0;
43
44float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0};
45int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0};
46bool sliding = false;
47
48int max = 0xFF;
49float sum = 0;
50float place = 0;
51
52uint8_t * sample;
53uint16_t sample_length = 0;
54// float freq = 0;
55
56bool notes = false;
57bool note = false;
58float note_frequency = 0;
59float note_length = 0;
60float note_tempo = TEMPO_DEFAULT;
61float note_timbre = TIMBRE_DEFAULT;
62uint16_t note_position = 0;
63float (* notes_pointer)[][2];
64uint16_t notes_count;
65bool notes_repeat;
66float notes_rest;
67bool note_resting = false;
68
69uint8_t current_note = 0;
70uint8_t rest_counter = 0;
71
72#ifdef VIBRATO_ENABLE
73float vibrato_counter = 0;
74float vibrato_strength = .5;
75float vibrato_rate = 0.125;
76#endif
77
78float polyphony_rate = 0;
79
80bool inited = false;
81
82audio_config_t audio_config;
83
84uint16_t envelope_index = 0;
85
86void audio_toggle(void) {
87 audio_config.enable ^= 1;
88 eeconfig_write_audio(audio_config.raw);
89}
90
91void audio_on(void) {
92 audio_config.enable = 1;
93 eeconfig_write_audio(audio_config.raw);
94}
95
96void audio_off(void) {
97 audio_config.enable = 0;
98 eeconfig_write_audio(audio_config.raw);
99}
100
101#ifdef VIBRATO_ENABLE
102// Vibrato rate functions
103
104void set_vibrato_rate(float rate) {
105 vibrato_rate = rate;
106}
107
108void increase_vibrato_rate(float change) {
109 vibrato_rate *= change;
110}
111
112void decrease_vibrato_rate(float change) {
113 vibrato_rate /= change;
114}
115
116#ifdef VIBRATO_STRENGTH_ENABLE
117
118void set_vibrato_strength(float strength) {
119 vibrato_strength = strength;
120}
121
122void increase_vibrato_strength(float change) {
123 vibrato_strength *= change;
124}
125
126void decrease_vibrato_strength(float change) {
127 vibrato_strength /= change;
128}
129
130#endif
131
132#endif
133
134// Polyphony functions
135
136void set_polyphony_rate(float rate) {
137 polyphony_rate = rate;
138}
139
140void enable_polyphony() {
141 polyphony_rate = 5;
142}
143
144void disable_polyphony() {
145 polyphony_rate = 0;
146}
147
148void increase_polyphony_rate(float change) {
149 polyphony_rate *= change;
150}
151
152void decrease_polyphony_rate(float change) {
153 polyphony_rate /= change;
154}
155
156// Timbre function
157
158void set_timbre(float timbre) {
159 note_timbre = timbre;
160}
161
162// Tempo functions
163
164void set_tempo(float tempo) {
165 note_tempo = tempo;
166}
167
168void decrease_tempo(uint8_t tempo_change) {
169 note_tempo += (float) tempo_change;
170}
171
172void increase_tempo(uint8_t tempo_change) {
173 if (note_tempo - (float) tempo_change < 10) {
174 note_tempo = 10;
175 } else {
176 note_tempo -= (float) tempo_change;
177 }
178}
179
180void audio_init() {
181
182 /* check signature */
183 if (!eeconfig_is_enabled()) {
184 eeconfig_init();
185 }
186 audio_config.raw = eeconfig_read_audio();
187
188 #ifdef PWM_AUDIO
189 PLLFRQ = _BV(PDIV2);
190 PLLCSR = _BV(PLLE);
191 while(!(PLLCSR & _BV(PLOCK)));
192 PLLFRQ |= _BV(PLLTM0); /* PCK 48MHz */
193
194 /* Init a fast PWM on Timer4 */
195 TCCR4A = _BV(COM4A0) | _BV(PWM4A); /* Clear OC4A on Compare Match */
196 TCCR4B = _BV(CS40); /* No prescaling => f = PCK/256 = 187500Hz */
197 OCR4A = 0;
198
199 /* Enable the OC4A output */
200 DDRC |= _BV(PORTC6);
201
202 TIMSK3 &= ~_BV(OCIE3A); // Turn off 3A interputs
203
204 TCCR3A = 0x0; // Options not needed
205 TCCR3B = _BV(CS31) | _BV(CS30) | _BV(WGM32); // 64th prescaling and CTC
206 OCR3A = SAMPLE_DIVIDER - 1; // Correct count/compare, related to sample playback
207 #else
208 DDRC |= _BV(PORTC6);
209
210 TIMSK3 &= ~_BV(OCIE3A); // Turn off 3A interputs
211
212 TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
213 TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
214 #endif
215
216 inited = true;
217}
218
219void stop_all_notes() {
220 if (!inited) {
221 audio_init();
222 }
223 voices = 0;
224 #ifdef PWM_AUDIO
225 TIMSK3 &= ~_BV(OCIE3A);
226 #else
227 TIMSK3 &= ~_BV(OCIE3A);
228 TCCR3A &= ~_BV(COM3A1);
229 #endif
230 notes = false;
231 note = false;
232 frequency = 0;
233 volume = 0;
234
235 for (int i = 0; i < 8; i++) {
236 frequencies[i] = 0;
237 volumes[i] = 0;
238 }
239}
240
241void stop_note(float freq) {
242 if (note) {
243 if (!inited) {
244 audio_init();
245 }
246 #ifdef PWM_AUDIO
247 freq = freq / SAMPLE_RATE;
248 #endif
249 for (int i = 7; i >= 0; i--) {
250 if (frequencies[i] == freq) {
251 frequencies[i] = 0;
252 volumes[i] = 0;
253 for (int j = i; (j < 7); j++) {
254 frequencies[j] = frequencies[j+1];
255 frequencies[j+1] = 0;
256 volumes[j] = volumes[j+1];
257 volumes[j+1] = 0;
258 }
259 break;
260 }
261 }
262 voices--;
263 if (voices < 0)
264 voices = 0;
265 if (voice_place >= voices) {
266 voice_place = 0;
267 }
268 if (voices == 0) {
269 #ifdef PWM_AUDIO
270 TIMSK3 &= ~_BV(OCIE3A);
271 #else
272 TIMSK3 &= ~_BV(OCIE3A);
273 TCCR3A &= ~_BV(COM3A1);
274 #endif
275 frequency = 0;
276 volume = 0;
277 note = false;
278 }
279 }
280}
281
282#ifdef VIBRATO_ENABLE
283
284float mod(float a, int b)
285{
286 float r = fmod(a, b);
287 return r < 0 ? r + b : r;
288}
289
290float vibrato(float average_freq) {
291 #ifdef VIBRATO_STRENGTH_ENABLE
292 float vibrated_freq = average_freq * pow(VIBRATO_LUT[(int)vibrato_counter], vibrato_strength);
293 #else
294 float vibrated_freq = average_freq * VIBRATO_LUT[(int)vibrato_counter];
295 #endif
296 vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0/average_freq)), VIBRATO_LUT_LENGTH);
297 return vibrated_freq;
298}
299
300#endif
301
302ISR(TIMER3_COMPA_vect) {
303 if (note) {
304 #ifdef PWM_AUDIO
305 if (voices == 1) {
306 // SINE
307 OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 2;
308
309 // SQUARE
310 // if (((int)place) >= 1024){
311 // OCR4A = 0xFF >> 2;
312 // } else {
313 // OCR4A = 0x00;
314 // }
315
316 // SAWTOOTH
317 // OCR4A = (int)place / 4;
318
319 // TRIANGLE
320 // if (((int)place) >= 1024) {
321 // OCR4A = (int)place / 2;
322 // } else {
323 // OCR4A = 2048 - (int)place / 2;
324 // }
325
326 place += frequency;
327
328 if (place >= SINE_LENGTH)
329 place -= SINE_LENGTH;
330
331 } else {
332 int sum = 0;
333 for (int i = 0; i < voices; i++) {
334 // SINE
335 sum += pgm_read_byte(&sinewave[(uint16_t)places[i]]) >> 2;
336
337 // SQUARE
338 // if (((int)places[i]) >= 1024){
339 // sum += 0xFF >> 2;
340 // } else {
341 // sum += 0x00;
342 // }
343
344 places[i] += frequencies[i];
345
346 if (places[i] >= SINE_LENGTH)
347 places[i] -= SINE_LENGTH;
348 }
349 OCR4A = sum;
350 }
351 #else
352 if (voices > 0) {
353 float freq;
354 if (polyphony_rate > 0) {
355 if (voices > 1) {
356 voice_place %= voices;
357 if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) {
358 voice_place = (voice_place + 1) % voices;
359 place = 0.0;
360 }
361 }
362 #ifdef VIBRATO_ENABLE
363 if (vibrato_strength > 0) {
364 freq = vibrato(frequencies[voice_place]);
365 } else {
366 #else
367 {
368 #endif
369 freq = frequencies[voice_place];
370 }
371 } else {
372 if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) {
373 frequency = frequency * pow(2, 440/frequency/12/2);
374 } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) {
375 frequency = frequency * pow(2, -440/frequency/12/2);
376 } else {
377 frequency = frequencies[voices - 1];
378 }
379
380
381 #ifdef VIBRATO_ENABLE
382 if (vibrato_strength > 0) {
383 freq = vibrato(frequency);
384 } else {
385 #else
386 {
387 #endif
388 freq = frequency;
389 }
390 }
391
392 if (envelope_index < 65535) {
393 envelope_index++;
394 }
395 freq = voice_envelope(freq);
396
397 if (freq < 30.517578125)
398 freq = 30.52;
399 ICR3 = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period
400 OCR3A = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
401 }
402 #endif
403 }
404
405 // SAMPLE
406 // OCR4A = pgm_read_byte(&sample[(uint16_t)place_int]);
407
408 // place_int++;
409
410 // if (place_int >= sample_length)
411 // if (repeat)
412 // place_int -= sample_length;
413 // else
414 // TIMSK3 &= ~_BV(OCIE3A);
415
416
417 if (notes) {
418 #ifdef PWM_AUDIO
419 OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 0;
420
421 place += note_frequency;
422 if (place >= SINE_LENGTH)
423 place -= SINE_LENGTH;
424 #else
425 if (note_frequency > 0) {
426 float freq;
427
428 #ifdef VIBRATO_ENABLE
429 if (vibrato_strength > 0) {
430 freq = vibrato(note_frequency);
431 } else {
432 #else
433 {
434 #endif
435 freq = note_frequency;
436 }
437
438 if (envelope_index < 65535) {
439 envelope_index++;
440 }
441 freq = voice_envelope(freq);
442
443 ICR3 = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period
444 OCR3A = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
445 } else {
446 ICR3 = 0;
447 OCR3A = 0;
448 }
449 #endif
450
451
452 note_position++;
453 bool end_of_note = false;
454 if (ICR3 > 0)
455 end_of_note = (note_position >= (note_length / ICR3 * 0xFFFF));
456 else
457 end_of_note = (note_position >= (note_length * 0x7FF));
458 if (end_of_note) {
459 current_note++;
460 if (current_note >= notes_count) {
461 if (notes_repeat) {
462 current_note = 0;
463 } else {
464 #ifdef PWM_AUDIO
465 TIMSK3 &= ~_BV(OCIE3A);
466 #else
467 TIMSK3 &= ~_BV(OCIE3A);
468 TCCR3A &= ~_BV(COM3A1);
469 #endif
470 notes = false;
471 return;
472 }
473 }
474 if (!note_resting && (notes_rest > 0)) {
475 note_resting = true;
476 note_frequency = 0;
477 note_length = notes_rest;
478 current_note--;
479 } else {
480 note_resting = false;
481 #ifdef PWM_AUDIO
482 note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE;
483 note_length = (*notes_pointer)[current_note][1] * (note_tempo / 100);
484 #else
485 envelope_index = 0;
486 note_frequency = (*notes_pointer)[current_note][0];
487 note_length = ((*notes_pointer)[current_note][1] / 4) * (note_tempo / 100);
488 #endif
489 }
490 note_position = 0;
491 }
492
493 }
494
495 if (!audio_config.enable) {
496 notes = false;
497 note = false;
498 }
499}
500
501void play_note(float freq, int vol) {
502
503 if (!inited) {
504 audio_init();
505 }
506
507if (audio_config.enable && voices < 8) {
508 TIMSK3 &= ~_BV(OCIE3A);
509 // Cancel notes if notes are playing
510 if (notes)
511 stop_all_notes();
512 note = true;
513 envelope_index = 0;
514 #ifdef PWM_AUDIO
515 freq = freq / SAMPLE_RATE;
516 #endif
517 if (freq > 0) {
518 frequencies[voices] = freq;
519 volumes[voices] = vol;
520 voices++;
521 }
522
523 #ifdef PWM_AUDIO
524 TIMSK3 |= _BV(OCIE3A);
525 #else
526 TIMSK3 |= _BV(OCIE3A);
527 TCCR3A |= _BV(COM3A1);
528 #endif
529}
530
531}
532
533void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) {
534
535 if (!inited) {
536 audio_init();
537 }
538
539if (audio_config.enable) {
540 TIMSK3 &= ~_BV(OCIE3A);
541 // Cancel note if a note is playing
542 if (note)
543 stop_all_notes();
544 notes = true;
545
546 notes_pointer = np;
547 notes_count = n_count;
548 notes_repeat = n_repeat;
549 notes_rest = n_rest;
550
551 place = 0;
552 current_note = 0;
553 #ifdef PWM_AUDIO
554 note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE;
555 note_length = (*notes_pointer)[current_note][1] * (note_tempo / 100);
556 #else
557 note_frequency = (*notes_pointer)[current_note][0];
558 note_length = ((*notes_pointer)[current_note][1] / 4) * (note_tempo / 100);
559 #endif
560 note_position = 0;
561
562
563 #ifdef PWM_AUDIO
564 TIMSK3 |= _BV(OCIE3A);
565 #else
566 TIMSK3 |= _BV(OCIE3A);
567 TCCR3A |= _BV(COM3A1);
568 #endif
569}
570
571}
572
573#ifdef PWM_AUDIO
574void play_sample(uint8_t * s, uint16_t l, bool r) {
575 if (!inited) {
576 audio_init();
577 }
578
579 if (audio_config.enable) {
580 TIMSK3 &= ~_BV(OCIE3A);
581 stop_all_notes();
582 place_int = 0;
583 sample = s;
584 sample_length = l;
585 repeat = r;
586
587 TIMSK3 |= _BV(OCIE3A);
588 }
589}
590#endif
591
592//------------------------------------------------------------------------------
593// Override these functions in your keymap file to play different tunes on
594// startup and bootloader jump
595__attribute__ ((weak))
596void play_startup_tone()
597{
598}
599
600
601
602__attribute__ ((weak))
603void play_goodbye_tone()
604{
605
606}
607//------------------------------------------------------------------------------
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h
new file mode 100644
index 000000000..d1ccfdb82
--- /dev/null
+++ b/quantum/audio/audio.h
@@ -0,0 +1,89 @@
1#include <stdint.h>
2#include <stdbool.h>
3#include <avr/io.h>
4#include <util/delay.h>
5#include "musical_notes.h"
6#include "song_list.h"
7#include "voices.h"
8
9#ifndef AUDIO_H
10#define AUDIO_H
11
12// Largely untested PWM audio mode (doesn't sound as good)
13// #define PWM_AUDIO
14
15// #define VIBRATO_ENABLE
16
17// Enable vibrato strength/amplitude - slows down ISR too much
18// #define VIBRATO_STRENGTH_ENABLE
19
20typedef union {
21 uint8_t raw;
22 struct {
23 bool enable :1;
24 uint8_t level :7;
25 };
26} audio_config_t;
27
28void audio_toggle(void);
29void audio_on(void);
30void audio_off(void);
31
32// Vibrato rate functions
33
34#ifdef VIBRATO_ENABLE
35
36void set_vibrato_rate(float rate);
37void increase_vibrato_rate(float change);
38void decrease_vibrato_rate(float change);
39
40#ifdef VIBRATO_STRENGTH_ENABLE
41
42void set_vibrato_strength(float strength);
43void increase_vibrato_strength(float change);
44void decrease_vibrato_strength(float change);
45
46#endif
47
48#endif
49
50// Polyphony functions
51
52void set_polyphony_rate(float rate);
53void enable_polyphony();
54void disable_polyphony();
55void increase_polyphony_rate(float change);
56void decrease_polyphony_rate(float change);
57
58void set_timbre(float timbre);
59void set_tempo(float tempo);
60
61void increase_tempo(uint8_t tempo_change);
62void decrease_tempo(uint8_t tempo_change);
63
64void audio_init();
65
66#ifdef PWM_AUDIO
67void play_sample(uint8_t * s, uint16_t l, bool r);
68#endif
69void play_note(float freq, int vol);
70void stop_note(float freq);
71void stop_all_notes(void);
72void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest);
73
74#define SCALE (int []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \
75 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \
76 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \
77 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \
78 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), }
79
80// These macros are used to allow play_notes to play an array of indeterminate
81// length. This works around the limitation of C's sizeof operation on pointers.
82// The global float array for the song must be used here.
83#define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0]))))
84#define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style));
85
86void play_goodbye_tone(void);
87void play_startup_tone(void);
88
89#endif \ No newline at end of file
diff --git a/quantum/audio/musical_notes.h b/quantum/audio/musical_notes.h
new file mode 100644
index 000000000..b08d16a6f
--- /dev/null
+++ b/quantum/audio/musical_notes.h
@@ -0,0 +1,217 @@
1#ifndef MUSICAL_NOTES_H
2#define MUSICAL_NOTES_H
3
4// Tempo Placeholder
5#define TEMPO_DEFAULT 100
6
7
8#define SONG(notes...) { notes }
9
10
11// Note Types
12#define MUSICAL_NOTE(note, duration) {(NOTE##note), duration}
13#define WHOLE_NOTE(note) MUSICAL_NOTE(note, 64)
14#define HALF_NOTE(note) MUSICAL_NOTE(note, 32)
15#define QUARTER_NOTE(note) MUSICAL_NOTE(note, 16)
16#define EIGHTH_NOTE(note) MUSICAL_NOTE(note, 8)
17#define SIXTEENTH_NOTE(note) MUSICAL_NOTE(note, 4)
18
19#define WHOLE_DOT_NOTE(note) MUSICAL_NOTE(note, 64+32)
20#define HALF_DOT_NOTE(note) MUSICAL_NOTE(note, 32+16)
21#define QUARTER_DOT_NOTE(note) MUSICAL_NOTE(note, 16+8)
22#define EIGHTH_DOT_NOTE(note) MUSICAL_NOTE(note, 8+4)
23#define SIXTEENTH_DOT_NOTE(note) MUSICAL_NOTE(note, 4+2)
24
25// Note Type Shortcuts
26#define M__NOTE(note, duration) MUSICAL_NOTE(note, duration)
27#define W__NOTE(n) WHOLE_NOTE(n)
28#define H__NOTE(n) HALF_NOTE(n)
29#define Q__NOTE(n) QUARTER_NOTE(n)
30#define E__NOTE(n) EIGHTH_NOTE(n)
31#define S__NOTE(n) SIXTEENTH_NOTE(n)
32#define WD_NOTE(n) WHOLE_DOT_NOTE(n)
33#define HD_NOTE(n) HALF_DOT_NOTE(n)
34#define QD_NOTE(n) QUARTER_DOT_NOTE(n)
35#define ED_NOTE(n) EIGHTH_DOT_NOTE(n)
36#define SD_NOTE(n) SIXTEENTH_DOT_NOTE(n)
37
38// Note Styles
39// Staccato makes sure there is a rest between each note. Think: TA TA TA
40// Legato makes notes flow together. Think: TAAA
41#define STACCATO 0.01
42#define LEGATO 0
43
44// Note Timbre
45// Changes how the notes sound
46#define TIMBRE_12 0.125
47#define TIMBRE_25 0.250
48#define TIMBRE_50 0.500
49#define TIMBRE_75 0.750
50#define TIMBRE_DEFAULT TIMBRE_50
51
52
53// Notes - # = Octave
54
55#define NOTE_REST 0.00
56
57/* These notes are currently bugged
58#define NOTE_C0 16.35
59#define NOTE_CS0 17.32
60#define NOTE_D0 18.35
61#define NOTE_DS0 19.45
62#define NOTE_E0 20.60
63#define NOTE_F0 21.83
64#define NOTE_FS0 23.12
65#define NOTE_G0 24.50
66#define NOTE_GS0 25.96
67#define NOTE_A0 27.50
68#define NOTE_AS0 29.14
69#define NOTE_B0 30.87
70#define NOTE_C1 32.70
71#define NOTE_CS1 34.65
72#define NOTE_D1 36.71
73#define NOTE_DS1 38.89
74#define NOTE_E1 41.20
75#define NOTE_F1 43.65
76#define NOTE_FS1 46.25
77#define NOTE_G1 49.00
78#define NOTE_GS1 51.91
79#define NOTE_A1 55.00
80#define NOTE_AS1 58.27
81*/
82
83#define NOTE_B1 61.74
84#define NOTE_C2 65.41
85#define NOTE_CS2 69.30
86#define NOTE_D2 73.42
87#define NOTE_DS2 77.78
88#define NOTE_E2 82.41
89#define NOTE_F2 87.31
90#define NOTE_FS2 92.50
91#define NOTE_G2 98.00
92#define NOTE_GS2 103.83
93#define NOTE_A2 110.00
94#define NOTE_AS2 116.54
95#define NOTE_B2 123.47
96#define NOTE_C3 130.81
97#define NOTE_CS3 138.59
98#define NOTE_D3 146.83
99#define NOTE_DS3 155.56
100#define NOTE_E3 164.81
101#define NOTE_F3 174.61
102#define NOTE_FS3 185.00
103#define NOTE_G3 196.00
104#define NOTE_GS3 207.65
105#define NOTE_A3 220.00
106#define NOTE_AS3 233.08
107#define NOTE_B3 246.94
108#define NOTE_C4 261.63
109#define NOTE_CS4 277.18
110#define NOTE_D4 293.66
111#define NOTE_DS4 311.13
112#define NOTE_E4 329.63
113#define NOTE_F4 349.23
114#define NOTE_FS4 369.99
115#define NOTE_G4 392.00
116#define NOTE_GS4 415.30
117#define NOTE_A4 440.00
118#define NOTE_AS4 466.16
119#define NOTE_B4 493.88
120#define NOTE_C5 523.25
121#define NOTE_CS5 554.37
122#define NOTE_D5 587.33
123#define NOTE_DS5 622.25
124#define NOTE_E5 659.26
125#define NOTE_F5 698.46
126#define NOTE_FS5 739.99
127#define NOTE_G5 783.99
128#define NOTE_GS5 830.61
129#define NOTE_A5 880.00
130#define NOTE_AS5 932.33
131#define NOTE_B5 987.77
132#define NOTE_C6 1046.50
133#define NOTE_CS6 1108.73
134#define NOTE_D6 1174.66
135#define NOTE_DS6 1244.51
136#define NOTE_E6 1318.51
137#define NOTE_F6 1396.91
138#define NOTE_FS6 1479.98
139#define NOTE_G6 1567.98
140#define NOTE_GS6 1661.22
141#define NOTE_A6 1760.00
142#define NOTE_AS6 1864.66
143#define NOTE_B6 1975.53
144#define NOTE_C7 2093.00
145#define NOTE_CS7 2217.46
146#define NOTE_D7 2349.32
147#define NOTE_DS7 2489.02
148#define NOTE_E7 2637.02
149#define NOTE_F7 2793.83
150#define NOTE_FS7 2959.96
151#define NOTE_G7 3135.96
152#define NOTE_GS7 3322.44
153#define NOTE_A7 3520.00
154#define NOTE_AS7 3729.31
155#define NOTE_B7 3951.07
156#define NOTE_C8 4186.01
157#define NOTE_CS8 4434.92
158#define NOTE_D8 4698.64
159#define NOTE_DS8 4978.03
160#define NOTE_E8 5274.04
161#define NOTE_F8 5587.65
162#define NOTE_FS8 5919.91
163#define NOTE_G8 6271.93
164#define NOTE_GS8 6644.88
165#define NOTE_A8 7040.00
166#define NOTE_AS8 7458.62
167#define NOTE_B8 7902.13
168
169// Flat Aliases
170#define NOTE_DF0 NOTE_CS0
171#define NOTE_EF0 NOTE_DS0
172#define NOTE_GF0 NOTE_FS0
173#define NOTE_AF0 NOTE_GS0
174#define NOTE_BF0 NOTE_AS0
175#define NOTE_DF1 NOTE_CS1
176#define NOTE_EF1 NOTE_DS1
177#define NOTE_GF1 NOTE_FS1
178#define NOTE_AF1 NOTE_GS1
179#define NOTE_BF1 NOTE_AS1
180#define NOTE_DF2 NOTE_CS2
181#define NOTE_EF2 NOTE_DS2
182#define NOTE_GF2 NOTE_FS2
183#define NOTE_AF2 NOTE_GS2
184#define NOTE_BF2 NOTE_AS2
185#define NOTE_DF3 NOTE_CS3
186#define NOTE_EF3 NOTE_DS3
187#define NOTE_GF3 NOTE_FS3
188#define NOTE_AF3 NOTE_GS3
189#define NOTE_BF3 NOTE_AS3
190#define NOTE_DF4 NOTE_CS4
191#define NOTE_EF4 NOTE_DS4
192#define NOTE_GF4 NOTE_FS4
193#define NOTE_AF4 NOTE_GS4
194#define NOTE_BF4 NOTE_AS4
195#define NOTE_DF5 NOTE_CS5
196#define NOTE_EF5 NOTE_DS5
197#define NOTE_GF5 NOTE_FS5
198#define NOTE_AF5 NOTE_GS5
199#define NOTE_BF5 NOTE_AS5
200#define NOTE_DF6 NOTE_CS6
201#define NOTE_EF6 NOTE_DS6
202#define NOTE_GF6 NOTE_FS6
203#define NOTE_AF6 NOTE_GS6
204#define NOTE_BF6 NOTE_AS6
205#define NOTE_DF7 NOTE_CS7
206#define NOTE_EF7 NOTE_DS7
207#define NOTE_GF7 NOTE_FS7
208#define NOTE_AF7 NOTE_GS7
209#define NOTE_BF7 NOTE_AS7
210#define NOTE_DF8 NOTE_CS8
211#define NOTE_EF8 NOTE_DS8
212#define NOTE_GF8 NOTE_FS8
213#define NOTE_AF8 NOTE_GS8
214#define NOTE_BF8 NOTE_AS8
215
216
217#endif \ No newline at end of file
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h
new file mode 100644
index 000000000..fc6fcdeef
--- /dev/null
+++ b/quantum/audio/song_list.h
@@ -0,0 +1,117 @@
1#include "musical_notes.h"
2
3#ifndef SONG_LIST_H
4#define SONG_LIST_H
5
6#define ODE_TO_JOY \
7 Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \
8 Q__NOTE(_G4), Q__NOTE(_F4), Q__NOTE(_E4), Q__NOTE(_D4), \
9 Q__NOTE(_C4), Q__NOTE(_C4), Q__NOTE(_D4), Q__NOTE(_E4), \
10 QD_NOTE(_E4), E__NOTE(_D4), H__NOTE(_D4),
11
12#define ROCK_A_BYE_BABY \
13 QD_NOTE(_B4), E__NOTE(_D4), Q__NOTE(_B5), \
14 H__NOTE(_A5), Q__NOTE(_G5), \
15 QD_NOTE(_B4), E__NOTE(_D5), Q__NOTE(_G5), \
16 H__NOTE(_FS5),
17
18#define CLOSE_ENCOUNTERS_5_NOTE \
19 Q__NOTE(_D5), \
20 Q__NOTE(_E5), \
21 Q__NOTE(_C5), \
22 Q__NOTE(_C4), \
23 Q__NOTE(_G4),
24
25#define DOE_A_DEER \
26 QD_NOTE(_C4), E__NOTE(_D4), \
27 QD_NOTE(_E4), E__NOTE(_C4), \
28 Q__NOTE(_E4), Q__NOTE(_C4), \
29 Q__NOTE(_E4),
30
31#define GOODBYE_SOUND \
32 E__NOTE(_E7), \
33 E__NOTE(_A6), \
34 ED_NOTE(_E6),
35
36#define STARTUP_SOUND \
37 ED_NOTE(_E7 ), \
38 E__NOTE(_CS7), \
39 E__NOTE(_E6 ), \
40 E__NOTE(_A6 ), \
41 M__NOTE(_CS7, 20),
42
43#define QWERTY_SOUND \
44 E__NOTE(_GS6 ), \
45 E__NOTE(_A6 ), \
46 S__NOTE(_REST), \
47 Q__NOTE(_E7 ),
48
49#define COLEMAK_SOUND \
50 E__NOTE(_GS6 ), \
51 E__NOTE(_A6 ), \
52 S__NOTE(_REST), \
53 ED_NOTE(_E7 ), \
54 S__NOTE(_REST), \
55 ED_NOTE(_GS7 ),
56
57#define DVORAK_SOUND \
58 E__NOTE(_GS6 ), \
59 E__NOTE(_A6 ), \
60 S__NOTE(_REST), \
61 E__NOTE(_E7 ), \
62 S__NOTE(_REST), \
63 E__NOTE(_FS7 ), \
64 S__NOTE(_REST), \
65 E__NOTE(_E7 ),
66
67#define PLOVER_SOUND \
68 E__NOTE(_GS6 ), \
69 E__NOTE(_A6 ), \
70 S__NOTE(_REST), \
71 ED_NOTE(_E7 ), \
72 S__NOTE(_REST), \
73 ED_NOTE(_A7 ),
74
75#define PLOVER_GOODBYE_SOUND \
76 E__NOTE(_GS6 ), \
77 E__NOTE(_A6 ), \
78 S__NOTE(_REST), \
79 ED_NOTE(_A7 ), \
80 S__NOTE(_REST), \
81 ED_NOTE(_E7 ),
82
83#define MUSIC_SCALE_SOUND \
84 E__NOTE(_A5 ), \
85 E__NOTE(_B5 ), \
86 E__NOTE(_CS6), \
87 E__NOTE(_D6 ), \
88 E__NOTE(_E6 ), \
89 E__NOTE(_FS6), \
90 E__NOTE(_GS6), \
91 E__NOTE(_A6 ),
92
93#define CAPS_LOCK_ON_SOUND \
94 E__NOTE(_A3), \
95 E__NOTE(_B3),
96
97#define CAPS_LOCK_OFF_SOUND \
98 E__NOTE(_B3), \
99 E__NOTE(_A3),
100
101#define SCROLL_LOCK_ON_SOUND \
102 E__NOTE(_D4), \
103 E__NOTE(_E4),
104
105#define SCROLL_LOCK_OFF_SOUND \
106 E__NOTE(_E4), \
107 E__NOTE(_D4),
108
109#define NUM_LOCK_ON_SOUND \
110 E__NOTE(_D5), \
111 E__NOTE(_E5),
112
113#define NUM_LOCK_OFF_SOUND \
114 E__NOTE(_E5), \
115 E__NOTE(_D5),
116
117#endif
diff --git a/quantum/audio/vibrato_lut.h b/quantum/audio/vibrato_lut.h
new file mode 100644
index 000000000..a2b1f3e5c
--- /dev/null
+++ b/quantum/audio/vibrato_lut.h
@@ -0,0 +1,28 @@
1#include <avr/io.h>
2#include <avr/interrupt.h>
3#include <avr/pgmspace.h>
4
5#define VIBRATO_LUT_LENGTH 20
6
7const float VIBRATO_LUT[VIBRATO_LUT_LENGTH] = { \
81.00223368114872,
91.00425299436105,
101.00585842560279,
111.00689052852052,
121.0072464122237,
131.00689052852052,
141.00585842560279,
151.00425299436105,
161.00223368114872,
171,
180.99777129706302,
190.99576501699778,
200.994175695650927,
210.993156625943589,
220.992805720491269,
230.993156625943589,
240.994175695650927,
250.99576501699778,
260.99777129706302,
271
28}; \ No newline at end of file
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c
new file mode 100644
index 000000000..51652927b
--- /dev/null
+++ b/quantum/audio/voices.c
@@ -0,0 +1,60 @@
1#include "voices.h"
2
3extern uint16_t envelope_index;
4extern float note_timbre;
5
6voice_type voice = default_voice;
7
8void set_voice(voice_type v) {
9 voice = v;
10}
11
12float voice_envelope(float frequency) {
13 // envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz
14 uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency));
15
16 switch (voice) {
17 case default_voice:
18 // nothing here on purpose
19 break;
20 case butts_fader:
21 switch (compensated_index) {
22 case 0 ... 9:
23 frequency = frequency / 4;
24 note_timbre = TIMBRE_12;
25 break;
26 case 10 ... 19:
27 frequency = frequency / 2;
28 note_timbre = TIMBRE_12;
29 break;
30 case 20 ... 200:
31 note_timbre = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2)*.125;
32 break;
33 default:
34 note_timbre = 0;
35 break;
36 }
37 break;
38 case octave_crunch:
39 switch (compensated_index) {
40 case 0 ... 9:
41 case 20 ... 24:
42 case 30 ... 32:
43 frequency = frequency / 2;
44 note_timbre = TIMBRE_12;
45 break;
46 case 10 ... 19:
47 case 25 ... 29:
48 case 33 ... 35:
49 frequency = frequency * 2;
50 note_timbre = TIMBRE_12;
51 break;
52 default:
53 note_timbre = TIMBRE_12;
54 break;
55 }
56 break;
57 }
58
59 return frequency;
60} \ No newline at end of file
diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h
new file mode 100644
index 000000000..317f5d98c
--- /dev/null
+++ b/quantum/audio/voices.h
@@ -0,0 +1,21 @@
1#include <stdint.h>
2#include <stdbool.h>
3#include <avr/io.h>
4#include <util/delay.h>
5#include "musical_notes.h"
6#include "song_list.h"
7
8#ifndef VOICES_H
9#define VOICES_H
10
11float voice_envelope(float frequency);
12
13typedef enum {
14 default_voice,
15 butts_fader,
16 octave_crunch
17} voice_type;
18
19void set_voice(voice_type v);
20
21#endif \ No newline at end of file
diff --git a/quantum/audio/wave.h b/quantum/audio/wave.h
new file mode 100644
index 000000000..6ebc34851
--- /dev/null
+++ b/quantum/audio/wave.h
@@ -0,0 +1,265 @@
1#include <avr/io.h>
2#include <avr/interrupt.h>
3#include <avr/pgmspace.h>
4
5#define SINE_LENGTH 2048
6
7const uint8_t sinewave[] PROGMEM= //2048 values
8{
90x80,0x80,0x80,0x81,0x81,0x81,0x82,0x82,
100x83,0x83,0x83,0x84,0x84,0x85,0x85,0x85,
110x86,0x86,0x87,0x87,0x87,0x88,0x88,0x88,
120x89,0x89,0x8a,0x8a,0x8a,0x8b,0x8b,0x8c,
130x8c,0x8c,0x8d,0x8d,0x8e,0x8e,0x8e,0x8f,
140x8f,0x8f,0x90,0x90,0x91,0x91,0x91,0x92,
150x92,0x93,0x93,0x93,0x94,0x94,0x95,0x95,
160x95,0x96,0x96,0x96,0x97,0x97,0x98,0x98,
170x98,0x99,0x99,0x9a,0x9a,0x9a,0x9b,0x9b,
180x9b,0x9c,0x9c,0x9d,0x9d,0x9d,0x9e,0x9e,
190x9e,0x9f,0x9f,0xa0,0xa0,0xa0,0xa1,0xa1,
200xa2,0xa2,0xa2,0xa3,0xa3,0xa3,0xa4,0xa4,
210xa5,0xa5,0xa5,0xa6,0xa6,0xa6,0xa7,0xa7,
220xa7,0xa8,0xa8,0xa9,0xa9,0xa9,0xaa,0xaa,
230xaa,0xab,0xab,0xac,0xac,0xac,0xad,0xad,
240xad,0xae,0xae,0xae,0xaf,0xaf,0xb0,0xb0,
250xb0,0xb1,0xb1,0xb1,0xb2,0xb2,0xb2,0xb3,
260xb3,0xb4,0xb4,0xb4,0xb5,0xb5,0xb5,0xb6,
270xb6,0xb6,0xb7,0xb7,0xb7,0xb8,0xb8,0xb8,
280xb9,0xb9,0xba,0xba,0xba,0xbb,0xbb,0xbb,
290xbc,0xbc,0xbc,0xbd,0xbd,0xbd,0xbe,0xbe,
300xbe,0xbf,0xbf,0xbf,0xc0,0xc0,0xc0,0xc1,
310xc1,0xc1,0xc2,0xc2,0xc2,0xc3,0xc3,0xc3,
320xc4,0xc4,0xc4,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f7,0xf7,0xf7,0xf7,0xf7,0xf7,
590xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,
600xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,
610xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,
620xfa,0xfa,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,
630xfb,0xfb,0xfb,0xfb,0xfc,0xfc,0xfc,0xfc,
640xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,
650xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,
660xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfe,0xfe,
670xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
680xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
690xfe,0xfe,0xfe,0xfe,0xff,0xff,0xff,0xff,
700xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
710xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
720xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
730xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
740xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
750xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
760xff,0xff,0xff,0xff,0xff,0xfe,0xfe,0xfe,
770xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
780xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
790xfe,0xfe,0xfe,0xfd,0xfd,0xfd,0xfd,0xfd,
800xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,
810xfd,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,
820xfc,0xfc,0xfc,0xfc,0xfc,0xfb,0xfb,0xfb,
830xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfa,
840xfa,0xfa,0xfa,0xfa,0xfa,0x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0xcd,0xcd,0xcd,0xcc,0xcc,0xcc,
1110xcb,0xcb,0xcb,0xcb,0xca,0xca,0xca,0xc9,
1120xc9,0xc9,0xc8,0xc8,0xc8,0xc7,0xc7,0xc7,
1130xc6,0xc6,0xc6,0xc5,0xc5,0xc5,0xc4,0xc4,
1140xc4,0xc3,0xc3,0xc3,0xc2,0xc2,0xc2,0xc1,
1150xc1,0xc1,0xc0,0xc0,0xc0,0xbf,0xbf,0xbf,
1160xbe,0xbe,0xbe,0xbd,0xbd,0xbd,0xbc,0xbc,
1170xbc,0xbb,0xbb,0xbb,0xba,0xba,0xba,0xb9,
1180xb9,0xb8,0xb8,0xb8,0xb7,0xb7,0xb7,0xb6,
1190xb6,0xb6,0xb5,0xb5,0xb5,0xb4,0xb4,0xb4,
1200xb3,0xb3,0xb2,0xb2,0xb2,0xb1,0xb1,0xb1,
1210xb0,0xb0,0xb0,0xaf,0xaf,0xae,0xae,0xae,
1220xad,0xad,0xad,0xac,0xac,0xac,0xab,0xab,
1230xaa,0xaa,0xaa,0xa9,0xa9,0xa9,0xa8,0xa8,
1240xa7,0xa7,0xa7,0xa6,0xa6,0xa6,0xa5,0xa5,
1250xa5,0xa4,0xa4,0xa3,0xa3,0xa3,0xa2,0xa2,
1260xa2,0xa1,0xa1,0xa0,0xa0,0xa0,0x9f,0x9f,
1270x9e,0x9e,0x9e,0x9d,0x9d,0x9d,0x9c,0x9c,
1280x9b,0x9b,0x9b,0x9a,0x9a,0x9a,0x99,0x99,
1290x98,0x98,0x98,0x97,0x97,0x96,0x96,0x96,
1300x95,0x95,0x95,0x94,0x94,0x93,0x93,0x93,
1310x92,0x92,0x91,0x91,0x91,0x90,0x90,0x8f,
1320x8f,0x8f,0x8e,0x8e,0x8e,0x8d,0x8d,0x8c,
1330x8c,0x8c,0x8b,0x8b,0x8a,0x8a,0x8a,0x89,
1340x89,0x88,0x88,0x88,0x87,0x87,0x87,0x86,
1350x86,0x85,0x85,0x85,0x84,0x84,0x83,0x83,
1360x83,0x82,0x82,0x81,0x81,0x81,0x80,0x80,
1370x80,0x7f,0x7f,0x7e,0x7e,0x7e,0x7d,0x7d,
1380x7c,0x7c,0x7c,0x7b,0x7b,0x7a,0x7a,0x7a,
1390x79,0x79,0x78,0x78,0x78,0x77,0x77,0x77,
1400x76,0x76,0x75,0x75,0x75,0x74,0x74,0x73,
1410x73,0x73,0x72,0x72,0x71,0x71,0x71,0x70,
1420x70,0x70,0x6f,0x6f,0x6e,0x6e,0x6e,0x6d,
1430x6d,0x6c,0x6c,0x6c,0x6b,0x6b,0x6a,0x6a,
1440x6a,0x69,0x69,0x69,0x68,0x68,0x67,0x67,
1450x67,0x66,0x66,0x65,0x65,0x65,0x64,0x64,
1460x64,0x63,0x63,0x62,0x62,0x62,0x61,0x61,
1470x61,0x60,0x60,0x5f,0x5f,0x5f,0x5e,0x5e,
1480x5d,0x5d,0x5d,0x5c,0x5c,0x5c,0x5b,0x5b,
1490x5a,0x5a,0x5a,0x59,0x59,0x59,0x58,0x58,
1500x58,0x57,0x57,0x56,0x56,0x56,0x55,0x55,
1510x55,0x54,0x54,0x53,0x53,0x53,0x52,0x52,
1520x52,0x51,0x51,0x51,0x50,0x50,0x4f,0x4f,
1530x4f,0x4e,0x4e,0x4e,0x4d,0x4d,0x4d,0x4c,
1540x4c,0x4b,0x4b,0x4b,0x4a,0x4a,0x4a,0x49,
1550x49,0x49,0x48,0x48,0x48,0x47,0x47,0x47,
1560x46,0x46,0x45,0x45,0x45,0x44,0x44,0x44,
1570x43,0x43,0x43,0x42,0x42,0x42,0x41,0x41,
1580x41,0x40,0x40,0x40,0x3f,0x3f,0x3f,0x3e,
1590x3e,0x3e,0x3d,0x3d,0x3d,0x3c,0x3c,0x3c,
1600x3b,0x3b,0x3b,0x3a,0x3a,0x3a,0x39,0x39,
1610x39,0x38,0x38,0x38,0x37,0x37,0x37,0x36,
1620x36,0x36,0x35,0x35,0x35,0x34,0x34,0x34,
1630x34,0x33,0x33,0x33,0x32,0x32,0x32,0x31,
1640x31,0x31,0x30,0x30,0x30,0x30,0x2f,0x2f,
1650x2f,0x2e,0x2e,0x2e,0x2d,0x2d,0x2d,0x2d,
1660x2c,0x2c,0x2c,0x2b,0x2b,0x2b,0x2a,0x2a,
1670x2a,0x2a,0x29,0x29,0x29,0x28,0x28,0x28,
1680x28,0x27,0x27,0x27,0x26,0x26,0x26,0x26,
1690x25,0x25,0x25,0x25,0x24,0x24,0x24,0x23,
1700x23,0x23,0x23,0x22,0x22,0x22,0x22,0x21,
1710x21,0x21,0x21,0x20,0x20,0x20,0x1f,0x1f,
1720x1f,0x1f,0x1e,0x1e,0x1e,0x1e,0x1d,0x1d,
1730x1d,0x1d,0x1c,0x1c,0x1c,0x1c,0x1b,0x1b,
1740x1b,0x1b,0x1b,0x1a,0x1a,0x1a,0x1a,0x19,
1750x19,0x19,0x19,0x18,0x18,0x18,0x18,0x17,
1760x17,0x17,0x17,0x17,0x16,0x16,0x16,0x16,
1770x15,0x15,0x15,0x15,0x15,0x14,0x14,0x14,
1780x14,0x14,0x13,0x13,0x13,0x13,0x13,0x12,
1790x12,0x12,0x12,0x12,0x11,0x11,0x11,0x11,
1800x11,0x10,0x10,0x10,0x10,0x10,0xf,0xf,
1810xf,0xf,0xf,0xf,0xe,0xe,0xe,0xe,
1820xe,0xd,0xd,0xd,0xd,0xd,0xd,0xc,
1830xc,0xc,0xc,0xc,0xc,0xb,0xb,0xb,
1840xb,0xb,0xb,0xa,0xa,0xa,0xa,0xa,
1850xa,0xa,0x9,0x9,0x9,0x9,0x9,0x9,
1860x9,0x8,0x8,0x8,0x8,0x8,0x8,0x8,
1870x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,
1880x6,0x6,0x6,0x6,0x6,0x6,0x6,0x6,
1890x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,
1900x5,0x5,0x4,0x4,0x4,0x4,0x4,0x4,
1910x4,0x4,0x4,0x4,0x3,0x3,0x3,0x3,
1920x3,0x3,0x3,0x3,0x3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,0x12,0x12,
2230x12,0x12,0x13,0x13,0x13,0x13,0x13,0x14,
2240x14,0x14,0x14,0x14,0x15,0x15,0x15,0x15,
2250x15,0x16,0x16,0x16,0x16,0x17,0x17,0x17,
2260x17,0x17,0x18,0x18,0x18,0x18,0x19,0x19,
2270x19,0x19,0x1a,0x1a,0x1a,0x1a,0x1b,0x1b,
2280x1b,0x1b,0x1b,0x1c,0x1c,0x1c,0x1c,0x1d,
2290x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1e,0x1f,
2300x1f,0x1f,0x1f,0x20,0x20,0x20,0x21,0x21,
2310x21,0x21,0x22,0x22,0x22,0x22,0x23,0x23,
2320x23,0x23,0x24,0x24,0x24,0x25,0x25,0x25,
2330x25,0x26,0x26,0x26,0x26,0x27,0x27,0x27,
2340x28,0x28,0x28,0x28,0x29,0x29,0x29,0x2a,
2350x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2c,0x2c,
2360x2c,0x2d,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,
2370x2f,0x2f,0x2f,0x30,0x30,0x30,0x30,0x31,
2380x31,0x31,0x32,0x32,0x32,0x33,0x33,0x33,
2390x34,0x34,0x34,0x34,0x35,0x35,0x35,0x36,
2400x36,0x36,0x37,0x37,0x37,0x38,0x38,0x38,
2410x39,0x39,0x39,0x3a,0x3a,0x3a,0x3b,0x3b,
2420x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3e,
2430x3e,0x3e,0x3f,0x3f,0x3f,0x40,0x40,0x40,
2440x41,0x41,0x41,0x42,0x42,0x42,0x43,0x43,
2450x43,0x44,0x44,0x44,0x45,0x45,0x45,0x46,
2460x46,0x47,0x47,0x47,0x48,0x48,0x48,0x49,
2470x49,0x49,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,
2480x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,
2490x4f,0x4f,0x4f,0x50,0x50,0x51,0x51,0x51,
2500x52,0x52,0x52,0x53,0x53,0x53,0x54,0x54,
2510x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57,
2520x58,0x58,0x58,0x59,0x59,0x59,0x5a,0x5a,
2530x5a,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d,
2540x5d,0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60,
2550x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63,
2560x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66,
2570x67,0x67,0x67,0x68,0x68,0x69,0x69,0x69,
2580x6a,0x6a,0x6a,0x6b,0x6b,0x6c,0x6c,0x6c,
2590x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x70,
2600x70,0x70,0x71,0x71,0x71,0x72,0x72,0x73,
2610x73,0x73,0x74,0x74,0x75,0x75,0x75,0x76,
2620x76,0x77,0x77,0x77,0x78,0x78,0x78,0x79,
2630x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7c,0x7c,
2640x7c,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f
265}; \ No newline at end of file