Mercurial > audio-send
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/OpenAL32/Include/alFilter.h Tue Oct 25 13:02:31 2011 -0700 1.3 @@ -0,0 +1,92 @@ 1.4 +#ifndef _AL_FILTER_H_ 1.5 +#define _AL_FILTER_H_ 1.6 + 1.7 +#include "AL/al.h" 1.8 +#include "alu.h" 1.9 + 1.10 +#ifdef __cplusplus 1.11 +extern "C" { 1.12 +#endif 1.13 + 1.14 +typedef struct { 1.15 + ALfloat coeff; 1.16 +#ifndef _MSC_VER 1.17 + ALfloat history[0]; 1.18 +#else 1.19 + ALfloat history[1]; 1.20 +#endif 1.21 +} FILTER; 1.22 + 1.23 +static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input) 1.24 +{ 1.25 + ALfloat *history = &iir->history[offset*2]; 1.26 + ALfloat a = iir->coeff; 1.27 + ALfloat output = input; 1.28 + 1.29 + output = output + (history[0]-output)*a; 1.30 + history[0] = output; 1.31 + output = output + (history[1]-output)*a; 1.32 + history[1] = output; 1.33 + 1.34 + return output; 1.35 +} 1.36 +static __inline ALfloat lpFilter1P(FILTER *iir, ALuint offset, ALfloat input) 1.37 +{ 1.38 + ALfloat *history = &iir->history[offset]; 1.39 + ALfloat a = iir->coeff; 1.40 + ALfloat output = input; 1.41 + 1.42 + output = output + (history[0]-output)*a; 1.43 + history[0] = output; 1.44 + 1.45 + return output; 1.46 +} 1.47 + 1.48 +static __inline ALfloat lpFilter2PC(const FILTER *iir, ALuint offset, ALfloat input) 1.49 +{ 1.50 + const ALfloat *history = &iir->history[offset*2]; 1.51 + ALfloat a = iir->coeff; 1.52 + ALfloat output = input; 1.53 + 1.54 + output = output + (history[0]-output)*a; 1.55 + output = output + (history[1]-output)*a; 1.56 + 1.57 + return output; 1.58 +} 1.59 +static __inline ALfloat lpFilter1PC(FILTER *iir, ALuint offset, ALfloat input) 1.60 +{ 1.61 + const ALfloat *history = &iir->history[offset]; 1.62 + ALfloat a = iir->coeff; 1.63 + ALfloat output = input; 1.64 + 1.65 + output = output + (history[0]-output)*a; 1.66 + 1.67 + return output; 1.68 +} 1.69 + 1.70 +/* Calculates the low-pass filter coefficient given the pre-scaled gain and 1.71 + * cos(w) value. Note that g should be pre-scaled (sqr(gain) for one-pole, 1.72 + * sqrt(gain) for four-pole, etc) */ 1.73 +ALfloat lpCoeffCalc(ALfloat g, ALfloat cw); 1.74 + 1.75 + 1.76 +typedef struct ALfilter 1.77 +{ 1.78 + // Filter type (AL_FILTER_NULL, ...) 1.79 + ALenum type; 1.80 + 1.81 + ALfloat Gain; 1.82 + ALfloat GainHF; 1.83 + 1.84 + // Index to itself 1.85 + ALuint filter; 1.86 +} ALfilter; 1.87 + 1.88 + 1.89 +ALvoid ReleaseALFilters(ALCdevice *device); 1.90 + 1.91 +#ifdef __cplusplus 1.92 +} 1.93 +#endif 1.94 + 1.95 +#endif