Skip to main content

Algorithm

Trait Algorithm 

Source
pub trait Algorithm<T>: Send + Sync
where T: Transcendental,
{ // Required methods fn process( &mut self, input: Option<&[T]>, output: &mut [T], ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>; fn reset(&mut self); // Provided methods fn apply_command(&mut self, _value: T) { ... } fn init(&mut self, _sample_rate: f32) { ... } fn metadata(&self) -> AlgorithmMetadata { ... } }
Expand description

Unified processing primitive for ports and DSP blocks.

Every port in the graph owns an optional Box<dyn Algorithm>. When present, the port’s run_action() calls Algorithm::process() to fill its buffer.

Low-level DSP components (filters, generators, effects) also implement this trait directly, making them usable both inside the graph and standalone.

§Required methods

  • process() — the main per-block processing entry point.
  • reset() — restore initial state.

§Optional methods

  • init() — configure sample rate.
  • apply_command() — receive a real-time parameter value from the control path (called between samples by the graph driver).
  • metadata() — return descriptive info (defaults to empty).

Required Methods§

Source

fn process( &mut self, input: Option<&[T]>, output: &mut [T], ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Process one block of signal.

§Arguments
  • input — Signal data from upstream (empty when the port is unconnected, or None for source ports / control output ports).
  • output — Buffer to fill with processed data.
  • ctx — Processing context (clock tick, block position, etc.).
Source

fn reset(&mut self)

Reset the algorithm to its initial state.

Called when the owning node is reset, or when feedback delay lines need clearing.

Provided Methods§

Source

fn apply_command(&mut self, _value: T)

Receive a real-time command value from the control path.

Called by the graph driver between process() calls when a SetParameter targets this port. The algorithm should store the value and apply it (possibly smoothed) on the next process().

Default: no-op.

Source

fn init(&mut self, _sample_rate: f32)

Initialise the algorithm with a sample rate.

Called once when the node is added to the graph. Available for coefficient pre-computation.

Default: no-op.

Source

fn metadata(&self) -> AlgorithmMetadata

Descriptive metadata (defaults to empty).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> Algorithm<T> for Biquad<T>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for MoogLadder<T>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for OnePole<T>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for StateVariableFilter<T>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for BasicOscillator<T>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, _input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for EnvelopeGenerator<T>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for SimpleFmSynth<T>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, _input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for LFO<T>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, _input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for NoiseGenerator<T>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, _input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for Resampler<T>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, _input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for SamplePlayer<T>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, _input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for ControlMapper<T>
where T: Transcendental,

Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn apply_command(&mut self, value: T)

Source§

fn init(&mut self, _sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T> Algorithm<T> for ParamSmoother<T>
where T: Transcendental,

Source§

fn process( &mut self, _input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn apply_command(&mut self, value: T)

Source§

fn init(&mut self, _sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T, const MAX_DELAY: usize> Algorithm<T> for CombFilter<T, MAX_DELAY>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T, const MAX_SECTIONS: usize> Algorithm<T> for Butterworth<T, MAX_SECTIONS>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T, const MAX_SECTIONS: usize> Algorithm<T> for ChebyshevI<T, MAX_SECTIONS>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T, const MAX_SECTIONS: usize> Algorithm<T> for ChebyshevII<T, MAX_SECTIONS>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T, const N: usize> Algorithm<T> for FmSynth<T, N>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, _input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Source§

impl<T, const SIZE: usize> Algorithm<T> for WavetableOscillator<T, SIZE>
where T: Transcendental,

Source§

fn init(&mut self, sample_rate: f32)

Source§

fn reset(&mut self)

Source§

fn process( &mut self, _input: Option<&[T]>, output: &mut [T], _ctx: &ActionContext<'_>, ) -> Result<(), ProcessError>

Source§

fn metadata(&self) -> AlgorithmMetadata

Implementors§