Macro rmididings::ProcessOsc [−][src]
macro_rules! ProcessOsc { ( $argt0:path, $f:expr ) => { ... }; ( $argt0:path, $argt1:path, $f:expr ) => { ... }; ( $argt0:path, $argt1:path, $argt2:path, $f:expr ) => { ... }; ( $argt0:path, $argt1:path, $argt2:path, $argt3:path, $f:expr ) => { ... }; ( $argt0:path, $argt1:path, $argt2:path, $argt3:path, $argt4:path, $f:expr ) => { ... }; ( $argt0:path, $argt1:path, $argt2:path, $argt3:path, $argt4:path, $argt5:path, $f:expr ) => { ... }; ( $argt0:path, $argt1:path, $argt2:path, $argt3:path, $argt4:path, $argt5:path, $argt6:path, $f:expr ) => { ... }; ( $argt0:path, $argt1:path, $argt2:path, $argt3:path, $argt4:path, $argt5:path, $argt6:path, $argt7:path, $f:expr ) => { ... }; }
Expand description
Process an incoming OSC event using a function, which returns a patch to run on the event.
A maximum of eight OSC arguments is currently supported (please open an issue if you need more).
Examples
use rmididings::osc::OscType as o; let filter = Chain!(OscAddrFilter("/foo"), ProcessOsc!(o::Int, |i: &i32| NoteOn(*i as u8, 30))); let mut evs = EventStream::from(OscEvent(0, "/foo".to_string(), vec![o::Int(60)])); filter.run(&mut evs); assert_eq!(evs, NoteOnEvent(0,0,60,30));
use rmididings::osc::OscType as o; let filter = Chain!(OscAddrFilter("/foo"), ProcessOsc!(o::Int, |i: &i32| NoteOn(*i as u8, 30))); let ev1 = OscEvent(0, "/foo".to_string(), vec![o::Int(60)]); let ev2 = OscEvent(0, "/foo".to_string(), vec![o::Int(60), o::Int(10)]); let ev3 = OscEvent(0, "/foo".to_string(), vec![o::Float(1.0)]); let ev4 = OscEvent(0, "/foo".to_string(), vec![]); let ev5 = NoteOnEvent(0,0,62,30); let mut evs = EventStream::from(vec![&ev1, &ev2, &ev3, &ev4, &ev5]); filter.run(&mut evs); assert_eq!(evs, vec![NoteOnEvent(0,0,60,30), ev2, ev3, ev4, ev5]);