module Sound.Sc3.Common.Math.Filter.Beq where
bLowPassCoef :: Floating a => a -> a -> a -> (a,a,a,a,a)
bLowPassCoef :: forall a. Floating a => a -> a -> a -> (a, a, a, a, a)
bLowPassCoef a
sr a
freq a
rq =
let w0 :: a
w0 = forall a. Floating a => a
pi forall a. Num a => a -> a -> a
* a
2 forall a. Num a => a -> a -> a
* a
freq forall a. Num a => a -> a -> a
* (a
1 forall a. Fractional a => a -> a -> a
/ a
sr)
cos_w0 :: a
cos_w0 = forall a. Floating a => a -> a
cos a
w0
i :: a
i = a
1 forall a. Num a => a -> a -> a
- a
cos_w0
alpha :: a
alpha = forall a. Floating a => a -> a
sin a
w0 forall a. Num a => a -> a -> a
* a
0.5 forall a. Num a => a -> a -> a
* a
rq
b0rz :: a
b0rz = forall a. Fractional a => a -> a
recip (a
1 forall a. Num a => a -> a -> a
+ a
alpha)
a0 :: a
a0 = a
i forall a. Num a => a -> a -> a
* a
0.5 forall a. Num a => a -> a -> a
* a
b0rz
a1 :: a
a1 = a
i forall a. Num a => a -> a -> a
* a
b0rz
b1 :: a
b1 = a
cos_w0 forall a. Num a => a -> a -> a
* a
2 forall a. Num a => a -> a -> a
* a
b0rz
b2 :: a
b2 = (a
1 forall a. Num a => a -> a -> a
- a
alpha) forall a. Num a => a -> a -> a
* forall a. Num a => a -> a
negate a
b0rz
in (a
a0,a
a1,a
a0,a
b1,a
b2)
bHiPassCoef :: Floating t => t -> t -> t -> (t, t, t, t, t)
bHiPassCoef :: forall a. Floating a => a -> a -> a -> (a, a, a, a, a)
bHiPassCoef t
sr t
freq t
rq =
let w0 :: t
w0 = forall a. Floating a => a
pi forall a. Num a => a -> a -> a
* t
2 forall a. Num a => a -> a -> a
* t
freq forall a. Num a => a -> a -> a
* (t
1 forall a. Fractional a => a -> a -> a
/ t
sr)
cos_w0 :: t
cos_w0 = forall a. Floating a => a -> a
cos t
w0
i :: t
i = t
1 forall a. Num a => a -> a -> a
+ t
cos_w0
alpha :: t
alpha = forall a. Floating a => a -> a
sin t
w0 forall a. Num a => a -> a -> a
* t
0.5 forall a. Num a => a -> a -> a
* t
rq
b0rz :: t
b0rz = forall a. Fractional a => a -> a
recip (t
1 forall a. Num a => a -> a -> a
+ t
alpha)
a0 :: t
a0 = t
i forall a. Num a => a -> a -> a
* t
0.5 forall a. Num a => a -> a -> a
* t
b0rz
a1 :: t
a1 = forall a. Num a => a -> a
negate t
i forall a. Num a => a -> a -> a
* t
b0rz
b1 :: t
b1 = t
cos_w0 forall a. Num a => a -> a -> a
* t
2 forall a. Num a => a -> a -> a
* t
b0rz
b2 :: t
b2 = (t
1 forall a. Num a => a -> a -> a
- t
alpha) forall a. Num a => a -> a -> a
* forall a. Num a => a -> a
negate t
b0rz
in (t
a0, t
a1, t
a0, t
b1, t
b2)
bAllPassCoef :: Floating t => t -> t -> t -> (t, t, t, t, t)
bAllPassCoef :: forall a. Floating a => a -> a -> a -> (a, a, a, a, a)
bAllPassCoef t
sr t
freq t
rq =
let w0 :: t
w0 = forall a. Floating a => a
pi forall a. Num a => a -> a -> a
* t
2 forall a. Num a => a -> a -> a
* t
freq forall a. Num a => a -> a -> a
* (t
1 forall a. Fractional a => a -> a -> a
/ t
sr)
alpha :: t
alpha = forall a. Floating a => a -> a
sin t
w0 forall a. Num a => a -> a -> a
* t
0.5 forall a. Num a => a -> a -> a
* t
rq
b0rz :: t
b0rz = forall a. Fractional a => a -> a
recip (t
1 forall a. Num a => a -> a -> a
+ t
alpha)
a0 :: t
a0 = (t
1 forall a. Num a => a -> a -> a
- t
alpha) forall a. Num a => a -> a -> a
* t
b0rz
b1 :: t
b1 = t
2.0 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
cos t
w0 forall a. Num a => a -> a -> a
* t
b0rz
in (t
a0,forall a. Num a => a -> a
negate t
b1, t
1.0, t
b1,forall a. Num a => a -> a
negate t
a0)
bBandPassCoef :: Floating t => t -> t -> t -> (t, t, t, t, t)
bBandPassCoef :: forall a. Floating a => a -> a -> a -> (a, a, a, a, a)
bBandPassCoef t
sr t
freq t
bw =
let w0 :: t
w0 = forall a. Floating a => a
pi forall a. Num a => a -> a -> a
* t
2 forall a. Num a => a -> a -> a
* t
freq forall a. Num a => a -> a -> a
* (t
1 forall a. Fractional a => a -> a -> a
/ t
sr)
sin_w0 :: t
sin_w0 = forall a. Floating a => a -> a
sin t
w0
alpha :: t
alpha = t
sin_w0 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
sinh (t
0.34657359027997 forall a. Num a => a -> a -> a
* t
bw forall a. Num a => a -> a -> a
* t
w0 forall a. Fractional a => a -> a -> a
/ t
sin_w0)
b0rz :: t
b0rz = forall a. Fractional a => a -> a
recip (t
1 forall a. Num a => a -> a -> a
+ t
alpha)
a0 :: t
a0 = t
alpha forall a. Num a => a -> a -> a
* t
b0rz
b1 :: t
b1 = forall a. Floating a => a -> a
cos t
w0 forall a. Num a => a -> a -> a
* t
2 forall a. Num a => a -> a -> a
* t
b0rz
b2 :: t
b2 = (t
1 forall a. Num a => a -> a -> a
- t
alpha) forall a. Num a => a -> a -> a
* forall a. Num a => a -> a
negate t
b0rz
in (t
a0, t
0.0, forall a. Num a => a -> a
negate t
a0, t
b1, t
b2)
bBandStopCoef :: Floating t => t -> t -> t -> (t, t, t, t, t)
bBandStopCoef :: forall a. Floating a => a -> a -> a -> (a, a, a, a, a)
bBandStopCoef t
sr t
freq t
bw =
let w0 :: t
w0 = forall a. Floating a => a
pi forall a. Num a => a -> a -> a
* t
2 forall a. Num a => a -> a -> a
* t
freq forall a. Num a => a -> a -> a
* (t
1 forall a. Fractional a => a -> a -> a
/ t
sr)
sin_w0 :: t
sin_w0 = forall a. Floating a => a -> a
sin t
w0
alpha :: t
alpha = t
sin_w0 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
sinh (t
0.34657359027997 forall a. Num a => a -> a -> a
* t
bw forall a. Num a => a -> a -> a
* t
w0 forall a. Fractional a => a -> a -> a
/ t
sin_w0)
b0rz :: t
b0rz = forall a. Fractional a => a -> a
recip (t
1 forall a. Num a => a -> a -> a
+ t
alpha)
b1 :: t
b1 = t
2.0 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
cos t
w0 forall a. Num a => a -> a -> a
* t
b0rz
b2 :: t
b2 = (t
1 forall a. Num a => a -> a -> a
- t
alpha) forall a. Num a => a -> a -> a
* forall a. Num a => a -> a
negate t
b0rz
in (t
b0rz, forall a. Num a => a -> a
negate t
b1, t
b0rz, t
b1, t
b2)
bPeakEQCoef :: Floating t => t -> t -> t -> t -> (t, t, t, t, t)
bPeakEQCoef :: forall t. Floating t => t -> t -> t -> t -> (t, t, t, t, t)
bPeakEQCoef t
sr t
freq t
rq t
db =
let a :: t
a = t
10 forall a. Floating a => a -> a -> a
** (t
db forall a. Fractional a => a -> a -> a
/ t
40)
w0 :: t
w0 = forall a. Floating a => a
pi forall a. Num a => a -> a -> a
* t
2 forall a. Num a => a -> a -> a
* t
freq forall a. Num a => a -> a -> a
* (t
1 forall a. Fractional a => a -> a -> a
/ t
sr)
alpha :: t
alpha = forall a. Floating a => a -> a
sin t
w0 forall a. Num a => a -> a -> a
* t
0.5 forall a. Num a => a -> a -> a
* t
rq
b0rz :: t
b0rz = forall a. Fractional a => a -> a
recip (t
1 forall a. Num a => a -> a -> a
+ (t
alpha forall a. Fractional a => a -> a -> a
/ t
a))
a0 :: t
a0 = (t
1 forall a. Num a => a -> a -> a
+ (t
alpha forall a. Num a => a -> a -> a
* t
a)) forall a. Num a => a -> a -> a
* t
b0rz
a2 :: t
a2 = (t
1 forall a. Num a => a -> a -> a
- (t
alpha forall a. Num a => a -> a -> a
* t
a)) forall a. Num a => a -> a -> a
* t
b0rz
b1 :: t
b1 = t
2.0 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
cos t
w0 forall a. Num a => a -> a -> a
* t
b0rz
b2 :: t
b2 = (t
1 forall a. Num a => a -> a -> a
- (t
alpha forall a. Fractional a => a -> a -> a
/ t
a)) forall a. Num a => a -> a -> a
* forall a. Num a => a -> a
negate t
b0rz
in (t
a0, forall a. Num a => a -> a
negate t
b1, t
a2, t
b1, t
b2)
bLowShelfCoef :: Floating t => t -> t -> t -> t -> (t, t, t, t, t)
bLowShelfCoef :: forall t. Floating t => t -> t -> t -> t -> (t, t, t, t, t)
bLowShelfCoef t
sr t
freq t
rs t
db =
let a :: t
a = t
10 forall a. Floating a => a -> a -> a
** (t
db forall a. Fractional a => a -> a -> a
/ t
40)
w0 :: t
w0 = forall a. Floating a => a
pi forall a. Num a => a -> a -> a
* t
2 forall a. Num a => a -> a -> a
* t
freq forall a. Num a => a -> a -> a
* (t
1 forall a. Fractional a => a -> a -> a
/ t
sr)
cos_w0 :: t
cos_w0 = forall a. Floating a => a -> a
cos t
w0
sin_w0 :: t
sin_w0 = forall a. Floating a => a -> a
sin t
w0
alpha :: t
alpha = t
sin_w0 forall a. Num a => a -> a -> a
* t
0.5 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
sqrt ((t
a forall a. Num a => a -> a -> a
+ forall a. Fractional a => a -> a
recip t
a) forall a. Num a => a -> a -> a
* (t
rs forall a. Num a => a -> a -> a
- t
1) forall a. Num a => a -> a -> a
+ t
2.0)
i :: t
i = (t
a forall a. Num a => a -> a -> a
+ t
1) forall a. Num a => a -> a -> a
* t
cos_w0
j :: t
j = (t
a forall a. Num a => a -> a -> a
- t
1) forall a. Num a => a -> a -> a
* t
cos_w0
k :: t
k = t
2 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
sqrt t
a forall a. Num a => a -> a -> a
* t
alpha
b0rz :: t
b0rz = forall a. Fractional a => a -> a
recip ((t
a forall a. Num a => a -> a -> a
+ t
1) forall a. Num a => a -> a -> a
+ t
j forall a. Num a => a -> a -> a
+ t
k)
a0 :: t
a0 = t
a forall a. Num a => a -> a -> a
* ((t
a forall a. Num a => a -> a -> a
+ t
1) forall a. Num a => a -> a -> a
- t
j forall a. Num a => a -> a -> a
+ t
k) forall a. Num a => a -> a -> a
* t
b0rz
a1 :: t
a1 = t
2 forall a. Num a => a -> a -> a
* t
a forall a. Num a => a -> a -> a
* ((t
a forall a. Num a => a -> a -> a
- t
1) forall a. Num a => a -> a -> a
- t
i) forall a. Num a => a -> a -> a
* t
b0rz
a2 :: t
a2 = t
a forall a. Num a => a -> a -> a
* ((t
a forall a. Num a => a -> a -> a
+ t
1) forall a. Num a => a -> a -> a
- t
j forall a. Num a => a -> a -> a
- t
k) forall a. Num a => a -> a -> a
* t
b0rz
b1 :: t
b1 = t
2.0 forall a. Num a => a -> a -> a
* ((t
a forall a. Num a => a -> a -> a
- t
1) forall a. Num a => a -> a -> a
+ t
i) forall a. Num a => a -> a -> a
* t
b0rz
b2 :: t
b2 = ((t
a forall a. Num a => a -> a -> a
+ t
1) forall a. Num a => a -> a -> a
+ t
j forall a. Num a => a -> a -> a
- t
k) forall a. Num a => a -> a -> a
* forall a. Num a => a -> a
negate t
b0rz
in (t
a0, t
a1, t
a2, t
b1, t
b2)
bHiShelfCoef :: Floating t => t -> t -> t -> t -> (t, t, t, t, t)
bHiShelfCoef :: forall t. Floating t => t -> t -> t -> t -> (t, t, t, t, t)
bHiShelfCoef t
sr t
freq t
rs t
db =
let a :: t
a = t
10 forall a. Floating a => a -> a -> a
** (t
db forall a. Fractional a => a -> a -> a
/ t
40)
w0 :: t
w0 = forall a. Floating a => a
pi forall a. Num a => a -> a -> a
* t
2 forall a. Num a => a -> a -> a
* t
freq forall a. Num a => a -> a -> a
* (t
1 forall a. Fractional a => a -> a -> a
/ t
sr)
cos_w0 :: t
cos_w0 = forall a. Floating a => a -> a
cos t
w0
sin_w0 :: t
sin_w0 = forall a. Floating a => a -> a
sin t
w0
alpha :: t
alpha = t
sin_w0 forall a. Num a => a -> a -> a
* t
0.5 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
sqrt((t
a forall a. Num a => a -> a -> a
+ forall a. Fractional a => a -> a
recip t
a) forall a. Num a => a -> a -> a
* (t
rs forall a. Num a => a -> a -> a
- t
1) forall a. Num a => a -> a -> a
+ t
2.0)
i :: t
i = (t
aforall a. Num a => a -> a -> a
+t
1) forall a. Num a => a -> a -> a
* t
cos_w0
j :: t
j = (t
aforall a. Num a => a -> a -> a
-t
1) forall a. Num a => a -> a -> a
* t
cos_w0
k :: t
k = t
2 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
sqrt t
a forall a. Num a => a -> a -> a
* t
alpha
b0rz :: t
b0rz = forall a. Fractional a => a -> a
recip ((t
a forall a. Num a => a -> a -> a
+ t
1) forall a. Num a => a -> a -> a
- t
j forall a. Num a => a -> a -> a
+ t
k)
a0 :: t
a0 = t
a forall a. Num a => a -> a -> a
* ((t
a forall a. Num a => a -> a -> a
+ t
1) forall a. Num a => a -> a -> a
+ t
j forall a. Num a => a -> a -> a
+ t
k) forall a. Num a => a -> a -> a
* t
b0rz
a1 :: t
a1 = -t
2.0 forall a. Num a => a -> a -> a
* t
a forall a. Num a => a -> a -> a
* ((t
a forall a. Num a => a -> a -> a
- t
1) forall a. Num a => a -> a -> a
+ t
i) forall a. Num a => a -> a -> a
* t
b0rz
a2 :: t
a2 = t
a forall a. Num a => a -> a -> a
* ((t
a forall a. Num a => a -> a -> a
+ t
1) forall a. Num a => a -> a -> a
+ t
j forall a. Num a => a -> a -> a
- t
k) forall a. Num a => a -> a -> a
* t
b0rz
b1 :: t
b1 = -t
2.0 forall a. Num a => a -> a -> a
* ((t
a forall a. Num a => a -> a -> a
- t
1) forall a. Num a => a -> a -> a
- t
i) forall a. Num a => a -> a -> a
* t
b0rz
b2 :: t
b2 = ((t
a forall a. Num a => a -> a -> a
+ t
1) forall a. Num a => a -> a -> a
- t
j forall a. Num a => a -> a -> a
- t
k) forall a. Num a => a -> a -> a
* forall a. Num a => a -> a
negate t
b0rz
in (t
a0, t
a1, t
a2, t
b1, t
b2)