frac32buffer filter input
frac32buffer filter output
combo fc
class LPbiq {
public:
float x1 = 0, x2 = 0, y1 = 0, y2 = 0;
void calc(float x[], const float b0, const float a1) {
const float b1 = 2 * b0;
// unity gain at DC => 2*b0 + b1 + a1 + a2 = 1
// => a2 = 1 - 2 * b0 - b1 - a1;
const float a2 = 1 - 2 * b1 - a1;
for (uint8_t i = 0; i < BUFSIZE; i++) {
float y = b0 * (x[i] + x2) + b1 * x1;
x2 = x1;
x1 = x[i];
y += a1 * y1 + a2 * y2;
x[i] = y; // output to buffer for the next filter
y2 = y1;
y1 = y;
}
}
};
float x[BUFSIZE];
LPbiq a, b, c, d, e;
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
for (int i = 0; i < BUFSIZE; i++)
x[i] = (float)inlet_in[i];
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// krate 17.7k
#if attr_fc == 1
a.calc(x, 0.753126f, -1.218067f);
b.calc(x, 0.486465f, -0.786782f);
c.calc(x, 0.629527f, -1.018164f);
d.calc(x, 0.507411f, -0.820659f);
e.calc(x, 0.552540f, -0.893649f);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// 15.3k
#elif attr_fc == 2
a.calc(x, 0.621309f, -0.733416f);
b.calc(x, 0.373874f, -0.441334f);
c.calc(x, 0.502253f, -0.592878f);
d.calc(x, 0.392078f, -0.462823f);
e.calc(x, 0.431976f, -0.509921f);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// 12.7k
#elif attr_fc == 3
a.calc(x, 0.472370f, -0.158397f);
b.calc(x, 0.275096f, -0.092246f);
c.calc(x, 0.375837f, -0.126027f);
d.calc(x, 0.289176f, -0.096968f);
e.calc(x, 0.320270f, -0.107394f);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// 9k
#elif attr_fc == 4
a.calc(x, 0.269777f, 0.668954f);
b.calc(x, 0.161365f, 0.400131f);
c.calc(x, 0.217451f, 0.539203f);
d.calc(x, 0.169297f, 0.419799f);
e.calc(x, 0.186705f, 0.462966f);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// 6.5k
#elif attr_fc == 5
a.calc(x, 0.152447f, 1.180262f);
b.calc(x, 0.097731f, 0.756643f);
c.calc(x, 0.126983f, 0.983119f);
d.calc(x, 0.101999f, 0.789688f);
e.calc(x, 0.111212f, 0.861017f);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// 4.2k
#elif attr_fc == 6
a.calc(x, 0.068127f, 1.576759f);
b.calc(x, 0.048594f, 1.124686f);
c.calc(x, 0.059553f, 1.378322f);
d.calc(x, 0.050275f, 1.163580f);
e.calc(x, 0.053804f, 1.245270f);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// 3.3k
#elif attr_fc == 7
a.calc(x, 0.043113f, 1.704935f);
b.calc(x, 0.032490f, 1.284833f);
c.calc(x, 0.038593f, 1.526199f);
d.calc(x, 0.033451f, 1.322835f);
e.calc(x, 0.035439f, 1.401464f);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// 2.5k
#elif attr_fc == 8
a.calc(x, 0.025268f, 1.803428f);
b.calc(x, 0.020139f, 1.437375f);
c.calc(x, 0.023156f, 1.652679f);
d.calc(x, 0.020627f, 1.472214f);
e.calc(x, 0.021621f, 1.543164f);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// 1.4k
#elif attr_fc == 9
a.calc(x, 0.008141f, 1.912150f);
b.calc(x, 0.007095f, 1.666465f);
c.calc(x, 0.007733f, 1.816243f);
d.calc(x, 0.007203f, 1.691808f);
e.calc(x, 0.007417f, 1.742062f);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// 900
#elif attr_fc == 10
a.calc(x, 0.003403f, 1.950375f);
b.calc(x, 0.003105f, 1.779490f);
c.calc(x, 0.003290f, 1.885522f);
d.calc(x, 0.003137f, 1.797855f);
e.calc(x, 0.003200f, 1.833754f);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#endif
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
for (int i = 0; i < BUFSIZE; i++)
outlet_out[i] = (int32_t)x[i];