ToneStack.cc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. ToneStack.cc
  3. Copyright 2006-7
  4. David Yeh <dtyeh@ccrma.stanford.edu>
  5. Tim Goetze <tim@quitte.de> (cosmetics)
  6. Tone Stack emulation.
  7. *
  8. */
  9. /*
  10. This program is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2
  13. of the License, or (at your option) any later version.
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. GNU General Public License for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with this program; if not, write to the Free Software
  20. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  21. 02111-1307, USA or point your web browser to http://www.gnu.org.
  22. */
  23. #include "basics.h"
  24. #include "ToneStack.h"
  25. #include "Descriptor.h"
  26. #include "dsp/tonestack/ks_tab.h"
  27. #include "dsp/tonestack/vs_tab.h"
  28. DSP::TSParameters
  29. DSP::ToneStack::presets[] = {
  30. /* for convenience, temporarily define k and MOhms as well as nF and pF */
  31. #define k * 1000
  32. #define M * 1000000
  33. #define nF * 1e-9
  34. #define pF * 1e-12
  35. /* parameter order is R1 - R4, C1 - C3 */
  36. /* { 250000, 1000000, 25000, 56000, 0.25e-9, 20e-9, 20e-9 }, DY */
  37. /* Fender */
  38. {250 k, 1 M, 25 k, 56 k, 250 pF, 20 nF, 20 nF}, /* 59 Bassman 5F6-A */
  39. {250 k, 250 k, 10 k, 100 k, 120 pF, 100 nF, 47 nF}, /* 69 Twin Reverb AA270 */
  40. {250 k, 250 k, 4.8 k, 100 k, 250 pF, 100 nF, 47 nF}, /* 64 Princeton AA1164 */
  41. /* Marshall */
  42. {220 k, 1 M, 22 k, 33 k, 470 pF, 22 nF, 22 nF}, /* 59/81 JCM-800 Lead 100 2203 */
  43. /* R4 is a 10 k fixed + 100 k pot in series actually */
  44. {250 k, 1 M, 25 k, 56 k, 500 pF, 22 nF, 22 nF}, /* 81 2000 Lead */
  45. #if 0
  46. {220 k, 1 M, 22 k, 33 k, 470 pF, 22 nF, 22 nF}, /* 90 JCM-900 Master 2100 (same as JCM-800) */
  47. {250 k, 1 M, 25 k, 33 k, 500 pF, 22 nF, 22 nF}, /* 67 Major Lead 200 */
  48. {250 k, 250 k, 25 k, 56 k, 250 pF, 47 nF, 47 nF}, /* undated M2199 30W solid state */
  49. #endif
  50. /* Vox -- R3 is fixed (circuit differs anyway) */
  51. {1 M, 1 M, 10 k, 100 k, 50 pF, 22 nF, 22 nF}, /* 59/86 AC-30 */
  52. #undef k
  53. #undef M
  54. #undef nF
  55. #undef pF
  56. };
  57. int DSP::ToneStack::n_presets = TS_N_PRESETS;
  58. void
  59. ToneStack::activate()
  60. {
  61. tonestack.activate (ports + 2);
  62. }
  63. template <sample_func_t F>
  64. void
  65. ToneStack::one_cycle (int frames)
  66. {
  67. sample_t * s = ports[0];
  68. tonestack.start_cycle (ports + 1);
  69. sample_t * d = ports[5];
  70. for (int i = 0; i < frames; ++i)
  71. {
  72. register sample_t a = s[i];
  73. a = tonestack.process (a + normal);
  74. F (d, i, a, adding_gain);
  75. }
  76. }
  77. PortInfo
  78. ToneStack::port_info [] =
  79. {
  80. {
  81. "in",
  82. INPUT | AUDIO,
  83. {BOUNDED, -1, 1}
  84. }, {
  85. "model",
  86. INPUT | CONTROL,
  87. {BOUNDED | DEFAULT_0 | INTEGER, 0, TS_N_PRESETS - 1}
  88. }, {
  89. "bass",
  90. INPUT | CONTROL,
  91. {BOUNDED | DEFAULT_MID, 0, 1}
  92. }, {
  93. "mid",
  94. INPUT | CONTROL,
  95. {BOUNDED | DEFAULT_MID, 0, 1}
  96. }, {
  97. "treble",
  98. INPUT | CONTROL,
  99. {BOUNDED | DEFAULT_MID, 0, 1}
  100. }, {
  101. "out",
  102. OUTPUT | AUDIO,
  103. {0}
  104. }
  105. };
  106. template <> void
  107. Descriptor<ToneStack>::setup()
  108. {
  109. UniqueID = 2589;
  110. Label = "ToneStack";
  111. Properties = HARD_RT;
  112. Name = CAPS "ToneStack - Tone stack emulation";
  113. Maker = "David Yeh <dtyeh@ccrma.stanford.edu>";
  114. Copyright = "GPL, 2006-7";
  115. /* fill port info and vtable */
  116. autogen();
  117. }
  118. /* //////////////////////////////////////////////////////////////////////// */
  119. template <sample_func_t F>
  120. void
  121. ToneStackLT::one_cycle (int frames)
  122. {
  123. sample_t * s = ports[0];
  124. tonestack.updatecoefs (ports + 1);
  125. sample_t * d = ports[4];
  126. for (int i = 0; i < frames; ++i)
  127. {
  128. register sample_t a = s[i];
  129. a = tonestack.process (a + normal);
  130. F (d, i, a, adding_gain);
  131. }
  132. }
  133. PortInfo
  134. ToneStackLT::port_info [] =
  135. {
  136. {
  137. "in",
  138. INPUT | AUDIO,
  139. {BOUNDED, -1, 1}
  140. }, {
  141. "bass",
  142. INPUT | CONTROL,
  143. {BOUNDED | DEFAULT_MID, 0, 1}
  144. }, {
  145. "mid",
  146. INPUT | CONTROL,
  147. {BOUNDED | DEFAULT_MID, 0, 1}
  148. }, {
  149. "treble",
  150. INPUT | CONTROL,
  151. {BOUNDED | DEFAULT_MID, 0, 1}
  152. }, {
  153. "out",
  154. OUTPUT | AUDIO,
  155. {0}
  156. }
  157. };
  158. template <> void
  159. Descriptor<ToneStackLT>::setup()
  160. {
  161. UniqueID = 2590;
  162. Label = "ToneStackLT";
  163. Properties = HARD_RT;
  164. Name = CAPS "ToneStackLT - Tone stack emulation, lattice filter 44.1";
  165. Maker = "David Yeh <dtyeh@ccrma.stanford.edu>";
  166. Copyright = "GPL, 2006-7";
  167. /* fill port info and vtable */
  168. autogen();
  169. }