mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: vst2 host?
This commit is contained in:
parent
228805d30d
commit
4b0055a21c
7 changed files with 151 additions and 42 deletions
100
Cargo.lock
generated
100
Cargo.lock
generated
|
|
@ -185,7 +185,7 @@ dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -461,6 +461,36 @@ dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num_enum"
|
||||||
|
version = "0.5.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9"
|
||||||
|
dependencies = [
|
||||||
|
"num_enum_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num_enum_derive"
|
||||||
|
version = "0.5.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-crate",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "object"
|
name = "object"
|
||||||
version = "0.35.0"
|
version = "0.35.0"
|
||||||
|
|
@ -511,6 +541,16 @@ version = "0.3.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
|
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-crate"
|
||||||
|
version = "1.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"toml_edit 0.19.15",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.81"
|
version = "1.0.81"
|
||||||
|
|
@ -619,7 +659,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -674,7 +714,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a"
|
checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -708,7 +748,18 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"rustversion",
|
"rustversion",
|
||||||
"syn",
|
"syn 2.0.60",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.109"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -735,6 +786,7 @@ dependencies = [
|
||||||
"midly",
|
"midly",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
"toml",
|
"toml",
|
||||||
|
"vst",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -746,7 +798,7 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_spanned",
|
"serde_spanned",
|
||||||
"toml_datetime",
|
"toml_datetime",
|
||||||
"toml_edit",
|
"toml_edit 0.22.14",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -758,6 +810,17 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml_edit"
|
||||||
|
version = "0.19.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
|
||||||
|
dependencies = [
|
||||||
|
"indexmap",
|
||||||
|
"toml_datetime",
|
||||||
|
"winnow 0.5.40",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_edit"
|
name = "toml_edit"
|
||||||
version = "0.22.14"
|
version = "0.22.14"
|
||||||
|
|
@ -768,7 +831,7 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_spanned",
|
"serde_spanned",
|
||||||
"toml_datetime",
|
"toml_datetime",
|
||||||
"winnow",
|
"winnow 0.6.13",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -811,6 +874,20 @@ version = "0.9.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vst"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "caf1ddbb85e53de6c1534f97340b065ca127678dcc31f88a33b93e54a5ac38dc"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"libc",
|
||||||
|
"libloading",
|
||||||
|
"log",
|
||||||
|
"num-traits",
|
||||||
|
"num_enum",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.11.0+wasi-snapshot-preview1"
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
|
|
@ -978,6 +1055,15 @@ version = "0.52.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winnow"
|
||||||
|
version = "0.5.40"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winnow"
|
name = "winnow"
|
||||||
version = "0.6.13"
|
version = "0.6.13"
|
||||||
|
|
@ -1004,5 +1090,5 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,6 @@ microxdg = "0.1.2"
|
||||||
toml = "0.8.12"
|
toml = "0.8.12"
|
||||||
better-panic = "0.3.0"
|
better-panic = "0.3.0"
|
||||||
midly = "0.5"
|
midly = "0.5"
|
||||||
|
|
||||||
|
vst = "0.4.0"
|
||||||
|
#vst3 = "0.1.0"
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,16 @@ use crate::prelude::*;
|
||||||
|
|
||||||
pub struct Chain {
|
pub struct Chain {
|
||||||
name: String,
|
name: String,
|
||||||
devices: Vec<Box<dyn Device>>
|
devices: Vec<Box<dyn Device>>,
|
||||||
|
focused: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Chain {
|
impl Chain {
|
||||||
pub fn new (name: &str, devices: Vec<Box<dyn Device>>) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
|
pub fn new (name: &str, devices: Vec<Box<dyn Device>>) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
|
||||||
Ok(DynamicDevice::new(render, handle, process, Self {
|
Ok(DynamicDevice::new(render, handle, process, Self {
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
devices
|
devices,
|
||||||
|
focused: 0
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,18 +30,17 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
||||||
buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
||||||
buf.set_string(area.x + 2, y, "Input...", Style::default().dim());
|
buf.set_string(area.x + 2, y, "Input...", Style::default().dim());
|
||||||
let mut x = 0u16;
|
let mut x = 0u16;
|
||||||
y = y + 1;
|
|
||||||
for device in state.devices.iter() {
|
for device in state.devices.iter() {
|
||||||
let result = device.render(buf, Rect {
|
let result = device.render(buf, Rect {
|
||||||
x: area.x,
|
x: area.x,
|
||||||
y: area.y + y,
|
y,
|
||||||
width: area.width,
|
width: area.width,
|
||||||
height: area.height.saturating_sub(y)
|
height: 21//area.height.saturating_sub(y)
|
||||||
})?;
|
})?;
|
||||||
//buf.set_string(area.x, y, format!("{y}---TOP---+{h}"), Style::default().red());
|
//let result = Rect { x: 0, y: 0, width: result.width, height: 21 };
|
||||||
x = x.max(result.width);
|
x = x.max(result.width);
|
||||||
y = y + result.height;
|
y = y + result.height;
|
||||||
y = y + 1;
|
//y = y + 1;
|
||||||
buf.set_string(area.x, y, "│", Style::default().black());
|
buf.set_string(area.x, y, "│", Style::default().black());
|
||||||
buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
||||||
buf.set_string(area.x + 2, y, " Patch in ┐ │ └ Patch out", Style::default().dim());
|
buf.set_string(area.x + 2, y, " Patch in ┐ │ └ Patch out", Style::default().dim());
|
||||||
|
|
@ -48,7 +49,12 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
||||||
//buf.set_string(area.x + area.width - 1, area.y + 1, "│", Style::default().black());
|
//buf.set_string(area.x + area.width - 1, area.y + 1, "│", Style::default().black());
|
||||||
//buf.set_string(area.x + 2, y, "Patch...", Style::default().dim());
|
//buf.set_string(area.x + 2, y, "Patch...", Style::default().dim());
|
||||||
}
|
}
|
||||||
Ok(Rect { x: area.x, y: area.y, width: x, height: y })
|
Ok(draw_box(buf, Rect {
|
||||||
|
x: area.x,
|
||||||
|
y: area.y,
|
||||||
|
width: area.width,
|
||||||
|
height: y - area.y,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle (_: &mut Chain, _: &AppEvent) -> Usually<bool> {
|
pub fn handle (_: &mut Chain, _: &AppEvent) -> Usually<bool> {
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,28 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub struct Plugin {
|
pub struct Plugin {
|
||||||
name: String
|
name: String,
|
||||||
|
plugin: Option<::vst::host::PluginInstance>
|
||||||
}
|
}
|
||||||
|
|
||||||
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>> {
|
||||||
Ok(DynamicDevice::new(render, handle, process, Self {
|
let device = DynamicDevice::new(render, handle, process, Self {
|
||||||
name: name.into()
|
name: name.into(),
|
||||||
}))
|
plugin: None,
|
||||||
|
});
|
||||||
|
let mut loader = ::vst::host::PluginLoader::load(
|
||||||
|
&std::path::Path::new("/nix/store/ij3sz7nqg5l7v2dygdvzy3w6cj62bd6r-helm-0.9.0/lib/lxvst/helm.so"),
|
||||||
|
device.state.clone()
|
||||||
|
)?;
|
||||||
|
let plugin = loader.instance()?;
|
||||||
|
device.state.lock().unwrap().plugin = Some(plugin);
|
||||||
|
Ok(device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ::vst::host::Host for Plugin {}
|
||||||
|
|
||||||
pub fn process (_: &mut Plugin, _: &Client, _: &ProcessScope) -> Control {
|
pub fn process (_: &mut Plugin, _: &Client, _: &ProcessScope) -> Control {
|
||||||
Control::Continue
|
Control::Continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,12 @@ impl Device for Rows {
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
Event::Key(KeyEvent { code: KeyCode::Enter, .. }) => {
|
Event::Key(KeyEvent { code: KeyCode::Enter, .. }) => {
|
||||||
self.focused = false;
|
self.focused = true;
|
||||||
self.items[self.focus].handle(&AppEvent::Focus)?;
|
self.items[self.focus].handle(&AppEvent::Focus)?;
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
Event::Key(KeyEvent { code: KeyCode::Esc, .. }) => {
|
Event::Key(KeyEvent { code: KeyCode::Esc, .. }) => {
|
||||||
self.focused = true;
|
self.focused = false;
|
||||||
self.items[self.focus].handle(&AppEvent::Blur)?;
|
self.items[self.focus].handle(&AppEvent::Blur)?;
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,10 @@ fn main () -> Result<(), Box<dyn Error>> {
|
||||||
crate::device::run(Rows::new(false, vec![
|
crate::device::run(Rows::new(false, vec![
|
||||||
Box::new(transport),
|
Box::new(transport),
|
||||||
Box::new(Columns::new(false, vec![
|
Box::new(Columns::new(false, vec![
|
||||||
|
Box::new(Chain::new("Chain#0000", vec![
|
||||||
Box::new(Sequencer::new("Melody#000", &timebase)?),
|
Box::new(Sequencer::new("Melody#000", &timebase)?),
|
||||||
|
Box::new(Plugin::new("Plugin#000")?),
|
||||||
|
])?),
|
||||||
Box::new(Sequencer::new("Melody#001", &timebase)?),
|
Box::new(Sequencer::new("Melody#001", &timebase)?),
|
||||||
Box::new(Sequencer::new("Rhythm#000", &timebase)?),
|
Box::new(Sequencer::new("Rhythm#000", &timebase)?),
|
||||||
])),
|
])),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue