From 0a4be3470e5cd48c95bef5a30a169ea671646132 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 26 May 2013 17:04:45 -0700 Subject: Pre-apply the a[0] EQ filter coefficient Saves 20 fp divisions per sample --- Alc/effects/equalizer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Alc/effects/equalizer.c') diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c index 441c785f..f9744fb9 100644 --- a/Alc/effects/equalizer.c +++ b/Alc/effects/equalizer.c @@ -216,6 +216,12 @@ static ALvoid ALequalizerState_Update(ALequalizerState *state, ALCdevice *device state->bandfilter[it].a[2] = 1.0f - alpha / gain; break; } + state->bandfilter[it].b[0] /= state->bandfilter[it].a[0]; + state->bandfilter[it].b[1] /= state->bandfilter[it].a[0]; + state->bandfilter[it].b[2] /= state->bandfilter[it].a[0]; + state->bandfilter[it].a[0] /= state->bandfilter[it].a[0]; + state->bandfilter[it].a[1] /= state->bandfilter[it].a[0]; + state->bandfilter[it].a[2] /= state->bandfilter[it].a[0]; } } @@ -240,11 +246,11 @@ static ALvoid ALequalizerState_Process(ALequalizerState *state, ALuint SamplesTo { ALEQFilter *filter = &state->bandfilter[ft]; - tempsmp = filter->b[0] / filter->a[0] * smp + - filter->b[1] / filter->a[0] * filter->x[0] + - filter->b[2] / filter->a[0] * filter->x[1] - - filter->a[1] / filter->a[0] * filter->y[0] - - filter->a[2] / filter->a[0] * filter->y[1]; + tempsmp = filter->b[0] * smp + + filter->b[1] * filter->x[0] + + filter->b[2] * filter->x[1] - + filter->a[1] * filter->y[0] - + filter->a[2] * filter->y[1]; filter->x[1] = filter->x[0]; filter->x[0] = smp; -- cgit v1.2.3