diff options
author | Bad Diode <bd@badd10de.dev> | 2023-02-08 14:42:58 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-02-08 14:42:58 +0100 |
commit | c5095a38738d0f432245d14f91098c6309c1f6cc (patch) | |
tree | 36b36ef25eabac6c0c7ee69398378b2d395db2d7 /src | |
parent | 08983247025697848579b35ef693d0b44904f728 (diff) | |
download | launchpad-polymaker-c5095a38738d0f432245d14f91098c6309c1f6cc.tar.gz launchpad-polymaker-c5095a38738d0f432245d14f91098c6309c1f6cc.zip |
Add a voice counter
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 30 |
1 files changed, 18 insertions, 12 deletions
@@ -32,6 +32,10 @@ | |||
32 | 32 | ||
33 | #include "app.h" | 33 | #include "app.h" |
34 | 34 | ||
35 | // Housekeeping and debugging. | ||
36 | u16 frame = 0; | ||
37 | u16 value = 0; | ||
38 | |||
35 | // store ADC frame pointer | 39 | // store ADC frame pointer |
36 | static const u16 *g_ADC = 0; | 40 | static const u16 *g_ADC = 0; |
37 | 41 | ||
@@ -155,6 +159,11 @@ app_midi_event(u8 port, u8 status, u8 d1, u8 d2) { | |||
155 | if (port == DINMIDI) { | 159 | if (port == DINMIDI) { |
156 | hal_send_midi(USBMIDI, status, d1, d2); | 160 | hal_send_midi(USBMIDI, status, d1, d2); |
157 | } | 161 | } |
162 | if ((status & 0xF0) == NOTEON) { | ||
163 | value++; | ||
164 | } else if ((status & 0xF0) == NOTEOFF) { | ||
165 | value--; | ||
166 | } | ||
158 | } | 167 | } |
159 | 168 | ||
160 | void | 169 | void |
@@ -192,20 +201,17 @@ print_number(u8 n, u16 r, u16 g, u16 b, u8 x, u8 y) { | |||
192 | } | 201 | } |
193 | } | 202 | } |
194 | 203 | ||
195 | u16 frame = 0; | ||
196 | u16 value = 0; | ||
197 | |||
198 | void | 204 | void |
199 | update(void) { | 205 | update(void) { |
200 | for (int i = 0; i < PAD_COUNT; ++i) { | 206 | // for (int i = 0; i < PAD_COUNT; ++i) { |
201 | // Get the first detected button value. | 207 | // // Get the first detected button value. |
202 | u16 x = (99 * g_ADC[i]) >> 12; | 208 | // u16 x = (99 * g_ADC[i]) >> 12; |
203 | if (x > 3) { | 209 | // if (x > 3) { |
204 | value = x; | 210 | // value = x; |
205 | return; | 211 | // return; |
206 | } | 212 | // } |
207 | } | 213 | // } |
208 | value = 0; | 214 | // value = 0; |
209 | } | 215 | } |
210 | 216 | ||
211 | void | 217 | void |