annotate OpenAL32/Include/alFilter.h @ 24:d51f1a2b4c30

adding java build file
author Robert McIntyre <rlm@mit.edu>
date Fri, 18 Nov 2011 16:05:47 -0700
parents f9476ff7637e
children
rev   line source
rlm@0 1 #ifndef _AL_FILTER_H_
rlm@0 2 #define _AL_FILTER_H_
rlm@0 3
rlm@0 4 #include "AL/al.h"
rlm@0 5 #include "alu.h"
rlm@0 6
rlm@0 7 #ifdef __cplusplus
rlm@0 8 extern "C" {
rlm@0 9 #endif
rlm@0 10
rlm@0 11 typedef struct {
rlm@0 12 ALfloat coeff;
rlm@0 13 #ifndef _MSC_VER
rlm@0 14 ALfloat history[0];
rlm@0 15 #else
rlm@0 16 ALfloat history[1];
rlm@0 17 #endif
rlm@0 18 } FILTER;
rlm@0 19
rlm@0 20 static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input)
rlm@0 21 {
rlm@0 22 ALfloat *history = &iir->history[offset*2];
rlm@0 23 ALfloat a = iir->coeff;
rlm@0 24 ALfloat output = input;
rlm@0 25
rlm@0 26 output = output + (history[0]-output)*a;
rlm@0 27 history[0] = output;
rlm@0 28 output = output + (history[1]-output)*a;
rlm@0 29 history[1] = output;
rlm@0 30
rlm@0 31 return output;
rlm@0 32 }
rlm@0 33 static __inline ALfloat lpFilter1P(FILTER *iir, ALuint offset, ALfloat input)
rlm@0 34 {
rlm@0 35 ALfloat *history = &iir->history[offset];
rlm@0 36 ALfloat a = iir->coeff;
rlm@0 37 ALfloat output = input;
rlm@0 38
rlm@0 39 output = output + (history[0]-output)*a;
rlm@0 40 history[0] = output;
rlm@0 41
rlm@0 42 return output;
rlm@0 43 }
rlm@0 44
rlm@0 45 static __inline ALfloat lpFilter2PC(const FILTER *iir, ALuint offset, ALfloat input)
rlm@0 46 {
rlm@0 47 const ALfloat *history = &iir->history[offset*2];
rlm@0 48 ALfloat a = iir->coeff;
rlm@0 49 ALfloat output = input;
rlm@0 50
rlm@0 51 output = output + (history[0]-output)*a;
rlm@0 52 output = output + (history[1]-output)*a;
rlm@0 53
rlm@0 54 return output;
rlm@0 55 }
rlm@0 56 static __inline ALfloat lpFilter1PC(FILTER *iir, ALuint offset, ALfloat input)
rlm@0 57 {
rlm@0 58 const ALfloat *history = &iir->history[offset];
rlm@0 59 ALfloat a = iir->coeff;
rlm@0 60 ALfloat output = input;
rlm@0 61
rlm@0 62 output = output + (history[0]-output)*a;
rlm@0 63
rlm@0 64 return output;
rlm@0 65 }
rlm@0 66
rlm@0 67 /* Calculates the low-pass filter coefficient given the pre-scaled gain and
rlm@0 68 * cos(w) value. Note that g should be pre-scaled (sqr(gain) for one-pole,
rlm@0 69 * sqrt(gain) for four-pole, etc) */
rlm@0 70 ALfloat lpCoeffCalc(ALfloat g, ALfloat cw);
rlm@0 71
rlm@0 72
rlm@0 73 typedef struct ALfilter
rlm@0 74 {
rlm@0 75 // Filter type (AL_FILTER_NULL, ...)
rlm@0 76 ALenum type;
rlm@0 77
rlm@0 78 ALfloat Gain;
rlm@0 79 ALfloat GainHF;
rlm@0 80
rlm@0 81 // Index to itself
rlm@0 82 ALuint filter;
rlm@0 83 } ALfilter;
rlm@0 84
rlm@0 85
rlm@0 86 ALvoid ReleaseALFilters(ALCdevice *device);
rlm@0 87
rlm@0 88 #ifdef __cplusplus
rlm@0 89 }
rlm@0 90 #endif
rlm@0 91
rlm@0 92 #endif