use crate::*; impl> + Has> HasDevices for T { fn devices (&self) -> &Vec { self.get() } fn devices_mut (&mut self) -> &mut Vec { self.get_mut() } } pub trait HasDevices: Has { fn devices (&self) -> &Vec; fn devices_mut (&mut self) -> &mut Vec; } #[derive(Debug)] pub enum Device { #[cfg(feature = "sampler")] Sampler(Sampler), #[cfg(feature = "lv2")] // TODO Lv2(Lv2), #[cfg(feature = "vst2")] // TODO Vst2, #[cfg(feature = "vst3")] // TODO Vst3, #[cfg(feature = "clap")] // TODO Clap, #[cfg(feature = "sf2")] // TODO Sf2, } impl Device { pub fn name (&self) -> &str { match self { Self::Sampler(sampler) => sampler.name.as_ref(), _ => todo!(), } } pub fn midi_ins (&self) -> &[JackMidiIn] { match self { //Self::Sampler(Sampler { midi_in, .. }) => &[midi_in], _ => todo!() } } pub fn midi_outs (&self) -> &[JackMidiOut] { match self { Self::Sampler(_) => &[], _ => todo!() } } pub fn audio_ins (&self) -> &[JackAudioIn] { match self { Self::Sampler(Sampler { audio_ins, .. }) => audio_ins.as_slice(), _ => todo!() } } pub fn audio_outs (&self) -> &[JackAudioOut] { match self { Self::Sampler(Sampler { audio_outs, .. }) => audio_outs.as_slice(), _ => todo!() } } } pub struct DeviceAudio<'a>(pub &'a mut Device); audio!(|self: DeviceAudio<'a>, client, scope|{ use Device::*; match self.0 { #[cfg(feature = "sampler")] Sampler(sampler) => sampler.process(client, scope), #[cfg(feature = "lv2")] Lv2(lv2) => lv2.process(client, scope), #[cfg(feature = "vst2")] Vst2 => { todo!() }, // TODO #[cfg(feature = "vst3")] Vst3 => { todo!() }, // TODO #[cfg(feature = "clap")] Clap => { todo!() }, // TODO #[cfg(feature = "sf2")] Sf2 => { todo!() }, // TODO } }); #[tengri_proc::command(Device)] impl DeviceCommand { }