Skip to main content

Plugin

Trait Plugin 

Source
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§

Source

fn info(&self) -> PluginInfo

Plugin metadata.

Source

fn init(&mut self, sample_rate: f64, max_buffer_size: usize)

Called once when the plugin is loaded. Preallocate everything here.

Source

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 by sample_offset.
Source

fn parameter_count(&self) -> usize

Number of parameters this plugin exposes.

Source

fn parameter_info(&self, index: usize) -> Option<ParameterInfo>

Get info about a parameter.

Source

fn get_parameter(&self, index: usize) -> f32

Get current parameter value (0.0..1.0 normalized).

Source

fn set_parameter(&mut self, index: usize, value: f32)

Set parameter value. Clamped to 0.0..1.0.

Source

fn reset(&mut self)

Reset internal state (clear delay lines, reset envelopes, etc).

Implementors§