AUDIO
Source snapshot · 11 November 2026

API reference / ravet_signal::StereoFir

Struct StereoFir 

pub struct StereoFir<S: FirSample = f32> { /* private fields */ }
Expand description

A prepared stereo direct-form FIR with a fixed tap count.

Each channel has its own impulse response; both have the same length. Preparation copies 1..=16,384 finite taps per channel and allocates history for blocks of up to maximum_frames (1..=65,536). Processing and reset never allocate, lock or perform I/O. Longer blocks are processed in prepared-size pieces, so results do not depend on block partitioning.

The filter is causal with zero added latency: output n is sum(h[k] * x[n - k]). StereoFir::tail_samples is taps - 1. Nonfinite input propagates. Each output is summed sequentially from the oldest tap to the newest, so results do not depend on block partitioning. On arm64 each step is a fused multiply-add, so results can differ in the last bits between arm64 and other targets. Replacing a response requires a new instance on a control thread.

Implementations§

§

impl<S: FirSample> StereoFir<S>

pub fn new( impulse: &[S], maximum_frames: usize, ) -> Result<Self, ConvolutionError>

Prepare the same response on both channels.

pub fn with_responses( left: &[S], right: &[S], maximum_frames: usize, ) -> Result<Self, ConvolutionError>

Prepare separate left and right responses of equal length.

pub fn taps(&self) -> usize

Taps per channel.

pub fn maximum_frames(&self) -> usize

Prepared maximum block length.

pub fn latency_samples(&self) -> usize

Algorithmic latency: always zero.

pub fn tail_samples(&self) -> usize

Samples of output that follow the last nonzero input.

pub fn reset(&mut self)

Clear both histories without allocating.

pub fn process( &mut self, left: &mut [S], right: &mut [S], ) -> Result<(), ChannelLengthMismatch>

Filter both channels in place. Blocks of any length are accepted.

Channels of different lengths reject with ChannelLengthMismatch before any sample or history changes.

Trait Implementations§

§

impl<S: Clone + FirSample> Clone for StereoFir<S>

§

fn clone(&self) -> StereoFir<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · §

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<S: Debug + FirSample> Debug for StereoFir<S>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for StereoFir<S>

§

impl<S> RefUnwindSafe for StereoFir<S>
where S: RefUnwindSafe,

§

impl<S> Send for StereoFir<S>
where S: Send,

§

impl<S> Sync for StereoFir<S>
where S: Sync,

§

impl<S> Unpin for StereoFir<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for StereoFir<S>

§

impl<S> UnwindSafe for StereoFir<S>
where S: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.