Use +/-90 degrees for stereo sources with non-HRTF stereo output.
[openal-soft.git] / OpenAL32 / Include / alFilter.h
blob09cef93c08f814466b6a32ab6efb03234543e793
1 #ifndef _AL_FILTER_H_
2 #define _AL_FILTER_H_
4 #include "alMain.h"
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 #define LOWPASSFREQREF (5000)
12 typedef struct {
13 ALfloat coeff;
14 #ifndef _MSC_VER
15 ALfloat history[0];
16 #else
17 ALfloat history[1];
18 #endif
19 } FILTER;
21 static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input)
23 ALfloat *history = &iir->history[offset*2];
24 ALfloat a = iir->coeff;
25 ALfloat output = input;
27 output = output + (history[0]-output)*a;
28 history[0] = output;
29 output = output + (history[1]-output)*a;
30 history[1] = output;
32 return output;
35 static __inline ALfloat lpFilter2PC(const FILTER *iir, ALuint offset, ALfloat input)
37 const ALfloat *history = &iir->history[offset*2];
38 ALfloat a = iir->coeff;
39 ALfloat output = input;
41 output = output + (history[0]-output)*a;
42 output = output + (history[1]-output)*a;
44 return output;
47 /* Calculates the low-pass filter coefficient given the pre-scaled gain and
48 * cos(w) value. Note that g should be pre-scaled (sqr(gain) for one-pole,
49 * sqrt(gain) for four-pole, etc) */
50 ALfloat lpCoeffCalc(ALfloat g, ALfloat cw);
53 typedef struct ALfilter {
54 // Filter type (AL_FILTER_NULL, ...)
55 ALenum type;
57 ALfloat Gain;
58 ALfloat GainHF;
60 void (*SetParami)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint val);
61 void (*SetParamiv)(struct ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals);
62 void (*SetParamf)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val);
63 void (*SetParamfv)(struct ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals);
65 void (*GetParami)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint *val);
66 void (*GetParamiv)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals);
67 void (*GetParamf)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val);
68 void (*GetParamfv)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals);
70 /* Self ID */
71 ALuint id;
72 } ALfilter;
74 #define ALfilter_SetParami(x, c, p, v) ((x)->SetParami((x),(c),(p),(v)))
75 #define ALfilter_SetParamiv(x, c, p, v) ((x)->SetParamiv((x),(c),(p),(v)))
76 #define ALfilter_SetParamf(x, c, p, v) ((x)->SetParamf((x),(c),(p),(v)))
77 #define ALfilter_SetParamfv(x, c, p, v) ((x)->SetParamfv((x),(c),(p),(v)))
79 #define ALfilter_GetParami(x, c, p, v) ((x)->GetParami((x),(c),(p),(v)))
80 #define ALfilter_GetParamiv(x, c, p, v) ((x)->GetParamiv((x),(c),(p),(v)))
81 #define ALfilter_GetParamf(x, c, p, v) ((x)->GetParamf((x),(c),(p),(v)))
82 #define ALfilter_GetParamfv(x, c, p, v) ((x)->GetParamfv((x),(c),(p),(v)))
84 ALvoid ReleaseALFilters(ALCdevice *device);
86 #ifdef __cplusplus
88 #endif
90 #endif