]> git.sesse.net Git - vlc/blob - modules/audio_filter/spatializer/comb.hpp
Fixed undenormalise for 64 bits.
[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 class comb
13 {
14 public:
15     comb();
16     void    setbuffer(float *buf, int size);
17     inline  float    process(float inp);
18     void    mute();
19     void    setdamp(float val);
20     float    getdamp();
21     void    setfeedback(float val);
22     float    getfeedback();
23 private:
24     float    feedback;
25     float    filterstore;
26     float    damp1;
27     float    damp2;
28     float    *buffer;
29     int    bufsize;
30     int    bufidx;
31 };
32
33
34 // Big to inline - but crucial for speed
35
36 inline float comb::process(float input)
37 {
38     float output;
39
40     output = undenormalise( buffer[bufidx] );
41
42     filterstore = undenormalise( output*damp2 + filterstore*damp1 );
43
44     buffer[bufidx] = input + filterstore*feedback;
45
46     if(++bufidx>=bufsize) bufidx = 0;
47
48     return output;
49 }
50
51 #endif //_comb_
52
53 //ends