Skip to content

Commit d45500b

Browse files
committed
fix one pole highpass filter
1 parent 30446e0 commit d45500b

File tree

3 files changed

+2
-8
lines changed

3 files changed

+2
-8
lines changed

crates/firewheel-core/src/dsp/filter/single_pole_iir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl OnePoleIirHPF {
8282

8383
#[inline(always)]
8484
pub fn process(&mut self, s: f32, coeff: OnePoleIirHPFCoeff) -> f32 {
85-
self.yz1 = (coeff.a0 * s) + (coeff.b1 * self.yz1) - self.xz1;
85+
self.yz1 = (coeff.b1 * self.yz1) + (coeff.a0 * (s - self.xz1));
8686
self.xz1 = s;
8787
self.yz1
8888
}
@@ -322,7 +322,7 @@ impl<const LANES: usize> OnePoleIirHPFSimd<LANES> {
322322
coeff: &OnePoleIirHPFCoeffSimd<LANES>,
323323
) -> [f32; LANES] {
324324
core::array::from_fn(|i| {
325-
self.yz1[i] = (coeff.a0[i] * input[i]) + (coeff.b1[i] * self.yz1[i]) - self.xz1[i];
325+
self.yz1[i] = (coeff.b1[i] * self.yz1[i]) + (coeff.a0[i] * (input[i] - self.xz1[i]));
326326
self.xz1[i] = input[i];
327327
self.yz1[i]
328328
})

crates/firewheel-nodes/src/fast_filters/bandpass.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ pub type FastBandpassStereoNode = FastBandpassNode<2>;
2828

2929
/// A simple single-pole IIR bandpass filter node that is computationally
3030
/// efficient
31-
///
32-
/// It is computationally efficient, but it doesn't do that great of
33-
/// a job at attenuating low frequencies.
3431
#[derive(Diff, Patch, Debug, Clone, Copy, PartialEq)]
3532
#[cfg_attr(feature = "bevy", derive(bevy_ecs::prelude::Component))]
3633
#[cfg_attr(feature = "bevy_reflect", derive(bevy_reflect::Reflect))]

crates/firewheel-nodes/src/fast_filters/highpass.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ pub type FastHighpassStereoNode = FastHighpassNode<2>;
2525

2626
/// A simple single-pole IIR highpass filter that is computationally
2727
/// efficient
28-
///
29-
/// It is computationally efficient, but it doesn't do that great of
30-
/// a job at attenuating low frequencies.
3128
#[derive(Diff, Patch, Debug, Clone, Copy, PartialEq)]
3229
#[cfg_attr(feature = "bevy", derive(bevy_ecs::prelude::Component))]
3330
#[cfg_attr(feature = "bevy_reflect", derive(bevy_reflect::Reflect))]

0 commit comments

Comments
 (0)