aboutsummaryrefslogtreecommitdiff
path: root/quantum/audio
diff options
context:
space:
mode:
authorIBNobody <IBNobody@users.noreply.github.com>2016-04-22 00:01:38 -0500
committerJack Humbert <jack.humb@gmail.com>2016-04-22 01:01:38 -0400
commit082a0f313d8c842a5de7bae30ec8a3597e35880b (patch)
tree2e53e01fb96aef81a3727ec4ecfbccd6e11cb74b /quantum/audio
parent7b3f212500210ae85063b043952b5b3ef6988ad6 (diff)
downloadqmk_firmware-082a0f313d8c842a5de7bae30ec8a3597e35880b.tar.gz
qmk_firmware-082a0f313d8c842a5de7bae30ec8a3597e35880b.zip
fixed compiler warnings (#273)
Diffstat (limited to 'quantum/audio')
-rw-r--r--quantum/audio/audio.h6
-rw-r--r--quantum/audio/voices.c37
-rw-r--r--quantum/audio/voices.h4
3 files changed, 30 insertions, 17 deletions
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h
index d1ccfdb82..89769507e 100644
--- a/quantum/audio/audio.h
+++ b/quantum/audio/audio.h
@@ -50,8 +50,8 @@ void decrease_vibrato_strength(float change);
50// Polyphony functions 50// Polyphony functions
51 51
52void set_polyphony_rate(float rate); 52void set_polyphony_rate(float rate);
53void enable_polyphony(); 53void enable_polyphony(void);
54void disable_polyphony(); 54void disable_polyphony(void);
55void increase_polyphony_rate(float change); 55void increase_polyphony_rate(float change);
56void decrease_polyphony_rate(float change); 56void decrease_polyphony_rate(float change);
57 57
@@ -61,7 +61,7 @@ void set_tempo(float tempo);
61void increase_tempo(uint8_t tempo_change); 61void increase_tempo(uint8_t tempo_change);
62void decrease_tempo(uint8_t tempo_change); 62void decrease_tempo(uint8_t tempo_change);
63 63
64void audio_init(); 64void audio_init(void);
65 65
66#ifdef PWM_AUDIO 66#ifdef PWM_AUDIO
67void play_sample(uint8_t * s, uint16_t l, bool r); 67void play_sample(uint8_t * s, uint16_t l, bool r);
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c
index 98631f0cb..330ffb803 100644
--- a/quantum/audio/voices.c
+++ b/quantum/audio/voices.c
@@ -1,4 +1,5 @@
1#include "voices.h" 1#include "voices.h"
2#include "stdlib.h"
2 3
3// these are imported from audio.c 4// these are imported from audio.c
4extern uint16_t envelope_index; 5extern uint16_t envelope_index;
@@ -27,26 +28,31 @@ float voice_envelope(float frequency) {
27 case default_voice: 28 case default_voice:
28 note_timbre = TIMBRE_50; 29 note_timbre = TIMBRE_50;
29 polyphony_rate = 0; 30 polyphony_rate = 0;
30 break; 31 break;
32
31 case butts_fader: 33 case butts_fader:
32 polyphony_rate = 0; 34 polyphony_rate = 0;
33 switch (compensated_index) { 35 switch (compensated_index) {
34 case 0 ... 9: 36 case 0 ... 9:
35 frequency = frequency / 4; 37 frequency = frequency / 4;
36 note_timbre = TIMBRE_12; 38 note_timbre = TIMBRE_12;
37 break; 39 break;
40
38 case 10 ... 19: 41 case 10 ... 19:
39 frequency = frequency / 2; 42 frequency = frequency / 2;
40 note_timbre = TIMBRE_12; 43 note_timbre = TIMBRE_12;
41 break; 44 break;
45
42 case 20 ... 200: 46 case 20 ... 200:
43 note_timbre = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2)*.125; 47 note_timbre = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2)*.125;
44 break; 48 break;
49
45 default: 50 default:
46 note_timbre = 0; 51 note_timbre = 0;
47 break; 52 break;
48 } 53 }
49 break; 54 break;
55
50 case octave_crunch: 56 case octave_crunch:
51 polyphony_rate = 0; 57 polyphony_rate = 0;
52 switch (compensated_index) { 58 switch (compensated_index) {
@@ -56,17 +62,20 @@ float voice_envelope(float frequency) {
56 frequency = frequency / 2; 62 frequency = frequency / 2;
57 note_timbre = TIMBRE_12; 63 note_timbre = TIMBRE_12;
58 break; 64 break;
65
59 case 10 ... 19: 66 case 10 ... 19:
60 case 25 ... 29: 67 case 25 ... 29:
61 case 33 ... 35: 68 case 33 ... 35:
62 frequency = frequency * 2; 69 frequency = frequency * 2;
63 note_timbre = TIMBRE_12; 70 note_timbre = TIMBRE_12;
64 break; 71 break;
72
65 default: 73 default:
66 note_timbre = TIMBRE_12; 74 note_timbre = TIMBRE_12;
67 break; 75 break;
68 } 76 }
69 break; 77 break;
78
70 case duty_osc: 79 case duty_osc:
71 // This slows the loop down a substantial amount, so higher notes may freeze 80 // This slows the loop down a substantial amount, so higher notes may freeze
72 polyphony_rate = 0; 81 polyphony_rate = 0;
@@ -78,13 +87,17 @@ float voice_envelope(float frequency) {
78 // note_timbre = (sin((float)compensated_index/10000*OCS_SPEED) * OCS_AMP / 2) + .5; 87 // note_timbre = (sin((float)compensated_index/10000*OCS_SPEED) * OCS_AMP / 2) + .5;
79 // triangle wave is a bit faster 88 // triangle wave is a bit faster
80 note_timbre = (float)abs((compensated_index*OCS_SPEED % 3000) - 1500) * ( OCS_AMP / 1500 ) + (1 - OCS_AMP) / 2; 89 note_timbre = (float)abs((compensated_index*OCS_SPEED % 3000) - 1500) * ( OCS_AMP / 1500 ) + (1 - OCS_AMP) / 2;
81 break; 90 break;
82 } 91 }
83 break; 92 break;
93
84 case duty_octave_down: 94 case duty_octave_down:
85 polyphony_rate = 0; 95 polyphony_rate = 0;
86 note_timbre = (envelope_index % 2) * .125 + .375 * 2; 96 note_timbre = (envelope_index % 2) * .125 + .375 * 2;
87 break; 97 break;
98
99 default:
100 break;
88 } 101 }
89 102
90 return frequency; 103 return frequency;
diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h
index 5aa99f4b1..2822fb6ac 100644
--- a/quantum/audio/voices.h
+++ b/quantum/audio/voices.h
@@ -20,7 +20,7 @@ typedef enum {
20} voice_type; 20} voice_type;
21 21
22void set_voice(voice_type v); 22void set_voice(voice_type v);
23void voice_iterate(); 23void voice_iterate(void);
24void voice_deiterate(); 24void voice_deiterate(void);
25 25
26#endif \ No newline at end of file 26#endif \ No newline at end of file