summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c24
-rw-r--r--Alc/mixer.c25
-rw-r--r--OpenAL32/Include/alu.h34
3 files changed, 54 insertions, 29 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);
}
}
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 36e81e0b..dd13a293 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -39,6 +39,11 @@
extern "C" {
#endif
+enum ActiveFilters {
+ AF_None = 0,
+ AF_LowPass = 1,
+};
+
typedef struct HrtfState {
alignas(16) ALfloat History[SRC_HISTORY_LENGTH];
alignas(16) ALfloat Values[HRIR_LENGTH][2];
@@ -54,6 +59,16 @@ typedef struct HrtfParams {
typedef struct DirectParams {
ALfloat (*OutBuffer)[BUFFERSIZE];
+ enum ActiveFilters Filters[MAX_INPUT_CHANNELS];
+ ALfilterState LpFilter[MAX_INPUT_CHANNELS];
+
+ /* If not 'moving', gain/coefficients are set directly without fading. */
+ ALboolean Moving;
+ /* Stepping counter for gain/coefficient fading. */
+ ALuint Counter;
+ /* History/coefficient offset. */
+ ALuint Offset;
+
union {
struct {
HrtfParams Params[MAX_INPUT_CHANNELS];
@@ -72,19 +87,17 @@ typedef struct DirectParams {
ALfloat Target[MAX_INPUT_CHANNELS][MaxChannels];
} Gains;
} Mix;
- /* If not 'moving', gain/coefficients are set directly without fading. */
- ALboolean Moving;
- /* Stepping counter for gain/coefficient fading. */
- ALuint Counter;
- /* History/coefficient offset. */
- ALuint Offset;
-
- ALfilterState LpFilter[MAX_INPUT_CHANNELS];
} DirectParams;
typedef struct SendParams {
ALfloat (*OutBuffer)[BUFFERSIZE];
+ enum ActiveFilters Filters[MAX_INPUT_CHANNELS];
+ ALfilterState LpFilter[MAX_INPUT_CHANNELS];
+
+ ALboolean Moving;
+ ALuint Counter;
+
/* Gain control, which applies to all input channels to a single (mono)
* output buffer. */
struct {
@@ -92,11 +105,6 @@ typedef struct SendParams {
ALfloat Step;
ALfloat Target;
} Gain;
-
- ALboolean Moving;
- ALuint Counter;
-
- ALfilterState LpFilter[MAX_INPUT_CHANNELS];
} SendParams;