Struct Stereo Fir
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>
impl<S: FirSample> StereoFir<S>
pub fn new(
impulse: &[S],
maximum_frames: usize,
) -> Result<Self, ConvolutionError>
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>
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 maximum_frames(&self) -> usize
pub fn maximum_frames(&self) -> usize
Prepared maximum block length.
pub fn latency_samples(&self) -> usize
pub fn latency_samples(&self) -> usize
Algorithmic latency: always zero.
pub fn tail_samples(&self) -> usize
pub fn tail_samples(&self) -> usize
Samples of output that follow the last nonzero input.
pub fn reset(&mut self)
pub fn reset(&mut self)
Clear both histories without allocating.
pub fn process(
&mut self,
left: &mut [S],
right: &mut [S],
) -> Result<(), ChannelLengthMismatch>
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.