aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-04-08 13:43:19 -0700
committerChris Robinson <[email protected]>2017-04-08 13:43:19 -0700
commit319d0971986309d7882a9be42a5aef7dc612945d (patch)
tree4c05460eaa7949e7438969dd60b5d3d8d769a0da /utils
parent5ef7d8fe6248bccc8edf895afece8e1b44b0f4ea (diff)
Pre-compute the sinc4 resampler coefficient table
Diffstat (limited to 'utils')
-rw-r--r--utils/bsincgen.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/utils/bsincgen.c b/utils/bsincgen.c
index d53b3cb5..33783a27 100644
--- a/utils/bsincgen.c
+++ b/utils/bsincgen.c
@@ -364,11 +364,49 @@ static void BsiGenerateTables()
fprintf(stdout, " },\n {");
for(si = 0; si < (BSINC_SCALE_COUNT - 1); si++)
fprintf(stdout, " %d,", mt[si]);
- fprintf(stdout, " 0 }\n };\n");
+ fprintf(stdout, " 0 }\n };\n\n");
+}
+
+
+/* These methods generate a much simplified 4-point sinc interpolator using a
+ * Kaiser windows. This is much simpler to process at run-time, but has notably
+ * more aliasing noise.
+ */
+
+/* Same as in alu.h! */
+#define FRACTIONBITS (12)
+#define FRACTIONONE (1<<FRACTIONBITS)
+
+static double SincKaiser(double r, double x)
+{
+ /* Limit rippling to -60dB. */
+ return Kaiser(CalcKaiserBeta(60.0), x / r) * Sinc(x);
+}
+
+static void Sinc4GenerateTables(void)
+{
+ static double filter[FRACTIONONE][4];
+
+ int i;
+ for(i = 0;i < FRACTIONONE;i++)
+ {
+ double mu = (double)i / FRACTIONONE;
+ filter[i][0] = SincKaiser(2.0, mu - -1.0);
+ filter[i][1] = SincKaiser(2.0, mu - 0.0);
+ filter[i][2] = SincKaiser(2.0, mu - 1.0);
+ filter[i][3] = SincKaiser(2.0, mu - 2.0);
+ }
+
+ fprintf(stdout, "static const float sinc4Tab[%d][4] =\n{\n", FRACTIONONE);
+ for(i = 0;i < FRACTIONONE;i++)
+ fprintf(stdout, " { %+14.9ef, %+14.9ef, %+14.9ef, %+14.9ef },\n",
+ filter[i][0], filter[i][1], filter[i][2], filter[i][3]);
+ fprintf(stdout, "};\n\n");
}
int main(void)
{
BsiGenerateTables();
+ Sinc4GenerateTables();
return 0;
}