diff options
author | Chris Robinson <[email protected]> | 2017-08-17 05:18:46 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-08-17 05:51:18 -0700 |
commit | 9fd3e5f52933de4c413784d04cc6196cd18b116e (patch) | |
tree | fb65a8ac7558028070cd64f42b16328f83bf3181 /utils | |
parent | e0408d8edfb0a5804d4ef9bd3e805d08d62d9266 (diff) |
Correct the bsinc filter order
Despite the claim that it was an 11th order filter, the transition width was
generated by specifying 12th order. A 12th order filter would need 14 sample
points rather than the 12 it had.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/bsincgen.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/utils/bsincgen.c b/utils/bsincgen.c index 76047968..657c78ca 100644 --- a/utils/bsincgen.c +++ b/utils/bsincgen.c @@ -47,6 +47,7 @@ #define BSINC_REJECTION (60.0)
#define BSINC_POINTS_MIN (12)
+#define BSINC_ORDER (11)
static double MinDouble(double a, double b)
{ return (a <= b) ? a : b; }
@@ -147,7 +148,7 @@ static void BsiGenerateTables() band, but it may vary due to the linear interpolation between scales
of the filter.
*/
- width = CalcKaiserWidth(BSINC_REJECTION, BSINC_POINTS_MIN);
+ width = CalcKaiserWidth(BSINC_REJECTION, BSINC_ORDER);
beta = CalcKaiserBeta(BSINC_REJECTION);
scaleBase = width / 2.0;
scaleRange = 1.0 - scaleBase;
@@ -242,19 +243,19 @@ static void BsiGenerateTables() i += 4 * BSINC_PHASE_COUNT * mt[si];
fprintf(stdout, "/* Generated by bsincgen, do not edit! */\n\n"
-"/* Table of windowed sinc coefficients and deltas. This 11th order filter\n"
-" * has a rejection of -60 dB, yielding a transition width of ~0.302\n"
+"/* Table of windowed sinc coefficients and deltas. This %dth order filter\n"
+" * has a rejection of -%gdB, yielding a transition width of ~%.3f\n"
" * (normalized frequency). Order increases when downsampling to a limit of\n"
" * one octave, after which the quality of the filter (transition width)\n"
" * suffers to reduce the CPU cost. The bandlimiting will cut all sound after\n"
-" * downsampling by ~2.73 octaves.\n"
+" * downsampling by ~%.2f octaves.\n"
" */\n"
"static const struct {\n"
" alignas(16) const float Tab[%d];\n"
" const float scaleBase, scaleRange;\n"
" const int m[BSINC_SCALE_COUNT];\n"
" const int filterOffset[BSINC_SCALE_COUNT];\n"
-"} bsinc = {\n", i);
+"} bsinc = {\n", BSINC_ORDER, BSINC_REJECTION, width, log2(1.0/scaleBase), i);
fprintf(stdout, " /* Tab */ {\n");
for(si = 0; si < BSINC_SCALE_COUNT; si++)
@@ -321,7 +322,7 @@ static void Sinc4GenerateTables(void) {
static double filter[FRACTIONONE][4];
- const double width = CalcKaiserWidth(BSINC_REJECTION, 4);
+ const double width = CalcKaiserWidth(BSINC_REJECTION, 3);
const double beta = CalcKaiserBeta(BSINC_REJECTION);
const double scaleBase = width / 2.0;
const double scaleRange = 1.0 - scaleBase;
|