Trait vst2::plugin::Plugin [] [src]

pub trait Plugin {
    fn get_info(&self) -> Info;

    fn new(host: HostCallback) -> Self
    where
        Self: Sized + Default
, { ... } fn init(&mut self) { ... } fn change_preset(&mut self, preset: i32) { ... } fn get_preset_num(&self) -> i32 { ... } fn set_preset_name(&mut self, name: String) { ... } fn get_preset_name(&self, preset: i32) -> String { ... } fn get_parameter_label(&self, index: i32) -> String { ... } fn get_parameter_text(&self, index: i32) -> String { ... } fn get_parameter_name(&self, index: i32) -> String { ... } fn get_parameter(&self, index: i32) -> f32 { ... } fn set_parameter(&mut self, index: i32, value: f32) { ... } fn can_be_automated(&self, index: i32) -> bool { ... } fn string_to_parameter(&mut self, index: i32, text: String) -> bool { ... } fn set_sample_rate(&mut self, rate: f32) { ... } fn set_block_size(&mut self, size: i64) { ... } fn resume(&mut self) { ... } fn suspend(&mut self) { ... } fn vendor_specific(
        &mut self,
        index: i32,
        value: isize,
        ptr: *mut c_void,
        opt: f32
    ) -> isize { ... } fn can_do(&self, can_do: CanDo) -> Supported { ... } fn get_tail_size(&self) -> isize { ... } fn process(&mut self, buffer: AudioBuffer<f32>) { ... } fn process_f64(&mut self, buffer: AudioBuffer<f64>) { ... } fn process_events(&mut self, events: Vec<Event>) { ... } fn get_editor(&mut self) -> Option<&mut Editor> { ... } fn get_preset_data(&mut self) -> Vec<u8> { ... } fn get_bank_data(&mut self) -> Vec<u8> { ... } fn load_preset_data(&mut self, data: &[u8]) { ... } fn load_bank_data(&mut self, data: &[u8]) { ... } fn get_input_info(&self, input: i32) -> ChannelInfo { ... } fn get_output_info(&self, output: i32) -> ChannelInfo { ... } }

Must be implemented by all VST plugins.

All methods except get_info provide a default implementation which does nothing and can be safely overridden.

Required Methods

This method must return an Info struct.

Provided Methods

Called during initialization to pass a HostCallback to the plugin.

This method can be overriden to set host as a field in the plugin struct.

Example

// ...
use vst2::plugin::HostCallback;

struct ExamplePlugin {
    host: HostCallback
}

impl Plugin for ExamplePlugin {
    fn new(host: HostCallback) -> ExamplePlugin {
        ExamplePlugin {
            host: host
        }
    }

    fn init(&mut self) {
        info!("loaded with host vst version: {}", self.host.vst_version());
    }

    // ...
}

Called when plugin is fully initialized.

Set the current preset to the index specified by preset.

Get the current preset index.

Set the current preset name.

Get the name of the preset at the index specified by preset.

Get parameter label for parameter at index (e.g. "db", "sec", "ms", "%").

Get the parameter value for parameter at index (e.g. "1.0", "150", "Plate", "Off").

Get the name of parameter at index.

Get the value of paramater at index. Should be value between 0.0 and 1.0.

Set the value of parameter at index. value is between 0.0 and 1.0.

Return whether parameter at index can be automated.

Use String as input for parameter value. Used by host to provide an editable field to adjust a parameter value. E.g. "100" may be interpreted as 100hz for parameter. Returns if the input string was used.

Called when sample rate is changed by host.

Called when block size is changed by host.

Called when plugin is turned on.

Called when plugin is turned off.

Vendor specific handling.

Return whether plugin supports specified action.

Get the tail size of plugin when it is stopped. Used in offline processing as well.

Process an audio buffer containing f32 values.

Example

// Processor that clips samples above 0.4 or below -0.4:
fn process(&mut self, buffer: AudioBuffer<f32>){
    let (inputs, mut outputs) = buffer.split();

    for (channel, ibuf) in inputs.iter().enumerate() {
        for (i, sample) in ibuf.iter().enumerate() {
            outputs[channel][i] = if *sample > 0.4 {
                0.4
            } else if *sample < -0.4 {
                -0.4
            } else {
                *sample
            };
        }
    }
}

Process an audio buffer containing f64 values.

Example

// Processor that clips samples above 0.4 or below -0.4:
fn process_f64(&mut self, buffer: AudioBuffer<f64>){
    let (inputs, mut outputs) = buffer.split();

    for (channel, ibuf) in inputs.iter().enumerate() {
        for (i, sample) in ibuf.iter().enumerate() {
            outputs[channel][i] = if *sample > 0.4 {
                0.4
            } else if *sample < -0.4 {
                -0.4
            } else {
                *sample
            };
        }
    }
}

Handle incoming events sent from the host.

This is always called before the start of process or process_f64.

Return handle to plugin editor if supported.

If preset_chunks is set to true in plugin info, this should return the raw chunk data for the current preset.

If preset_chunks is set to true in plugin info, this should return the raw chunk data for the current plugin bank.

If preset_chunks is set to true in plugin info, this should load a preset from the given chunk data.

If preset_chunks is set to true in plugin info, this should load a preset bank from the given chunk data.

Get information about an input channel. Only used by some hosts.

Get information about an output channel. Only used by some hosts.

Implementors