wip: lv2 support?

This commit is contained in:
🪞👃🪞 2024-06-20 20:40:08 +03:00
parent 4b0055a21c
commit 1e395274f6
7 changed files with 153 additions and 10 deletions

108
Cargo.lock generated
View file

@ -260,7 +260,7 @@ dependencies = [
"crossterm_winapi", "crossterm_winapi",
"libc", "libc",
"mio", "mio",
"parking_lot", "parking_lot 0.12.2",
"signal-hook", "signal-hook",
"signal-hook-mio", "signal-hook-mio",
"winapi", "winapi",
@ -325,6 +325,15 @@ dependencies = [
"hashbrown", "hashbrown",
] ]
[[package]]
name = "instant"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
dependencies = [
"cfg-if",
]
[[package]] [[package]]
name = "is_terminal_polyfill" name = "is_terminal_polyfill"
version = "1.70.0" version = "1.70.0"
@ -394,6 +403,40 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "lilv"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba8b5b9e4cc7a3f588377578868738c997eec13045ce31d727735181e425327a"
dependencies = [
"lilv-sys",
"lv2_raw",
"parking_lot 0.11.2",
"pkg-config",
]
[[package]]
name = "lilv-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aee56a6fdb8db62d01819f171d579c65fb0e03bcd077e1ea4509e06b6d58f53c"
dependencies = [
"lv2_raw",
]
[[package]]
name = "livi"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3a0c5cce0462040d482a75d2b3a7a4fa5593e9a2a4937167e1880ce6d941e43"
dependencies = [
"lilv",
"log",
"lv2-sys",
"lv2_raw",
"ringbuf",
]
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.12" version = "0.4.12"
@ -419,6 +462,21 @@ dependencies = [
"hashbrown", "hashbrown",
] ]
[[package]]
name = "lv2-sys"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dd0f9e7de3649dcec348de51cbf611ab88688b97c0ce038f8c07b996b2a8e30"
[[package]]
name = "lv2_raw"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "573ce7231f64fe795ad80134913f88f2e7f7f550527f6bd54d690a56cabf6a48"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.7.2" version = "2.7.2"
@ -506,6 +564,17 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "parking_lot"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
dependencies = [
"instant",
"lock_api",
"parking_lot_core 0.8.6",
]
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.12.2" version = "0.12.2"
@ -513,7 +582,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb"
dependencies = [ dependencies = [
"lock_api", "lock_api",
"parking_lot_core", "parking_lot_core 0.9.10",
]
[[package]]
name = "parking_lot_core"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc"
dependencies = [
"cfg-if",
"instant",
"libc",
"redox_syscall 0.2.16",
"smallvec",
"winapi",
] ]
[[package]] [[package]]
@ -524,7 +607,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"redox_syscall", "redox_syscall 0.5.1",
"smallvec", "smallvec",
"windows-targets 0.52.5", "windows-targets 0.52.5",
] ]
@ -609,6 +692,15 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "redox_syscall"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
"bitflags 1.3.2",
]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.5.1" version = "0.5.1"
@ -618,6 +710,15 @@ dependencies = [
"bitflags 2.5.0", "bitflags 2.5.0",
] ]
[[package]]
name = "ringbuf"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79abed428d1fd2a128201cec72c5f6938e2da607c6f3745f769fabea399d950a"
dependencies = [
"crossbeam-utils",
]
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.24" version = "0.1.24"
@ -782,6 +883,7 @@ dependencies = [
"clap", "clap",
"crossterm", "crossterm",
"jack", "jack",
"livi",
"microxdg", "microxdg",
"midly", "midly",
"ratatui", "ratatui",

View file

@ -15,3 +15,4 @@ midly = "0.5"
vst = "0.4.0" vst = "0.4.0"
#vst3 = "0.1.0" #vst3 = "0.1.0"
livi = "0.7.4"

View file

@ -4,5 +4,10 @@
]; ];
buildInputs = with pkgs; [ buildInputs = with pkgs; [
jack2 jack2
lilv
serd
libclang
]; ];
VST3_SDK_DIR = "/home/user/Lab/Music/tek/vst3sdk/";
LIBCLANG_PATH = "${pkgs.libclang.lib.outPath}/lib";
} }

View file

@ -1,8 +1,18 @@
use crate::prelude::*; use crate::prelude::*;
mod lv2;
mod vst2;
mod vst3;
pub struct Plugin { pub struct Plugin {
name: String, name: String,
plugin: Option<::vst::host::PluginInstance> plugin: Option<PluginKind>
}
enum PluginKind {
VST2(::vst::host::PluginInstance),
VST3,
LV2(::livi::Plugin),
} }
impl Plugin { impl Plugin {
@ -11,12 +21,9 @@ impl Plugin {
name: name.into(), name: name.into(),
plugin: None, plugin: None,
}); });
let mut loader = ::vst::host::PluginLoader::load( device.state.lock().unwrap().plugin = Some(self::lv2::plug_in(
&std::path::Path::new("/nix/store/ij3sz7nqg5l7v2dygdvzy3w6cj62bd6r-helm-0.9.0/lib/lxvst/helm.so"), "file:///nix/store/ij3sz7nqg5l7v2dygdvzy3w6cj62bd6r-helm-0.9.0/lib/lv2/helm.lv2"
device.state.clone() )?);
)?;
let plugin = loader.instance()?;
device.state.lock().unwrap().plugin = Some(plugin);
Ok(device) Ok(device)
} }
} }

17
src/device/plugin/lv2.rs Normal file
View file

@ -0,0 +1,17 @@
use crate::prelude::*;
use super::*;
pub fn plug_in (path: &str) -> Usually<PluginKind> {
let world = ::livi::World::with_load_bundle(&path);
world.build_features(::livi::FeaturesBuilder {
min_block_length: 1,
max_block_length: 65536,
});
let mut plugin = None;
for p in world.iter_plugins() {
plugin = Some(p);
break
}
let result = PluginKind::LV2(plugin.unwrap());
Ok(result)
}

11
src/device/plugin/vst2.rs Normal file
View file

@ -0,0 +1,11 @@
use crate::prelude::*;
use super::*;
fn set_vst_plugin (host: &Arc<Mutex<Plugin>>, path: &str) -> Usually<PluginKind> {
let mut loader = ::vst::host::PluginLoader::load(
&std::path::Path::new("/nix/store/ij3sz7nqg5l7v2dygdvzy3w6cj62bd6r-helm-0.9.0/lib/lxvst/helm.so"),
host.clone()
)?;
Ok(PluginKind::VST2(loader.instance()?))
}
//"file:///nix/store/ij3sz7nqg5l7v2dygdvzy3w6cj62bd6r-helm-0.9.0/lib/lxvst/helm.so"

View file