From 0b5b39d5e60b250a41a6f306f3167a553d5dad58 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 17 May 2014 07:17:48 -0700 Subject: Add a flag to specify when the low-pass filter needs to apply --- Alc/mixer.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'Alc/mixer.c') diff --git a/Alc/mixer.c b/Alc/mixer.c index fc3fecbd..ac433e35 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -84,12 +84,21 @@ static void SilenceData(ALfloat *dst, ALuint samples) } -static void DoFilter(ALfilterState *filter, ALfloat *restrict dst, const ALfloat *restrict src, - ALuint numsamples) +static void DoFilters(ALfilterState *lpfilter, ALfloat *restrict dst, const ALfloat *restrict src, + ALuint numsamples, enum ActiveFilters type) { ALuint i; - for(i = 0;i < numsamples;i++) - dst[i] = ALfilterState_processSingle(filter, src[i]); + switch(type) + { + case AF_None: + memcpy(dst, src, numsamples * sizeof(ALfloat)); + break; + + case AF_LowPass: + for(i = 0;i < numsamples;i++) + dst[i] = ALfilterState_processSingle(lpfilter, src[i]); + break; + } } @@ -323,8 +332,8 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo) { DirectParams *directparms = &src->Direct; - DoFilter(&directparms->LpFilter[chan], SrcData, ResampledData, - DstBufferSize); + DoFilters(&directparms->LpFilter[chan], SrcData, ResampledData, + DstBufferSize, directparms->Filters[chan]); src->DryMix(directparms, SrcData, chan, OutPos, DstBufferSize); } @@ -334,8 +343,8 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo) if(!sendparms->OutBuffer) continue; - DoFilter(&sendparms->LpFilter[chan], SrcData, ResampledData, - DstBufferSize); + DoFilters(&sendparms->LpFilter[chan], SrcData, ResampledData, + DstBufferSize, sendparms->Filters[chan]); src->WetMix(sendparms, SrcData, OutPos, DstBufferSize); } } -- cgit v1.2.3