mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-07-17 07:46:57 +02:00
115 lines
3.2 KiB
Rust
115 lines
3.2 KiB
Rust
use crate::*;
|
|
|
|
def_command!(DeviceCommand: |device: Device| {});
|
|
|
|
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!()
|
|
}
|
|
}
|
|
}
|
|
|
|
/// A device that can be plugged into the chain.
|
|
///
|
|
/// ```
|
|
/// let device = tek::Device::default();
|
|
/// ```
|
|
#[derive(Debug, Default)] pub enum Device {
|
|
#[default]
|
|
Bypass,
|
|
Mute,
|
|
#[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,
|
|
}
|
|
|
|
/// Some sort of wrapper?
|
|
pub struct DeviceAudio<'a>(pub &'a mut Device);
|
|
|
|
impl_audio!(|self: DeviceAudio<'a>, client, scope|{
|
|
use Device::*;
|
|
match self.0 {
|
|
Mute => { Control::Continue },
|
|
Bypass => { /*TODO*/ Control::Continue },
|
|
#[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
|
|
}
|
|
});
|
|
|
|
pub fn device_kinds () -> &'static [&'static str] {
|
|
&[
|
|
#[cfg(feature = "sampler")] "Sampler",
|
|
#[cfg(feature = "lv2")] "Plugin (LV2)",
|
|
]
|
|
}
|
|
|
|
impl<T: AsRef<Vec<Device>> + AsMut<Vec<Device>>> HasDevices for T {
|
|
fn devices (&self) -> &Vec<Device> {
|
|
self.as_ref()
|
|
}
|
|
fn devices_mut (&mut self) -> &mut Vec<Device> {
|
|
self.as_mut()
|
|
}
|
|
}
|
|
|
|
pub trait HasDevices: AsRef<Vec<Device>> + AsMut<Vec<Device>> {
|
|
fn devices (&self) -> &Vec<Device> {
|
|
self.as_ref()
|
|
}
|
|
fn devices_mut (&mut self) -> &mut Vec<Device> {
|
|
self.as_mut()
|
|
}
|
|
}
|
|
|
|
pub mod arrange; pub use self::arrange::*;
|
|
pub mod browse; pub use self::browse::*;
|
|
pub mod clock; pub use self::clock::*;
|
|
pub mod dialog; pub use self::dialog::*;
|
|
pub mod editor; pub use self::editor::*;
|
|
pub mod menu; pub use self::menu::*;
|
|
pub mod mix; pub use self::mix::*;
|
|
pub mod port; pub use self::port::*;
|
|
pub mod sample; pub use self::sample::*;
|
|
pub mod sequence; pub use self::sequence::*;
|
|
|
|
#[cfg(feature = "plugin")] pub mod plugin;
|
|
#[cfg(feature = "plugin")] pub use self::plugin::*;
|