Add a ALfilterState method to process multiple samples at once
This commit is contained in:
parent
cd53a4b74c
commit
a5631e05cc
20
Alc/mixer.c
20
Alc/mixer.c
@ -96,20 +96,22 @@ static void DoFilters(ALfilterState *lpfilter, ALfilterState *hpfilter,
|
||||
break;
|
||||
|
||||
case AF_LowPass:
|
||||
for(i = 0;i < numsamples;i++)
|
||||
dst[i] = ALfilterState_processSingle(lpfilter, src[i]);
|
||||
ALfilterState_process(lpfilter, dst, src, numsamples);
|
||||
break;
|
||||
|
||||
case AF_HighPass:
|
||||
for(i = 0;i < numsamples;i++)
|
||||
dst[i] = ALfilterState_processSingle(hpfilter, src[i]);
|
||||
ALfilterState_process(hpfilter, dst, src, numsamples);
|
||||
break;
|
||||
|
||||
case AF_BandPass:
|
||||
for(i = 0;i < numsamples;i++)
|
||||
dst[i] = ALfilterState_processSingle(hpfilter,
|
||||
ALfilterState_processSingle(lpfilter, src[i])
|
||||
);
|
||||
for(i = 0;i < numsamples;)
|
||||
{
|
||||
ALfloat temp[64];
|
||||
ALuint todo = minu(64, numsamples-i);
|
||||
|
||||
ALfilterState_process(lpfilter, temp, src, todo);
|
||||
ALfilterState_process(hpfilter, dst, temp, todo);
|
||||
i += todo;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,14 @@ DECL_TEMPLATE(cubic32)
|
||||
#undef DECL_TEMPLATE
|
||||
|
||||
|
||||
void ALfilterState_processC(ALfilterState *filter, ALfloat *restrict dst, const ALfloat *src, ALuint numsamples)
|
||||
{
|
||||
ALuint i;
|
||||
for(i = 0;i < numsamples;i++)
|
||||
*(dst++) = ALfilterState_processSingle(filter, *(src++));
|
||||
}
|
||||
|
||||
|
||||
static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2],
|
||||
const ALuint IrSize,
|
||||
ALfloat (*restrict Coeffs)[2],
|
||||
|
@ -36,7 +36,10 @@ typedef struct ALfilterState {
|
||||
ALfloat y[2]; /* History of two last output samples */
|
||||
ALfloat a[3]; /* Transfer function coefficients "a" */
|
||||
ALfloat b[3]; /* Transfer function coefficients "b" */
|
||||
|
||||
void (*process)(struct ALfilterState *self, ALfloat *restrict dst, const ALfloat *src, ALuint numsamples);
|
||||
} ALfilterState;
|
||||
#define ALfilterState_process(a, ...) ((a)->process((a), __VA_ARGS__))
|
||||
|
||||
void ALfilterState_clear(ALfilterState *filter);
|
||||
void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat gain, ALfloat freq_mult, ALfloat bandwidth);
|
||||
@ -58,6 +61,8 @@ inline ALfloat ALfilterState_processSingle(ALfilterState *filter, ALfloat sample
|
||||
return outsmp;
|
||||
}
|
||||
|
||||
void ALfilterState_processC(ALfilterState *filter, ALfloat *restrict dst, const ALfloat *src, ALuint numsamples);
|
||||
|
||||
|
||||
typedef struct ALfilter {
|
||||
// Filter type (AL_FILTER_NULL, ...)
|
||||
|
@ -412,6 +412,8 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g
|
||||
filter->a[2] /= filter->a[0];
|
||||
filter->a[1] /= filter->a[0];
|
||||
filter->a[0] /= filter->a[0];
|
||||
|
||||
filter->process = ALfilterState_processC;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user