iir_int: rounding bias
This commit is contained in:
parent
611bd3e855
commit
31781a9d0e
|
@ -28,9 +28,9 @@ impl Vec5 {
|
||||||
let alpha = fsin / (2. * q);
|
let alpha = fsin / (2. * q);
|
||||||
// IIR uses Q2.30 fixed point
|
// IIR uses Q2.30 fixed point
|
||||||
let a0 = (1. + alpha) / (1 << IIR::SHIFT) as f64;
|
let a0 = (1. + alpha) / (1 << IIR::SHIFT) as f64;
|
||||||
let b0 = (k / 2. * (1. - fcos) / a0) as _;
|
let b0 = (k / 2. * (1. - fcos) / a0 + 0.5) as _;
|
||||||
let a1 = (2. * fcos / a0) as _;
|
let a1 = (2. * fcos / a0 + 0.5) as _;
|
||||||
let a2 = ((alpha - 1.) / a0) as _;
|
let a2 = ((alpha - 1.) / a0 + 0.5) as _;
|
||||||
|
|
||||||
Self([b0, 2 * b0, b0, a1, a2])
|
Self([b0, 2 * b0, b0, a1, a2])
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lowpass_gen() {
|
fn lowpass_gen() {
|
||||||
let ba = Vec5::lowpass(1e-5, 1. / 2f64.sqrt(), 2e5);
|
let ba = Vec5::lowpass(1e-5, 1. / 2f64.sqrt(), 2.);
|
||||||
println!("{:?}", ba.0);
|
println!("{:?}", ba.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue