diff options
author | Chris Robinson <[email protected]> | 2021-02-24 21:44:55 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-02-24 22:21:18 -0800 |
commit | 6e676b81d588f9bfd2b0b69af48cdf9a701ca24a (patch) | |
tree | 24904c3230cc5c62f95aace4a766cd874914022f /alc | |
parent | 5511bffdeb3dedd9e73f41cd873dbd448b3b153a (diff) |
Avoiding cutting all bsinc resampler output at scale 0
This is mostly for the SampleConverter, used by some capture backends. When
recording at really low rates, like 5512hz, with a device capturing at a higher
rate like 44100hz or 48000hz, it hits the filter's downscaling limit and
produces pure silence.
In such cases, it's better to just accept some aliasing noise so that the app
will still get some recognizable audio. The alternative would be to scale the
desired rate by 2x, 3x, etc until it's above the bsinc limit, then take every
2nd, 3rd, etc sample of the result as if by an extra simpler resampler pass.
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alu.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp index deffaad1..8f056e7c 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -182,8 +182,8 @@ inline void BsincPrepare(const uint increment, BsincState *state, const BSincTab if(increment > MixerFracOne) { - sf = MixerFracOne / static_cast<float>(increment); - sf = maxf(0.0f, (BSincScaleCount-1) * (sf-table->scaleBase) * table->scaleRange); + sf = MixerFracOne/static_cast<float>(increment) - table->scaleBase; + sf = maxf(0.0f, BSincScaleCount*sf*table->scaleRange - 1.0f); si = float2uint(sf); /* The interpolation factor is fit to this diagonally-symmetric curve * to reduce the transition ripple caused by interpolating different |