Use arrays instead of pointer-to-arrays for the low-pass filter
This commit is contained in:
parent
d3e5fcd13e
commit
597e01153e
@ -87,24 +87,9 @@ int InitLowPassFilter(ALCcontext *Context, FILTER *iir)
|
|||||||
ProtoCoef[1].b1 = 1.847759;
|
ProtoCoef[1].b1 = 1.847759;
|
||||||
ProtoCoef[1].b2 = 1.0;
|
ProtoCoef[1].b2 = 1.0;
|
||||||
|
|
||||||
/*
|
/* Clear the coefficient and history arrays */
|
||||||
* Allocate array of z-domain coefficients for each filter section
|
memset(iir->coef, 0, sizeof(iir->coef));
|
||||||
* plus filter gain variable
|
memset(iir->history, 0, sizeof(iir->history));
|
||||||
*/
|
|
||||||
iir->coef = (float*)calloc(4*FILTER_SECTIONS + 1, sizeof(float));
|
|
||||||
if(!iir->coef)
|
|
||||||
{
|
|
||||||
AL_PRINT("Unable to allocate coef array\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate history array */
|
|
||||||
iir->history = (float*)calloc(2*FILTER_SECTIONS, sizeof(float));
|
|
||||||
if(!iir->history) {
|
|
||||||
AL_PRINT("\nUnable to allocate history array\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
k = 1.0; /* Set overall filter gain */
|
k = 1.0; /* Set overall filter gain */
|
||||||
coef = iir->coef + 1; /* Skip k, or gain */
|
coef = iir->coef + 1; /* Skip k, or gain */
|
||||||
|
@ -7,9 +7,11 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define FILTER_SECTIONS 2 /* 2 filter sections for 24 db/oct filter */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float *history; /* pointer to history in filter */
|
float history[2*FILTER_SECTIONS]; /* history in filter */
|
||||||
float *coef; /* pointer to coefficients of filter */
|
float coef[4*FILTER_SECTIONS + 1]; /* coefficients of filter */
|
||||||
} FILTER;
|
} FILTER;
|
||||||
|
|
||||||
#define AL_FILTER_TYPE 0x8001
|
#define AL_FILTER_TYPE 0x8001
|
||||||
@ -53,8 +55,6 @@ AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pf
|
|||||||
|
|
||||||
ALvoid ReleaseALFilters(ALvoid);
|
ALvoid ReleaseALFilters(ALvoid);
|
||||||
|
|
||||||
#define FILTER_SECTIONS 2 /* 2 filter sections for 24 db/oct filter */
|
|
||||||
|
|
||||||
int InitLowPassFilter(ALCcontext *Context, FILTER *iir);
|
int InitLowPassFilter(ALCcontext *Context, FILTER *iir);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -141,9 +141,6 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effect
|
|||||||
|
|
||||||
ALAuxiliaryEffectSlot = ((ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i]));
|
ALAuxiliaryEffectSlot = ((ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i]));
|
||||||
|
|
||||||
free(ALAuxiliaryEffectSlot->iirFilter.coef);
|
|
||||||
free(ALAuxiliaryEffectSlot->iirFilter.history);
|
|
||||||
|
|
||||||
// Remove Source from list of Sources
|
// Remove Source from list of Sources
|
||||||
list = &Context->AuxiliaryEffectSlot;
|
list = &Context->AuxiliaryEffectSlot;
|
||||||
while(*list && *list != ALAuxiliaryEffectSlot)
|
while(*list && *list != ALAuxiliaryEffectSlot)
|
||||||
|
@ -181,9 +181,6 @@ ALAPI ALvoid ALAPIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
|
|||||||
ALSource->Send[j].Slot = NULL;
|
ALSource->Send[j].Slot = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(ALSource->iirFilter.coef);
|
|
||||||
free(ALSource->iirFilter.history);
|
|
||||||
|
|
||||||
// Decrement Source count
|
// Decrement Source count
|
||||||
Context->SourceCount--;
|
Context->SourceCount--;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user