Skip to main content

PluginLogic64

Trait PluginLogic64 

Source
pub trait PluginLogic64: Send + 'static {
Show 14 methods // Required methods fn reset(&mut self, sample_rate: f64, max_block_size: usize); fn process( &mut self, buffer: &mut AudioBuffer<'_, f64>, events: &EventList, context: &mut ProcessContext<'_>, ) -> ProcessStatus; // Provided methods fn supports_in_place() -> bool where Self: Sized { ... } fn bus_layouts() -> Vec<BusLayout> where Self: Sized { ... } fn save_state(&self) -> Vec<u8> { ... } fn load_state(&mut self, _data: &[u8]) -> Result<(), StateLoadError> { ... } fn state_changed(&mut self) { ... } fn latency(&self) -> u32 { ... } fn tail(&self) -> u32 { ... } fn layout(&self) -> GridLayout { ... } fn render(&self, _backend: &mut dyn RenderBackend) { ... } fn uses_custom_render(&self) -> bool { ... } fn hit_test( &self, widgets: &[WidgetRegion], x: f32, y: f32, ) -> Option<usize> { ... } fn custom_editor(&self) -> Option<Box<dyn Editor>> { ... }
}
Expand description

The f64-buffer user-facing plugin trait. Same surface as PluginLogic but with the audio buffer pinned to f64.

Plugin authors don’t usually name this directly - truce::prelude64 re-exports it as PluginLogic, so the impl header reads the same regardless of which precision the prelude chose. Pick truce::prelude64 (and thus this leaf) when the DSP path runs in f64 end-to-end and the wrapper-boundary widen/narrow memcpy is worth the cleaner DSP code.

Required Methods§

Source

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

Reset for a new sample rate / block size. Called before the first process and any time the host reconfigures.

Source

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

Process one block of audio. Real-time - no allocations, locks, or I/O.

Provided Methods§

Source

fn supports_in_place() -> bool
where Self: Sized,

Opt into zero-copy in-place I/O. When this returns true, the format wrapper skips its safety memcpy on host-aliased buffers and hands the plugin the raw shared memory through AudioBuffer::in_out_mut(ch). The plugin must check AudioBuffer::is_in_place(ch) per channel before reading input(ch).

Default false: the wrapper copies aliased inputs into scratch so input(ch) and output(ch) are always disjoint. Costs one memcpy per aliased channel per block.

Source

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

Supported audio bus configurations. The host picks one; the others are rejected at bus-config time before process is ever called. Default: stereo in, stereo out.

Source

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

Serialize plugin-specific state (DSP state, not params - those are saved automatically). Default: no extra state.

Source

fn load_state(&mut self, _data: &[u8]) -> Result<(), StateLoadError>

Restore plugin-specific state.

§Errors

Return Err(StateLoadError) when the blob is malformed or otherwise can’t be interpreted - the format wrapper logs the failure (and on hosts that support it, surfaces it to the DAW).

Source

fn state_changed(&mut self)

Called on the audio thread immediately after Self::load_state returns. Invalidate or recompute any caches the next process() reads. Default: no-op.

Source

fn latency(&self) -> u32

Report latency in samples for plugin delay compensation.

Source

fn tail(&self) -> u32

Report tail time in samples (audio produced after input stops - reverbs, delays). u32::MAX for infinite tail.

Source

fn layout(&self) -> GridLayout

Return the widget layout for the built-in GUI. Default: empty layout. Plugins that supply a custom editor via Self::custom_editor can leave this default.

Source

fn render(&self, _backend: &mut dyn RenderBackend)

Render the GUI into a backend. Default: no-op. Override only for custom GPU/CPU rasterisation outside the standard widget set; flip Self::uses_custom_render to true when you do.

Source

fn uses_custom_render(&self) -> bool

Whether this plugin overrides Self::render. The shell uses the standard widget drawing from Self::layout when this is false. Default: false.

Source

fn hit_test(&self, widgets: &[WidgetRegion], x: f32, y: f32) -> Option<usize>

Hit test: which widget (if any) is at (x, y)? Default: circular for knobs, rectangular for everything else, meters skipped.

Source

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

Provide a custom Editor instead of the built-in widget layout (egui, iced, slint, raw window handle). The shell calls this first; if it returns None, falls back to the built-in editor from Self::layout.

Implementors§