DPF with Max Gen
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.

537 lines
17KB

  1. #include "gen_exported.h"
  2. namespace gen_exported {
  3. /*******************************************************************************************************************
  4. Copyright (c) 2012 Cycling '74
  5. Permission is hereby granted, free of charge, to any person obtaining a copy of this software
  6. and associated documentation files (the "Software"), to deal in the Software without restriction,
  7. including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
  9. subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all copies
  11. or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  13. INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  14. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  15. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  16. OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. *******************************************************************************************************************/
  18. // global noise generator
  19. Noise noise;
  20. static const int GENLIB_LOOPCOUNT_BAIL = 100000;
  21. // The State struct contains all the state and procedures for the gendsp kernel
  22. typedef struct State {
  23. CommonState __commonstate;
  24. Delay m_delay_10;
  25. Delay m_delay_11;
  26. Delta m_delta_29;
  27. Delta m_delta_26;
  28. Delta m_delta_23;
  29. Delta m_delta_33;
  30. Delta m_delta_36;
  31. Delta m_delta_20;
  32. Delta m_delta_39;
  33. Delta m_delta_42;
  34. Phasor m_phasor_32;
  35. Phasor m_phasor_19;
  36. Sah m_sah_25;
  37. Sah m_sah_35;
  38. Sah m_sah_24;
  39. Sah m_sah_27;
  40. Sah m_sah_28;
  41. Sah m_sah_41;
  42. Sah m_sah_30;
  43. Sah m_sah_34;
  44. Sah m_sah_37;
  45. Sah m_sah_38;
  46. Sah m_sah_31;
  47. Sah m_sah_40;
  48. Sah m_sah_22;
  49. Sah m_sah_44;
  50. Sah m_sah_43;
  51. Sah m_sah_21;
  52. double m_y_1;
  53. double m_history_5;
  54. double m_history_6;
  55. double samplerate;
  56. double m_history_4;
  57. double m_history_2;
  58. double m_history_7;
  59. double m_history_3;
  60. double m_history_8;
  61. double m_ratio_12;
  62. double m_history_9;
  63. double m_delay_18;
  64. double samples_to_seconds;
  65. double m_cutoff_16;
  66. double m_blur_17;
  67. double m_delay_14;
  68. double m_mix_13;
  69. double m_ratio_15;
  70. int vectorsize;
  71. int __exception;
  72. // re-initialize all member variables;
  73. inline void reset(double __sr, int __vs) {
  74. __exception = 0;
  75. vectorsize = __vs;
  76. samplerate = __sr;
  77. m_y_1 = 0;
  78. m_history_2 = 0;
  79. m_history_3 = 0;
  80. m_history_4 = 0;
  81. m_history_5 = 0;
  82. m_history_6 = 0;
  83. m_history_7 = 0;
  84. m_history_8 = 0;
  85. m_history_9 = 0;
  86. m_delay_10.reset("m_delay_10", 96000);
  87. m_delay_11.reset("m_delay_11", 96000);
  88. m_ratio_12 = 2;
  89. m_mix_13 = 0.5;
  90. m_delay_14 = 100;
  91. m_ratio_15 = 0.5;
  92. m_cutoff_16 = 2250;
  93. m_blur_17 = 0.25;
  94. m_delay_18 = 100;
  95. samples_to_seconds = (1 / samplerate);
  96. m_phasor_19.reset(0);
  97. m_delta_20.reset(0);
  98. m_sah_21.reset(0);
  99. m_sah_22.reset(0);
  100. m_delta_23.reset(0);
  101. m_sah_24.reset(0);
  102. m_sah_25.reset(0);
  103. m_delta_26.reset(0);
  104. m_sah_27.reset(0);
  105. m_sah_28.reset(0);
  106. m_delta_29.reset(0);
  107. m_sah_30.reset(0);
  108. m_sah_31.reset(0);
  109. m_phasor_32.reset(0);
  110. m_delta_33.reset(0);
  111. m_sah_34.reset(0);
  112. m_sah_35.reset(0);
  113. m_delta_36.reset(0);
  114. m_sah_37.reset(0);
  115. m_sah_38.reset(0);
  116. m_delta_39.reset(0);
  117. m_sah_40.reset(0);
  118. m_sah_41.reset(0);
  119. m_delta_42.reset(0);
  120. m_sah_43.reset(0);
  121. m_sah_44.reset(0);
  122. genlib_reset_complete(this);
  123. };
  124. // the signal processing routine;
  125. inline int perform(t_sample ** __ins, t_sample ** __outs, int __n) {
  126. vectorsize = __n;
  127. const t_sample * __in1 = __ins[0];
  128. t_sample * __out1 = __outs[0];
  129. if (__exception) {
  130. return __exception;
  131. } else if (( (__in1 == 0) || (__out1 == 0) )) {
  132. __exception = GENLIB_ERR_NULL_BUFFER;
  133. return __exception;
  134. };
  135. double expr_5155 = safediv(((m_cutoff_16 * 2) * 3.1415926535898), 44100);
  136. double sin_5012 = sin(expr_5155);
  137. double clamp_5013 = ((sin_5012 <= 1e-05) ? 1e-05 : ((sin_5012 >= 0.99999) ? 0.99999 : sin_5012));
  138. double mstosamps_5148 = (m_delay_14 * (samplerate * 0.001));
  139. double mstosamps_5077 = (m_delay_18 * (samplerate * 0.001));
  140. double rsub_5064 = (1 - m_ratio_12);
  141. double mul_5063 = (rsub_5064 * 1000);
  142. double div_5062 = safediv(mul_5063, m_delay_18);
  143. samples_to_seconds = (1 / samplerate);
  144. double rsub_5135 = (1 - m_ratio_15);
  145. double mul_5134 = (rsub_5135 * 1000);
  146. double div_5133 = safediv(mul_5134, m_delay_14);
  147. // the main sample loop;
  148. while ((__n--)) {
  149. const double in1 = (*(__in1++));
  150. double noise_5014 = noise();
  151. double abs_5031 = fabs(noise_5014);
  152. double mul_5035 = (abs_5031 * m_blur_17);
  153. double noise_5086 = noise();
  154. double abs_5104 = fabs(noise_5086);
  155. double mul_5112 = (abs_5104 * m_blur_17);
  156. double noise_5015 = noise();
  157. double abs_5032 = fabs(noise_5015);
  158. double mul_5038 = (abs_5032 * m_blur_17);
  159. double noise_5084 = noise();
  160. double abs_5102 = fabs(noise_5084);
  161. double mul_5106 = (abs_5102 * m_blur_17);
  162. double noise_5017 = noise();
  163. double abs_5034 = fabs(noise_5017);
  164. double mul_5044 = (abs_5034 * m_blur_17);
  165. double noise_5087 = noise();
  166. double abs_5105 = fabs(noise_5087);
  167. double mul_5115 = (abs_5105 * m_blur_17);
  168. double noise_5016 = noise();
  169. double abs_5033 = fabs(noise_5016);
  170. double mul_5041 = (abs_5033 * m_blur_17);
  171. double noise_5085 = noise();
  172. double abs_5103 = fabs(noise_5085);
  173. double mul_5109 = (abs_5103 * m_blur_17);
  174. double phasor_5083 = m_phasor_19(div_5062, samples_to_seconds);
  175. double add_5055 = ((phasor_5083 + m_history_9) + 0.75);
  176. double mod_5054 = safemod(add_5055, 1);
  177. double delta_5037 = m_delta_20(mod_5054);
  178. double sah_5018 = m_sah_21(mul_5035, delta_5037, 0);
  179. double sah_5036 = m_sah_22(mstosamps_5077, delta_5037, 0);
  180. double mul_5027 = (sah_5036 * mod_5054);
  181. double sub_5053 = (mod_5054 - 0.5);
  182. double mul_5052 = (sub_5053 * 3.1415926535898);
  183. double cos_5051 = cos(mul_5052);
  184. double mul_5046 = (cos_5051 * cos_5051);
  185. double add_5061 = ((phasor_5083 + m_history_8) + 0.5);
  186. double mod_5060 = safemod(add_5061, 1);
  187. double delta_5040 = m_delta_23(mod_5060);
  188. double sah_5020 = m_sah_24(mul_5038, delta_5040, 0);
  189. double sah_5039 = m_sah_25(mstosamps_5077, delta_5040, 0);
  190. double mul_5028 = (sah_5039 * mod_5060);
  191. double sub_5059 = (mod_5060 - 0.5);
  192. double mul_5058 = (sub_5059 * 3.1415926535898);
  193. double cos_5057 = cos(mul_5058);
  194. double mul_5047 = (cos_5057 * cos_5057);
  195. double add_5082 = ((phasor_5083 + m_history_7) + 0);
  196. double mod_5081 = safemod(add_5082, 1);
  197. double delta_5025 = m_delta_26(mod_5081);
  198. double sah_5024 = m_sah_27(mul_5044, delta_5025, 0);
  199. double sah_5045 = m_sah_28(mstosamps_5077, delta_5025, 0);
  200. double mul_5030 = (sah_5045 * mod_5081);
  201. double sub_5080 = (mod_5081 - 0.5);
  202. double mul_5079 = (sub_5080 * 3.1415926535898);
  203. double cos_5078 = cos(mul_5079);
  204. double mul_5049 = (cos_5078 * cos_5078);
  205. double add_5076 = ((phasor_5083 + m_history_6) + 0.25);
  206. double mod_5075 = safemod(add_5076, 1);
  207. double delta_5043 = m_delta_29(mod_5075);
  208. double sah_5022 = m_sah_30(mul_5041, delta_5043, 0);
  209. double sah_5042 = m_sah_31(mstosamps_5077, delta_5043, 0);
  210. double mul_5029 = (sah_5042 * mod_5075);
  211. double tap_5068 = m_delay_11.read_linear(mul_5030);
  212. double tap_5069 = m_delay_11.read_linear(mul_5029);
  213. double tap_5070 = m_delay_11.read_linear(mul_5028);
  214. double tap_5071 = m_delay_11.read_linear(mul_5027);
  215. double mul_5050 = (tap_5071 * mul_5046);
  216. double mul_5056 = (tap_5070 * mul_5047);
  217. double mul_5066 = (tap_5068 * mul_5049);
  218. double sub_5074 = (mod_5075 - 0.5);
  219. double mul_5073 = (sub_5074 * 3.1415926535898);
  220. double cos_5072 = cos(mul_5073);
  221. double mul_5048 = (cos_5072 * cos_5072);
  222. double mul_5065 = (tap_5069 * mul_5048);
  223. double phasor_5154 = m_phasor_32(div_5133, samples_to_seconds);
  224. double add_5147 = ((m_history_5 + phasor_5154) + 0.25);
  225. double mod_5146 = safemod(add_5147, 1);
  226. double delta_5114 = m_delta_33(mod_5146);
  227. double sah_5092 = m_sah_34(mul_5112, delta_5114, 0);
  228. double sah_5113 = m_sah_35(mstosamps_5148, delta_5114, 0);
  229. double mul_5100 = (sah_5113 * mod_5146);
  230. double sub_5145 = (mod_5146 - 0.5);
  231. double mul_5144 = (sub_5145 * 3.1415926535898);
  232. double cos_5143 = cos(mul_5144);
  233. double mul_5119 = (cos_5143 * cos_5143);
  234. double add_5126 = ((m_history_4 + phasor_5154) + 0.75);
  235. double mod_5125 = safemod(add_5126, 1);
  236. double delta_5108 = m_delta_36(mod_5125);
  237. double sah_5088 = m_sah_37(mul_5106, delta_5108, 0);
  238. double sah_5107 = m_sah_38(mstosamps_5148, delta_5108, 0);
  239. double mul_5098 = (sah_5107 * mod_5125);
  240. double sub_5124 = (mod_5125 - 0.5);
  241. double mul_5123 = (sub_5124 * 3.1415926535898);
  242. double cos_5122 = cos(mul_5123);
  243. double mul_5117 = (cos_5122 * cos_5122);
  244. double add_5153 = ((m_history_3 + phasor_5154) + 0);
  245. double mod_5152 = safemod(add_5153, 1);
  246. double delta_5095 = m_delta_39(mod_5152);
  247. double sah_5094 = m_sah_40(mul_5115, delta_5095, 0);
  248. double sah_5116 = m_sah_41(mstosamps_5148, delta_5095, 0);
  249. double mul_5101 = (sah_5116 * mod_5152);
  250. double sub_5151 = (mod_5152 - 0.5);
  251. double mul_5150 = (sub_5151 * 3.1415926535898);
  252. double cos_5149 = cos(mul_5150);
  253. double mul_5120 = (cos_5149 * cos_5149);
  254. double add_5132 = ((m_history_2 + phasor_5154) + 0.5);
  255. double mod_5131 = safemod(add_5132, 1);
  256. double delta_5111 = m_delta_42(mod_5131);
  257. double sah_5090 = m_sah_43(mul_5109, delta_5111, 0);
  258. double sah_5110 = m_sah_44(mstosamps_5148, delta_5111, 0);
  259. double mul_5099 = (sah_5110 * mod_5131);
  260. double tap_5139 = m_delay_10.read_linear(mul_5101);
  261. double tap_5140 = m_delay_10.read_linear(mul_5100);
  262. double tap_5141 = m_delay_10.read_linear(mul_5099);
  263. double tap_5142 = m_delay_10.read_linear(mul_5098);
  264. double mul_5137 = (tap_5139 * mul_5120);
  265. double mul_5136 = (tap_5140 * mul_5119);
  266. double mul_5121 = (tap_5142 * mul_5117);
  267. double sub_5130 = (mod_5131 - 0.5);
  268. double mul_5129 = (sub_5130 * 3.1415926535898);
  269. double cos_5128 = cos(mul_5129);
  270. double mul_5118 = (cos_5128 * cos_5128);
  271. double mul_5127 = (tap_5141 * mul_5118);
  272. double add_5174 = (((((((mul_5066 + mul_5065) + mul_5056) + mul_5050) + mul_5121) + mul_5127) + mul_5136) + mul_5137);
  273. double mix_5173 = (m_y_1 + (clamp_5013 * (add_5174 - m_y_1)));
  274. double mix_5010 = mix_5173;
  275. double mix_5175 = (in1 + (m_mix_13 * (mix_5010 - in1)));
  276. double out1 = mix_5175;
  277. double history_5019_next_5156 = sah_5018;
  278. double history_5021_next_5157 = sah_5020;
  279. double history_5026_next_5158 = sah_5024;
  280. double history_5023_next_5159 = sah_5022;
  281. double history_5093_next_5160 = sah_5092;
  282. double history_5089_next_5161 = sah_5088;
  283. double history_5096_next_5162 = sah_5094;
  284. double history_5091_next_5163 = sah_5090;
  285. double y0_next_5164 = mix_5010;
  286. m_delay_11.write(in1);
  287. m_delay_10.write(in1);
  288. m_history_9 = history_5019_next_5156;
  289. m_history_8 = history_5021_next_5157;
  290. m_history_7 = history_5026_next_5158;
  291. m_history_6 = history_5023_next_5159;
  292. m_history_5 = history_5093_next_5160;
  293. m_history_4 = history_5089_next_5161;
  294. m_history_3 = history_5096_next_5162;
  295. m_history_2 = history_5091_next_5163;
  296. m_y_1 = y0_next_5164;
  297. m_delay_10.step();
  298. m_delay_11.step();
  299. // assign results to output buffer;
  300. (*(__out1++)) = out1;
  301. };
  302. return __exception;
  303. };
  304. inline void set_ratio2(double _value) {
  305. m_ratio_12 = (_value < 0.5 ? 0.5 : (_value > 2 ? 2 : _value));
  306. };
  307. inline void set_mix(double _value) {
  308. m_mix_13 = (_value < 0 ? 0 : (_value > 1 ? 1 : _value));
  309. };
  310. inline void set_delay1(double _value) {
  311. m_delay_14 = (_value < 0.1 ? 0.1 : (_value > 1000 ? 1000 : _value));
  312. };
  313. inline void set_ratio1(double _value) {
  314. m_ratio_15 = (_value < 0.5 ? 0.5 : (_value > 2 ? 2 : _value));
  315. };
  316. inline void set_cutoff(double _value) {
  317. m_cutoff_16 = (_value < 0 ? 0 : (_value > 3000 ? 3000 : _value));
  318. };
  319. inline void set_blur(double _value) {
  320. m_blur_17 = (_value < 0.01 ? 0.01 : (_value > 0.25 ? 0.25 : _value));
  321. };
  322. inline void set_delay2(double _value) {
  323. m_delay_18 = (_value < 0.1 ? 0.1 : (_value > 1000 ? 1000 : _value));
  324. };
  325. } State;
  326. ///
  327. /// Configuration for the genlib API
  328. ///
  329. /// Number of signal inputs and outputs
  330. int gen_kernel_numins = 1;
  331. int gen_kernel_numouts = 1;
  332. int num_inputs() { return gen_kernel_numins; }
  333. int num_outputs() { return gen_kernel_numouts; }
  334. int num_params() { return 7; }
  335. /// Assistive lables for the signal inputs and outputs
  336. const char * gen_kernel_innames[] = { "in1" };
  337. const char * gen_kernel_outnames[] = { "out1" };
  338. /// Invoke the signal process of a State object
  339. int perform(CommonState *cself, t_sample **ins, long numins, t_sample **outs, long numouts, long n) {
  340. State * self = (State *)cself;
  341. return self->perform(ins, outs, n);
  342. }
  343. /// Reset all parameters and stateful operators of a State object
  344. void reset(CommonState *cself) {
  345. State * self = (State *)cself;
  346. self->reset(cself->sr, cself->vs);
  347. }
  348. /// Set a parameter of a State object
  349. void setparameter(CommonState *cself, long index, double value, void *ref) {
  350. State * self = (State *)cself;
  351. switch (index) {
  352. case 0: self->set_ratio2(value); break;
  353. case 1: self->set_mix(value); break;
  354. case 2: self->set_delay1(value); break;
  355. case 3: self->set_ratio1(value); break;
  356. case 4: self->set_cutoff(value); break;
  357. case 5: self->set_blur(value); break;
  358. case 6: self->set_delay2(value); break;
  359. default: break;
  360. }
  361. }
  362. /// Get the value of a parameter of a State object
  363. void getparameter(CommonState *cself, long index, double *value) {
  364. State *self = (State *)cself;
  365. switch (index) {
  366. case 0: *value = self->m_ratio_12; break;
  367. case 1: *value = self->m_mix_13; break;
  368. case 2: *value = self->m_delay_14; break;
  369. case 3: *value = self->m_ratio_15; break;
  370. case 4: *value = self->m_cutoff_16; break;
  371. case 5: *value = self->m_blur_17; break;
  372. case 6: *value = self->m_delay_18; break;
  373. default: break;
  374. }
  375. }
  376. /// Allocate and configure a new State object and it's internal CommonState:
  377. void * create(double sr, long vs) {
  378. State *self = new State;
  379. self->reset(sr, vs);
  380. ParamInfo *pi;
  381. self->__commonstate.inputnames = gen_kernel_innames;
  382. self->__commonstate.outputnames = gen_kernel_outnames;
  383. self->__commonstate.numins = gen_kernel_numins;
  384. self->__commonstate.numouts = gen_kernel_numouts;
  385. self->__commonstate.sr = sr;
  386. self->__commonstate.vs = vs;
  387. self->__commonstate.params = (ParamInfo *)genlib_sysmem_newptr(7 * sizeof(ParamInfo));
  388. self->__commonstate.numparams = 7;
  389. // initialize parameter 0 ("m_ratio_12")
  390. pi = self->__commonstate.params + 0;
  391. pi->name = "ratio2";
  392. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  393. pi->defaultvalue = self->m_ratio_12;
  394. pi->defaultref = 0;
  395. pi->hasinputminmax = false;
  396. pi->inputmin = 0;
  397. pi->inputmax = 1;
  398. pi->hasminmax = true;
  399. pi->outputmin = 0.5;
  400. pi->outputmax = 2;
  401. pi->exp = 0;
  402. pi->units = ""; // no units defined
  403. // initialize parameter 1 ("m_mix_13")
  404. pi = self->__commonstate.params + 1;
  405. pi->name = "mix";
  406. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  407. pi->defaultvalue = self->m_mix_13;
  408. pi->defaultref = 0;
  409. pi->hasinputminmax = false;
  410. pi->inputmin = 0;
  411. pi->inputmax = 1;
  412. pi->hasminmax = true;
  413. pi->outputmin = 0;
  414. pi->outputmax = 1;
  415. pi->exp = 0;
  416. pi->units = ""; // no units defined
  417. // initialize parameter 2 ("m_delay_14")
  418. pi = self->__commonstate.params + 2;
  419. pi->name = "delay1";
  420. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  421. pi->defaultvalue = self->m_delay_14;
  422. pi->defaultref = 0;
  423. pi->hasinputminmax = false;
  424. pi->inputmin = 0;
  425. pi->inputmax = 1;
  426. pi->hasminmax = true;
  427. pi->outputmin = 0.1;
  428. pi->outputmax = 1000;
  429. pi->exp = 0;
  430. pi->units = ""; // no units defined
  431. // initialize parameter 3 ("m_ratio_15")
  432. pi = self->__commonstate.params + 3;
  433. pi->name = "ratio1";
  434. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  435. pi->defaultvalue = self->m_ratio_15;
  436. pi->defaultref = 0;
  437. pi->hasinputminmax = false;
  438. pi->inputmin = 0;
  439. pi->inputmax = 1;
  440. pi->hasminmax = true;
  441. pi->outputmin = 0.5;
  442. pi->outputmax = 2;
  443. pi->exp = 0;
  444. pi->units = ""; // no units defined
  445. // initialize parameter 4 ("m_cutoff_16")
  446. pi = self->__commonstate.params + 4;
  447. pi->name = "cutoff";
  448. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  449. pi->defaultvalue = self->m_cutoff_16;
  450. pi->defaultref = 0;
  451. pi->hasinputminmax = false;
  452. pi->inputmin = 0;
  453. pi->inputmax = 1;
  454. pi->hasminmax = true;
  455. pi->outputmin = 0;
  456. pi->outputmax = 3000;
  457. pi->exp = 0;
  458. pi->units = ""; // no units defined
  459. // initialize parameter 5 ("m_blur_17")
  460. pi = self->__commonstate.params + 5;
  461. pi->name = "blur";
  462. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  463. pi->defaultvalue = self->m_blur_17;
  464. pi->defaultref = 0;
  465. pi->hasinputminmax = false;
  466. pi->inputmin = 0;
  467. pi->inputmax = 1;
  468. pi->hasminmax = true;
  469. pi->outputmin = 0.01;
  470. pi->outputmax = 0.25;
  471. pi->exp = 0;
  472. pi->units = ""; // no units defined
  473. // initialize parameter 6 ("m_delay_18")
  474. pi = self->__commonstate.params + 6;
  475. pi->name = "delay2";
  476. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  477. pi->defaultvalue = self->m_delay_18;
  478. pi->defaultref = 0;
  479. pi->hasinputminmax = false;
  480. pi->inputmin = 0;
  481. pi->inputmax = 1;
  482. pi->hasminmax = true;
  483. pi->outputmin = 0.1;
  484. pi->outputmax = 1000;
  485. pi->exp = 0;
  486. pi->units = ""; // no units defined
  487. return self;
  488. }
  489. /// Release all resources and memory used by a State object:
  490. void destroy(CommonState *cself) {
  491. State * self = (State *)cself;
  492. genlib_sysmem_freeptr(cself->params);
  493. delete self;
  494. }
  495. } // gen_exported::