To load an external VST plugin, use PluginLoader::load. You must provide the path to the library file (e.g., .dll on Windows, .so on Linux, or the mach-o file inside a .vst bundle on macOS) and an Arc<Mutex<T>> where T implements the Host trait.
Once loaded, you can call .instance() to create a PluginInstance which allows you to interact with the plugin's parameters, process audio, and manage its editor.
Platform-specific path notes:
- Linux/Windows: Path to the library (e.g.,
C:\Plugins\plugin.dll or /path/to/plugin.so). - OS X: Path to the mach-o file within the
.vst bundle (e.g., /Library/Audio/Plug-Ins/VST/Plugin.vst/Contents/MacOS/PluginHooksVST).
# use std::path::Path;
# use std::sync::{Arc, Mutex};
# use vst::host::{Host, PluginLoader};
# struct MyHost;
# impl MyHost { fn new() -> MyHost { MyHost } }
# impl Host for MyHost {
# fn automate(&self, _: i32, _: f32) {}
# fn get_plugin_id(&self) -> i32 { 0 }
# }
# let host = Arc::new(Mutex::new(MyHost::new()));
# let path = Path::new(".");
let mut plugin = PluginLoader::load(path, host.clone()).unwrap();
let instance = plugin.instance().unwrap();