Add "fast" variants for the bsinc resamplers
This simply omits the scale factor from the filter, similar to how up-sampling does. The consequence of this is less smooth transitions when ramping the pitch while down-sampling, but otherwise behaves fine.
This commit is contained in:
+5
-2
@@ -63,7 +63,9 @@ constexpr ALchar alErrOutOfMemory[] = "Out of Memory";
|
||||
constexpr ALchar alPointResampler[] = "Nearest";
|
||||
constexpr ALchar alLinearResampler[] = "Linear";
|
||||
constexpr ALchar alCubicResampler[] = "Cubic";
|
||||
constexpr ALchar alFastBSinc12Resampler[] = "11th order Sinc (fast)";
|
||||
constexpr ALchar alBSinc12Resampler[] = "11th order Sinc";
|
||||
constexpr ALchar alFastBSinc24Resampler[] = "23rd order Sinc (fast)";
|
||||
constexpr ALchar alBSinc24Resampler[] = "23rd order Sinc";
|
||||
|
||||
} // namespace
|
||||
@@ -798,8 +800,9 @@ START_API_FUNC
|
||||
{
|
||||
const char *ResamplerNames[] = {
|
||||
alPointResampler, alLinearResampler,
|
||||
alCubicResampler, alBSinc12Resampler,
|
||||
alBSinc24Resampler,
|
||||
alCubicResampler, alFastBSinc12Resampler,
|
||||
alBSinc12Resampler, alFastBSinc24Resampler,
|
||||
alBSinc24Resampler
|
||||
};
|
||||
static_assert(al::size(ResamplerNames) == static_cast<ALuint>(Resampler::Max)+1,
|
||||
"Incorrect ResamplerNames list");
|
||||
|
||||
+4
-4
@@ -947,9 +947,9 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons
|
||||
voice->mStep = MAX_PITCH<<FRACTIONBITS;
|
||||
else
|
||||
voice->mStep = maxu(fastf2u(Pitch * FRACTIONONE), 1);
|
||||
if(props->mResampler == Resampler::BSinc24)
|
||||
if(props->mResampler == Resampler::BSinc24 || props->mResampler == Resampler::FastBSinc24)
|
||||
BsincPrepare(voice->mStep, &voice->mResampleState.bsinc, &bsinc24);
|
||||
else if(props->mResampler == Resampler::BSinc12)
|
||||
else if(props->mResampler == Resampler::BSinc12 || props->mResampler == Resampler::FastBSinc12)
|
||||
BsincPrepare(voice->mStep, &voice->mResampleState.bsinc, &bsinc12);
|
||||
voice->mResampler = SelectResampler(props->mResampler, voice->mStep);
|
||||
|
||||
@@ -1277,9 +1277,9 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A
|
||||
voice->mStep = MAX_PITCH<<FRACTIONBITS;
|
||||
else
|
||||
voice->mStep = maxu(fastf2u(Pitch * FRACTIONONE), 1);
|
||||
if(props->mResampler == Resampler::BSinc24)
|
||||
if(props->mResampler == Resampler::BSinc24 || props->mResampler == Resampler::FastBSinc24)
|
||||
BsincPrepare(voice->mStep, &voice->mResampleState.bsinc, &bsinc24);
|
||||
else if(props->mResampler == Resampler::BSinc12)
|
||||
else if(props->mResampler == Resampler::BSinc12 || props->mResampler == Resampler::FastBSinc12)
|
||||
BsincPrepare(voice->mStep, &voice->mResampleState.bsinc, &bsinc12);
|
||||
voice->mResampler = SelectResampler(props->mResampler, voice->mStep);
|
||||
|
||||
|
||||
@@ -46,7 +46,9 @@ enum class Resampler {
|
||||
Point,
|
||||
Linear,
|
||||
Cubic,
|
||||
FastBSinc12,
|
||||
BSinc12,
|
||||
FastBSinc24,
|
||||
BSinc24,
|
||||
|
||||
Max = BSinc24
|
||||
|
||||
+2
-2
@@ -167,9 +167,9 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType,
|
||||
converter->mResample = Resample_<CopyTag,CTag>;
|
||||
else
|
||||
{
|
||||
if(resampler == Resampler::BSinc24)
|
||||
if(resampler == Resampler::BSinc24 || resampler == Resampler::FastBSinc24)
|
||||
BsincPrepare(converter->mIncrement, &converter->mState.bsinc, &bsinc24);
|
||||
else if(resampler == Resampler::BSinc12)
|
||||
else if(resampler == Resampler::BSinc12 || resampler == Resampler::FastBSinc12)
|
||||
BsincPrepare(converter->mIncrement, &converter->mState.bsinc, &bsinc12);
|
||||
converter->mResample = SelectResampler(resampler, converter->mIncrement);
|
||||
}
|
||||
|
||||
+6
-1
@@ -161,6 +161,9 @@ ResamplerFunc SelectResampler(Resampler resampler, ALuint increment)
|
||||
case Resampler::BSinc24:
|
||||
if(increment <= FRACTIONONE)
|
||||
{
|
||||
/* fall-through */
|
||||
case Resampler::FastBSinc12:
|
||||
case Resampler::FastBSinc24:
|
||||
#ifdef HAVE_NEON
|
||||
if((CPUCapFlags&CPU_CAP_NEON))
|
||||
return Resample_<FastBSincTag,NEONTag>;
|
||||
@@ -191,7 +194,7 @@ void aluInitMixer()
|
||||
if(auto resopt = ConfigValueStr(nullptr, nullptr, "resampler"))
|
||||
{
|
||||
struct ResamplerEntry {
|
||||
const char name[12];
|
||||
const char name[16];
|
||||
const Resampler resampler;
|
||||
};
|
||||
constexpr ResamplerEntry ResamplerList[]{
|
||||
@@ -199,7 +202,9 @@ void aluInitMixer()
|
||||
{ "point", Resampler::Point },
|
||||
{ "cubic", Resampler::Cubic },
|
||||
{ "bsinc12", Resampler::BSinc12 },
|
||||
{ "fast_bsinc12", Resampler::FastBSinc12 },
|
||||
{ "bsinc24", Resampler::BSinc24 },
|
||||
{ "fast_bsinc24", Resampler::FastBSinc24 },
|
||||
};
|
||||
|
||||
const char *str{resopt->c_str()};
|
||||
|
||||
+5
-1
@@ -161,14 +161,18 @@
|
||||
#cf_level = 0
|
||||
|
||||
## resampler: (global)
|
||||
# Selects the resampler used when mixing sources. Valid values are:
|
||||
# Selects the default resampler used when mixing sources. Valid values are:
|
||||
# point - nearest sample, no interpolation
|
||||
# linear - extrapolates samples using a linear slope between samples
|
||||
# cubic - extrapolates samples using a Catmull-Rom spline
|
||||
# bsinc12 - extrapolates samples using a band-limited Sinc filter (varying
|
||||
# between 12 and 24 points, with anti-aliasing)
|
||||
# fast_bsinc12 - same as bsinc12, except without interpolation between down-
|
||||
# sampling scales
|
||||
# bsinc24 - extrapolates samples using a band-limited Sinc filter (varying
|
||||
# between 24 and 48 points, with anti-aliasing)
|
||||
# fast_bsinc24 - same as bsinc24, except without interpolation between down-
|
||||
# sampling scales
|
||||
#resampler = linear
|
||||
|
||||
## rt-prio: (global)
|
||||
|
||||
@@ -101,7 +101,9 @@ static const struct NameValuePair {
|
||||
{ "Linear", "linear" },
|
||||
{ "Default (Linear)", "" },
|
||||
{ "Cubic Spline", "cubic" },
|
||||
{ "11th order Sinc (fast)", "fast_bsinc12" },
|
||||
{ "11th order Sinc", "bsinc12" },
|
||||
{ "23rd order Sinc (fast)", "fast_bsinc24" },
|
||||
{ "23rd order Sinc", "bsinc24" },
|
||||
|
||||
{ "", "" }
|
||||
|
||||
Reference in New Issue
Block a user