aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-08-27 10:16:36 -0700
committerChris Robinson <[email protected]>2017-08-27 10:16:36 -0700
commita4d357de06b3860f49f2f6f70899d825b920947b (patch)
tree3532665177753d3f6d6cb8a5c6a9b702a48d403a /Alc/ALu.c
parent773d4664ff8f31837374164b64b992b86fcc80f7 (diff)
Add a higher quality bsinc resampler using 24 sample points
This improves the transition width, allowing more of the higher frequencies remain audible. It would be preferrable to have an upper limit of 32 points instead of 48, to reduce the overall table size and the CPU cost for down- sampling.
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 17227f8a..7c261f73 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -225,7 +225,7 @@ void aluInit(void)
* modified for use with an interpolated increment for buttery-smooth pitch
* changes.
*/
-ALboolean BsincPrepare(const ALuint increment, BsincState *state)
+ALboolean BsincPrepare(const ALuint increment, BsincState *state, const BSincTable *table)
{
ALboolean uncut = AL_TRUE;
ALfloat sf;
@@ -234,7 +234,7 @@ ALboolean BsincPrepare(const ALuint increment, BsincState *state)
if(increment > FRACTIONONE)
{
sf = (ALfloat)FRACTIONONE / increment;
- if(sf < bsinc12.scaleBase)
+ if(sf < table->scaleBase)
{
/* Signal has been completely cut. The return result can be used
* to skip the filter (and output zeros) as an optimization.
@@ -245,7 +245,7 @@ ALboolean BsincPrepare(const ALuint increment, BsincState *state)
}
else
{
- sf = (BSINC_SCALE_COUNT - 1) * (sf - bsinc12.scaleBase) * bsinc12.scaleRange;
+ sf = (BSINC_SCALE_COUNT - 1) * (sf - table->scaleBase) * table->scaleRange;
si = fastf2i(sf);
/* The interpolation factor is fit to this diagonally-symmetric
* curve to reduce the transition ripple caused by interpolating
@@ -261,9 +261,9 @@ ALboolean BsincPrepare(const ALuint increment, BsincState *state)
}
state->sf = sf;
- state->m = bsinc12.m[si];
+ state->m = table->m[si];
state->l = -((state->m/2) - 1);
- state->filter = bsinc12.Tab + bsinc12.filterOffset[si];
+ state->filter = table->Tab + table->filterOffset[si];
return uncut;
}
@@ -1038,9 +1038,12 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *p
voice->Step = MAX_PITCH<<FRACTIONBITS;
else
voice->Step = maxi(fastf2i(Pitch*FRACTIONONE + 0.5f), 1);
- if(props->Resampler == BSinc12Resampler)
- BsincPrepare(voice->Step, &voice->ResampleState.bsinc);
+ if(props->Resampler == BSinc24Resampler)
+ BsincPrepare(voice->Step, &voice->ResampleState.bsinc, &bsinc24);
+ else if(props->Resampler == BSinc12Resampler)
+ BsincPrepare(voice->Step, &voice->ResampleState.bsinc, &bsinc12);
else
+
voice->ResampleState.sinc4.filter = sinc4Tab;
voice->Resampler = SelectResampler(props->Resampler);
@@ -1384,8 +1387,10 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop
voice->Step = MAX_PITCH<<FRACTIONBITS;
else
voice->Step = maxi(fastf2i(Pitch*FRACTIONONE + 0.5f), 1);
- if(props->Resampler == BSinc12Resampler)
- BsincPrepare(voice->Step, &voice->ResampleState.bsinc);
+ if(props->Resampler == BSinc24Resampler)
+ BsincPrepare(voice->Step, &voice->ResampleState.bsinc, &bsinc24);
+ else if(props->Resampler == BSinc12Resampler)
+ BsincPrepare(voice->Step, &voice->ResampleState.bsinc, &bsinc12);
else
voice->ResampleState.sinc4.filter = sinc4Tab;
voice->Resampler = SelectResampler(props->Resampler);