Trait Block

Source
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§

Source

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 port
  • outputs - Slice of mutable output buffer references, one per output port
  • modulation_values - Values from connected modulator blocks, indexed by BlockId
  • context - The DSP context with sample rate and timing info
Source

fn input_count(&self) -> usize

Returns the number of input ports this block accepts.

Source

fn output_count(&self) -> usize

Returns the number of output ports this block produces.

Source

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§

Source

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).

Source

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 Hz
  • ramp_time_ms - Smoothing ramp time in milliseconds

Default implementation is a no-op for blocks without smoothing.

Implementors§