Update filter histories even when they're not used
If the filter properties are continually updated, and the HF or LF gain goes from <1, to 1, and later back to <1, the history shouldn't hold stale values from before it was at 1.
This commit is contained in:
@@ -260,12 +260,16 @@ static const ALfloat *DoFilters(ALfilterState *lpfilter, ALfilterState *hpfilter
|
||||
switch(type)
|
||||
{
|
||||
case AF_None:
|
||||
ALfilterState_processPassthru(lpfilter, src, numsamples);
|
||||
ALfilterState_processPassthru(hpfilter, src, numsamples);
|
||||
break;
|
||||
|
||||
case AF_LowPass:
|
||||
ALfilterState_process(lpfilter, dst, src, numsamples);
|
||||
ALfilterState_processPassthru(hpfilter, dst, numsamples);
|
||||
return dst;
|
||||
case AF_HighPass:
|
||||
ALfilterState_processPassthru(lpfilter, src, numsamples);
|
||||
ALfilterState_process(hpfilter, dst, src, numsamples);
|
||||
return dst;
|
||||
|
||||
|
||||
@@ -63,6 +63,8 @@ inline ALfloat ALfilterState_processSingle(ALfilterState *filter, ALfloat sample
|
||||
|
||||
void ALfilterState_processC(ALfilterState *filter, ALfloat *restrict dst, const ALfloat *src, ALuint numsamples);
|
||||
|
||||
void ALfilterState_processPassthru(ALfilterState *filter, const ALfloat *src, ALuint numsamples);
|
||||
|
||||
|
||||
typedef struct ALfilter {
|
||||
// Filter type (AL_FILTER_NULL, ...)
|
||||
|
||||
@@ -420,6 +420,24 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g
|
||||
filter->process = ALfilterState_processC;
|
||||
}
|
||||
|
||||
void ALfilterState_processPassthru(ALfilterState *filter, const ALfloat *src, ALuint numsamples)
|
||||
{
|
||||
if(numsamples >= 2)
|
||||
{
|
||||
filter->x[1] = src[numsamples-2];
|
||||
filter->x[0] = src[numsamples-1];
|
||||
filter->y[1] = src[numsamples-2];
|
||||
filter->y[0] = src[numsamples-1];
|
||||
}
|
||||
else if(numsamples == 1)
|
||||
{
|
||||
filter->x[1] = filter->x[0];
|
||||
filter->x[0] = src[0];
|
||||
filter->y[1] = filter->y[0];
|
||||
filter->y[0] = src[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void lp_SetParami(ALfilter *UNUSED(filter), ALCcontext *context, ALenum UNUSED(param), ALint UNUSED(val))
|
||||
{ SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM); }
|
||||
|
||||
Reference in New Issue
Block a user