pub trait Block<S: Sample> {
// Required methods
fn process(
&mut self,
inputs: &[&[S]],
outputs: &mut [&mut [S]],
modulation_values: &[S],
context: &DspContext,
);
fn input_count(&self) -> usize;
fn output_count(&self) -> usize;
fn modulation_outputs(&self) -> &[ModulationOutput];
// Provided methods
fn channel_config(&self) -> ChannelConfig { ... }
fn set_smoothing(&mut self, _sample_rate: f64, _ramp_time_ms: f64) { ... }
}Expand description
The core trait for DSP processing units.
A block represents a single DSP operation (oscillator, filter, gain, etc.)
that processes audio buffers. Blocks are connected together in a Graph
to form a complete signal processing chain.
Required Methods§
Sourcefn process(
&mut self,
inputs: &[&[S]],
outputs: &mut [&mut [S]],
modulation_values: &[S],
context: &DspContext,
)
fn process( &mut self, inputs: &[&[S]], outputs: &mut [&mut [S]], modulation_values: &[S], context: &DspContext, )
Process audio through this block.
§Arguments
inputs- Slice of input buffer references, one per input portoutputs- Slice of mutable output buffer references, one per output portmodulation_values- Values from connected modulator blocks, indexed byBlockIdcontext- The DSP context with sample rate and timing info
Sourcefn input_count(&self) -> usize
fn input_count(&self) -> usize
Returns the number of input ports this block accepts.
Sourcefn output_count(&self) -> usize
fn output_count(&self) -> usize
Returns the number of output ports this block produces.
Sourcefn modulation_outputs(&self) -> &[ModulationOutput]
fn modulation_outputs(&self) -> &[ModulationOutput]
Returns the modulation outputs this block provides.
Only modulator blocks (LFOs, envelopes) return non-empty slices. Generator and effector blocks return an empty slice.
Provided Methods§
Sourcefn channel_config(&self) -> ChannelConfig
fn channel_config(&self) -> ChannelConfig
Returns how this block handles multi-channel audio.
Default is ChannelConfig::Parallel (process each channel independently).
Override to ChannelConfig::Explicit for blocks that handle channel
routing internally (panners, mixers, splitters/mergers).
Sourcefn set_smoothing(&mut self, _sample_rate: f64, _ramp_time_ms: f64)
fn set_smoothing(&mut self, _sample_rate: f64, _ramp_time_ms: f64)
Configure smoothing time for parameter changes.
§Arguments
sample_rate- Audio sample rate in Hzramp_time_ms- Smoothing ramp time in milliseconds
Default implementation is a no-op for blocks without smoothing.