From bcf81cd44eee5f9d0235a122bcee94377de1b935 Mon Sep 17 00:00:00 2001 From: Cassandra de la Cruz-Munoz Date: Sat, 30 Dec 2023 10:38:53 -0500 Subject: [PATCH] create VmcExtMidiCcVal --- src/lib.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 1a74f00..708f49d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -615,3 +615,33 @@ impl MessageBehavior for VmcExtMidiNote { }); } } + +struct VmcExtMidiCcVal { + knob: i32, + value: f32, +} + +impl MessageBehavior for VmcExtMidiCcVal { + fn to_sendable_osc_message(&self) -> OscMessage { + return OscMessage { + addr: String::from("/VMC/Ext/Midi/CC/Val"), + args: vec![OscType::from(self.knob), OscType::from(self.value)], + }; + } + fn parse_from_osc_message(msg: OscMessage) -> Result { + if msg.args.len() != 2 { + return Err(String::from("arg count invalid")); + } + let knob: i32; + let value: f32; + match msg.args[0] { + OscType::Int(i) => knob = i, + _ => return Err(String::from("arg type invalid")), + } + match msg.args[1] { + OscType::Float(f) => value = f, + _ => return Err(String::from("arg type invalid")), + } + return Ok(VmcExtMidiCcVal { knob, value }); + } +}