mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
100 lines
2.3 KiB
Rust
100 lines
2.3 KiB
Rust
use crate::*;
|
|
|
|
pub fn device_kinds () -> &'static [&'static str] {
|
|
&[
|
|
"Sampler",
|
|
"Plugin (LV2)",
|
|
]
|
|
}
|
|
|
|
impl<T: Has<Vec<Device>> + Has<Track>> HasDevices for T {
|
|
fn devices (&self) -> &Vec<Device> {
|
|
self.get()
|
|
}
|
|
fn devices_mut (&mut self) -> &mut Vec<Device> {
|
|
self.get_mut()
|
|
}
|
|
}
|
|
|
|
pub trait HasDevices: Has<Track> {
|
|
fn devices (&self) -> &Vec<Device>;
|
|
fn devices_mut (&mut self) -> &mut Vec<Device>;
|
|
}
|
|
|
|
#[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) -> &[MidiInput] {
|
|
match self {
|
|
//Self::Sampler(Sampler { midi_in, .. }) => &[midi_in],
|
|
_ => todo!()
|
|
}
|
|
}
|
|
pub fn midi_outs (&self) -> &[MidiOutput] {
|
|
match self {
|
|
Self::Sampler(_) => &[],
|
|
_ => todo!()
|
|
}
|
|
}
|
|
pub fn audio_ins (&self) -> &[AudioInput] {
|
|
match self {
|
|
Self::Sampler(Sampler { audio_ins, .. }) => audio_ins.as_slice(),
|
|
_ => todo!()
|
|
}
|
|
}
|
|
pub fn audio_outs (&self) -> &[AudioOutput] {
|
|
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 {
|
|
}
|