diff options
author | Thomas White <taw@physics.org> | 2023-04-23 22:17:06 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2023-04-25 17:57:33 +0200 |
commit | 323118c40d732d878c66494c048c62ab37fd25e5 (patch) | |
tree | b0b192a585e8e35cce68911bee1d720dd1fe6879 | |
parent | 065f3f58a46a174519b7df2a34dacf1981770100 (diff) |
Implement simple faders and potentiometers
-rw-r--r-- | x1k2-midi-osc.c | 30 |
1 files changed, 30 insertions, 0 deletions
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); } |