Protect ring buffer access with the lock
[openal-soft/openal-hmr.git] / OpenAL32 / Include / alFilter.h
blob0f00f029276d87a3e904801a4bd4cb20093c5d67
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 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;
27 history[0] = output;
28 output = output + (history[1]-output)*a;
29 history[1] = output;
30 output = output + (history[2]-output)*a;
31 history[2] = output;
32 output = output + (history[3]-output)*a;
33 history[3] = output;
35 return output;
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;
45 history[0] = output;
46 output = output + (history[1]-output)*a;
47 history[1] = output;
49 return output;
53 #define AL_FILTER_TYPE 0x8001
55 #define AL_FILTER_NULL 0x0000
56 #define AL_FILTER_LOWPASS 0x0001
57 #define AL_FILTER_HIGHPASS 0x0002
58 #define AL_FILTER_BANDPASS 0x0003
60 #define AL_LOWPASS_GAIN 0x0001
61 #define AL_LOWPASS_GAINHF 0x0002
64 typedef struct ALfilter_struct
66 // Filter type (AL_FILTER_NULL, ...)
67 ALenum type;
69 ALfloat Gain;
70 ALfloat GainHF;
72 // Index to itself
73 ALuint filter;
75 struct ALfilter_struct *next;
76 } ALfilter;
78 ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters);
79 ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters);
80 ALboolean AL_APIENTRY alIsFilter(ALuint filter);
82 ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue);
83 ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValues);
84 ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue);
85 ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, ALfloat *pflValues);
87 ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue);
88 ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues);
89 ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue);
90 ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues);
92 ALvoid ReleaseALFilters(ALvoid);
94 #ifdef __cplusplus
96 #endif
98 #endif