diff --git a/crates/tek_api/Cargo.toml b/crates/tek_api/Cargo.toml index 0352a1e8..c8f25c24 100644 --- a/crates/tek_api/Cargo.toml +++ b/crates/tek_api/Cargo.toml @@ -9,3 +9,4 @@ uuid = { version = "1.10.0", features = [ "v4" ] } vst = "0.4.0" livi = "0.7.4" symphonia = { version = "0.5.4", features = [ "all" ] } +wavers = "1.4.3" diff --git a/crates/tek_api/src/api_edn.rs b/crates/tek_api/src/api_edn.rs index 00a2f451..f6b196e7 100644 --- a/crates/tek_api/src/api_edn.rs +++ b/crates/tek_api/src/api_edn.rs @@ -169,7 +169,29 @@ impl Sample { }, _ => panic!("unexpected in sample {name}"), }); - let (end, data) = read_sample_data(&format!("{dir}/{file}"))?; - Ok((midi, Arc::new(RwLock::new(Self::new(&name, start, end, data))))) + let (end, data) = Sample::read_data(&format!("{dir}/{file}"))?; + Ok((midi, Arc::new(RwLock::new(Self { + name: name.into(), + start, + end, + channels: data, + rate: None + })))) + } + + /// Read WAV from file + pub fn read_data (src: &str) -> Usually<(usize, Vec>)> { + let mut channels: Vec> = vec![]; + for channel in wavers::Wav::from_path(src)?.channels() { + channels.push(channel); + } + let mut end = 0; + let mut data: Vec> = vec![]; + for samples in channels.iter() { + let channel = Vec::from(samples.as_ref()); + end = end.max(channel.len()); + data.push(channel); + } + Ok((end, data)) } } diff --git a/crates/tek_api/src/lib.rs b/crates/tek_api/src/lib.rs index 1b346ebf..818d694f 100644 --- a/crates/tek_api/src/lib.rs +++ b/crates/tek_api/src/lib.rs @@ -214,22 +214,30 @@ pub struct Plugin { } /// Supported plugin formats. -#[derive(Default, Debug)] +#[derive(Default)] pub enum PluginKind { #[default] None, LV2(LV2Plugin), - VST2 { - instance: ::vst::host::PluginInstance - }, + VST2 { instance: ::vst::host::PluginInstance }, VST3, } +impl std::fmt::Debug for PluginKind { + fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + write!(f, "{}", match self { + Self::None => "(none)", + Self::LV2(_) => "LV2", + Self::VST2{..} => "VST2", + Self::VST3 => "VST3", + }) + } +} /// A LV2 plugin. #[derive(Debug)] pub struct LV2Plugin { pub world: livi::World, pub instance: livi::Instance, - pub plugin: livi::LiviPlugin, + pub plugin: livi::Plugin, pub features: Arc, pub port_list: Vec, pub input_buffer: Vec, diff --git a/crates/tek_tui/src/sampler.rs b/crates/tek_tui/src/sampler.rs index 463a1e42..c2f46c0e 100644 --- a/crates/tek_tui/src/sampler.rs +++ b/crates/tek_tui/src/sampler.rs @@ -143,22 +143,6 @@ impl Sample { }}; } -/// Read WAV from file -pub fn read_sample_data (src: &str) -> Usually<(usize, Vec>)> { - let mut channels: Vec> = vec![]; - for channel in wavers::Wav::from_path(src)?.channels() { - channels.push(channel); - } - let mut end = 0; - let mut data: Vec> = vec![]; - for samples in channels.iter() { - let channel = Vec::from(samples.as_ref()); - end = end.max(channel.len()); - data.push(channel); - } - Ok((end, data)) -} - use std::fs::File; use symphonia::core::codecs::CODEC_TYPE_NULL; use symphonia::core::errors::Error;