Pan.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. Pan.h
  3. Copyright 2004-11 Tim Goetze <tim@quitte.de>
  4. http://quitte.de/dsp/
  5. panorama with width control,
  6. stereo image width reduction
  7. */
  8. /*
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License
  11. as published by the Free Software Foundation; either version 2
  12. of the License, or (at your option) any later version.
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  20. 02111-1307, USA or point your web browser to http://www.gnu.org.
  21. */
  22. #ifndef _PAN_H_
  23. #define _PAN_H_
  24. #include "dsp/Delay.h"
  25. #include "dsp/OnePole.h"
  26. class PanTap
  27. {
  28. public:
  29. int t;
  30. DSP::OnePoleLP damper;
  31. sample_t get (DSP::Delay & delay)
  32. {
  33. return damper.process (delay[t]);
  34. }
  35. void reset (double c)
  36. {
  37. damper.set_f (c);
  38. damper.reset();
  39. }
  40. };
  41. class Pan
  42. : public Plugin
  43. {
  44. public:
  45. sample_t pan;
  46. sample_t gain_l, gain_r;
  47. DSP::Delay delay;
  48. PanTap tap;
  49. template <sample_func_t F>
  50. void one_cycle (int frames);
  51. inline void set_pan (sample_t);
  52. public:
  53. static PortInfo port_info [];
  54. void init();
  55. void activate();
  56. void run (int n)
  57. {
  58. one_cycle<store_func> (n);
  59. }
  60. void run_adding (int n)
  61. {
  62. one_cycle<adding_func> (n);
  63. }
  64. };
  65. /* stereo width reduction */
  66. class Narrower
  67. : public Plugin
  68. {
  69. public:
  70. sample_t strength;
  71. template <sample_func_t F>
  72. void one_cycle (int frames);
  73. public:
  74. static PortInfo port_info [];
  75. void init();
  76. void activate();
  77. void run (int n)
  78. {
  79. one_cycle<store_func> (n);
  80. }
  81. void run_adding (int n)
  82. {
  83. one_cycle<adding_func> (n);
  84. }
  85. };
  86. #endif /* _PAN_H_ */