aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/filters
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-01-24 10:22:38 -0800
committerChris Robinson <[email protected]>2019-01-24 10:22:38 -0800
commitb5569d84550fda34f7ba9c8fcc0a9de1e48a0468 (patch)
tree81b315407d06b4c905231b470f6f5185b582eb17 /Alc/filters
parent98be1d1bf5608425cb679ab492922f1b5b925323 (diff)
Slight cleanup for NfcFilterCreate4
Diffstat (limited to 'Alc/filters')
-rw-r--r--Alc/filters/nfc.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/Alc/filters/nfc.cpp b/Alc/filters/nfc.cpp
index f08ed65b..e607dd56 100644
--- a/Alc/filters/nfc.cpp
+++ b/Alc/filters/nfc.cpp
@@ -202,6 +202,7 @@ NfcFilter4 NfcFilterCreate4(const float w0, const float w1) noexcept
{
NfcFilter4 nfc{};
float b_10, b_11, g_1;
+ float b_00, b_01, g_0;
float r;
nfc.base_gain = 1.0f;
@@ -211,39 +212,32 @@ NfcFilter4 NfcFilterCreate4(const float w0, const float w1) noexcept
r = 0.5f * w0;
b_10 = B[4][0] * r;
b_11 = B[4][1] * r * r;
+ b_00 = B[4][2] * r;
+ b_01 = B[4][3] * r * r;
g_1 = 1.0f + b_10 + b_11;
+ g_0 = 1.0f + b_00 + b_01;
- nfc.gain *= g_1;
+ nfc.gain *= g_1 * g_0;
nfc.b1 = (2.0f*b_10 + 4.0f*b_11) / g_1;
nfc.b2 = 4.0f * b_11 / g_1;
-
- b_10 = B[4][2] * r;
- b_11 = B[4][3] * r * r;
- g_1 = 1.0f + b_10 + b_11;
-
- nfc.gain *= g_1;
- nfc.b3 = (2.0f*b_10 + 4.0f*b_11) / g_1;
- nfc.b4 = 4.0f * b_11 / g_1;
+ nfc.b3 = (2.0f*b_00 + 4.0f*b_01) / g_0;
+ nfc.b4 = 4.0f * b_01 / g_0;
/* Calculate bass-cut coefficients. */
r = 0.5f * w1;
b_10 = B[4][0] * r;
b_11 = B[4][1] * r * r;
+ b_00 = B[4][2] * r;
+ b_01 = B[4][3] * r * r;
g_1 = 1.0f + b_10 + b_11;
+ g_0 = 1.0f + b_00 + b_01;
- nfc.base_gain /= g_1;
- nfc.gain /= g_1;
+ nfc.base_gain /= g_1 * g_0;
+ nfc.gain /= g_1 * g_0;
nfc.a1 = (2.0f*b_10 + 4.0f*b_11) / g_1;
nfc.a2 = 4.0f * b_11 / g_1;
-
- b_10 = B[4][2] * r;
- b_11 = B[4][3] * r * r;
- g_1 = 1.0f + b_10 + b_11;
-
- nfc.base_gain /= g_1;
- nfc.gain /= g_1;
- nfc.a3 = (2.0f*b_10 + 4.0f*b_11) / g_1;
- nfc.a4 = 4.0f * b_11 / g_1;
+ nfc.a3 = (2.0f*b_00 + 4.0f*b_01) / g_0;
+ nfc.a4 = 4.0f * b_01 / g_0;
return nfc;
}