aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2016-04-17 18:14:42 -0400
committerJack Humbert <jack.humb@gmail.com>2016-04-17 18:14:42 -0400
commitce463ef424c5bd26b84ead7de5f31eab366f98eb (patch)
treef97f634ce31104ab74244c4b252fefee097d71f0
parent319fbe344b81081ced4c44792a7b868d5400edbb (diff)
downloadqmk_firmware-ce463ef424c5bd26b84ead7de5f31eab366f98eb.tar.gz
qmk_firmware-ce463ef424c5bd26b84ead7de5f31eab366f98eb.zip
audio fixes
-rw-r--r--keyboard/preonic/keymaps/default/keymap.c7
-rw-r--r--quantum/audio.c6
-rw-r--r--quantum/audio.h1
3 files changed, 9 insertions, 5 deletions
diff --git a/keyboard/preonic/keymaps/default/keymap.c b/keyboard/preonic/keymaps/default/keymap.c
index 48bc72dab..2591af9f0 100644
--- a/keyboard/preonic/keymaps/default/keymap.c
+++ b/keyboard/preonic/keymaps/default/keymap.c
@@ -224,6 +224,7 @@ float tone_music[][2] = {
224 {440.0*pow(2.0,(23)/12.0), 8}, 224 {440.0*pow(2.0,(23)/12.0), 8},
225 {440.0*pow(2.0,(24)/12.0), 8} 225 {440.0*pow(2.0,(24)/12.0), 8}
226}; 226};
227float ode_to_joy[][2] = SONG(ODE_TO_JOY);
227#endif 228#endif
228 229
229void persistant_default_layer_set(uint16_t default_layer) { 230void persistant_default_layer_set(uint16_t default_layer) {
@@ -312,7 +313,9 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
312 case 9: 313 case 9:
313 if (record->event.pressed) { 314 if (record->event.pressed) {
314 #ifdef AUDIO_ENABLE 315 #ifdef AUDIO_ENABLE
315 PLAY_NOTE_ARRAY(tone_music, false, 0); 316 init_notes();
317 set_tempo(150);
318 PLAY_NOTE_ARRAY(ode_to_joy, false, .25);
316 layer_on(_MUSIC); 319 layer_on(_MUSIC);
317 #endif 320 #endif
318 } 321 }
@@ -339,6 +342,6 @@ void process_action_user(keyrecord_t *record) {
339void matrix_init_user(void) { 342void matrix_init_user(void) {
340 #ifdef AUDIO_ENABLE 343 #ifdef AUDIO_ENABLE
341 init_notes(); 344 init_notes();
342 play_notes(&start_up, false, 0); 345 PLAY_NOTE_ARRAY(start_up, false, 0);
343 #endif 346 #endif
344} 347}
diff --git a/quantum/audio.c b/quantum/audio.c
index 855e97361..e0413051a 100644
--- a/quantum/audio.c
+++ b/quantum/audio.c
@@ -257,7 +257,7 @@ ISR(TIMER3_COMPA_vect) {
257 place = 0.0; 257 place = 0.0;
258 } 258 }
259 ICR3 = (int)(((double)F_CPU) / (frequencies[voice_place] * CPU_PRESCALER)); // Set max to the period 259 ICR3 = (int)(((double)F_CPU) / (frequencies[voice_place] * CPU_PRESCALER)); // Set max to the period
260 OCR3A = (int)((((double)F_CPU) / (note_frequency * CPU_PRESCALER)) * note_timbre); // Set compare to half the period 260 OCR3A = (int)((((double)F_CPU) / (frequencies[voice_place] * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
261 //OCR3A = (int)(((double)F_CPU) / (frequencies[voice_place] * CPU_PRESCALER)) >> 1 * duty_place; // Set compare to half the period 261 //OCR3A = (int)(((double)F_CPU) / (frequencies[voice_place] * CPU_PRESCALER)) >> 1 * duty_place; // Set compare to half the period
262 place++; 262 place++;
263 // if (duty_counter > (frequencies[voice_place] / 500)) { 263 // if (duty_counter > (frequencies[voice_place] / 500)) {
@@ -353,6 +353,7 @@ if (audio_config.enable) {
353 353
354 if (note) 354 if (note)
355 stop_all_notes(); 355 stop_all_notes();
356 notes = true;
356 357
357 notes_pointer = np; 358 notes_pointer = np;
358 notes_count = n_count; 359 notes_count = n_count;
@@ -378,7 +379,6 @@ if (audio_config.enable) {
378 TCCR3A |= _BV(COM3A1); 379 TCCR3A |= _BV(COM3A1);
379 #endif 380 #endif
380 381
381 notes = true;
382} 382}
383 383
384} 384}
@@ -408,6 +408,7 @@ if (audio_config.enable && voices < 8) {
408 408
409 if (notes) 409 if (notes)
410 stop_all_notes(); 410 stop_all_notes();
411 note = true;
411 #ifdef PWM_AUDIO 412 #ifdef PWM_AUDIO
412 freq = freq / SAMPLE_RATE; 413 freq = freq / SAMPLE_RATE;
413 #endif 414 #endif
@@ -439,7 +440,6 @@ if (audio_config.enable && voices < 8) {
439 TCCR3A |= _BV(COM3A1); 440 TCCR3A |= _BV(COM3A1);
440 #endif 441 #endif
441 442
442 note = true;
443} 443}
444 444
445} 445}
diff --git a/quantum/audio.h b/quantum/audio.h
index 3aba8370a..05d314c94 100644
--- a/quantum/audio.h
+++ b/quantum/audio.h
@@ -3,6 +3,7 @@
3#include <avr/io.h> 3#include <avr/io.h>
4#include <util/delay.h> 4#include <util/delay.h>
5#include "musical_notes.h" 5#include "musical_notes.h"
6#include "song_list.h"
6 7
7#ifndef AUDIO_H 8#ifndef AUDIO_H
8#define AUDIO_H 9#define AUDIO_H