mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
fetching lv2 parameters
This commit is contained in:
parent
1e395274f6
commit
ce1c28edb9
2 changed files with 40 additions and 15 deletions
|
|
@ -6,24 +6,26 @@ mod vst3;
|
||||||
|
|
||||||
pub struct Plugin {
|
pub struct Plugin {
|
||||||
name: String,
|
name: String,
|
||||||
|
path: String,
|
||||||
plugin: Option<PluginKind>
|
plugin: Option<PluginKind>
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PluginKind {
|
enum PluginKind {
|
||||||
VST2(::vst::host::PluginInstance),
|
VST2(::vst::host::PluginInstance),
|
||||||
VST3,
|
VST3,
|
||||||
LV2(::livi::Plugin),
|
LV2(Vec<::livi::Port>, ::livi::Instance),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const HELM: &'static str = "file:///nix/store/ij3sz7nqg5l7v2dygdvzy3w6cj62bd6r-helm-0.9.0/lib/lv2/helm.lv2";
|
||||||
|
|
||||||
impl Plugin {
|
impl Plugin {
|
||||||
pub fn new (name: &str) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
|
pub fn new (name: &str) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
|
||||||
let device = DynamicDevice::new(render, handle, process, Self {
|
let device = DynamicDevice::new(render, handle, process, Self {
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
|
path: HELM.into(),
|
||||||
plugin: None,
|
plugin: None,
|
||||||
});
|
});
|
||||||
device.state.lock().unwrap().plugin = Some(self::lv2::plug_in(
|
device.state.lock().unwrap().plugin = Some(self::lv2::plug_in(HELM)?);
|
||||||
"file:///nix/store/ij3sz7nqg5l7v2dygdvzy3w6cj62bd6r-helm-0.9.0/lib/lv2/helm.lv2"
|
|
||||||
)?);
|
|
||||||
Ok(device)
|
Ok(device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -38,15 +40,32 @@ pub fn render (state: &Plugin, buf: &mut Buffer, Rect { x, y, .. }: Rect)
|
||||||
-> Usually<Rect>
|
-> Usually<Rect>
|
||||||
{
|
{
|
||||||
let style = Style::default().gray();
|
let style = Style::default().gray();
|
||||||
draw_box(buf, Rect { x, y, width: 40, height: 8 });
|
|
||||||
buf.set_string(x + 1, y + 1, &format!(" {}", state.name), style.white().bold());
|
buf.set_string(x + 1, y + 1, &format!(" {}", state.name), style.white().bold());
|
||||||
buf.set_string(x + 13, y + 1, &format!("│ Plugin Name"), style.not_dim());
|
buf.set_string(x + 13, y + 1, &format!("│ ...{}...", &HELM[13..30]), style.not_dim());
|
||||||
buf.set_string(x + 0, y + 2, &format!("├--------------------------------------┤"), style.dim());
|
buf.set_string(x + 0, y + 2, &format!("├--------------------------------------┤"), style.dim());
|
||||||
|
match &state.plugin {
|
||||||
|
Some(PluginKind::LV2(ports, instance)) => {
|
||||||
|
let mut height = 3;
|
||||||
|
for (i, port) in ports.iter().enumerate() {
|
||||||
|
if i >= 10 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
buf.set_string(x + 2, y + 3 + i as u16, &format!("{:20} = {:03}",
|
||||||
|
port.name,
|
||||||
|
port.default_value
|
||||||
|
), Style::default());
|
||||||
|
height = height + 1;
|
||||||
|
}
|
||||||
|
Ok(draw_box(buf, Rect { x, y, width: 40, height }))
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
buf.set_string(x + 1, y + 3, &format!(" Parameter 1 0.0"), style);
|
buf.set_string(x + 1, y + 3, &format!(" Parameter 1 0.0"), style);
|
||||||
buf.set_string(x + 1, y + 4, &format!(" Parameter 2 0.0"), style);
|
buf.set_string(x + 1, y + 4, &format!(" Parameter 2 0.0"), style);
|
||||||
buf.set_string(x + 1, y + 5, &format!(" Parameter 3 0.0"), style);
|
buf.set_string(x + 1, y + 5, &format!(" Parameter 3 0.0"), style);
|
||||||
buf.set_string(x + 1, y + 6, &format!(" Parameter 4 0.0"), style);
|
buf.set_string(x + 1, y + 6, &format!(" Parameter 4 0.0"), style);
|
||||||
Ok(Rect { x, y, width: 40, height: 7 })
|
Ok(draw_box(buf, Rect { x, y, width: 40, height: 7 }))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle (_: &mut Plugin, _: &AppEvent) -> Usually<bool> {
|
pub fn handle (_: &mut Plugin, _: &AppEvent) -> Usually<bool> {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
pub fn plug_in (path: &str) -> Usually<PluginKind> {
|
pub fn plug_in (uri: &str) -> Usually<PluginKind> {
|
||||||
let world = ::livi::World::with_load_bundle(&path);
|
let world = ::livi::World::with_load_bundle(&uri);
|
||||||
world.build_features(::livi::FeaturesBuilder {
|
let features = world.build_features(::livi::FeaturesBuilder {
|
||||||
min_block_length: 1,
|
min_block_length: 1,
|
||||||
max_block_length: 65536,
|
max_block_length: 65536,
|
||||||
});
|
});
|
||||||
|
|
@ -12,6 +12,12 @@ pub fn plug_in (path: &str) -> Usually<PluginKind> {
|
||||||
plugin = Some(p);
|
plugin = Some(p);
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
let result = PluginKind::LV2(plugin.unwrap());
|
let plugin = plugin.unwrap();
|
||||||
|
let mut ports = vec![];
|
||||||
|
for port in plugin.ports() {
|
||||||
|
ports.push(port);
|
||||||
|
}
|
||||||
|
let instance = unsafe { plugin.instantiate(features.clone(), 48000.0).expect("boop") };
|
||||||
|
let result = PluginKind::LV2(ports, instance);
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue