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.

663 lines
22KB

  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_22;
  25. Delay m_delay_14;
  26. Delay m_delay_15;
  27. Delay m_delay_13;
  28. Delay m_delay_12;
  29. Delay m_delay_23;
  30. Delay m_delay_16;
  31. Delay m_delay_18;
  32. Delay m_delay_17;
  33. Delay m_delay_20;
  34. Delay m_delay_19;
  35. Delay m_delay_21;
  36. Delay m_delay_24;
  37. Delta m_delta_34;
  38. Delta m_delta_43;
  39. Delta m_delta_37;
  40. Delta m_delta_40;
  41. Phasor m_phasor_33;
  42. Sah m_sah_42;
  43. Sah m_sah_41;
  44. Sah m_sah_39;
  45. Sah m_sah_36;
  46. Sah m_sah_38;
  47. Sah m_sah_35;
  48. Sah m_sah_44;
  49. Sah m_sah_45;
  50. double m_history_10;
  51. double m_history_5;
  52. double m_history_6;
  53. double m_history_7;
  54. double m_smth_11;
  55. double m_history_4;
  56. double m_y_2;
  57. double m_history_3;
  58. double samplerate;
  59. double m_history_1;
  60. double m_history_9;
  61. double m_history_8;
  62. double m_ratio_32;
  63. double samples_to_seconds;
  64. double m_mix_26;
  65. double m_bandwidth_25;
  66. double m_damping_28;
  67. double m_decay_27;
  68. double m_tone_30;
  69. double m_shimmer_31;
  70. double m_roomsize_29;
  71. int vectorsize;
  72. int __exception;
  73. // re-initialize all member variables;
  74. inline void reset(double __sr, int __vs) {
  75. __exception = 0;
  76. vectorsize = __vs;
  77. samplerate = __sr;
  78. m_history_1 = 0;
  79. m_y_2 = 0;
  80. m_history_3 = 0;
  81. m_history_4 = 0;
  82. m_history_5 = 0;
  83. m_history_6 = 0;
  84. m_history_7 = 0;
  85. m_history_8 = 0;
  86. m_history_9 = 0;
  87. m_history_10 = 0;
  88. m_smth_11 = 0;
  89. m_delay_12.reset("m_delay_12", 7000);
  90. m_delay_13.reset("m_delay_13", 5000);
  91. m_delay_14.reset("m_delay_14", 6000);
  92. m_delay_15.reset("m_delay_15", 48000);
  93. m_delay_16.reset("m_delay_16", 16000);
  94. m_delay_17.reset("m_delay_17", 96000);
  95. m_delay_18.reset("m_delay_18", 15000);
  96. m_delay_19.reset("m_delay_19", 12000);
  97. m_delay_20.reset("m_delay_20", 10000);
  98. m_delay_21.reset("m_delay_21", 48000);
  99. m_delay_22.reset("m_delay_22", 48000);
  100. m_delay_23.reset("m_delay_23", 48000);
  101. m_delay_24.reset("m_delay_24", 48000);
  102. m_bandwidth_25 = 75;
  103. m_mix_26 = 50;
  104. m_decay_27 = 50;
  105. m_damping_28 = 50;
  106. m_roomsize_29 = 150;
  107. m_tone_30 = 1500;
  108. m_shimmer_31 = 50;
  109. m_ratio_32 = 2;
  110. samples_to_seconds = (1 / samplerate);
  111. m_phasor_33.reset(0);
  112. m_delta_34.reset(0);
  113. m_sah_35.reset(0);
  114. m_sah_36.reset(0);
  115. m_delta_37.reset(0);
  116. m_sah_38.reset(0);
  117. m_sah_39.reset(0);
  118. m_delta_40.reset(0);
  119. m_sah_41.reset(0);
  120. m_sah_42.reset(0);
  121. m_delta_43.reset(0);
  122. m_sah_44.reset(0);
  123. m_sah_45.reset(0);
  124. genlib_reset_complete(this);
  125. };
  126. // the signal processing routine;
  127. inline int perform(t_sample ** __ins, t_sample ** __outs, int __n) {
  128. vectorsize = __n;
  129. const t_sample * __in1 = __ins[0];
  130. t_sample * __out1 = __outs[0];
  131. t_sample * __out2 = __outs[1];
  132. if (__exception) {
  133. return __exception;
  134. } else if (( (__in1 == 0) || (__out1 == 0) || (__out2 == 0) )) {
  135. __exception = GENLIB_ERR_NULL_BUFFER;
  136. return __exception;
  137. };
  138. double mul_5308 = (m_mix_26 * 0.01);
  139. double mul_5307 = (m_damping_28 * 0.01);
  140. double expr_5535 = safediv((m_roomsize_29 * 48000), 340);
  141. double mul_5306 = (m_bandwidth_25 * 0.01);
  142. double rsub_5305 = (1 - mul_5306);
  143. double mul_5309 = (m_shimmer_31 * 0.01);
  144. double expr_5525 = safediv(((m_tone_30 * 2) * 3.1415926535898), 48000);
  145. double sin_5313 = sin(expr_5525);
  146. double clamp_5314 = ((sin_5313 <= 1e-05) ? 1e-05 : ((sin_5313 >= 0.99999) ? 0.99999 : sin_5313));
  147. double expr_5524 = safepow(1.0418, m_decay_27);
  148. double expr_5534 = safepow(0.001, safediv(1, (expr_5524 * 48000)));
  149. double rsub_5364 = (1 - m_ratio_32);
  150. double mul_5363 = (rsub_5364 * 10);
  151. samples_to_seconds = (1 / samplerate);
  152. double mul_5303 = (m_decay_27 * 2);
  153. double clamp_5298 = ((mul_5303 <= 0) ? 0 : ((mul_5303 >= 100) ? 100 : mul_5303));
  154. double mul_5302 = (clamp_5298 * 0.01);
  155. double atodb_5301 = atodb(mul_5302);
  156. double sub_5300 = (atodb_5301 - 9);
  157. double dbtoa_5299 = dbtoa(sub_5300);
  158. // the main sample loop;
  159. while ((__n--)) {
  160. const double in1 = (*(__in1++));
  161. double mix_5568 = (expr_5535 + (0.999 * (m_smth_11 - expr_5535)));
  162. double mix_5297 = mix_5568;
  163. double noise_5315 = noise();
  164. double abs_5332 = fabs(noise_5315);
  165. double mul_5336 = (abs_5332 * 0.25);
  166. double noise_5316 = noise();
  167. double abs_5333 = fabs(noise_5316);
  168. double mul_5339 = (abs_5333 * 0.25);
  169. double noise_5317 = noise();
  170. double abs_5334 = fabs(noise_5317);
  171. double mul_5342 = (abs_5334 * 0.25);
  172. double mul_5514 = (mix_5297 * 0.81649);
  173. double tap_5438 = m_delay_24.read_linear(mul_5514);
  174. double noise_5318 = noise();
  175. double abs_5335 = fabs(noise_5318);
  176. double mul_5345 = (abs_5335 * 0.25);
  177. double mul_5513 = (mix_5297 * 0.7071);
  178. double tap_5432 = m_delay_23.read_linear(mul_5513);
  179. double mul_5512 = (mix_5297 * 0.63245);
  180. double tap_5426 = m_delay_22.read_linear(mul_5512);
  181. double mul_5515 = (mix_5297 * 1);
  182. double tap_5520 = m_delay_21.read_linear(mul_5515);
  183. double expr_5528 = (-safepow(expr_5534, mul_5514));
  184. double mul_5434 = (tap_5438 * expr_5528);
  185. double mix_5569 = (mul_5434 + (mul_5307 * (m_history_10 - mul_5434)));
  186. double mix_5436 = mix_5569;
  187. double expr_5527 = (-safepow(expr_5534, mul_5513));
  188. double mul_5428 = (tap_5432 * expr_5527);
  189. double mix_5570 = (mul_5428 + (mul_5307 * (m_history_9 - mul_5428)));
  190. double mix_5430 = mix_5570;
  191. double expr_5526 = (-safepow(expr_5534, mul_5512));
  192. double mul_5422 = (tap_5426 * expr_5526);
  193. double mix_5571 = (mul_5422 + (mul_5307 * (m_history_8 - mul_5422)));
  194. double mix_5424 = mix_5571;
  195. double expr_5533 = (-safepow(expr_5534, mul_5515));
  196. double mul_5511 = (tap_5520 * expr_5533);
  197. double mix_5572 = (mul_5511 + (mul_5307 * (m_history_7 - mul_5511)));
  198. double mix_5518 = mix_5572;
  199. double mul_5509 = (mix_5297 * 0.000527);
  200. int int_5508 = int(mul_5509);
  201. double mul_5486 = (int_5508 * 400.600006);
  202. double tap_5485 = m_delay_20.read_linear(mul_5486);
  203. double mul_5483 = (tap_5485 * 0.625);
  204. double mul_5465 = (int_5508 * 419.5);
  205. double tap_5464 = m_delay_19.read_linear(mul_5465);
  206. double mul_5462 = (tap_5464 * 0.625);
  207. double mul_5493 = (int_5508 * 568.299988);
  208. double tap_5492 = m_delay_18.read_linear(mul_5493);
  209. double phasor_5382 = m_phasor_33(mul_5363, samples_to_seconds);
  210. double add_5356 = ((m_history_6 + phasor_5382) + 0.75);
  211. double mod_5355 = safemod(add_5356, 1);
  212. double delta_5338 = m_delta_34(mod_5355);
  213. double sah_5319 = m_sah_35(mul_5336, delta_5338, 0);
  214. int sah_5337 = m_sah_36(4800, delta_5338, 0);
  215. double mul_5328 = (sah_5337 * mod_5355);
  216. double sub_5354 = (mod_5355 - 0.5);
  217. double mul_5353 = (sub_5354 * 3.1415926535898);
  218. double cos_5352 = cos(mul_5353);
  219. double mul_5347 = (cos_5352 * cos_5352);
  220. double add_5362 = ((m_history_5 + phasor_5382) + 0.5);
  221. double mod_5361 = safemod(add_5362, 1);
  222. double delta_5341 = m_delta_37(mod_5361);
  223. double sah_5321 = m_sah_38(mul_5339, delta_5341, 0);
  224. int sah_5340 = m_sah_39(4800, delta_5341, 0);
  225. double mul_5329 = (sah_5340 * mod_5361);
  226. double sub_5360 = (mod_5361 - 0.5);
  227. double mul_5359 = (sub_5360 * 3.1415926535898);
  228. double cos_5358 = cos(mul_5359);
  229. double mul_5348 = (cos_5358 * cos_5358);
  230. double add_5376 = ((m_history_4 + phasor_5382) + 0.25);
  231. double mod_5375 = safemod(add_5376, 1);
  232. double delta_5344 = m_delta_40(mod_5375);
  233. double sah_5323 = m_sah_41(mul_5342, delta_5344, 0);
  234. int sah_5343 = m_sah_42(4800, delta_5344, 0);
  235. double mul_5330 = (sah_5343 * mod_5375);
  236. double sub_5374 = (mod_5375 - 0.5);
  237. double mul_5373 = (sub_5374 * 3.1415926535898);
  238. double cos_5372 = cos(mul_5373);
  239. double mul_5349 = (cos_5372 * cos_5372);
  240. double add_5381 = ((m_history_3 + phasor_5382) + 0);
  241. double mod_5380 = safemod(add_5381, 1);
  242. double delta_5326 = m_delta_43(mod_5380);
  243. double sah_5325 = m_sah_44(mul_5345, delta_5326, 0);
  244. int sah_5346 = m_sah_45(4800, delta_5326, 0);
  245. double mul_5331 = (sah_5346 * mod_5380);
  246. double tap_5368 = m_delay_17.read_linear(mul_5331);
  247. double tap_5369 = m_delay_17.read_linear(mul_5330);
  248. double tap_5370 = m_delay_17.read_linear(mul_5329);
  249. double tap_5371 = m_delay_17.read_linear(mul_5328);
  250. double mul_5351 = (tap_5371 * mul_5347);
  251. double mul_5357 = (tap_5370 * mul_5348);
  252. double mul_5365 = (tap_5369 * mul_5349);
  253. double sub_5379 = (mod_5380 - 0.5);
  254. double mul_5378 = (sub_5379 * 3.1415926535898);
  255. double cos_5377 = cos(mul_5378);
  256. double mul_5350 = (cos_5377 * cos_5377);
  257. double mul_5366 = (tap_5368 * mul_5350);
  258. double add_5574 = (((mul_5366 + mul_5365) + mul_5357) + mul_5351);
  259. double mix_5573 = (m_y_2 + (clamp_5314 * (add_5574 - m_y_2)));
  260. double mix_5311 = mix_5573;
  261. double mix_5575 = (in1 + (mul_5309 * (mix_5311 - in1)));
  262. double mix_5383 = mix_5575;
  263. double mul_5386 = (mix_5383 * 0.707);
  264. double mix_5576 = (mul_5386 + (rsub_5305 * (m_history_1 - mul_5386)));
  265. double mix_5522 = mix_5576;
  266. double sub_5415 = (mix_5518 - mix_5436);
  267. double sub_5412 = (mix_5430 - mix_5424);
  268. double sub_5411 = (sub_5415 - sub_5412);
  269. double mul_5394 = (sub_5411 * 0.5);
  270. double add_5452 = (mix_5297 + 5);
  271. double expr_5529 = safepow(expr_5534, add_5452);
  272. double add_5410 = (sub_5415 + sub_5412);
  273. double rsub_5408 = (0 - add_5410);
  274. double mul_5393 = (rsub_5408 * 0.5);
  275. double mul_5472 = (int_5508 * 566.700012);
  276. double tap_5471 = m_delay_16.read_linear(mul_5472);
  277. double add_5416 = (mix_5518 + mix_5436);
  278. double add_5414 = (mix_5430 + mix_5424);
  279. double add_5409 = (add_5416 + add_5414);
  280. double mul_5392 = (add_5409 * 0.5);
  281. double sub_5413 = (add_5416 - add_5414);
  282. double mul_5395 = (sub_5413 * 0.5);
  283. double mul_5490 = (tap_5492 * 0.625);
  284. double mul_5458 = (mix_5297 * 0.41);
  285. double add_5455 = (mul_5458 + 5);
  286. double expr_5532 = safepow(expr_5534, add_5455);
  287. double mul_5457 = (mix_5297 * 0.3);
  288. double add_5454 = (mul_5457 + 5);
  289. double expr_5531 = safepow(expr_5534, add_5454);
  290. double mul_5456 = (mix_5297 * 0.155);
  291. double add_5453 = (mul_5456 + 5);
  292. double tap_5440 = m_delay_15.read_linear(add_5455);
  293. double tap_5441 = m_delay_15.read_linear(add_5454);
  294. double tap_5442 = m_delay_15.read_linear(add_5453);
  295. double tap_5443 = m_delay_15.read_linear(add_5452);
  296. double mul_5448 = (tap_5441 * expr_5531);
  297. double add_5419 = (mul_5394 + mul_5448);
  298. double mul_5444 = (tap_5443 * expr_5529);
  299. double add_5417 = (mul_5392 + mul_5444);
  300. double mul_5450 = (tap_5440 * expr_5532);
  301. double add_5420 = (mul_5395 + mul_5450);
  302. double expr_5530 = safepow(expr_5534, add_5453);
  303. double mul_5446 = (tap_5442 * expr_5530);
  304. double add_5418 = (mul_5393 + mul_5446);
  305. double mul_5469 = (tap_5471 * 0.625);
  306. double mul_5507 = (mix_5297 * 0.110732);
  307. double tap_5506 = m_delay_14.read_cubic(mul_5507);
  308. double mul_5500 = (int_5508 * 162.100006);
  309. double tap_5499 = m_delay_13.read_linear(mul_5500);
  310. double mul_5504 = (tap_5506 * 0.75);
  311. double sub_5503 = (mix_5522 - mul_5504);
  312. double mul_5502 = (sub_5503 * 0.75);
  313. double add_5501 = (mul_5502 + tap_5506);
  314. double mul_5479 = (int_5508 * 144.800003);
  315. double tap_5478 = m_delay_12.read_linear(mul_5479);
  316. double mul_5497 = (tap_5499 * 0.75);
  317. double mul_5476 = (tap_5478 * 0.75);
  318. double mul_5403 = (mul_5450 * mul_5302);
  319. double mul_5401 = (mul_5446 * mul_5302);
  320. double add_5389 = (mul_5403 + mul_5401);
  321. double mul_5402 = (mul_5448 * mul_5302);
  322. double mul_5400 = (mul_5444 * mul_5302);
  323. double add_5388 = (mul_5402 + mul_5400);
  324. double sub_5398 = (add_5389 - add_5388);
  325. double mul_5407 = (mul_5395 * dbtoa_5299);
  326. double mul_5405 = (mul_5393 * dbtoa_5299);
  327. double add_5391 = (mul_5407 + mul_5405);
  328. double mul_5406 = (mul_5394 * dbtoa_5299);
  329. double mul_5404 = (mul_5392 * dbtoa_5299);
  330. double add_5390 = (mul_5406 + mul_5404);
  331. double sub_5399 = (add_5391 - add_5390);
  332. double add_5385 = (sub_5399 + sub_5398);
  333. double add_5397 = (add_5385 + mix_5383);
  334. double sub_5496 = (add_5397 - mul_5497);
  335. double mul_5495 = (sub_5496 * 0.75);
  336. double add_5494 = (mul_5495 + tap_5499);
  337. double sub_5489 = (add_5494 - mul_5490);
  338. double mul_5488 = (sub_5489 * 0.625);
  339. double add_5487 = (mul_5488 + tap_5492);
  340. double sub_5482 = (add_5487 - mul_5483);
  341. double mul_5481 = (sub_5482 * 0.625);
  342. double add_5480 = (mul_5481 + tap_5485);
  343. double mul_5396 = (add_5480 * mul_5308);
  344. double out1 = (in1 + mul_5396);
  345. double add_5387 = (add_5385 + mix_5383);
  346. double sub_5475 = (add_5387 - mul_5476);
  347. double mul_5474 = (sub_5475 * 0.75);
  348. double add_5473 = (mul_5474 + tap_5478);
  349. double sub_5468 = (add_5473 - mul_5469);
  350. double mul_5467 = (sub_5468 * 0.625);
  351. double add_5466 = (mul_5467 + tap_5471);
  352. double sub_5461 = (add_5466 - mul_5462);
  353. double mul_5460 = (sub_5461 * 0.625);
  354. double add_5459 = (mul_5460 + tap_5464);
  355. double mul_5384 = (add_5459 * mul_5308);
  356. double out2 = (in1 + mul_5384);
  357. double smth_next_5536 = mix_5297;
  358. double history_5435_next_5537 = mix_5436;
  359. double history_5429_next_5538 = mix_5430;
  360. double history_5423_next_5539 = mix_5424;
  361. double history_5517_next_5540 = mix_5518;
  362. double history_5320_next_5541 = sah_5319;
  363. double history_5322_next_5542 = sah_5321;
  364. double history_5324_next_5543 = sah_5323;
  365. double history_5327_next_5544 = sah_5325;
  366. double y0_next_5545 = mix_5311;
  367. double history_5521_next_5546 = mix_5522;
  368. m_delay_24.write(add_5419);
  369. m_delay_23.write(add_5418);
  370. m_delay_22.write(add_5417);
  371. m_delay_21.write(add_5420);
  372. m_delay_20.write(sub_5482);
  373. m_delay_19.write(sub_5461);
  374. m_delay_18.write(sub_5489);
  375. m_delay_17.write(in1);
  376. m_delay_16.write(sub_5468);
  377. m_delay_15.write(add_5501);
  378. m_delay_14.write(sub_5503);
  379. m_delay_13.write(sub_5496);
  380. m_delay_12.write(sub_5475);
  381. m_smth_11 = smth_next_5536;
  382. m_history_10 = history_5435_next_5537;
  383. m_history_9 = history_5429_next_5538;
  384. m_history_8 = history_5423_next_5539;
  385. m_history_7 = history_5517_next_5540;
  386. m_history_6 = history_5320_next_5541;
  387. m_history_5 = history_5322_next_5542;
  388. m_history_4 = history_5324_next_5543;
  389. m_history_3 = history_5327_next_5544;
  390. m_y_2 = y0_next_5545;
  391. m_history_1 = history_5521_next_5546;
  392. m_delay_12.step();
  393. m_delay_13.step();
  394. m_delay_14.step();
  395. m_delay_15.step();
  396. m_delay_16.step();
  397. m_delay_17.step();
  398. m_delay_18.step();
  399. m_delay_19.step();
  400. m_delay_20.step();
  401. m_delay_21.step();
  402. m_delay_22.step();
  403. m_delay_23.step();
  404. m_delay_24.step();
  405. // assign results to output buffer;
  406. (*(__out1++)) = out1;
  407. (*(__out2++)) = out2;
  408. };
  409. return __exception;
  410. };
  411. inline void set_bandwidth(double _value) {
  412. m_bandwidth_25 = (_value < 0 ? 0 : (_value > 100 ? 100 : _value));
  413. };
  414. inline void set_mix(double _value) {
  415. m_mix_26 = (_value < 0 ? 0 : (_value > 100 ? 100 : _value));
  416. };
  417. inline void set_decay(double _value) {
  418. m_decay_27 = (_value < 1 ? 1 : (_value > 100 ? 100 : _value));
  419. };
  420. inline void set_damping(double _value) {
  421. m_damping_28 = (_value < 0 ? 0 : (_value > 100 ? 100 : _value));
  422. };
  423. inline void set_roomsize(double _value) {
  424. m_roomsize_29 = (_value < 1 ? 1 : (_value > 300 ? 300 : _value));
  425. };
  426. inline void set_tone(double _value) {
  427. m_tone_30 = (_value < 500 ? 500 : (_value > 6000 ? 6000 : _value));
  428. };
  429. inline void set_shimmer(double _value) {
  430. m_shimmer_31 = (_value < 0 ? 0 : (_value > 100 ? 100 : _value));
  431. };
  432. inline void set_ratio(double _value) {
  433. m_ratio_32 = (_value < 0.5 ? 0.5 : (_value > 2 ? 2 : _value));
  434. };
  435. } State;
  436. ///
  437. /// Configuration for the genlib API
  438. ///
  439. /// Number of signal inputs and outputs
  440. int gen_kernel_numins = 1;
  441. int gen_kernel_numouts = 2;
  442. int num_inputs() { return gen_kernel_numins; }
  443. int num_outputs() { return gen_kernel_numouts; }
  444. int num_params() { return 8; }
  445. /// Assistive lables for the signal inputs and outputs
  446. const char * gen_kernel_innames[] = { "in1" };
  447. const char * gen_kernel_outnames[] = { "out1", "out2" };
  448. /// Invoke the signal process of a State object
  449. int perform(CommonState *cself, t_sample **ins, long numins, t_sample **outs, long numouts, long n) {
  450. State * self = (State *)cself;
  451. return self->perform(ins, outs, n);
  452. }
  453. /// Reset all parameters and stateful operators of a State object
  454. void reset(CommonState *cself) {
  455. State * self = (State *)cself;
  456. self->reset(cself->sr, cself->vs);
  457. }
  458. /// Set a parameter of a State object
  459. void setparameter(CommonState *cself, long index, double value, void *ref) {
  460. State * self = (State *)cself;
  461. switch (index) {
  462. case 0: self->set_bandwidth(value); break;
  463. case 1: self->set_mix(value); break;
  464. case 2: self->set_decay(value); break;
  465. case 3: self->set_damping(value); break;
  466. case 4: self->set_roomsize(value); break;
  467. case 5: self->set_tone(value); break;
  468. case 6: self->set_shimmer(value); break;
  469. case 7: self->set_ratio(value); break;
  470. default: break;
  471. }
  472. }
  473. /// Get the value of a parameter of a State object
  474. void getparameter(CommonState *cself, long index, double *value) {
  475. State *self = (State *)cself;
  476. switch (index) {
  477. case 0: *value = self->m_bandwidth_25; break;
  478. case 1: *value = self->m_mix_26; break;
  479. case 2: *value = self->m_decay_27; break;
  480. case 3: *value = self->m_damping_28; break;
  481. case 4: *value = self->m_roomsize_29; break;
  482. case 5: *value = self->m_tone_30; break;
  483. case 6: *value = self->m_shimmer_31; break;
  484. case 7: *value = self->m_ratio_32; break;
  485. default: break;
  486. }
  487. }
  488. /// Allocate and configure a new State object and it's internal CommonState:
  489. void * create(double sr, long vs) {
  490. State *self = new State;
  491. self->reset(sr, vs);
  492. ParamInfo *pi;
  493. self->__commonstate.inputnames = gen_kernel_innames;
  494. self->__commonstate.outputnames = gen_kernel_outnames;
  495. self->__commonstate.numins = gen_kernel_numins;
  496. self->__commonstate.numouts = gen_kernel_numouts;
  497. self->__commonstate.sr = sr;
  498. self->__commonstate.vs = vs;
  499. self->__commonstate.params = (ParamInfo *)genlib_sysmem_newptr(8 * sizeof(ParamInfo));
  500. self->__commonstate.numparams = 8;
  501. // initialize parameter 0 ("m_bandwidth_25")
  502. pi = self->__commonstate.params + 0;
  503. pi->name = "bandwidth";
  504. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  505. pi->defaultvalue = self->m_bandwidth_25;
  506. pi->defaultref = 0;
  507. pi->hasinputminmax = false;
  508. pi->inputmin = 0;
  509. pi->inputmax = 1;
  510. pi->hasminmax = true;
  511. pi->outputmin = 0;
  512. pi->outputmax = 100;
  513. pi->exp = 0;
  514. pi->units = ""; // no units defined
  515. // initialize parameter 1 ("m_mix_26")
  516. pi = self->__commonstate.params + 1;
  517. pi->name = "mix";
  518. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  519. pi->defaultvalue = self->m_mix_26;
  520. pi->defaultref = 0;
  521. pi->hasinputminmax = false;
  522. pi->inputmin = 0;
  523. pi->inputmax = 1;
  524. pi->hasminmax = true;
  525. pi->outputmin = 0;
  526. pi->outputmax = 100;
  527. pi->exp = 0;
  528. pi->units = ""; // no units defined
  529. // initialize parameter 2 ("m_decay_27")
  530. pi = self->__commonstate.params + 2;
  531. pi->name = "decay";
  532. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  533. pi->defaultvalue = self->m_decay_27;
  534. pi->defaultref = 0;
  535. pi->hasinputminmax = false;
  536. pi->inputmin = 0;
  537. pi->inputmax = 1;
  538. pi->hasminmax = true;
  539. pi->outputmin = 1;
  540. pi->outputmax = 100;
  541. pi->exp = 0;
  542. pi->units = ""; // no units defined
  543. // initialize parameter 3 ("m_damping_28")
  544. pi = self->__commonstate.params + 3;
  545. pi->name = "damping";
  546. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  547. pi->defaultvalue = self->m_damping_28;
  548. pi->defaultref = 0;
  549. pi->hasinputminmax = false;
  550. pi->inputmin = 0;
  551. pi->inputmax = 1;
  552. pi->hasminmax = true;
  553. pi->outputmin = 0;
  554. pi->outputmax = 100;
  555. pi->exp = 0;
  556. pi->units = ""; // no units defined
  557. // initialize parameter 4 ("m_roomsize_29")
  558. pi = self->__commonstate.params + 4;
  559. pi->name = "roomsize";
  560. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  561. pi->defaultvalue = self->m_roomsize_29;
  562. pi->defaultref = 0;
  563. pi->hasinputminmax = false;
  564. pi->inputmin = 0;
  565. pi->inputmax = 1;
  566. pi->hasminmax = true;
  567. pi->outputmin = 1;
  568. pi->outputmax = 300;
  569. pi->exp = 0;
  570. pi->units = ""; // no units defined
  571. // initialize parameter 5 ("m_tone_30")
  572. pi = self->__commonstate.params + 5;
  573. pi->name = "tone";
  574. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  575. pi->defaultvalue = self->m_tone_30;
  576. pi->defaultref = 0;
  577. pi->hasinputminmax = false;
  578. pi->inputmin = 0;
  579. pi->inputmax = 1;
  580. pi->hasminmax = true;
  581. pi->outputmin = 500;
  582. pi->outputmax = 6000;
  583. pi->exp = 0;
  584. pi->units = ""; // no units defined
  585. // initialize parameter 6 ("m_shimmer_31")
  586. pi = self->__commonstate.params + 6;
  587. pi->name = "shimmer";
  588. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  589. pi->defaultvalue = self->m_shimmer_31;
  590. pi->defaultref = 0;
  591. pi->hasinputminmax = false;
  592. pi->inputmin = 0;
  593. pi->inputmax = 1;
  594. pi->hasminmax = true;
  595. pi->outputmin = 0;
  596. pi->outputmax = 100;
  597. pi->exp = 0;
  598. pi->units = ""; // no units defined
  599. // initialize parameter 7 ("m_ratio_32")
  600. pi = self->__commonstate.params + 7;
  601. pi->name = "ratio";
  602. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  603. pi->defaultvalue = self->m_ratio_32;
  604. pi->defaultref = 0;
  605. pi->hasinputminmax = false;
  606. pi->inputmin = 0;
  607. pi->inputmax = 1;
  608. pi->hasminmax = true;
  609. pi->outputmin = 0.5;
  610. pi->outputmax = 2;
  611. pi->exp = 0;
  612. pi->units = ""; // no units defined
  613. return self;
  614. }
  615. /// Release all resources and memory used by a State object:
  616. void destroy(CommonState *cself) {
  617. State * self = (State *)cself;
  618. genlib_sysmem_freeptr(cself->params);
  619. delete self;
  620. }
  621. } // gen_exported::