pub trait PurePluginLogic: 'static {
type Params: Params;
// Required methods
fn process(
params: &Self::Params,
buffer: &mut AudioBuffer<'_, f32>,
events: &EventList,
context: &mut ProcessContext<'_>,
) -> ProcessStatus;
fn editor(params: Arc<Self::Params>) -> Box<dyn Editor>;
// Provided methods
fn supports_in_place() -> bool { ... }
fn bus_layouts() -> Vec<BusLayout> { ... }
fn migrate_state(foreign: &ForeignState<'_>) -> Option<MigratedState> { ... }
}Expand description
The stateless f32 plugin trait: PluginLogic minus every
state-shaped item. For a pure parameter-driven effect - one
whose process is a function of params and input only - this
removes the type DspState = () / init / _state: &mut ()
plumbing entirely:
pub struct Gain;
impl PurePluginLogic for Gain {
type Params = GainParams;
fn process(params: &GainParams, buffer: &mut AudioBuffer, events: &EventList, ctx: &mut ProcessContext) -> ProcessStatus {
/* ... */
}
fn editor(params: Arc<GainParams>) -> Box<dyn Editor> { /* ... */ }
}A blanket impl makes every PurePluginLogic a PluginLogic with
DspState = (), so truce::plugin! and every shell consume it
unchanged - and implementing both traits for one type is
correctly rejected as conflicting. When the plugin grows DSP
state, switch the impl header to PluginLogic and add the
state type and arguments.
Required: Self::process, Self::editor. Optional:
Self::bus_layouts, Self::supports_in_place,
Self::migrate_state. Anything state-shaped (reset,
save_state, latency, tail, …) needs state to act on -
implement PluginLogic directly if you need those.
Required Associated Types§
Required Methods§
Sourcefn process(
params: &Self::Params,
buffer: &mut AudioBuffer<'_, f32>,
events: &EventList,
context: &mut ProcessContext<'_>,
) -> ProcessStatus
fn process( params: &Self::Params, buffer: &mut AudioBuffer<'_, f32>, events: &EventList, context: &mut ProcessContext<'_>, ) -> ProcessStatus
Process one block of audio as a pure function of params
and input. Same real-time contract as the stateful
leaf’s process, minus the state argument.
Provided Methods§
Sourcefn supports_in_place() -> bool
fn supports_in_place() -> bool
Opt into zero-copy in-place I/O. Same contract as the
stateful leaf’s supports_in_place.
Sourcefn bus_layouts() -> Vec<BusLayout>
fn bus_layouts() -> Vec<BusLayout>
Supported audio bus configurations. Same contract as the
stateful leaf’s bus_layouts. Default: the standard audio
effect - stereo and mono.
Sourcefn migrate_state(foreign: &ForeignState<'_>) -> Option<MigratedState>
fn migrate_state(foreign: &ForeignState<'_>) -> Option<MigratedState>
Translate foreign state into truce shape. Same contract
as the stateful leaf’s migrate_state - a stateless
plugin may still inherit params from a previous
framework’s blob.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".