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
))) /
81 #define AL_FILTER_TYPE 0x8001
83 #define AL_FILTER_NULL 0x0000
84 #define AL_FILTER_LOWPASS 0x0001
85 #define AL_FILTER_HIGHPASS 0x0002
86 #define AL_FILTER_BANDPASS 0x0003
88 #define AL_LOWPASS_GAIN 0x0001
89 #define AL_LOWPASS_GAINHF 0x0002
92 typedef struct ALfilter
94 // Filter type (AL_FILTER_NULL, ...)
103 struct ALfilter
*next
;
106 ALvoid AL_APIENTRY
alGenFilters(ALsizei n
, ALuint
*filters
);
107 ALvoid AL_APIENTRY
alDeleteFilters(ALsizei n
, ALuint
*filters
);
108 ALboolean AL_APIENTRY
alIsFilter(ALuint filter
);
110 ALvoid AL_APIENTRY
alFilteri(ALuint filter
, ALenum param
, ALint iValue
);
111 ALvoid AL_APIENTRY
alFilteriv(ALuint filter
, ALenum param
, ALint
*piValues
);
112 ALvoid AL_APIENTRY
alFilterf(ALuint filter
, ALenum param
, ALfloat flValue
);
113 ALvoid AL_APIENTRY
alFilterfv(ALuint filter
, ALenum param
, ALfloat
*pflValues
);
115 ALvoid AL_APIENTRY
alGetFilteri(ALuint filter
, ALenum param
, ALint
*piValue
);
116 ALvoid AL_APIENTRY
alGetFilteriv(ALuint filter
, ALenum param
, ALint
*piValues
);
117 ALvoid AL_APIENTRY
alGetFilterf(ALuint filter
, ALenum param
, ALfloat
*pflValue
);
118 ALvoid AL_APIENTRY
alGetFilterfv(ALuint filter
, ALenum param
, ALfloat
*pflValues
);
120 ALvoid
ReleaseALFilters(ALCdevice
*device
);