extern crate vst;
use std::env;
use std::path::Path;
use std::process;
use std::sync::{Arc, Mutex};
use vst::host::{Host, PluginLoader};
use vst::plugin::Plugin;
#[allow(dead_code)]
struct SampleHost;
impl Host for SampleHost {
fn automate(&self, index: i32, value: f32) {
println!("Parameter {} had its value changed to {}", index, value);
}
}
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("usage: simple_host path/to/vst");
process::exit(1);
}
let path = Path::new(&args[1]);
let host = Arc::new(Mutex::new(SampleHost));
println!("Loading {}...", path.to_str().unwrap());
let mut loader =
PluginLoader::load(path, Arc::clone(&host)).unwrap_or_else(|e| panic!("Failed to load plugin: {}", e));
let mut instance = loader.instance().unwrap();
let info = instance.get_info();
println!(
"Loaded '{}':\n\t\
Vendor: {}\n\t\
Presets: {}\n\t\
Parameters: {}\n\t\
VST ID: {}\n\t\
Version: {}\n\t\
Initial Delay: {} samples",
info.name, info.vendor, info.presets, info.parameters, info.unique_id, info.version, info.initial_delay
);
instance.init();
println!("Initialized instance!");
println!("Closing instance...");
}