Trait vst::plugin::Plugin

source ·
pub trait Plugin: Send {
Show 19 methods fn get_info(&self) -> Info; fn new(host: HostCallback) -> Self
    where
        Self: Sized
; fn init(&mut self) { ... } 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: &mut AudioBuffer<'_, f32>) { ... } fn process_f64(&mut self, buffer: &mut AudioBuffer<'_, f64>) { ... } fn process_events(&mut self, events: &Events) { ... } fn get_parameter_object(&mut self) -> Arc<dyn PluginParameters> { ... } fn get_input_info(&self, input: i32) -> ChannelInfo { ... } fn get_output_info(&self, output: i32) -> ChannelInfo { ... } fn start_process(&mut self) { ... } fn stop_process(&mut self) { ... } fn get_editor(&mut self) -> Option<Box<dyn Editor>> { ... }
}
👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.
Expand description

Must be implemented by all VST plugins.

All methods except new and 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§

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

This method must return an Info struct.

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

Called during initialization to pass a HostCallback to the plugin.

This method can be overridden 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
        }
    }

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

    // ...
}

Provided Methods§

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

Called when plugin is fully initialized.

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

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

Called when sample rate is changed by host.

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

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

Called when block size is changed by host.

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

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

Called to transition the plugin into the resumed state.

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

Called to transition the plugin into the suspended state.

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

Vendor specific handling.

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

Return whether plugin supports specified action.

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

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

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

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

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.

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

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.

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

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.

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

Get a reference to the shared parameter object.

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

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

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

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

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

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.

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

Called after the stop of process call.

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

👎Deprecated: This crate has been deprecated. See https://github.com/RustAudio/vst-rs for more information.

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.

Implementors§