aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-08-27 10:16:36 -0700
committerChris Robinson <[email protected]>2017-08-27 10:16:36 -0700
commita4d357de06b3860f49f2f6f70899d825b920947b (patch)
tree3532665177753d3f6d6cb8a5c6a9b702a48d403a /utils
parent773d4664ff8f31837374164b64b992b86fcc80f7 (diff)
Add a higher quality bsinc resampler using 24 sample points
This improves the transition width, allowing more of the higher frequencies remain audible. It would be preferrable to have an upper limit of 32 points instead of 48, to reduce the overall table size and the CPU cost for down- sampling.
Diffstat (limited to 'utils')
-rw-r--r--utils/bsincgen.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/utils/bsincgen.c b/utils/bsincgen.c
index e84f1edc..945a99eb 100644
--- a/utils/bsincgen.c
+++ b/utils/bsincgen.c
@@ -51,13 +51,14 @@
#endif
// The number of distinct scale and phase intervals within the filter table.
+// Must be the same as in alu.h!
#define BSINC_SCALE_COUNT (16)
#define BSINC_PHASE_COUNT (16)
-/* 24 points includes the doubling for downsampling. So the maximum allowed
- * order is 11, which is 12 sample points that multiplied by 2 is 24.
+/* 48 points includes the doubling for downsampling, so the maximum number of
+ * base sample points is 24, which is 23rd order.
*/
-#define BSINC_POINTS_MAX (24)
+#define BSINC_POINTS_MAX (48)
static double MinDouble(double a, double b)
{ return (a <= b) ? a : b; }
@@ -251,7 +252,7 @@ static void BsiGenerateTables(FILE *output, const char *tabname, const double re
" * width) suffers to reduce the CPU cost. The bandlimiting will cut all sound\n"
" * after downsampling by ~%.2f octaves.\n"
" */\n"
-"static const BSincTable %s = {\n",
+"const BSincTable %s = {\n",
order, (((order%100)/10) == 1) ? "th" :
((order%10) == 1) ? "st" :
((order%10) == 2) ? "nd" :
@@ -386,6 +387,8 @@ int main(int argc, char *argv[])
" const int filterOffset[BSINC_SCALE_COUNT];\n"
" alignas(16) const float Tab[];\n"
"} BSincTable;\n\n");
+ /* A 23rd order filter with a -60dB drop at nyquist. */
+ BsiGenerateTables(output, "bsinc24", 60.0, 23);
/* An 11th order filter with a -60dB drop at nyquist. */
BsiGenerateTables(output, "bsinc12", 60.0, 11);
Sinc4GenerateTables(output, 60.0);