From 0bf7911b379832336f305868155d6ae0028511c6 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 20 Jul 2022 10:18:47 +0200 Subject: [PATCH] audioconvert: tweak resampler window some more By: Kevin Yin R->A calculation removed: it wasn't valid anyway. No behavior change. Placed existing A in there directly. cosh window -> strangely tweaked exp window: remove the discontinuity at the border, which is wrong for a window function. If A changes in the future, this window will be better. With the current A, you will not be able to tell the difference on any graph. (Of course, it's not a cosh window anymore.) Fixes #2574 --- spa/plugins/audioconvert/resample-native.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spa/plugins/audioconvert/resample-native.c b/spa/plugins/audioconvert/resample-native.c index 3ada3f3a9..b46a09fc1 100644 --- a/spa/plugins/audioconvert/resample-native.c +++ b/spa/plugins/audioconvert/resample-native.c @@ -68,14 +68,15 @@ static inline double window_blackman(double x, double n_taps) } static inline double window_cosh(double x, double n_taps) { - double R = 190.0, r; - double A = (-325.1E-6 * R + 0.1677) * R - 3.149; + double r; + double A = 16.97789; double x2; x = 2.0 * x / n_taps; x2 = x * x; if (x2 >= 1.0) return 0.0; - r = cosh(A * sqrt(1 - x2)) / cosh(A); + /* doi:10.1109/RME.2008.4595727 with tweak */ + r = (exp(A * sqrt(1 - x2)) - 1) / (exp(A) - 1); return r; }