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
Provided Methods
fn new(host: HostCallback) -> Self where
Self: Sized + Default,
Self: Sized + 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 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()); } // ... }
fn init(&mut self)
Called when plugin is fully initialized.
fn change_preset(&mut self, preset: i32)
Set the current preset to the index specified by preset
.
fn get_preset_num(&self) -> i32
Get the current preset index.
fn set_preset_name(&mut self, name: String)
Set the current preset name.
fn get_preset_name(&self, preset: i32) -> String
Get the name of the preset at the index specified by preset
.
fn get_parameter_label(&self, index: i32) -> String
Get parameter label for parameter at index
(e.g. "db", "sec", "ms", "%").
fn get_parameter_text(&self, index: i32) -> String
Get the parameter value for parameter at index
(e.g. "1.0", "150", "Plate", "Off").
fn get_parameter_name(&self, index: i32) -> String
Get the name of parameter at index
.
fn get_parameter(&self, index: i32) -> f32
Get the value of paramater at index
. Should be value between 0.0 and 1.0.
fn set_parameter(&mut self, index: i32, value: f32)
Set the value of parameter at index
. value
is between 0.0 and 1.0.
fn can_be_automated(&self, index: i32) -> bool
Return whether parameter at index
can be automated.
fn string_to_parameter(&mut self, index: i32, text: String) -> bool
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.
fn set_sample_rate(&mut self, rate: f32)
Called when sample rate is changed by host.
fn set_block_size(&mut self, size: i64)
Called when block size is changed by host.
fn resume(&mut self)
Called when plugin is turned on.
fn suspend(&mut self)
Called when plugin is turned off.
fn vendor_specific(
&mut self,
index: i32,
value: isize,
ptr: *mut c_void,
opt: f32
) -> isize
&mut self,
index: i32,
value: isize,
ptr: *mut c_void,
opt: f32
) -> isize
Vendor specific handling.
fn can_do(&self, can_do: CanDo) -> Supported
Return whether plugin supports specified action.
fn get_tail_size(&self) -> isize
Get the tail size of plugin when it is stopped. Used in offline processing as well.
fn process(&mut self, buffer: 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: 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 }; } } }
fn process_f64(&mut self, buffer: 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: 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 }; } } }
fn process_events(&mut self, events: Vec<Event>)
Handle incoming events sent from the host.
This is always called before the start of process
or process_f64
.
fn get_editor(&mut self) -> Option<&mut Editor>
Return handle to plugin editor if supported.
fn get_preset_data(&mut self) -> Vec<u8>
If preset_chunks
is set to true in plugin info, this should return the raw chunk data for
the current preset.
fn get_bank_data(&mut self) -> Vec<u8>
If preset_chunks
is set to true in plugin info, this should return the raw chunk data for
the current plugin bank.
fn load_preset_data(&mut self, data: &[u8])
If preset_chunks
is set to true in plugin info, this should load a preset from the given
chunk data.
fn load_bank_data(&mut self, data: &[u8])
If preset_chunks
is set to true in plugin info, this should load a preset bank from the
given chunk data.
fn get_input_info(&self, input: i32) -> ChannelInfo
Get information about an input channel. Only used by some hosts.
fn get_output_info(&self, output: i32) -> ChannelInfo
Get information about an output channel. Only used by some hosts.
Implementors
impl Plugin for PluginInstance