aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c14
-rw-r--r--Alc/alcEcho.c3
-rw-r--r--Alc/alcModulator.c7
-rw-r--r--Alc/alcReverb.c5
-rw-r--r--Alc/mixer.c12
-rw-r--r--OpenAL32/Include/alFilter.h14
-rw-r--r--OpenAL32/Include/alSource.h6
7 files changed, 28 insertions, 33 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 1288f7b2..6b6917bf 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -254,6 +254,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ALboolean DirectChannels;
ALfloat hwidth = 0.0f;
ALfloat Pitch;
+ ALfloat coeff;
ALfloat cw;
ALint i, c;
@@ -459,11 +460,14 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
/* We use two chained one-pole filters, so we need to take the
* square root of the squared gain, which is the same as the base
* gain. */
- ALSource->Params.Direct.iirFilter.coeff = lpCoeffCalc(DryGainHF, cw);
+ coeff = lpCoeffCalc(DryGainHF, cw);
+ for(c = 0;c < num_channels;c++)
+ ALSource->Params.Direct.Filter[c].coeff = lpCoeffCalc(DryGainHF, cw);
for(i = 0;i < NumSends;i++)
{
- ALfloat a = lpCoeffCalc(WetGainHF[i], cw);
- ALSource->Params.Send[i].iirFilter.coeff = a;
+ coeff = lpCoeffCalc(WetGainHF[i], cw);
+ for(c = 0;c < num_channels;c++)
+ ALSource->Params.Send[i].Filter[c].coeff = coeff;
}
}
@@ -903,11 +907,11 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
/* Update filter coefficients. */
cw = cosf(F_PI*2.0f * LOWPASSFREQREF / Frequency);
- ALSource->Params.Direct.iirFilter.coeff = lpCoeffCalc(DryGainHF, cw);
+ ALSource->Params.Direct.Filter[0].coeff = lpCoeffCalc(DryGainHF, cw);
for(i = 0;i < NumSends;i++)
{
ALfloat a = lpCoeffCalc(WetGainHF[i], cw);
- ALSource->Params.Send[i].iirFilter.coeff = a;
+ ALSource->Params.Send[i].Filter[0].coeff = a;
}
}
diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c
index ada61c96..1aab9870 100644
--- a/Alc/alcEcho.c
+++ b/Alc/alcEcho.c
@@ -48,7 +48,6 @@ typedef struct ALechoState {
ALfloat FeedGain;
FILTER iirFilter;
- ALfloat history[2];
} ALechoState;
static ALvoid ALechoState_Destroy(ALechoState *state)
@@ -144,7 +143,7 @@ static ALvoid ALechoState_Process(ALechoState *state, ALuint SamplesToDo, const
// Apply damping and feedback gain to the second tap, and mix in the
// new sample
- smp = lpFilter2P(&state->iirFilter, 0, temps[i][1]+SamplesIn[i]);
+ smp = lpFilter2P(&state->iirFilter, temps[i][1]+SamplesIn[i]);
state->SampleBuffer[offset&mask] = smp * state->FeedGain;
}
diff --git a/Alc/alcModulator.c b/Alc/alcModulator.c
index 5d4fdab8..bb90d646 100644
--- a/Alc/alcModulator.c
+++ b/Alc/alcModulator.c
@@ -45,7 +45,6 @@ typedef struct ALmodulatorState {
ALfloat Gain[MaxChannels];
FILTER iirFilter;
- ALfloat history[1];
} ALmodulatorState;
#define WAVEFORM_FRACBITS 24
@@ -68,9 +67,9 @@ static __inline ALfloat Square(ALuint index)
}
-static __inline ALfloat hpFilter1P(FILTER *iir, ALuint offset, ALfloat input)
+static __inline ALfloat hpFilter1P(FILTER *iir, ALfloat input)
{
- ALfloat *history = &iir->history[offset];
+ ALfloat *history = iir->history;
ALfloat a = iir->coeff;
ALfloat output = input;
@@ -100,7 +99,7 @@ static void Process##func(ALmodulatorState *state, ALuint SamplesToDo, \
{ \
ALfloat samp; \
samp = SamplesIn[base+i]; \
- samp = hpFilter1P(&state->iirFilter, 0, samp); \
+ samp = hpFilter1P(&state->iirFilter, samp); \
\
index += step; \
index &= WAVEFORM_FRACMASK; \
diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c
index 2bed00a5..01f4ab83 100644
--- a/Alc/alcReverb.c
+++ b/Alc/alcReverb.c
@@ -51,7 +51,6 @@ typedef struct ALreverbState {
// Master effect low-pass filter (2 chained 1-pole filters).
FILTER LpFilter;
- ALfloat LpHistory[2];
struct {
// Modulator delay line.
@@ -483,7 +482,7 @@ static __inline ALvoid VerbPass(ALreverbState *State, ALfloat in, ALfloat *RESTR
ALfloat feed, late[4], taps[4];
// Low-pass filter the incoming sample.
- in = lpFilter2P(&State->LpFilter, 0, in);
+ in = lpFilter2P(&State->LpFilter, in);
// Feed the initial delay line.
DelayLineIn(&State->Delay, State->Offset, in);
@@ -522,7 +521,7 @@ static __inline ALvoid EAXVerbPass(ALreverbState *State, ALfloat in, ALfloat *RE
ALfloat feed, taps[4];
// Low-pass filter the incoming sample.
- in = lpFilter2P(&State->LpFilter, 0, in);
+ in = lpFilter2P(&State->LpFilter, in);
// Perform any modulation on the input.
in = EAXModulation(State, in);
diff --git a/Alc/mixer.c b/Alc/mixer.c
index f75a7803..84f48094 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -84,13 +84,13 @@ static void SilenceData(ALfloat *dst, ALuint samples)
}
-static void Filter2P(FILTER *filter, ALuint chan, ALfloat *RESTRICT dst,
- const ALfloat *RESTRICT src, ALuint numsamples)
+static void Filter2P(FILTER *filter, ALfloat *RESTRICT dst, const ALfloat *RESTRICT src,
+ ALuint numsamples)
{
ALuint i;
for(i = 0;i < numsamples;i++)
- dst[i] = lpFilter2P(filter, chan, src[i]);
- dst[i] = lpFilter2PC(filter, chan, src[i]);
+ dst[i] = lpFilter2P(filter, src[i]);
+ dst[i] = lpFilter2PC(filter, src[i]);
}
@@ -328,7 +328,7 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
{
DirectParams *directparms = &Source->Params.Direct;
- Filter2P(&directparms->iirFilter, chan, SrcData, ResampledData,
+ Filter2P(&directparms->Filter[chan], SrcData, ResampledData,
DstBufferSize);
Source->Params.DryMix(directparms, SrcData, chan, OutPos,
SamplesToDo, DstBufferSize);
@@ -340,7 +340,7 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
if(!sendparms->Slot)
continue;
- Filter2P(&sendparms->iirFilter, chan, SrcData, ResampledData,
+ Filter2P(&sendparms->Filter[chan], SrcData, ResampledData,
DstBufferSize);
Source->Params.WetMix(sendparms, SrcData, OutPos,
SamplesToDo, DstBufferSize);
diff --git a/OpenAL32/Include/alFilter.h b/OpenAL32/Include/alFilter.h
index 09cef93c..94feb3ee 100644
--- a/OpenAL32/Include/alFilter.h
+++ b/OpenAL32/Include/alFilter.h
@@ -11,16 +11,12 @@ extern "C" {
typedef struct {
ALfloat coeff;
-#ifndef _MSC_VER
- ALfloat history[0];
-#else
- ALfloat history[1];
-#endif
+ ALfloat history[2];
} FILTER;
-static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input)
+static __inline ALfloat lpFilter2P(FILTER *iir, ALfloat input)
{
- ALfloat *history = &iir->history[offset*2];
+ ALfloat *history = iir->history;
ALfloat a = iir->coeff;
ALfloat output = input;
@@ -32,9 +28,9 @@ static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input)
return output;
}
-static __inline ALfloat lpFilter2PC(const FILTER *iir, ALuint offset, ALfloat input)
+static __inline ALfloat lpFilter2PC(const FILTER *iir, ALfloat input)
{
- const ALfloat *history = &iir->history[offset*2];
+ const ALfloat *history = iir->history;
ALfloat a = iir->coeff;
ALfloat output = input;
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index d8ffc9aa..bd1b2931 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -62,8 +62,7 @@ typedef struct DirectParams {
ALfloat Gains[MaxChannels][MaxChannels];
/* A low-pass filter, using 2 chained one-pole filters. */
- FILTER iirFilter;
- ALfloat history[MaxChannels*2];
+ FILTER Filter[MaxChannels];
} DirectParams;
typedef struct SendParams {
@@ -74,8 +73,7 @@ typedef struct SendParams {
ALfloat Gain;
/* A low-pass filter, using 2 chained one-pole filters. */
- FILTER iirFilter;
- ALfloat history[MaxChannels*2];
+ FILTER Filter[MaxChannels];
} SendParams;