]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
audio fixes
authorJack Humbert <jack.humb@gmail.com>
Sun, 17 Apr 2016 22:14:42 +0000 (18:14 -0400)
committerJack Humbert <jack.humb@gmail.com>
Sun, 17 Apr 2016 22:14:42 +0000 (18:14 -0400)
keyboard/preonic/keymaps/default/keymap.c
quantum/audio.c
quantum/audio.h

index 48bc72dab7b4b5681109712b3ce8bfd2c9e4d360..2591af9f02986edc36966b213ce717659200b4e4 100644 (file)
@@ -224,6 +224,7 @@ float tone_music[][2] = {
   {440.0*pow(2.0,(23)/12.0), 8},
   {440.0*pow(2.0,(24)/12.0), 8}
 };
+float ode_to_joy[][2] = SONG(ODE_TO_JOY);
 #endif
 
 void 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)
         case 9:
           if (record->event.pressed) {
             #ifdef AUDIO_ENABLE
-              PLAY_NOTE_ARRAY(tone_music, false, 0);
+              init_notes();
+              set_tempo(150);
+              PLAY_NOTE_ARRAY(ode_to_joy, false, .25);
               layer_on(_MUSIC);
             #endif
           }
@@ -339,6 +342,6 @@ void process_action_user(keyrecord_t *record) {
 void matrix_init_user(void) {
   #ifdef AUDIO_ENABLE
     init_notes();
-    play_notes(&start_up, false, 0);
+    PLAY_NOTE_ARRAY(start_up, false, 0);
   #endif
 }
index 855e97361b3a67335ad15237243b49b78fb530d0..e0413051a092e17e901c24aea4da553b5f0bad5b 100644 (file)
@@ -257,7 +257,7 @@ ISR(TIMER3_COMPA_vect) {
                     place = 0.0;
                 }
                 ICR3 = (int)(((double)F_CPU) / (frequencies[voice_place] * CPU_PRESCALER)); // Set max to the period
-                OCR3A = (int)((((double)F_CPU) / (note_frequency * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
+                OCR3A = (int)((((double)F_CPU) / (frequencies[voice_place] * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
                 //OCR3A = (int)(((double)F_CPU) / (frequencies[voice_place] * CPU_PRESCALER)) >> 1 * duty_place; // Set compare to half the period
                 place++;
                 // if (duty_counter > (frequencies[voice_place] / 500)) {
@@ -353,6 +353,7 @@ if (audio_config.enable) {
 
     if (note)
         stop_all_notes();
+    notes = true;
 
     notes_pointer = np;
     notes_count = n_count;
@@ -378,7 +379,6 @@ if (audio_config.enable) {
         TCCR3A |= _BV(COM3A1);
     #endif
 
-    notes = true;
 }
 
 }
@@ -408,6 +408,7 @@ if (audio_config.enable && voices < 8) {
 
     if (notes)
         stop_all_notes();
+    note = true;
     #ifdef PWM_AUDIO
         freq = freq / SAMPLE_RATE;
     #endif
@@ -439,7 +440,6 @@ if (audio_config.enable && voices < 8) {
         TCCR3A |= _BV(COM3A1);
     #endif
 
-    note = true;
 }
 
 }
index 3aba8370ac7f85792b755ca58a45109437d54dbd..05d314c940f476cf93ac552c7463eec24bdd321b 100644 (file)
@@ -3,6 +3,7 @@
 #include <avr/io.h>
 #include <util/delay.h>
 #include "musical_notes.h"
+#include "song_list.h"
 
 #ifndef AUDIO_H
 #define AUDIO_H