DOSBox-X
|
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 #include "../FileStream.h" 00012 00013 class comb 00014 { 00015 public: 00016 comb(); 00017 void setbuffer(float *buf, int size); 00018 void deletebuffer(); 00019 inline float process(float input); 00020 void mute(); 00021 void setdamp(float val); 00022 float getdamp(); 00023 void setfeedback(float val); 00024 float getfeedback(); 00025 00026 void saveState( std::ostream &stream ); 00027 void loadState( std::istream &stream ); 00028 private: 00029 float feedback = 0; 00030 float filterstore; 00031 float damp1 = 0; 00032 float damp2 = 0; 00033 float *buffer = NULL; 00034 int bufsize = 0; 00035 int bufidx; 00036 }; 00037 00038 00039 // Big to inline - but crucial for speed 00040 00041 inline float comb::process(float input) 00042 { 00043 float output; 00044 00045 output = undenormalise(buffer[bufidx]); 00046 00047 filterstore = undenormalise((output*damp2) + (filterstore*damp1)); 00048 00049 buffer[bufidx] = input + (filterstore*feedback); 00050 00051 if (++bufidx>=bufsize) bufidx = 0; 00052 00053 return output; 00054 } 00055 00056 #endif //_comb_