mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: refactor into fewer crates
This commit is contained in:
parent
c367a0444e
commit
77703d83a5
105 changed files with 64 additions and 131 deletions
63
deps/vst/examples/simple_host.rs
vendored
Normal file
63
deps/vst/examples/simple_host.rs
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
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]);
|
||||
|
||||
// Create the host
|
||||
let host = Arc::new(Mutex::new(SampleHost));
|
||||
|
||||
println!("Loading {}...", path.to_str().unwrap());
|
||||
|
||||
// Load the plugin
|
||||
let mut loader =
|
||||
PluginLoader::load(path, Arc::clone(&host)).unwrap_or_else(|e| panic!("Failed to load plugin: {}", e));
|
||||
|
||||
// Create an instance of the plugin
|
||||
let mut instance = loader.instance().unwrap();
|
||||
|
||||
// Get the plugin information
|
||||
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
|
||||
);
|
||||
|
||||
// Initialize the instance
|
||||
instance.init();
|
||||
println!("Initialized instance!");
|
||||
|
||||
println!("Closing instance...");
|
||||
// Close the instance. This is not necessary as the instance is shut down when
|
||||
// it is dropped as it goes out of scope.
|
||||
// drop(instance);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue