pub trait Convert {
// Required method
fn next_sample<I>(&mut self, iter: &mut I) -> Option<f64>
where I: Iterator<Item = f64>,
Self: Sized;
// Provided methods
fn process<I>(&mut self, iter: I) -> ConvertIter<'_, I, Self> ⓘ
where I: Iterator<Item = f64>,
Self: Sized { ... }
fn process_block(
&mut self,
input: &[f64],
output: &mut [f64],
) -> (usize, usize)
where Self: Sized { ... }
fn flush(&mut self, output: &mut [f64]) -> usize
where Self: Sized { ... }
}Required Methods§
Provided Methods§
Sourcefn process<I>(&mut self, iter: I) -> ConvertIter<'_, I, Self> ⓘ
fn process<I>(&mut self, iter: I) -> ConvertIter<'_, I, Self> ⓘ
Process samples and return an iterator, can be called multiple times.
Sourcefn process_block(&mut self, input: &[f64], output: &mut [f64]) -> (usize, usize)where
Self: Sized,
fn process_block(&mut self, input: &[f64], output: &mut [f64]) -> (usize, usize)where
Self: Sized,
Convert as many samples as fit in output, consuming from input.
Returns (consumed, produced).
Sourcefn flush(&mut self, output: &mut [f64]) -> usizewhere
Self: Sized,
fn flush(&mut self, output: &mut [f64]) -> usizewhere
Self: Sized,
Continue converting by feeding zeros, writing into output.
Call this after the last input block to drain FIR delay (or the last linear interval). Returns the number of samples written.
A single call may not finish draining if output fills first. Keep
calling until the return value is 0 (and provide a fresh buffer each
time). A converter that has not yet seen any input writes nothing.
Default implementation: fills output by repeatedly calling
Self::next_sample with zeros until the slice is full or
next_sample returns None. It does not detect an empty delay
line, so custom Convert types that rely on this default will keep
writing for the whole buffer. Built-in sinc::Converter and
linear::Converter override flush to stop once their delay line
is empty (still call until 0 if the buffer was too small).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".