aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-05-17 07:17:48 -0700
committerChris Robinson <[email protected]>2014-05-17 07:17:48 -0700
commit0b5b39d5e60b250a41a6f306f3167a553d5dad58 (patch)
tree22141ce0bc2e5e009d217b3beedaa3f59eec48cd /Alc
parent70f1e54068f2ccfce30f9e5db8ea61b01283f59b (diff)
Add a flag to specify when the low-pass filter needs to apply
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c24
-rw-r--r--Alc/mixer.c25
2 files changed, 33 insertions, 16 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 07b6d501..8baa5a4f 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -581,23 +581,29 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext)
src->WetMix = SelectSendMixer();
{
- ALfloat gain = maxf(0.01f, DryGainHF);
+ ALfloat gainhf = maxf(0.01f, DryGainHF);
ALfloat hfscale = ALSource->Direct.HFReference / Frequency;
for(c = 0;c < num_channels;c++)
+ {
+ src->Direct.Filters[c] = (gainhf != 1.0f) ? AF_LowPass : AF_None;
ALfilterState_setParams(
- &src->Direct.LpFilter[c], ALfilterType_HighShelf, gain,
+ &src->Direct.LpFilter[c], ALfilterType_HighShelf, gainhf,
hfscale, 0.0f
);
+ }
}
for(i = 0;i < NumSends;i++)
{
- ALfloat gain = maxf(0.01f, WetGainHF[i]);
+ ALfloat gainhf = maxf(0.01f, WetGainHF[i]);
ALfloat hfscale = ALSource->Send[i].HFReference / Frequency;
for(c = 0;c < num_channels;c++)
+ {
+ src->Send[i].Filters[c] = (gainhf != 1.0f) ? AF_LowPass : AF_None;
ALfilterState_setParams(
- &src->Send[i].LpFilter[c], ALfilterType_HighShelf, gain,
+ &src->Send[i].LpFilter[c], ALfilterType_HighShelf, gainhf,
hfscale, 0.0f
);
+ }
}
}
@@ -1082,19 +1088,21 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
src->WetMix = SelectSendMixer();
{
- ALfloat gain = maxf(0.01f, DryGainHF);
+ ALfloat gainhf = maxf(0.01f, DryGainHF);
ALfloat hfscale = ALSource->Direct.HFReference / Frequency;
+ src->Direct.Filters[0] = (gainhf != 1.0f) ? AF_LowPass : AF_None;
ALfilterState_setParams(
- &src->Direct.LpFilter[0], ALfilterType_HighShelf, gain,
+ &src->Direct.LpFilter[0], ALfilterType_HighShelf, gainhf,
hfscale, 0.0f
);
}
for(i = 0;i < NumSends;i++)
{
- ALfloat gain = maxf(0.01f, WetGainHF[i]);
+ ALfloat gainhf = maxf(0.01f, WetGainHF[i]);
ALfloat hfscale = ALSource->Send[i].HFReference / Frequency;
+ src->Direct.Filters[0] = (gainhf != 1.0f) ? AF_LowPass : AF_None;
ALfilterState_setParams(
- &src->Send[i].LpFilter[0], ALfilterType_HighShelf, gain,
+ &src->Send[i].LpFilter[0], ALfilterType_HighShelf, gainhf,
hfscale, 0.0f
);
}
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);
}
}