aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-04-14 22:04:18 -0700
committerChris Robinson <[email protected]>2009-04-14 22:04:18 -0700
commite9a6a1d6f559e6ed738328bea22f461dab467e63 (patch)
tree122f17d48bf7ae8300f9c595add6c1eb58771696 /Alc
parentf245f0ef87cfefd053c656b7f93cc618d46c6532 (diff)
Use a 2-pole filter for the wet path low-pass filter
This should help keep CPU use from increasing a lot when the number of sends increases. Also changes the function names to reflect the difference
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 650aa991..a8371367 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -181,7 +181,7 @@ __inline ALuint aluChannelsFromFormat(ALenum format)
}
-static __inline ALfloat lpFilter(FILTER *iir, ALfloat input)
+static __inline ALfloat lpFilter4P(FILTER *iir, ALfloat input)
{
ALfloat *history = iir->history;
ALfloat a = iir->coeff;
@@ -199,7 +199,7 @@ static __inline ALfloat lpFilter(FILTER *iir, ALfloat input)
return output;
}
-static __inline ALfloat lpFilterMC(FILTER *iir, ALuint chan, ALfloat input)
+static __inline ALfloat lpFilter2P(FILTER *iir, ALuint chan, ALfloat input)
{
ALfloat *history = &iir->history[chan*2];
ALfloat a = iir->coeff;
@@ -1052,7 +1052,10 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
for(i = 0;i < MAX_SENDS;i++)
{
- g = aluSqrt(__max(WetGainHF[i], 0.0001f));
+ // The wet path uses two chained one-pole filters,
+ // so take the base gain (square root of the
+ // squared gain)
+ g = __max(WetGainHF[i], 0.01f);
a = 0.0f;
if(g < 0.9999f) // 1-epsilon
a = (1 - g*cw - aluSqrt(2*g*(1-cw) - g*g*(1 - cw*cw))) / (1 - g);
@@ -1062,8 +1065,7 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
else
{
// Multi-channel sources use two chained one-pole
- // filters, so take the base gain (square root of the
- // squared gain)
+ // filters
cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / ALContext->Frequency);
g = __max(DryGainHF, 0.01f);
a = 0.0f;
@@ -1177,7 +1179,7 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
value = lerp(Data[k], Data[k+1], DataPosFrac);
//Direct path final mix buffer and panning
- outsamp = lpFilter(DryFilter, value);
+ outsamp = lpFilter4P(DryFilter, value);
DryBuffer[j][FRONT_LEFT] += outsamp*DrySend[FRONT_LEFT];
DryBuffer[j][FRONT_RIGHT] += outsamp*DrySend[FRONT_RIGHT];
DryBuffer[j][SIDE_LEFT] += outsamp*DrySend[SIDE_LEFT];
@@ -1190,7 +1192,7 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
//Room path final mix buffer and panning
for(i = 0;i < MAX_SENDS;i++)
{
- outsamp = lpFilter(WetFilter[i], value);
+ outsamp = lpFilter2P(WetFilter[i], 0, value);
WetBuffer[i][j] += outsamp*WetSend[i];
}
@@ -1217,7 +1219,7 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
for(i = 0;i < Channels;i++) \
{ \
value = lerp(Data[k*Channels + i], Data[(k+1)*Channels + i], DataPosFrac); \
- values[i] = lpFilterMC(DryFilter, chans[i], value)*DrySend[chans[i]]; \
+ values[i] = lpFilter2P(DryFilter, chans[i], value)*DrySend[chans[i]]; \
} \
for(out = 0;out < OUTPUTCHANNELS;out++) \
{ \