]> git.sesse.net Git - vlc/blob - modules/audio_filter/spatializer/allpass.hpp
Fixed undenormalise for 64 bits.
[vlc] / modules / audio_filter / spatializer / allpass.hpp
1 // Allpass filter 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 _allpass_
8 #define _allpass_
9 #include "denormals.h"
10
11 class allpass
12 {
13 public:
14         allpass();
15     void    setbuffer(float *buf, int size);
16     inline  float    process(float inp);
17     void    mute();
18     void    setfeedback(float val);
19     float    getfeedback();
20 // private:
21     float    feedback;
22     float    *buffer;
23     int    bufsize;
24     int    bufidx;
25 };
26
27
28 // Big to inline - but crucial for speed
29
30 inline float allpass::process(float input)
31 {
32     float output;
33     float bufout;
34
35     bufout = undenormalise( buffer[bufidx] );
36
37     output = -input + bufout;
38     buffer[bufidx] = input + (bufout*feedback);
39
40     if(++bufidx>=bufsize) bufidx = 0;
41
42     return output;
43 }
44
45 #endif//_allpass
46
47 //ends