iir: tweak math a bit
This commit is contained in:
parent
ddbfa9d988
commit
dcc71d5d11
@ -22,8 +22,9 @@ impl Vec5 {
|
|||||||
pub fn lowpass(f: f32, q: f32, k: f32) -> Self {
|
pub fn lowpass(f: f32, q: f32, k: f32) -> Self {
|
||||||
// 3rd order Taylor approximation of sin and cos.
|
// 3rd order Taylor approximation of sin and cos.
|
||||||
let f = f * 2. * PI;
|
let f = f * 2. * PI;
|
||||||
let fsin = f - f * f * f / 6.;
|
let f2 = f * f * 0.5;
|
||||||
let fcos = 1. - f * f / 2.;
|
let fcos = 1. - f2;
|
||||||
|
let fsin = f * (1. - f2 / 3.);
|
||||||
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 f32;
|
let a0 = (1. + alpha) / (1 << IIR::SHIFT) as f32;
|
||||||
|
Loading…
Reference in New Issue
Block a user