20 static __inline ALfloat
lpFilter2P(FILTER
*iir
, ALuint offset
, ALfloat input
)
22 ALfloat
*history
= &iir
->history
[offset
*2];
23 ALfloat a
= iir
->coeff
;
24 ALfloat output
= input
;
26 output
= output
+ (history
[0]-output
)*a
;
28 output
= output
+ (history
[1]-output
)*a
;
34 static __inline ALfloat
lpFilter2PC(const FILTER
*iir
, ALuint offset
, ALfloat input
)
36 const ALfloat
*history
= &iir
->history
[offset
*2];
37 ALfloat a
= iir
->coeff
;
38 ALfloat output
= input
;
40 output
= output
+ (history
[0]-output
)*a
;
41 output
= output
+ (history
[1]-output
)*a
;
46 /* Calculates the low-pass filter coefficient given the pre-scaled gain and
47 * cos(w) value. Note that g should be pre-scaled (sqr(gain) for one-pole,
48 * sqrt(gain) for four-pole, etc) */
49 ALfloat
lpCoeffCalc(ALfloat g
, ALfloat cw
);
52 typedef struct ALfilter
{
53 // Filter type (AL_FILTER_NULL, ...)
59 void (*SetParami
)(struct ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALint val
);
60 void (*SetParamiv
)(struct ALfilter
*filter
, ALCcontext
*context
, ALenum param
, const ALint
*vals
);
61 void (*SetParamf
)(struct ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat val
);
62 void (*SetParamfv
)(struct ALfilter
*filter
, ALCcontext
*context
, ALenum param
, const ALfloat
*vals
);
64 void (*GetParami
)(struct ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALint
*val
);
65 void (*GetParamiv
)(struct ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALint
*vals
);
66 void (*GetParamf
)(struct ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat
*val
);
67 void (*GetParamfv
)(struct ALfilter
*filter
, ALCcontext
*context
, ALenum param
, ALfloat
*vals
);
73 #define ALfilter_SetParami(x, c, p, v) ((x)->SetParami((x),(c),(p),(v)))
74 #define ALfilter_SetParamiv(x, c, p, v) ((x)->SetParamiv((x),(c),(p),(v)))
75 #define ALfilter_SetParamf(x, c, p, v) ((x)->SetParamf((x),(c),(p),(v)))
76 #define ALfilter_SetParamfv(x, c, p, v) ((x)->SetParamfv((x),(c),(p),(v)))
78 #define ALfilter_GetParami(x, c, p, v) ((x)->GetParami((x),(c),(p),(v)))
79 #define ALfilter_GetParamiv(x, c, p, v) ((x)->GetParamiv((x),(c),(p),(v)))
80 #define ALfilter_GetParamf(x, c, p, v) ((x)->GetParamf((x),(c),(p),(v)))
81 #define ALfilter_GetParamfv(x, c, p, v) ((x)->GetParamfv((x),(c),(p),(v)))
83 ALvoid
ReleaseALFilters(ALCdevice
*device
);