From 7d5940101b68167b5562f1d0d9c002d553593eb5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 24 Nov 2025 10:35:53 +0100 Subject: [PATCH] resample: tweak cutoff some more Increase the cutoff frequency for the lower quality modes. This should give significantly better high frequency preservation at the expense of more (but likely inaudible) aliasing. Reduce the cutoff for the higher qualities in blackman and exp to compensate the the wider transition band in those windows. Increase cutoff for kaiser because of the sharper rolloff. --- spa/plugins/audioconvert/resample-native.c | 90 +++++++++++----------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/spa/plugins/audioconvert/resample-native.c b/spa/plugins/audioconvert/resample-native.c index 329e59c20..d4a8a4734 100644 --- a/spa/plugins/audioconvert/resample-native.c +++ b/spa/plugins/audioconvert/resample-native.c @@ -33,21 +33,21 @@ struct window_info { struct window_info window_info[]; static const struct quality blackman_qualities[] = { - { 8, 0.53, 0.53, { 0.16, }}, - { 16, 0.67, 0.67, { 0.20, }}, - { 24, 0.75, 0.75, { 0.16, }}, - { 32, 0.80, 0.80, { 0.16, }}, - { 48, 0.85, 0.85, { 0.16, }}, /* default */ - { 64, 0.88, 0.88, { 0.16, }}, - { 80, 0.895, 0.895, { 0.16, }}, - { 96, 0.910, 0.910, { 0.16, }}, - { 128, 0.936, 0.936, { 0.16, }}, - { 144, 0.945, 0.945, { 0.16, }}, - { 160, 0.950, 0.950, { 0.16, }}, - { 192, 0.960, 0.960, { 0.16, }}, - { 256, 0.970, 0.970, { 0.16, }}, - { 896, 0.990, 0.990, { 0.16, }}, - { 1024, 0.995, 0.995, { 0.16, }}, + { 8, 0.58, 0.58, { 0.16, }}, + { 16, 0.70, 0.70, { 0.20, }}, + { 24, 0.77, 0.77, { 0.16, }}, + { 32, 0.82, 0.82, { 0.16, }}, + { 48, 0.87, 0.87, { 0.16, }}, /* default */ + { 64, 0.895, 0.895, { 0.16, }}, + { 80, 0.910, 0.910, { 0.16, }}, + { 96, 0.925, 0.925, { 0.16, }}, + { 128, 0.942, 0.942, { 0.16, }}, + { 144, 0.950, 0.950, { 0.16, }}, + { 160, 0.958, 0.958, { 0.16, }}, + { 192, 0.966, 0.966, { 0.16, }}, + { 256, 0.975, 0.975, { 0.16, }}, + { 896, 0.988, 0.988, { 0.16, }}, + { 1024, 0.990, 0.990, { 0.16, }}, }; static inline void blackman_window(struct resample *r, double *w, double t, uint32_t n_taps) @@ -67,21 +67,21 @@ static inline void blackman_config(struct resample *r) } static const struct quality exp_qualities[] = { - { 8, 0.53, 0.53, { 16.97789, }}, - { 16, 0.67, 0.67, { 16.97789, }}, - { 24, 0.75, 0.75, { 16.97789, }}, - { 32, 0.80, 0.80, { 16.97789, }}, - { 48, 0.85, 0.85, { 16.97789, }}, /* default */ - { 64, 0.88, 0.88, { 16.97789, }}, - { 80, 0.895, 0.895, { 16.97789, }}, - { 96, 0.910, 0.910, { 16.97789, }}, - { 128, 0.936, 0.936, { 16.97789, }}, - { 144, 0.945, 0.945, { 16.97789, }}, - { 160, 0.950, 0.950, { 16.97789, }}, - { 192, 0.960, 0.960, { 16.97789, }}, - { 256, 0.970, 0.970, { 16.97789, }}, - { 896, 0.990, 0.990, { 16.97789, }}, - { 1024, 0.995, 0.995, { 16.97789, }}, + { 8, 0.58, 0.58, { 16.97789, }}, + { 16, 0.70, 0.70, { 16.97789, }}, + { 24, 0.77, 0.77, { 16.97789, }}, + { 32, 0.82, 0.82, { 16.97789, }}, + { 48, 0.87, 0.87, { 16.97789, }}, /* default */ + { 64, 0.895, 0.895, { 16.97789, }}, + { 80, 0.910, 0.910, { 16.97789, }}, + { 96, 0.925, 0.925, { 16.97789, }}, + { 128, 0.942, 0.942, { 16.97789, }}, + { 144, 0.950, 0.950, { 16.97789, }}, + { 160, 0.958, 0.958, { 16.97789, }}, + { 192, 0.966, 0.966, { 16.97789, }}, + { 256, 0.975, 0.975, { 16.97789, }}, + { 896, 0.988, 0.988, { 16.97789, }}, + { 1024, 0.990, 0.990, { 16.97789, }}, }; static inline void exp_window(struct resample *r, double *w, double t, uint32_t n_taps) @@ -104,21 +104,21 @@ static inline void exp_config(struct resample *r) #include "dbesi0.c" static const struct quality kaiser_qualities[] = { - { 8, 0.600000, 0.600000, { 3.553376, 110.000000, 0.888064 }}, - { 16, 0.770000, 0.770000, { 3.553376, 110.000000, 0.444032 }}, - { 24, 0.800000, 0.800000, { 3.904154, 120.000000, 0.325043 }}, - { 32, 0.850000, 0.850000, { 4.254931, 130.000000, 0.265548 }}, - { 48, 0.880000, 0.880000, { 4.254931, 130.000000, 0.177032 }}, - { 64, 0.900000, 0.900000, { 4.254931, 130.000000, 0.132774 }}, - { 80, 0.910000, 0.910000, { 4.254931, 130.000000, 0.106219 }}, - { 96, 0.930000, 0.930000, { 4.254931, 130.000000, 0.088516 }}, - { 128, 0.940000, 0.940000, { 4.254931, 130.000000, 0.066387 }}, - { 160, 0.950000, 0.950000, { 4.254931, 130.000000, 0.053110 }}, - { 192, 0.960000, 0.960000, { 4.254931, 130.000000, 0.044258 }}, - { 256, 0.970000, 0.970000, { 4.605709, 140.000000, 0.035914 }}, - { 512, 0.980000, 0.980000, { 4.781097, 145.000000, 0.018637 }}, - { 768, 0.985000, 0.985000, { 4.956486, 150.000000, 0.012878 }}, - { 1024, 0.990000, 0.990000, { 5.131875, 155.000000, 0.009999 }}, + { 8, 0.620000, 0.620000, { 3.553376, 110.000000, 0.888064 }}, + { 16, 0.780000, 0.780000, { 3.553376, 110.000000, 0.444032 }}, + { 24, 0.820000, 0.820000, { 3.904154, 120.000000, 0.325043 }}, + { 32, 0.865000, 0.865000, { 4.254931, 130.000000, 0.265548 }}, + { 48, 0.895000, 0.895000, { 4.254931, 130.000000, 0.177032 }}, + { 64, 0.915000, 0.915000, { 4.254931, 130.000000, 0.132774 }}, + { 80, 0.928000, 0.928000, { 4.254931, 130.000000, 0.106219 }}, + { 96, 0.942000, 0.942000, { 4.254931, 130.000000, 0.088516 }}, + { 128, 0.952000, 0.952000, { 4.254931, 130.000000, 0.066387 }}, + { 160, 0.960000, 0.960000, { 4.254931, 130.000000, 0.053110 }}, + { 192, 0.968000, 0.968000, { 4.254931, 130.000000, 0.044258 }}, + { 256, 0.976000, 0.976000, { 4.605709, 140.000000, 0.035914 }}, + { 512, 0.985000, 0.985000, { 4.781097, 145.000000, 0.018637 }}, + { 768, 0.990000, 0.990000, { 4.956486, 150.000000, 0.012878 }}, + { 1024, 0.993000, 0.993000, { 5.131875, 155.000000, 0.009999 }}, }; static inline void kaiser_window(struct resample *r, double *w, double t, uint32_t n_taps)