diff --git a/dsp/src/lockin.rs b/dsp/src/lockin.rs index d78c01b..75c7b97 100644 --- a/dsp/src/lockin.rs +++ b/dsp/src/lockin.rs @@ -12,7 +12,7 @@ impl Lockin { pub fn new(k: u8) -> Self { let lp = Lowpass::default(); Self { - state: [lp.clone(), lp.clone()], + state: [lp.clone(), lp], k, } } diff --git a/dsp/src/lowpass.rs b/dsp/src/lowpass.rs index e3a1353..b85e2ed 100644 --- a/dsp/src/lowpass.rs +++ b/dsp/src/lowpass.rs @@ -27,7 +27,7 @@ impl> Lowpass { let mut x1 = self.xy[0]; self.xy[0] = x; for y1 in self.xy[1..].iter_mut() { - x0 = *y1 + (((x0 >> 1) + (x1 >> 1) - *y1 + (1 << k - 1)) >> k); + x0 = *y1 + (((x0 >> 1) + (x1 >> 1) - *y1 + (1 << (k - 1))) >> k); x1 = *y1; *y1 = x0; }