Use the right method to clear a __m128 to 0
[openal-soft.git] / OpenAL32 / Include / alFilter.h
blobc871e6dc7e8f61b869a0704b60a0db917fb735c7
1 #ifndef _AL_FILTER_H_
2 #define _AL_FILTER_H_
4 #include "AL/al.h"
5 #include "alu.h"
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
11 typedef struct {
12 ALfloat coeff;
13 #ifndef _MSC_VER
14 ALfloat history[0];
15 #else
16 ALfloat history[1];
17 #endif
18 } FILTER;
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;
27 history[0] = output;
28 output = output + (history[1]-output)*a;
29 history[1] = output;
31 return output;
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;
43 return output;
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, ...)
54 ALenum type;
56 ALfloat Gain;
57 ALfloat GainHF;
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);
69 /* Self ID */
70 ALuint id;
71 } ALfilter;
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);
85 #ifdef __cplusplus
87 #endif
89 #endif