00001 // Comb filter class declaration 00002 // 00003 // Written by Jezar at Dreampoint, June 2000 00004 // http://www.dreampoint.co.uk 00005 // This code is public domain 00006 00007 #ifndef _comb_ 00008 #define _comb_ 00009 00010 #include "denormals.h" 00011 00012 class comb 00013 { 00014 public: 00015 comb(); 00016 void setbuffer(float *buf, int size); 00017 inline float process(float inp); 00018 void mute(); 00019 void setdamp(float val); 00020 float getdamp(); 00021 void setfeedback(float val); 00022 float getfeedback(); 00023 private: 00024 float feedback; 00025 float filterstore; 00026 float damp1; 00027 float damp2; 00028 float *buffer; 00029 int bufsize; 00030 int bufidx; 00031 }; 00032 00033 00034 // Big to inline - but crucial for speed 00035 00036 inline float comb::process(float input) 00037 { 00038 float output; 00039 00040 output = buffer[bufidx]; 00041 undenormalise(output); 00042 00043 filterstore = (output*damp2) + (filterstore*damp1); 00044 undenormalise(filterstore); 00045 00046 buffer[bufidx] = input + (filterstore*feedback); 00047 00048 if(++bufidx>=bufsize) bufidx = 0; 00049 00050 return output; 00051 } 00052 00053 #endif //_comb_ 00054 00055 //ends 00056 00057 00058 00059 00060
1.5.5