aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/mixer.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-04-08 13:43:19 -0700
committerChris Robinson <[email protected]>2017-04-08 13:43:19 -0700
commit319d0971986309d7882a9be42a5aef7dc612945d (patch)
tree4c05460eaa7949e7438969dd60b5d3d8d769a0da /Alc/mixer.c
parent5ef7d8fe6248bccc8edf895afece8e1b44b0f4ea (diff)
Pre-compute the sinc4 resampler coefficient table
Diffstat (limited to 'Alc/mixer.c')
-rw-r--r--Alc/mixer.c92
1 files changed, 0 insertions, 92 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c
index 69e52a6e..f4374882 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -43,8 +43,6 @@ static_assert((INT_MAX>>FRACTIONBITS)/MAX_PITCH > BUFFERSIZE,
extern inline void InitiatePositionArrays(ALuint frac, ALint increment, ALuint *restrict frac_arr, ALint *restrict pos_arr, ALsizei size);
-alignas(16) ALfloat ResampleCoeffs_FIR4[FRACTIONONE][4];
-
enum Resampler {
PointResampler,
@@ -155,91 +153,10 @@ static inline ResamplerFunc SelectResampler(enum Resampler resampler)
}
-/* The sinc resampler makes use of a Kaiser window to limit the needed sample
- * points to 4.
- */
-
-#ifndef M_PI
-#define M_PI (3.14159265358979323846)
-#endif
-static inline double Sinc(double x)
-{
- if(x == 0.0) return 1.0;
- return sin(x*M_PI) / (x*M_PI);
-}
-
-/* The zero-order modified Bessel function of the first kind, used for the
- * Kaiser window.
- *
- * I_0(x) = sum_{k=0}^inf (1 / k!)^2 (x / 2)^(2 k)
- * = sum_{k=0}^inf ((x / 2)^k / k!)^2
- */
-static double BesselI_0(double x)
-{
- double term, sum, x2, y, last_sum;
- int k;
-
- /* Start at k=1 since k=0 is trivial. */
- term = 1.0;
- sum = 1.0;
- x2 = x / 2.0;
- k = 1;
-
- /* Let the integration converge until the term of the sum is no longer
- * significant.
- */
- do {
- y = x2 / k;
- k ++;
- last_sum = sum;
- term *= y * y;
- sum += term;
- } while(sum != last_sum);
- return sum;
-}
-
-/* Calculate a Kaiser window from the given beta value and a normalized k
- * [-1, 1].
- *
- * w(k) = { I_0(B sqrt(1 - k^2)) / I_0(B), -1 <= k <= 1
- * { 0, elsewhere.
- *
- * Where k can be calculated as:
- *
- * k = i / l, where -l <= i <= l.
- *
- * or:
- *
- * k = 2 i / M - 1, where 0 <= i <= M.
- */
-static inline double Kaiser(double b, double k)
-{
- if(k <= -1.0 || k >= 1.0) return 0.0;
- return BesselI_0(b * sqrt(1.0 - (k*k))) / BesselI_0(b);
-}
-
-static inline double CalcKaiserBeta(double rejection)
-{
- if(rejection > 50.0)
- return 0.1102 * (rejection - 8.7);
- if(rejection >= 21.0)
- return (0.5842 * pow(rejection - 21.0, 0.4)) +
- (0.07886 * (rejection - 21.0));
- return 0.0;
-}
-
-static float SincKaiser(double r, double x)
-{
- /* Limit rippling to -60dB. */
- return (float)(Kaiser(CalcKaiserBeta(60.0), x / r) * Sinc(x));
-}
-
-
void aluInitMixer(void)
{
enum Resampler resampler = ResamplerDefault;
const char *str;
- ALuint i;
if(ConfigValueStr(NULL, NULL, "resampler", &str))
{
@@ -267,15 +184,6 @@ void aluInitMixer(void)
}
}
- for(i = 0;i < FRACTIONONE;i++)
- {
- ALdouble mu = (ALdouble)i / FRACTIONONE;
- ResampleCoeffs_FIR4[i][0] = SincKaiser(2.0, mu - -1.0);
- ResampleCoeffs_FIR4[i][1] = SincKaiser(2.0, mu - 0.0);
- ResampleCoeffs_FIR4[i][2] = SincKaiser(2.0, mu - 1.0);
- ResampleCoeffs_FIR4[i][3] = SincKaiser(2.0, mu - 2.0);
- }
-
MixHrtfSamples = SelectHrtfMixer();
MixSamples = SelectMixer();
ResampleSamples = SelectResampler(resampler);