view OpenAL32/Include/alFilter.h @ 0:f9476ff7637e

initial forking of open-al to create multiple listeners
author Robert McIntyre <rlm@mit.edu>
date Tue, 25 Oct 2011 13:02:31 -0700
parents
children
line wrap: on
line source
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)
21 {
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;
32 }
33 static __inline ALfloat lpFilter1P(FILTER *iir, ALuint offset, ALfloat input)
34 {
35 ALfloat *history = &iir->history[offset];
36 ALfloat a = iir->coeff;
37 ALfloat output = input;
39 output = output + (history[0]-output)*a;
40 history[0] = output;
42 return output;
43 }
45 static __inline ALfloat lpFilter2PC(const FILTER *iir, ALuint offset, ALfloat input)
46 {
47 const ALfloat *history = &iir->history[offset*2];
48 ALfloat a = iir->coeff;
49 ALfloat output = input;
51 output = output + (history[0]-output)*a;
52 output = output + (history[1]-output)*a;
54 return output;
55 }
56 static __inline ALfloat lpFilter1PC(FILTER *iir, ALuint offset, ALfloat input)
57 {
58 const ALfloat *history = &iir->history[offset];
59 ALfloat a = iir->coeff;
60 ALfloat output = input;
62 output = output + (history[0]-output)*a;
64 return output;
65 }
67 /* Calculates the low-pass filter coefficient given the pre-scaled gain and
68 * cos(w) value. Note that g should be pre-scaled (sqr(gain) for one-pole,
69 * sqrt(gain) for four-pole, etc) */
70 ALfloat lpCoeffCalc(ALfloat g, ALfloat cw);
73 typedef struct ALfilter
74 {
75 // Filter type (AL_FILTER_NULL, ...)
76 ALenum type;
78 ALfloat Gain;
79 ALfloat GainHF;
81 // Index to itself
82 ALuint filter;
83 } ALfilter;
86 ALvoid ReleaseALFilters(ALCdevice *device);
88 #ifdef __cplusplus
89 }
90 #endif
92 #endif