pub trait PluginLogic: Send + 'static {
// Required methods
fn reset(&mut self, sample_rate: f64, max_block_size: usize);
fn process(
&mut self,
buffer: &mut AudioBuffer<'_>,
events: &EventList,
context: &mut ProcessContext<'_>,
) -> ProcessStatus;
fn editor(&self) -> Box<dyn Editor>;
// 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 { ... }
}Expand description
The f32-buffer user-facing plugin trait.
Plugin authors implement this in a single impl block when
their audio path is f32 end-to-end (the default - matches
the host wire format for nearly all DAWs and formats).
truce::prelude and truce::prelude32 re-export this name
directly; truce::prelude64m does too (the m mixed-precision
prelude keeps the audio buffer at f32 and only switches the
param.read() precision).
Required: Self::reset, Self::process, Self::editor.
Everything else has a default. The editor is constructed
explicitly - layout-only plugins typically call
truce_gui::default_editor(self.params.clone(), self.layout())
(where layout() is a plain inherent method on the plugin
struct, not part of the trait).
Required Methods§
Sourcefn reset(&mut self, sample_rate: f64, max_block_size: usize)
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.
Sourcefn process(
&mut self,
buffer: &mut AudioBuffer<'_>,
events: &EventList,
context: &mut ProcessContext<'_>,
) -> ProcessStatus
fn process( &mut self, buffer: &mut AudioBuffer<'_>, events: &EventList, context: &mut ProcessContext<'_>, ) -> ProcessStatus
Process one block of audio. Real-time - no allocations, locks, or I/O.
Sourcefn editor(&self) -> Box<dyn Editor>
fn editor(&self) -> Box<dyn Editor>
Construct the editor for this plugin. Required.
There is no auto-fallback - every plugin explicitly
names which renderer it wants. For the built-in
widget layout, call
truce_gui::default_editor(params, layout); for
custom renderers, construct an EguiEditor /
IcedEditor / SlintEditor / hand-rolled Editor
here. The choice of renderer crate the plugin’s
Cargo.toml pulls IS the choice of editor.
Provided Methods§
Sourcefn supports_in_place() -> boolwhere
Self: Sized,
fn supports_in_place() -> boolwhere
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.
Sourcefn bus_layouts() -> Vec<BusLayout>where
Self: Sized,
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.
Sourcefn save_state(&self) -> Vec<u8> ⓘ
fn save_state(&self) -> Vec<u8> ⓘ
Serialize plugin-specific state (DSP state, not params - those are saved automatically). Default: no extra state.
Sourcefn load_state(&mut self, _data: &[u8]) -> Result<(), StateLoadError>
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).
Sourcefn state_changed(&mut self)
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".