pub trait Plugin: Send {
// Required methods
fn info(&self) -> PluginInfo;
fn init(&mut self, sample_rate: f64, max_buffer_size: usize);
fn process(
&mut self,
inputs: &[&[f32]],
outputs: &mut [&mut [f32]],
midi_events: &[MidiEvent],
);
fn parameter_count(&self) -> usize;
fn parameter_info(&self, index: usize) -> Option<ParameterInfo>;
fn get_parameter(&self, index: usize) -> f32;
fn set_parameter(&mut self, index: usize, value: f32);
fn reset(&mut self);
}Expand description
The core plugin trait. Every synth, effect, and utility implements this.
Required Methods§
Sourcefn info(&self) -> PluginInfo
fn info(&self) -> PluginInfo
Plugin metadata.
Sourcefn init(&mut self, sample_rate: f64, max_buffer_size: usize)
fn init(&mut self, sample_rate: f64, max_buffer_size: usize)
Called once when the plugin is loaded. Preallocate everything here.
Sourcefn process(
&mut self,
inputs: &[&[f32]],
outputs: &mut [&mut [f32]],
midi_events: &[MidiEvent],
)
fn process( &mut self, inputs: &[&[f32]], outputs: &mut [&mut [f32]], midi_events: &[MidiEvent], )
Process audio. Called from the audio thread — must be real-time safe.
inputs: input audio buffers (one slice per channel). Empty for instruments.outputs: output audio buffers to write into (one slice per channel).midi_events: MIDI events for this buffer, sorted bysample_offset.
Sourcefn parameter_count(&self) -> usize
fn parameter_count(&self) -> usize
Number of parameters this plugin exposes.
Sourcefn parameter_info(&self, index: usize) -> Option<ParameterInfo>
fn parameter_info(&self, index: usize) -> Option<ParameterInfo>
Get info about a parameter.
Sourcefn get_parameter(&self, index: usize) -> f32
fn get_parameter(&self, index: usize) -> f32
Get current parameter value (0.0..1.0 normalized).
Sourcefn set_parameter(&mut self, index: usize, value: f32)
fn set_parameter(&mut self, index: usize, value: f32)
Set parameter value. Clamped to 0.0..1.0.