Mercurial > audio-send
view OpenAL32/Include/alFilter.h @ 1:c41d773a85fb
moved org files, ignored html files
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 25 Oct 2011 13:03:35 -0700 |
parents | f9476ff7637e |
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 __cplusplus8 extern "C" {9 #endif11 typedef struct {12 ALfloat coeff;13 #ifndef _MSC_VER14 ALfloat history[0];15 #else16 ALfloat history[1];17 #endif18 } 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 and68 * 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 ALfilter74 {75 // Filter type (AL_FILTER_NULL, ...)76 ALenum type;78 ALfloat Gain;79 ALfloat GainHF;81 // Index to itself82 ALuint filter;83 } ALfilter;86 ALvoid ReleaseALFilters(ALCdevice *device);88 #ifdef __cplusplus89 }90 #endif92 #endif