aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-06-03 06:55:54 -0700
committerChris Robinson <[email protected]>2016-06-03 06:55:54 -0700
commite38a81c5b62a350e448f31fd482d92c61fd84c58 (patch)
tree39c1c612c58b8ad9d11dbd2110f99bfdbb6ac2ac /Alc
parentce676ab70a6b4c46869e4fa13e14b4da7ba6c008 (diff)
Improve the filter processing function
Diffstat (limited to 'Alc')
-rw-r--r--Alc/mixer_c.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c
index 7952ec93..f741e28f 100644
--- a/Alc/mixer_c.c
+++ b/Alc/mixer_c.c
@@ -96,8 +96,41 @@ const ALfloat *Resample_bsinc32_C(const BsincState *state, const ALfloat *src, A
void ALfilterState_processC(ALfilterState *filter, ALfloat *restrict dst, const ALfloat *src, ALuint numsamples)
{
ALuint i;
- for(i = 0;i < numsamples;i++)
- *(dst++) = ALfilterState_processSingle(filter, *(src++));
+ if(numsamples > 1)
+ {
+ dst[0] = filter->input_gain * src[0] +
+ filter->b1 * filter->x[0] +
+ filter->b2 * filter->x[1] -
+ filter->a1 * filter->y[0] -
+ filter->a2 * filter->y[1];
+ dst[1] = filter->input_gain * src[1] +
+ filter->b1 * src[0] +
+ filter->b2 * filter->x[0] -
+ filter->a1 * dst[0] -
+ filter->a2 * filter->y[0];
+ for(i = 2;i < numsamples;i++)
+ dst[i] = filter->input_gain * src[i] +
+ filter->b1 * src[i-1] +
+ filter->b2 * src[i-2] -
+ filter->a1 * dst[i-1] -
+ filter->a2 * dst[i-2];
+ filter->x[0] = src[i-1];
+ filter->x[1] = src[i-2];
+ filter->y[0] = dst[i-1];
+ filter->y[1] = dst[i-2];
+ }
+ else if(numsamples == 1)
+ {
+ dst[0] = filter->input_gain * src[0] +
+ filter->b1 * filter->x[0] +
+ filter->b2 * filter->x[1] -
+ filter->a1 * filter->y[0] -
+ filter->a2 * filter->y[1];
+ filter->x[1] = filter->x[0];
+ filter->x[0] = src[0];
+ filter->y[1] = filter->y[0];
+ filter->y[0] = dst[0];
+ }
}