]> git.sesse.net Git - vlc/blob - modules/audio_filter/spatializer/comb.hpp
Use var_Inherit* instead of var_CreateGet*.
[vlc] / modules / audio_filter / spatializer / comb.hpp
1 // Comb filter class declaration
2 //
3 // Written by Jezar at Dreampoint, June 2000
4 // http://www.dreampoint.co.uk
5 // This code is public domain
6
7 #ifndef _comb_
8 #define _comb_
9
10 #include "denormals.h"
11
12 /**
13 * Combination filter
14 *Takes multiple audio channels and mix them for one ear
15 */
16 class comb
17 {
18 public:
19     comb();
20     void    setbuffer(float *buf, int size);
21     inline  float    process(float inp);
22     void    mute();
23     void    setdamp(float val);
24     float    getdamp();
25     void    setfeedback(float val);
26     float    getfeedback();
27 private:
28     float    feedback;
29     float    filterstore;
30     float    damp1;
31     float    damp2;
32     float    *buffer;
33     int    bufsize;
34     int    bufidx;
35 };
36
37
38 // Big to inline - but crucial for speed
39
40 inline float comb::process(float input)
41 {
42 /* FIXME
43 * comb::process is not really ear-friendly the tunning values must
44 * be changed*/
45     float output;
46
47     output = undenormalise( buffer[bufidx] );
48
49     filterstore = undenormalise(output*damp2);
50
51     buffer[bufidx] = input + filterstore*feedback;
52
53     if(++bufidx>=bufsize) bufidx = 0;
54
55     return output;
56 }
57
58 #endif //_comb_
59
60 //ends