20 static __inline ALfloat
lpFilter4P(FILTER
*iir
, ALuint offset
, ALfloat input
)
22 ALfloat
*history
= &iir
->history
[offset
];
23 ALfloat a
= iir
->coeff
;
24 ALfloat output
= input
;
26 output
= output
+ (history
[0]-output
)*a
;
28 output
= output
+ (history
[1]-output
)*a
;
30 output
= output
+ (history
[2]-output
)*a
;
32 output
= output
+ (history
[3]-output
)*a
;
38 static __inline ALfloat
lpFilter2P(FILTER
*iir
, ALuint offset
, ALfloat input
)
40 ALfloat
*history
= &iir
->history
[offset
];
41 ALfloat a
= iir
->coeff
;
42 ALfloat output
= input
;
44 output
= output
+ (history
[0]-output
)*a
;
46 output
= output
+ (history
[1]-output
)*a
;
52 static __inline ALfloat
lpFilter1P(FILTER
*iir
, ALuint offset
, ALfloat input
)
54 ALfloat
*history
= &iir
->history
[offset
];
55 ALfloat a
= iir
->coeff
;
56 ALfloat output
= input
;
58 output
= output
+ (history
[0]-output
)*a
;
64 /* Calculates the low-pass filter coefficient given the pre-scaled gain and
65 * cos(w) value. Note that g should be pre-scaled (sqr(gain) for one-pole,
66 * sqrt(gain) for four-pole, etc) */
67 static __inline ALfloat
lpCoeffCalc(ALfloat g
, ALfloat cw
)
71 /* Be careful with gains < 0.01, as that causes the coefficient
72 * head towards 1, which will flatten the signal */
74 if(g
< 0.9999f
) /* 1-epsilon */
75 a
= (1 - g
*cw
- aluSqrt(2*g
*(1-cw
) - g
*g
*(1 - cw
*cw
))) /
82 typedef struct ALfilter
84 // Filter type (AL_FILTER_NULL, ...)
93 struct ALfilter
*next
;
97 ALvoid
ReleaseALFilters(ALCdevice
*device
);