aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-09-28 01:58:29 -0700
committerChris Robinson <[email protected]>2019-09-28 01:58:29 -0700
commit882b4acae80f41547a9e16b7def02a972842c857 (patch)
tree3c4474c01bcfc33ef2973f06adb4edca6ea8b5a0 /alc
parent00d5356b96d29775653bc6816fafff9cc94ef3ec (diff)
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.
Diffstat (limited to 'alc')
-rw-r--r--alc/alu.cpp8
-rw-r--r--alc/alu.h2
-rw-r--r--alc/converter.cpp4
-rw-r--r--alc/mixvoice.cpp7
4 files changed, 14 insertions, 7 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp
index 86d2789e..5df1c3a2 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -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);
diff --git a/alc/alu.h b/alc/alu.h
index e9858ddb..e2b25556 100644
--- a/alc/alu.h
+++ b/alc/alu.h
@@ -46,7 +46,9 @@ enum class Resampler {
Point,
Linear,
Cubic,
+ FastBSinc12,
BSinc12,
+ FastBSinc24,
BSinc24,
Max = BSinc24
diff --git a/alc/converter.cpp b/alc/converter.cpp
index b0efb839..aff1c353 100644
--- a/alc/converter.cpp
+++ b/alc/converter.cpp
@@ -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);
}
diff --git a/alc/mixvoice.cpp b/alc/mixvoice.cpp
index 58a08ce3..e9e0d8df 100644
--- a/alc/mixvoice.cpp
+++ b/alc/mixvoice.cpp
@@ -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()};