From c5095a38738d0f432245d14f91098c6309c1f6cc Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Wed, 8 Feb 2023 14:42:58 +0100 Subject: Add a voice counter --- src/app.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/app.c b/src/app.c index 013025c..9258965 100644 --- a/src/app.c +++ b/src/app.c @@ -32,6 +32,10 @@ #include "app.h" +// Housekeeping and debugging. +u16 frame = 0; +u16 value = 0; + // store ADC frame pointer static const u16 *g_ADC = 0; @@ -155,6 +159,11 @@ app_midi_event(u8 port, u8 status, u8 d1, u8 d2) { if (port == DINMIDI) { hal_send_midi(USBMIDI, status, d1, d2); } + if ((status & 0xF0) == NOTEON) { + value++; + } else if ((status & 0xF0) == NOTEOFF) { + value--; + } } void @@ -192,20 +201,17 @@ print_number(u8 n, u16 r, u16 g, u16 b, u8 x, u8 y) { } } -u16 frame = 0; -u16 value = 0; - void update(void) { - for (int i = 0; i < PAD_COUNT; ++i) { - // Get the first detected button value. - u16 x = (99 * g_ADC[i]) >> 12; - if (x > 3) { - value = x; - return; - } - } - value = 0; + // for (int i = 0; i < PAD_COUNT; ++i) { + // // Get the first detected button value. + // u16 x = (99 * g_ADC[i]) >> 12; + // if (x > 3) { + // value = x; + // return; + // } + // } + // value = 0; } void -- cgit v1.2.1