Trait rsynth::backend::vst_backend::vst::plugin::Plugin[]

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

    pub fn new(host: HostCallback) -> Self
    where
        Self: Default
, { ... }
pub fn init(&mut self) { ... }
pub fn set_sample_rate(&mut self, rate: f32) { ... }
pub fn set_block_size(&mut self, size: i64) { ... }
pub fn resume(&mut self) { ... }
pub fn suspend(&mut self) { ... }
pub fn vendor_specific(
        &mut self,
        index: i32,
        value: isize,
        ptr: *mut c_void,
        opt: f32
    ) -> isize { ... }
pub fn can_do(&self, can_do: CanDo) -> Supported { ... }
pub fn get_tail_size(&self) -> isize { ... }
pub fn process(&mut self, buffer: &mut AudioBuffer<'_, f32>) { ... }
pub fn process_f64(&mut self, buffer: &mut AudioBuffer<'_, f64>) { ... }
pub fn process_events(&mut self, events: &Events) { ... }
pub fn get_parameter_object(
        &mut self
    ) -> Arc<dyn PluginParameters + 'static> { ... }
pub fn get_input_info(&self, input: i32) -> ChannelInfo { ... }
pub fn get_output_info(&self, output: i32) -> ChannelInfo { ... }
pub fn start_process(&mut self) { ... }
pub fn stop_process(&mut self) { ... }
pub fn get_editor(&mut self) -> Option<Box<dyn Editor + 'static, Global>> { ... } }

Must be implemented by all VST plugins.

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

At any time, a plugin is in one of two states: suspended or resumed. While a plugin is in the suspended state, various processing parameters, such as the sample rate and block size, can be changed by the host, but no audio processing takes place. While a plugin is in the resumed state, audio processing methods and parameter access methods can be called by the host. A plugin starts in the suspended state and is switched between the states by the host using the resume and suspend methods.

Hosts call methods of the plugin on two threads: the UI thread and the processing thread. For this reason, the plugin API is separated into two traits: The Plugin trait containing setup and processing methods, and the PluginParameters trait containing methods for parameter access.

Required methods

pub fn get_info(&self) -> Info

This method must return an Info struct.

Loading content...

Provided methods

pub fn new(host: HostCallback) -> Self where
    Self: Default

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 vst::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());
    }

    // ...
}

pub fn init(&mut self)

Called when plugin is fully initialized.

This method is only called while the plugin is in the suspended state.

pub fn set_sample_rate(&mut self, rate: f32)

Called when sample rate is changed by host.

This method is only called while the plugin is in the suspended state.

pub fn set_block_size(&mut self, size: i64)

Called when block size is changed by host.

This method is only called while the plugin is in the suspended state.

pub fn resume(&mut self)

Called to transition the plugin into the resumed state.

pub fn suspend(&mut self)

Called to transition the plugin into the suspended state.

pub fn vendor_specific(
    &mut self,
    index: i32,
    value: isize,
    ptr: *mut c_void,
    opt: f32
) -> isize

Vendor specific handling.

pub fn can_do(&self, can_do: CanDo) -> Supported

Return whether plugin supports specified action.

This method is only called while the plugin is in the suspended state.

pub fn get_tail_size(&self) -> isize

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

pub fn process(&mut self, buffer: &mut AudioBuffer<'_, f32>)

Process an audio buffer containing f32 values.

Example

// Processor that clips samples above 0.4 or below -0.4:
fn process(&mut self, buffer: &mut AudioBuffer<f32>){
    // For each input and output
    for (input, output) in buffer.zip() {
        // For each input sample and output sample in buffer
        for (in_sample, out_sample) in input.into_iter().zip(output.into_iter()) {
            *out_sample = if *in_sample > 0.4 {
                0.4
            } else if *in_sample < -0.4 {
                -0.4
            } else {
                *in_sample
            };
        }
    }
}

This method is only called while the plugin is in the resumed state.

pub fn process_f64(&mut self, buffer: &mut AudioBuffer<'_, f64>)

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: &mut AudioBuffer<f64>){
    // For each input and output
    for (input, output) in buffer.zip() {
        // For each input sample and output sample in buffer
        for (in_sample, out_sample) in input.into_iter().zip(output.into_iter()) {
            *out_sample = if *in_sample > 0.4 {
                0.4
            } else if *in_sample < -0.4 {
                -0.4
            } else {
                *in_sample
            };
        }
    }
}

This method is only called while the plugin is in the resumed state.

pub fn process_events(&mut self, events: &Events)

Handle incoming events sent from the host.

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

This method is only called while the plugin is in the resumed state.

pub fn get_parameter_object(&mut self) -> Arc<dyn PluginParameters + 'static>

Get a reference to the shared parameter object.

pub fn get_input_info(&self, input: i32) -> ChannelInfo

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

pub fn get_output_info(&self, output: i32) -> ChannelInfo

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

pub fn start_process(&mut self)

Called one time before the start of process call.

This indicates that the process call will be interrupted (due to Host reconfiguration or bypass state when the plug-in doesn’t support softBypass).

This method is only called while the plugin is in the resumed state.

pub fn stop_process(&mut self)

Called after the stop of process call.

This method is only called while the plugin is in the resumed state.

pub fn get_editor(&mut self) -> Option<Box<dyn Editor + 'static, Global>>

Return handle to plugin editor if supported. The method need only return the object on the first call. Subsequent calls can just return None.

The editor object will typically contain an Arc reference to the parameter object through which it can communicate with the audio processing.

Loading content...

Implementors

impl Plugin for PluginInstance

Loading content...