Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

comb.hpp 953B

11 years ago
11 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #ifndef _comb_
  7. #define _comb_
  8. #include "denormals.h"
  9. class comb
  10. {
  11. public:
  12. comb();
  13. void setbuffer(float *buf, int size);
  14. inline float process(float inp);
  15. void mute();
  16. void setdamp(float val);
  17. float getdamp();
  18. void setfeedback(float val);
  19. float getfeedback();
  20. private:
  21. float feedback;
  22. float filterstore;
  23. float damp1;
  24. float damp2;
  25. float *buffer;
  26. int bufsize;
  27. int bufidx;
  28. };
  29. // Big to inline - but crucial for speed
  30. inline float comb::process(float input)
  31. {
  32. float output;
  33. output = buffer[bufidx];
  34. undenormalise(output);
  35. filterstore = (output*damp2) + (filterstore*damp1);
  36. undenormalise(filterstore);
  37. buffer[bufidx] = input + (filterstore*feedback);
  38. if(++bufidx>=bufsize) bufidx = 0;
  39. return output;
  40. }
  41. #endif //_comb_
  42. //ends