Make the filter functions global inline, and use it for echo
This commit is contained in:
@@ -140,39 +140,6 @@ __inline ALuint aluChannelsFromFormat(ALenum format)
|
||||
}
|
||||
|
||||
|
||||
static __inline ALfloat lpFilter4P(FILTER *iir, ALuint offset, ALfloat input)
|
||||
{
|
||||
ALfloat *history = &iir->history[offset];
|
||||
ALfloat a = iir->coeff;
|
||||
ALfloat output = input;
|
||||
|
||||
output = output + (history[0]-output)*a;
|
||||
history[0] = output;
|
||||
output = output + (history[1]-output)*a;
|
||||
history[1] = output;
|
||||
output = output + (history[2]-output)*a;
|
||||
history[2] = output;
|
||||
output = output + (history[3]-output)*a;
|
||||
history[3] = output;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input)
|
||||
{
|
||||
ALfloat *history = &iir->history[offset];
|
||||
ALfloat a = iir->coeff;
|
||||
ALfloat output = input;
|
||||
|
||||
output = output + (history[0]-output)*a;
|
||||
history[0] = output;
|
||||
output = output + (history[1]-output)*a;
|
||||
history[1] = output;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
static __inline ALshort aluF2S(ALfloat Value)
|
||||
{
|
||||
ALint i;
|
||||
|
||||
+1
-8
@@ -144,8 +144,6 @@ ALvoid EchoUpdate(ALCcontext *Context, struct ALeffectslot *Slot, ALeffect *Effe
|
||||
|
||||
ALvoid EchoProcess(ALechoState *state, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS])
|
||||
{
|
||||
ALfloat *history = state->iirFilter.history;
|
||||
const ALfloat a = state->iirFilter.coeff;
|
||||
const ALuint delay = state->BufferLength-1;
|
||||
ALuint tap1off = state->Tap[0].offset;
|
||||
ALuint tap2off = state->Tap[1].offset;
|
||||
@@ -156,12 +154,7 @@ ALvoid EchoProcess(ALechoState *state, ALuint SamplesToDo, const ALfloat *Sample
|
||||
for(i = 0;i < SamplesToDo;i++)
|
||||
{
|
||||
// Apply damping
|
||||
samp[0] = state->SampleBuffer[tap2off] + SamplesIn[i];
|
||||
|
||||
samp[0] += (history[0]-samp[0]) * a;
|
||||
history[0] = samp[0];
|
||||
samp[0] += (history[1]-samp[0]) * a;
|
||||
history[1] = samp[0];
|
||||
samp[0] = lpFilter2P(&state->iirFilter, 0, state->SampleBuffer[tap2off]+SamplesIn[i]);
|
||||
|
||||
// Apply feedback gain and mix in the new sample
|
||||
state->SampleBuffer[fboff] = samp[0] * state->FeedGain;
|
||||
|
||||
@@ -13,6 +13,39 @@ typedef struct {
|
||||
ALfloat history[0];
|
||||
} FILTER;
|
||||
|
||||
static __inline ALfloat lpFilter4P(FILTER *iir, ALuint offset, ALfloat input)
|
||||
{
|
||||
ALfloat *history = &iir->history[offset];
|
||||
ALfloat a = iir->coeff;
|
||||
ALfloat output = input;
|
||||
|
||||
output = output + (history[0]-output)*a;
|
||||
history[0] = output;
|
||||
output = output + (history[1]-output)*a;
|
||||
history[1] = output;
|
||||
output = output + (history[2]-output)*a;
|
||||
history[2] = output;
|
||||
output = output + (history[3]-output)*a;
|
||||
history[3] = output;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input)
|
||||
{
|
||||
ALfloat *history = &iir->history[offset];
|
||||
ALfloat a = iir->coeff;
|
||||
ALfloat output = input;
|
||||
|
||||
output = output + (history[0]-output)*a;
|
||||
history[0] = output;
|
||||
output = output + (history[1]-output)*a;
|
||||
history[1] = output;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
#define AL_FILTER_TYPE 0x8001
|
||||
|
||||
#define AL_FILTER_NULL 0x0000
|
||||
|
||||
Reference in New Issue
Block a user