Crate vst2 [] [src]

rust-vst2 is a rust implementation of the VST2.4 API


All Plugins must implement the Plugin trait and std::default::Default. The plugin_main! macro must also be called in order to export the necessary functions for the plugin to function.

Plugin Trait

All methods in this trait have a default implementation except for the get_info method which must be implemented by the plugin. Any of the default implementations may be overriden for custom functionality; the defaults do nothing on their own.

plugin_main! macro

plugin_main! will export the necessary functions to create a proper VST plugin. This must be called with your VST plugin struct name in order for the vst to work.

Example plugin

A barebones VST plugin:

extern crate vst2;

use vst2::plugin::{Info, Plugin};

struct BasicPlugin;

impl Plugin for BasicPlugin {
    fn get_info(&self) -> Info {
        Info {
            name: "Basic Plugin".to_string(),
            unique_id: 1357, // Used by hosts to differentiate between plugins.


plugin_main!(BasicPlugin); // Important!


Host Trait

All hosts must implement the Host trait. To load a VST plugin, you need to wrap your host in an Arc<Mutex<T>> wrapper for thread safety reasons. Along with the plugin path, this can be passed to the PluginLoader::load method to create a plugin loader which can spawn plugin instances.

Example Host

extern crate vst2;

use std::sync::{Arc, Mutex};
use std::path::Path;

use vst2::host::{Host, PluginLoader};
use vst2::plugin::Plugin;

struct SampleHost;

impl Host for SampleHost {
    fn automate(&mut self, index: i32, value: f32) {
        println!("Parameter {} had its value changed to {}", index, value);

fn main() {
    let host = Arc::new(Mutex::new(SampleHost));
    let path = Path::new("/path/to/vst");

    let mut loader = PluginLoader::load(path, host.clone()).unwrap();
    let mut instance = loader.instance().unwrap();

    println!("Loaded {}", instance.get_info().name);

    println!("Initialized instance!");

    println!("Closing instance...");
    // Not necessary as the instance is shut down when it goes out of scope anyway.
    // drop(instance);



Structures and types for interfacing with the VST 2.4 API.


Buffers to safely work with audio samples.


Meta data for dealing with input / output channels. Not all hosts use this so it is not necessary for plugin functionality.


All VST plugin editor related functionality.


Interfaces to VST events.


Host specific structures.


Plugin specific structures.



Exports the necessary symbols for the plugin to be used by a VST host.