Created
June 3, 2019 10:34
-
-
Save merryhime/4dec01b1f05d08900f2952596060ac3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case Type::LowShelf: | |
if(gain >= 0) { | |
n = 1 / (1 + k / q + k * k); | |
a0 = (1 + sqrt(v) / q * k + v * k * k) * n; | |
a1 = 2 * (v * k * k - 1) * n; | |
a2 = (1 - sqrt(v) / q * k + v * k * k) * n; | |
b1 = 2 * (k * k - 1) * n; | |
b2 = (1 - k / q + k * k) * n; | |
} else { | |
n = 1 / (1 + sqrt(v) / q * k + v * k * k); | |
a0 = (1 + k / q + k * k) * n; | |
a1 = 2 * (k * k - 1) * n; | |
a2 = (1 - k / q + k * k) * n; | |
b1 = 2 * (v * k * k - 1) * n; | |
b2 = (1 - sqrt(v) / q * k + v * k * k) * n; | |
} | |
break; | |
case Type::HighShelf: | |
if(gain >= 0) { | |
n = 1 / (1 + k / q + k * k); | |
a0 = (v + sqrt(v) / q * k + k * k) * n; | |
a1 = 2 * (k * k - v) * n; | |
a2 = (v - sqrt(v) / q * k + k * k) * n; | |
b1 = 2 * (k * k - 1) * n; | |
b2 = (1 - k / q + k * k) * n; | |
} else { | |
n = 1 / (v + sqrt(v) / q * k + k * k); | |
a0 = (1 + k / q + k * k) * n; | |
a1 = 2 * (k * k - 1) * n; | |
a2 = (1 - k / q + k * k) * n; | |
b1 = 2 * (k * k - v) * n; | |
b2 = (v - sqrt(v) / q * k + k * k) * n; | |
} | |
break; | |
// https://dsp.stackexchange.com/a/30429 | |
auto Biquad::shelfQuality(double gain, double slope) -> double { | |
double A = pow(10, gain / 40); | |
return 1 / sqrt((A + 1 / A) * (1 / slope - 1) + 2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment