diff options
author | Chris Robinson <[email protected]> | 2017-08-25 05:52:19 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-08-25 05:52:19 -0700 |
commit | 561e95528f55be2837541239236281c4cd63d728 (patch) | |
tree | 6d57db817feef0cc132293e0c319dd2796a8bc41 /Alc | |
parent | 9ea32713b57fd95832172de5e8d8534339bb646b (diff) |
Rename the bsinc resampler to bsinc12
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALu.c | 12 | ||||
-rw-r--r-- | Alc/bsinc_inc.c | 33 | ||||
-rw-r--r-- | Alc/converter.c | 2 | ||||
-rw-r--r-- | Alc/mixer.c | 4 |
4 files changed, 26 insertions, 25 deletions
@@ -234,7 +234,7 @@ ALboolean BsincPrepare(const ALuint increment, BsincState *state) if(increment > FRACTIONONE) { sf = (ALfloat)FRACTIONONE / increment; - if(sf < bsinc.scaleBase) + if(sf < bsinc12.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 - bsinc.scaleBase) * bsinc.scaleRange; + sf = (BSINC_SCALE_COUNT - 1) * (sf - bsinc12.scaleBase) * bsinc12.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 = bsinc.m[si]; + state->m = bsinc12.m[si]; state->l = -((state->m/2) - 1); - state->filter = bsinc.Tab + bsinc.filterOffset[si]; + state->filter = bsinc12.Tab + bsinc12.filterOffset[si]; return uncut; } @@ -1038,7 +1038,7 @@ 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 == BSincResampler) + if(props->Resampler == BSinc12Resampler) BsincPrepare(voice->Step, &voice->ResampleState.bsinc); else voice->ResampleState.sinc4.filter = sinc4Tab; @@ -1384,7 +1384,7 @@ 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 == BSincResampler) + if(props->Resampler == BSinc12Resampler) BsincPrepare(voice->Step, &voice->ResampleState.bsinc); else voice->ResampleState.sinc4.filter = sinc4Tab; diff --git a/Alc/bsinc_inc.c b/Alc/bsinc_inc.c index 23b4f356..306280a7 100644 --- a/Alc/bsinc_inc.c +++ b/Alc/bsinc_inc.c @@ -1,19 +1,24 @@ /* Generated by bsincgen, do not edit! */ -/* Table of windowed sinc coefficients and deltas. This 11th order filter - * has a rejection of -60dB, yielding a transition width of ~0.330 - * (normalized frequency). Order increases when downsampling to a limit of - * one octave, after which the quality of the filter (transition width) - * suffers to reduce the CPU cost. The bandlimiting will cut all sound after - * downsampling by ~2.60 octaves. - */ -static const struct { - alignas(16) const float Tab[19968]; +typedef struct BSincTable { const float scaleBase, scaleRange; const int m[BSINC_SCALE_COUNT]; const int filterOffset[BSINC_SCALE_COUNT]; -} bsinc = { - /* Tab */ { + alignas(16) const float Tab[]; +} BSincTable; + +/* This 11th order filter has a rejection of -60dB, yielding a transition width + * of ~0.330 (normalized frequency). Order increases when downsampling to a + * limit of one octave, after which the quality of the filter (transition + * width) suffers to reduce the CPU cost. The bandlimiting will cut all sound + * after downsampling by ~2.60 octaves. + */ +static const BSincTable bsinc12 = { + /* scaleBase */ 1.647904275e-01f, /* scaleRange */ 1.197304285e+00f, + /* m */ { 24, 24, 24, 24, 24, 24, 24, 20, 20, 20, 16, 16, 16, 12, 12, 12 }, + /* filterOffset */ { 0, 1536, 3072, 4608, 6144, 7680, 9216, 10752, 12032, 13312, 14592, 15616, 16640, 17664, 18432, 19200 }, + + /* Tab (19968 entries) */ { /* 0, 0 (24) */ +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +1.519885812e-03f, +3.451133814e-03f, +6.515582343e-03f, +1.087383005e-02f, +1.652921626e-02f, +2.328367055e-02f, +3.072645296e-02f, +3.826378940e-02f, +4.518869460e-02f, +5.078083067e-02f, +5.441847120e-02f, +5.568063817e-02f, +5.441847120e-02f, +5.078083067e-02f, +4.518869460e-02f, +3.826378940e-02f, +3.072645296e-02f, +2.328367055e-02f, +1.652921626e-02f, +1.087383005e-02f, +6.515582343e-03f, +3.451133814e-03f, +1.519885812e-03f, +4.670736076e-04f, @@ -1294,11 +1299,7 @@ static const struct { +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +1.544493457e-04f, +4.223256891e-05f, -2.661988046e-03f, +7.330028758e-03f, -3.445837508e-03f, -3.834855341e-02f, +2.120373480e-03f, +3.776872257e-02f, +1.185399556e-03f, -6.580914053e-03f, +2.738584812e-03f, -1.901296535e-04f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, - }, - - /* scaleBase */ 1.647904275e-01f, /* scaleRange */ 1.197304285e+00f, - /* m */ { 24, 24, 24, 24, 24, 24, 24, 20, 20, 20, 16, 16, 16, 12, 12, 12 }, - /* filterOffset */ { 0, 1536, 3072, 4608, 6144, 7680, 9216, 10752, 12032, 13312, 14592, 15616, 16640, 17664, 18432, 19200 } + } }; alignas(16) static const float sinc4Tab[FRACTIONONE][4] = { diff --git a/Alc/converter.c b/Alc/converter.c index 304e9a80..fa9928c2 100644 --- a/Alc/converter.c +++ b/Alc/converter.c @@ -34,7 +34,7 @@ SampleConverter *CreateSampleConverter(enum DevFmtType srcType, enum DevFmtType { /* TODO: Allow other resamplers. */ BsincPrepare(converter->mIncrement, &converter->mState.bsinc); - converter->mResample = SelectResampler(BSincResampler); + converter->mResample = SelectResampler(BSinc12Resampler); } END_MIXER_MODE(); diff --git a/Alc/mixer.c b/Alc/mixer.c index bb71fde4..cf2f96fb 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -141,7 +141,7 @@ ResamplerFunc SelectResampler(enum Resampler resampler) return Resample_fir4_SSE3; #endif return Resample_fir4_C; - case BSincResampler: + case BSinc12Resampler: #ifdef HAVE_NEON if((CPUCapFlags&CPU_CAP_NEON)) return Resample_bsinc_Neon; @@ -170,7 +170,7 @@ void aluInitMixer(void) else if(strcasecmp(str, "sinc4") == 0) ResamplerDefault = FIR4Resampler; else if(strcasecmp(str, "bsinc") == 0) - ResamplerDefault = BSincResampler; + ResamplerDefault = BSinc12Resampler; else if(strcasecmp(str, "cubic") == 0 || strcasecmp(str, "sinc8") == 0) { WARN("Resampler option \"%s\" is deprecated, using sinc4\n", str); |