From 323118c40d732d878c66494c048c62ab37fd25e5 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 23 Apr 2023 22:17:06 +0200 Subject: Implement simple faders and potentiometers --- x1k2-midi-osc.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/x1k2-midi-osc.c b/x1k2-midi-osc.c index 08c43db..16c4bfb 100644 --- a/x1k2-midi-osc.c +++ b/x1k2-midi-osc.c @@ -166,9 +166,39 @@ static void handle_note(int note, int vel, lo_address osc_send_addr) } +static void handle_encoder(int enc, int val, lo_address osc_send_addr) +{ + printf("encoder %i: %i\n", enc, val); +} + + static void handle_cc(int cc, int val, lo_address osc_send_addr) { + char tmp[32]; + const char *type; + int num; + printf("CC %i = %i\n", cc, val); + + if ( cc < 4 ) { + handle_encoder(cc+1, val, osc_send_addr); + return; + } else if ( cc<=15 ) { + type = "potentiometers"; + num = cc+1; + } else if ( cc<=19 ) { + type = "faders"; + num = cc-15; + } else if ( cc<=21 ) { + handle_encoder(cc-15, val, osc_send_addr); + return; + } else { + fprintf(stderr, "CC %i unrecognised!\n", cc); + return; + } + + snprintf(tmp, 32, "/x1k2/%s/%i", type, num); + lo_send(osc_send_addr, tmp, "i", val); } -- cgit v1.2.3