use super::{Complex, ComplexExt, Filter, MulScaled};
#[derive(Copy, Clone, Default)]
pub struct Lockin<T> {
state: [T; 2],
}
impl<T: Filter> Lockin<T> {
pub fn update_iq(&mut self, sample: i32, lo: Complex<i32>, k: &T::Config) -> Complex<i32> {
let mix = lo.mul_scaled(sample);
Complex {
re: self.state[0].update(mix.re, k),
im: self.state[1].update(mix.im, k),
}
}
pub fn update(&mut self, sample: i32, phase: i32, k: &T::Config) -> Complex<i32> {
self.update_iq(sample, Complex::from_angle(phase), k)
}
}