Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Send + 'static {
    // Required methods
    fn info() -> PluginInfo
       where Self: Sized;
    fn reset(&mut self, sample_rate: f64, max_block_size: usize);
    fn process(
        &mut self,
        buffer: &mut AudioBuffer<'_>,
        events: &EventList,
        context: &mut ProcessContext<'_>,
    ) -> ProcessStatus;

    // Provided methods
    fn bus_layouts() -> Vec<BusLayout>
       where Self: Sized { ... }
    fn init(&mut self) { ... }
    fn save_state(&self) -> Option<Vec<u8>> { ... }
    fn load_state(&mut self, _data: &[u8]) { ... }
    fn editor(&mut self) -> Option<Box<dyn Editor>> { ... }
    fn latency(&self) -> u32 { ... }
    fn tail(&self) -> u32 { ... }
    fn get_meter(&self, _meter_id: u32) -> f32 { ... }
}
Expand description

The core trait that all plugins implement.

Required Methods§

Source

fn info() -> PluginInfo
where Self: Sized,

Static metadata about the plugin.

Use plugin_info!() for zero-boilerplate (reads from truce.toml

  • Cargo.toml). Requires truce-build in [build-dependencies].
Source

fn reset(&mut self, sample_rate: f64, max_block_size: usize)

Called when sample rate or max block size changes. Reset filters, delay lines, etc. Not real-time safe.

Source

fn process( &mut self, buffer: &mut AudioBuffer<'_>, events: &EventList, context: &mut ProcessContext<'_>, ) -> ProcessStatus

Real-time audio processing.

Provided Methods§

Source

fn bus_layouts() -> Vec<BusLayout>
where Self: Sized,

Supported bus layouts. The host picks one.

Source

fn init(&mut self)

Called once after construction. Not real-time safe.

Source

fn save_state(&self) -> Option<Vec<u8>>

Save extra state beyond parameter values.

Source

fn load_state(&mut self, _data: &[u8])

Restore extra state.

Source

fn editor(&mut self) -> Option<Box<dyn Editor>>

GUI editor. Return None for headless plugins.

Source

fn latency(&self) -> u32

Processing latency in samples. Host uses this for delay compensation. Return 0 if the plugin adds no latency (default).

Source

fn tail(&self) -> u32

Tail time in samples. Return u32::MAX for infinite tail. Return 0 for no tail (default).

Source

fn get_meter(&self, _meter_id: u32) -> f32

Read a meter value by ID (0.0–1.0). Called by the GUI at ~60fps. Override to expose level meters, gain reduction, etc.

Implementors§