aboutsummaryrefslogtreecommitdiff
path: root/quantum/audio/voices.c
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2016-12-19 11:18:18 -0500
committerJack Humbert <jack.humb@gmail.com>2016-12-19 11:18:18 -0500
commit06c64bbff3e228df542149acde64eadaf59b9b0f (patch)
tree9bda86e11116ba8f66de345fd4ce940c2698d630 /quantum/audio/voices.c
parentae95834f5af7404c04e6fe3446019046278d814b (diff)
downloadqmk_firmware-06c64bbff3e228df542149acde64eadaf59b9b0f.tar.gz
qmk_firmware-06c64bbff3e228df542149acde64eadaf59b9b0f.zip
rgb clean-up, api clean-up
Diffstat (limited to 'quantum/audio/voices.c')
-rw-r--r--quantum/audio/voices.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c
index 19f7b646e..06ff275ba 100644
--- a/quantum/audio/voices.c
+++ b/quantum/audio/voices.c
@@ -6,6 +6,7 @@
6extern uint16_t envelope_index; 6extern uint16_t envelope_index;
7extern float note_timbre; 7extern float note_timbre;
8extern float polyphony_rate; 8extern float polyphony_rate;
9extern bool glissando;
9 10
10voice_type voice = default_voice; 11voice_type voice = default_voice;
11 12
@@ -27,11 +28,13 @@ float voice_envelope(float frequency) {
27 28
28 switch (voice) { 29 switch (voice) {
29 case default_voice: 30 case default_voice:
31 glissando = true;
30 note_timbre = TIMBRE_50; 32 note_timbre = TIMBRE_50;
31 polyphony_rate = 0; 33 polyphony_rate = 0;
32 break; 34 break;
33 35
34 case something: 36 case something:
37 glissando = false;
35 polyphony_rate = 0; 38 polyphony_rate = 0;
36 switch (compensated_index) { 39 switch (compensated_index) {
37 case 0 ... 9: 40 case 0 ... 9:
@@ -43,16 +46,51 @@ float voice_envelope(float frequency) {
43 break; 46 break;
44 47
45 case 20 ... 200: 48 case 20 ... 200:
46 note_timbre = .25 + .125 + pow(((float)compensated_index - 20) / (200 - 20), 2)*.125; 49 note_timbre = .125 + .125;
47 break; 50 break;
48 51
49 default: 52 default:
50 note_timbre = .25; 53 note_timbre = .125;
51 break; 54 break;
52 } 55 }
53 break; 56 break;
54 57
58 case drums:
59 glissando = false;
60 polyphony_rate = 0;
61 note_timbre = 0;
62 switch (envelope_index) {
63 case 0 ... 20:
64 note_timbre = 0.5;
65 default:
66 frequency = (rand() % (int)(frequency * 1.2 - frequency)) + (frequency * 0.8);
67 break;
68 }
69 // if (frequency < 80.0) {
70 // switch (envelope_index % 4) {
71 // case 0:
72 // frequency = 348.0;
73 // case 1:
74 // frequency = 53.0;
75 // case 2:
76 // frequency = 128.0;
77 // case 3:
78 // frequency = 934.0;
79 // default:
80 // break;
81 // }
82 // } else if (frequency < 160.0) {
83
84 // } else if (frequency < 320.0) {
85
86 // } else if (frequency < 640.0) {
87
88 // } else if (frequency < 1280.0) {
89
90 // }
91 break;
55 case butts_fader: 92 case butts_fader:
93 glissando = true;
56 polyphony_rate = 0; 94 polyphony_rate = 0;
57 switch (compensated_index) { 95 switch (compensated_index) {
58 case 0 ... 9: 96 case 0 ... 9:
@@ -100,6 +138,7 @@ float voice_envelope(float frequency) {
100 138
101 case duty_osc: 139 case duty_osc:
102 // This slows the loop down a substantial amount, so higher notes may freeze 140 // This slows the loop down a substantial amount, so higher notes may freeze
141 glissando = true;
103 polyphony_rate = 0; 142 polyphony_rate = 0;
104 switch (compensated_index) { 143 switch (compensated_index) {
105 default: 144 default:
@@ -114,6 +153,7 @@ float voice_envelope(float frequency) {
114 break; 153 break;
115 154
116 case duty_octave_down: 155 case duty_octave_down:
156 glissando = true;
117 polyphony_rate = 0; 157 polyphony_rate = 0;
118 note_timbre = (envelope_index % 2) * .125 + .375 * 2; 158 note_timbre = (envelope_index % 2) * .125 + .375 * 2;
119 if ((envelope_index % 4) == 0) 159 if ((envelope_index % 4) == 0)
@@ -122,6 +162,7 @@ float voice_envelope(float frequency) {
122 note_timbre = 0; 162 note_timbre = 0;
123 break; 163 break;
124 case delayed_vibrato: 164 case delayed_vibrato:
165 glissando = true;
125 polyphony_rate = 0; 166 polyphony_rate = 0;
126 note_timbre = TIMBRE_50; 167 note_timbre = TIMBRE_50;
127 #define VOICE_VIBRATO_DELAY 150 168 #define VOICE_VIBRATO_DELAY 150