mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
83 lines
2.8 KiB
Rust
83 lines
2.8 KiB
Rust
use crate::*;
|
|
|
|
pub enum MixerTrackCommand {}
|
|
|
|
/// A mixer track.
|
|
#[derive(Debug)]
|
|
pub struct MixerTrack {
|
|
pub name: String,
|
|
/// Inputs of 1st device
|
|
pub audio_ins: Vec<Port<AudioIn>>,
|
|
/// Outputs of last device
|
|
pub audio_outs: Vec<Port<AudioOut>>,
|
|
/// Device chain
|
|
pub devices: Vec<Box<dyn MixerTrackDevice>>,
|
|
}
|
|
|
|
//impl MixerTrackDevice for LV2Plugin {}
|
|
|
|
impl MixerTrack {
|
|
const SYM_NAME: &'static str = ":name";
|
|
const SYM_GAIN: &'static str = ":gain";
|
|
const SYM_SAMPLER: &'static str = "sampler";
|
|
const SYM_LV2: &'static str = "lv2";
|
|
pub fn from_edn <'a, 'e> (jack: &Arc<RwLock<JackClient>>, args: &[Edn<'e>]) -> Usually<Self> {
|
|
let mut _gain = 0.0f64;
|
|
let mut track = MixerTrack {
|
|
name: String::new(),
|
|
audio_ins: vec![],
|
|
audio_outs: vec![],
|
|
devices: vec![],
|
|
};
|
|
edn!(edn in args {
|
|
Edn::Map(map) => {
|
|
if let Some(Edn::Str(n)) = map.get(&Edn::Key(Self::SYM_NAME)) {
|
|
track.name = n.to_string();
|
|
}
|
|
if let Some(Edn::Double(g)) = map.get(&Edn::Key(Self::SYM_GAIN)) {
|
|
_gain = f64::from(*g);
|
|
}
|
|
},
|
|
Edn::List(args) => match args.get(0) {
|
|
// Add a sampler device to the track
|
|
Some(Edn::Symbol(Self::SYM_SAMPLER)) => {
|
|
track.devices.push(
|
|
Box::new(Sampler::from_edn(jack, &args[1..])?) as Box<dyn MixerTrackDevice>
|
|
);
|
|
panic!(
|
|
"unsupported in track {}: {:?}; tek_mixer not compiled with feature \"sampler\"",
|
|
&track.name,
|
|
args.get(0).unwrap()
|
|
)
|
|
},
|
|
// Add a LV2 plugin to the track.
|
|
Some(Edn::Symbol(Self::SYM_LV2)) => {
|
|
track.devices.push(
|
|
Box::new(LV2Plugin::from_edn(jack, &args[1..])?) as Box<dyn MixerTrackDevice>
|
|
);
|
|
panic!(
|
|
"unsupported in track {}: {:?}; tek_mixer not compiled with feature \"plugin\"",
|
|
&track.name,
|
|
args.get(0).unwrap()
|
|
)
|
|
},
|
|
None =>
|
|
panic!("empty list track {}", &track.name),
|
|
_ =>
|
|
panic!("unexpected in track {}: {:?}", &track.name, args.get(0).unwrap())
|
|
},
|
|
_ => {}
|
|
});
|
|
Ok(track)
|
|
}
|
|
}
|
|
|
|
pub trait MixerTrackDevice: Debug + Send + Sync {
|
|
fn boxed (self) -> Box<dyn MixerTrackDevice> where Self: Sized + 'static {
|
|
Box::new(self)
|
|
}
|
|
}
|
|
|
|
impl MixerTrackDevice for Sampler {}
|
|
|
|
impl MixerTrackDevice for Plugin {}
|