**References :** Posted by Bram

**Code :**

LP:

recursion: tmp = (1-p)*in + p*tmp with output = tmp

coefficient: p = (2-cos(x)) - sqrt((2-cos(x))^2 - 1) with x = 2*pi*cutoff/samplerate

coeficient approximation: p = (1 - 2*cutoff/samplerate)^2

HP:

recursion: tmp = (p-1)*in - p*tmp with output = tmp

coefficient: p = (2+cos(x)) - sqrt((2+cos(x))^2 - 1) with x = 2*pi*cutoff/samplerate

coeficient approximation: p = (2*cutoff/samplerate)^2

**Comments**

__from__ : skyphos_atw[AT]hotmail[DOT]com

__comment__ : coefficient: p = (2-cos(x)) - sqrt((2-cos(x))^2 - 1) with x = 2*pi*cutoff/samplerate
p is always -1 using the formula above. The square eliminates the squareroot and (2-cos(x)) - (2-cos(x)) is 0.

__from__ : q[AT]q

__comment__ : Look again. The -1 is inside the sqrt.

__from__ : batlord[[DOT]A[DOT]T[DOT]]o2[[DOT]D[DOT]O[DOT]T[DOT]]pl

__comment__ : skyphos:
sqrt((2-cos(x))^2 - 1) doesn't equal
sqrt((2-cos(x))^2) + sqrt(- 1)
so
-1 can be inside the sqrt, because (2-cos(x))^2 will be always >= one.

__from__ : No

__comment__ : HP is wrong!
Or at least it does not work here. It acts like a lofi low-shelf. However this works:
HP:
recursion: tmp = (1-p)*in + p*tmp with output = in-tmp
coefficient: p = (2-cos(x)) - sqrt((2-cos(x))^2 - 1) with x = 2*pi*cutoff/samplerate
coeficient approximation: p = (1 - 2*cutoff/samplerate)^2