Cabinet.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. Cabinet.h
  3. Copyright 2002-5 Tim Goetze <tim@quitte.de>
  4. http://quitte.de/dsp/
  5. CabinetI - 16th order IIR filters modeled after various impulse responses
  6. from Steve Harris' 'imp' plugin. Limited to 44.1 kHz sample rate.
  7. CabinetII - 32nd order IIR filters modeled after the same impulse responses
  8. using a different algorithm. Versions for 44.1 / 48 / 88.2 / 96 kHz sample
  9. rates, switched at runtime.
  10. */
  11. /*
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  23. 02111-1307, USA or point your web browser to http://www.gnu.org.
  24. */
  25. #ifndef _CABINET_H_
  26. #define _CABINET_H_
  27. #include "dsp/util.h"
  28. /* cabinet_float sets the data type used for the IIR history and thus the
  29. * computing precision. doubles tend to make the sound more vivid and lively.
  30. * You can squeeze out a few extra cycles by making this 'float' if needed.
  31. * Be warned though that CabinetII has not been tested with 32-bit floats and
  32. * might become unstable due to the lower computing precision. */
  33. typedef double cabinet_float;
  34. typedef struct {
  35. int n;
  36. cabinet_float a[16], b[16];
  37. float gain;
  38. } Model16;
  39. typedef struct {
  40. int n;
  41. cabinet_float a[32], b[32];
  42. float gain;
  43. } Model32;
  44. class CabinetI
  45. : public Plugin
  46. {
  47. public:
  48. sample_t gain;
  49. static Model16 models [];
  50. int model;
  51. void switch_model (int m);
  52. int n, h;
  53. cabinet_float * a, * b;
  54. cabinet_float x[16], y[16];
  55. template <sample_func_t F>
  56. void one_cycle (int frames);
  57. public:
  58. static PortInfo port_info [];
  59. void init();
  60. void activate();
  61. void run (int n)
  62. {
  63. one_cycle<store_func> (n);
  64. }
  65. void run_adding (int n)
  66. {
  67. one_cycle<adding_func> (n);
  68. }
  69. };
  70. /* Second version with 32nd order filters precalculated for
  71. * 44.1 / 48 / 88.2 / 96 kHz sample rates */
  72. class CabinetII
  73. : public Plugin
  74. {
  75. public:
  76. sample_t gain;
  77. static Model32 models44100 [];
  78. static Model32 models48000 [];
  79. static Model32 models88200 [];
  80. static Model32 models96000 [];
  81. Model32 * models;
  82. int model;
  83. void switch_model (int m);
  84. int n, h;
  85. cabinet_float * a, * b;
  86. cabinet_float x[32], y[32];
  87. template <sample_func_t F>
  88. void one_cycle (int frames);
  89. public:
  90. static PortInfo port_info [];
  91. sample_t adding_gain;
  92. void init();
  93. void activate();
  94. void run (int n)
  95. {
  96. one_cycle<store_func> (n);
  97. }
  98. void run_adding (int n)
  99. {
  100. one_cycle<adding_func> (n);
  101. }
  102. };
  103. #endif /* _CABINET_H_ */