Compress.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. Compress.h
  3. Copyright 2004-5 Tim Goetze <tim@quitte.de>, Steve Harris
  4. http://quitte.de/dsp/
  5. mono compressor.
  6. */
  7. /*
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public License
  10. as published by the Free Software Foundation; either version 2
  11. of the License, or (at your option) any later version.
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. 02111-1307, USA or point your web browser to http://www.gnu.org.
  20. */
  21. #ifndef _COMPRESS_H_
  22. #define _COMPRESS_H_
  23. #include "dsp/RMS.h"
  24. #include "dsp/util.h"
  25. class Compress
  26. : public Plugin
  27. {
  28. public:
  29. double fs;
  30. sample_t f;
  31. DSP::RMS rms;
  32. sample_t sum, amp, env, gain, gain_t;
  33. int count;
  34. template <sample_func_t F>
  35. void one_cycle (int frames);
  36. public:
  37. static PortInfo port_info [];
  38. void init() {}
  39. void activate()
  40. {
  41. rms.reset();
  42. sum = 0;
  43. count = 0;
  44. amp = 0;
  45. env = 0;
  46. gain = 0;
  47. gain_t = 0;
  48. }
  49. void run (int n)
  50. {
  51. one_cycle<store_func> (n);
  52. }
  53. void run_adding (int n)
  54. {
  55. one_cycle<adding_func> (n);
  56. }
  57. };
  58. #endif /* _COMPRESS_H_ */