Collection of DPF-based plugins for packaging
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.

767 lines
25KB

  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_14;
  25. Delay m_delay_11;
  26. Delay m_delay_18;
  27. Delay m_delay_15;
  28. Delay m_delay_12;
  29. Delay m_delay_17;
  30. Delay m_delay_13;
  31. Delay m_delay_20;
  32. Delay m_delay_19;
  33. Delay m_delay_21;
  34. Delay m_delay_23;
  35. Delay m_delay_22;
  36. Delay m_delay_16;
  37. Delta m_delta_41;
  38. Delta m_delta_47;
  39. Delta m_delta_44;
  40. Delta m_delta_38;
  41. Phasor m_phasor_37;
  42. Sah m_sah_48;
  43. Sah m_sah_49;
  44. Sah m_sah_46;
  45. Sah m_sah_45;
  46. Sah m_sah_42;
  47. Sah m_sah_43;
  48. Sah m_sah_40;
  49. Sah m_sah_39;
  50. double m_cutoff_34;
  51. double m_tail_33;
  52. double m_early_35;
  53. double samples_to_seconds;
  54. double m_tone_32;
  55. double m_mix_36;
  56. double m_spread_31;
  57. double m_ratio_24;
  58. double m_roomsize_29;
  59. double m_history_4;
  60. double m_history_5;
  61. double m_damping_30;
  62. double m_history_3;
  63. double m_history_1;
  64. double m_y_2;
  65. double samplerate;
  66. double m_history_7;
  67. double m_history_6;
  68. double m_history_9;
  69. double m_history_8;
  70. double m_blur_28;
  71. double m_decay_26;
  72. double m_shimmer_27;
  73. double m_history_10;
  74. double m_window_25;
  75. int vectorsize;
  76. int __exception;
  77. // re-initialize all member variables;
  78. inline void reset(double __sr, int __vs) {
  79. __exception = 0;
  80. vectorsize = __vs;
  81. samplerate = __sr;
  82. m_history_1 = 0;
  83. m_y_2 = 0;
  84. m_history_3 = 0;
  85. m_history_4 = 0;
  86. m_history_5 = 0;
  87. m_history_6 = 0;
  88. m_history_7 = 0;
  89. m_history_8 = 0;
  90. m_history_9 = 0;
  91. m_history_10 = 0;
  92. m_delay_11.reset("m_delay_11", 5000);
  93. m_delay_12.reset("m_delay_12", 7000);
  94. m_delay_13.reset("m_delay_13", 15000);
  95. m_delay_14.reset("m_delay_14", 16000);
  96. m_delay_15.reset("m_delay_15", 6000);
  97. m_delay_16.reset("m_delay_16", 96000);
  98. m_delay_17.reset("m_delay_17", 48000);
  99. m_delay_18.reset("m_delay_18", 10000);
  100. m_delay_19.reset("m_delay_19", 12000);
  101. m_delay_20.reset("m_delay_20", 48000);
  102. m_delay_21.reset("m_delay_21", 48000);
  103. m_delay_22.reset("m_delay_22", 48000);
  104. m_delay_23.reset("m_delay_23", 48000);
  105. m_ratio_24 = 2;
  106. m_window_25 = 100;
  107. m_decay_26 = 180;
  108. m_shimmer_27 = 0.5;
  109. m_blur_28 = 0.25;
  110. m_roomsize_29 = 150;
  111. m_damping_30 = 0.75;
  112. m_spread_31 = 25;
  113. m_tone_32 = 0.5;
  114. m_tail_33 = 0.25;
  115. m_cutoff_34 = 3000;
  116. m_early_35 = 0.25;
  117. m_mix_36 = 0.5;
  118. samples_to_seconds = (1 / samplerate);
  119. m_phasor_37.reset(0);
  120. m_delta_38.reset(0);
  121. m_sah_39.reset(0);
  122. m_sah_40.reset(0);
  123. m_delta_41.reset(0);
  124. m_sah_42.reset(0);
  125. m_sah_43.reset(0);
  126. m_delta_44.reset(0);
  127. m_sah_45.reset(0);
  128. m_sah_46.reset(0);
  129. m_delta_47.reset(0);
  130. m_sah_48.reset(0);
  131. m_sah_49.reset(0);
  132. genlib_reset_complete(this);
  133. };
  134. // the signal processing routine;
  135. inline int perform(t_sample ** __ins, t_sample ** __outs, int __n) {
  136. vectorsize = __n;
  137. const t_sample * __in1 = __ins[0];
  138. t_sample * __out1 = __outs[0];
  139. t_sample * __out2 = __outs[1];
  140. if (__exception) {
  141. return __exception;
  142. } else if (( (__in1 == 0) || (__out1 == 0) || (__out2 == 0) )) {
  143. __exception = GENLIB_ERR_NULL_BUFFER;
  144. return __exception;
  145. };
  146. double rsub_5405 = (1 - m_tone_32);
  147. double expr_5416 = safepow(0.001, safediv(1, (m_decay_26 * 44100)));
  148. double expr_5407 = safediv(((m_cutoff_34 * 2) * 3.1415926535898), 44100);
  149. double sin_5179 = sin(expr_5407);
  150. double clamp_5180 = ((sin_5179 <= 1e-05) ? 1e-05 : ((sin_5179 >= 0.99999) ? 0.99999 : sin_5179));
  151. double expr_5417 = safediv((m_roomsize_29 * 44100), 340);
  152. double mul_5394 = (expr_5417 * 0.63245);
  153. double expr_5408 = (-safepow(expr_5416, mul_5394));
  154. double mul_5397 = (expr_5417 * 1);
  155. double expr_5415 = (-safepow(expr_5416, mul_5397));
  156. double mul_5395 = (expr_5417 * 0.7071);
  157. double expr_5409 = (-safepow(expr_5416, mul_5395));
  158. double mul_5396 = (expr_5417 * 0.81649);
  159. double expr_5410 = (-safepow(expr_5416, mul_5396));
  160. double mul_5391 = (expr_5417 * 0.000527);
  161. int int_5390 = int(mul_5391);
  162. double mstosamps_5244 = (m_window_25 * (samplerate * 0.001));
  163. double add_5320 = (expr_5417 + 5);
  164. double expr_5411 = safepow(expr_5416, add_5320);
  165. double mul_5331 = (m_spread_31 * -0.380445);
  166. double add_5330 = (mul_5331 + 931);
  167. double rsub_5327 = (1341 - add_5330);
  168. double mul_5340 = (int_5390 * rsub_5327);
  169. double mul_5359 = (m_spread_31 * 0.376623);
  170. double add_5358 = (mul_5359 + 931);
  171. double rsub_5355 = (1341 - add_5358);
  172. double mul_5366 = (int_5390 * rsub_5355);
  173. double mul_5326 = (expr_5417 * 0.41);
  174. double add_5323 = (mul_5326 + 5);
  175. double expr_5414 = safepow(expr_5416, add_5323);
  176. double mul_5325 = (expr_5417 * 0.3);
  177. double add_5322 = (mul_5325 + 5);
  178. double expr_5413 = safepow(expr_5416, add_5322);
  179. double mul_5324 = (expr_5417 * 0.155);
  180. double add_5321 = (mul_5324 + 5);
  181. double expr_5412 = safepow(expr_5416, add_5321);
  182. double rsub_5231 = (1 - m_ratio_24);
  183. double mul_5230 = (rsub_5231 * 1000);
  184. double div_5229 = safediv(mul_5230, m_window_25);
  185. samples_to_seconds = (1 / samplerate);
  186. double mul_5389 = (expr_5417 * 0.110732);
  187. double mul_5333 = (m_spread_31 * -0.568366);
  188. double add_5329 = (mul_5333 + 369);
  189. double rsub_5328 = (add_5330 - add_5329);
  190. double mul_5347 = (int_5390 * rsub_5328);
  191. double mul_5375 = (m_spread_31 * 0.125541);
  192. double add_5357 = (mul_5375 + 369);
  193. double rsub_5356 = (add_5358 - add_5357);
  194. double mul_5373 = (int_5390 * rsub_5356);
  195. double add_5332 = (mul_5333 + 159);
  196. double mul_5354 = (int_5390 * add_5332);
  197. double add_5374 = (mul_5375 + 159);
  198. double mul_5382 = (int_5390 * add_5374);
  199. // the main sample loop;
  200. while ((__n--)) {
  201. const double in1 = (*(__in1++));
  202. double noise_5183 = noise();
  203. double abs_5200 = fabs(noise_5183);
  204. double mul_5208 = (abs_5200 * m_blur_28);
  205. double noise_5182 = noise();
  206. double abs_5199 = fabs(noise_5182);
  207. double mul_5205 = (abs_5199 * m_blur_28);
  208. double noise_5181 = noise();
  209. double abs_5198 = fabs(noise_5181);
  210. double mul_5202 = (abs_5198 * m_blur_28);
  211. double noise_5184 = noise();
  212. double abs_5201 = fabs(noise_5184);
  213. double mul_5211 = (abs_5201 * m_blur_28);
  214. double tap_5294 = m_delay_23.read_linear(mul_5394);
  215. double mul_5290 = (tap_5294 * expr_5408);
  216. double mix_5468 = (mul_5290 + (m_damping_30 * (m_history_10 - mul_5290)));
  217. double mix_5292 = mix_5468;
  218. double tap_5402 = m_delay_22.read_linear(mul_5397);
  219. double mul_5393 = (tap_5402 * expr_5415);
  220. double mix_5469 = (mul_5393 + (m_damping_30 * (m_history_9 - mul_5393)));
  221. double mix_5400 = mix_5469;
  222. double tap_5300 = m_delay_21.read_linear(mul_5395);
  223. double mul_5296 = (tap_5300 * expr_5409);
  224. double mix_5470 = (mul_5296 + (m_damping_30 * (m_history_8 - mul_5296)));
  225. double mix_5298 = mix_5470;
  226. double tap_5306 = m_delay_20.read_linear(mul_5396);
  227. double mul_5302 = (tap_5306 * expr_5410);
  228. double mix_5471 = (mul_5302 + (m_damping_30 * (m_history_7 - mul_5302)));
  229. double mix_5304 = mix_5471;
  230. double add_5284 = (mix_5400 + mix_5304);
  231. double add_5282 = (mix_5298 + mix_5292);
  232. double add_5277 = (add_5284 + add_5282);
  233. double mul_5260 = (add_5277 * 0.5);
  234. double sub_5281 = (add_5284 - add_5282);
  235. double mul_5263 = (sub_5281 * 0.5);
  236. double tap_5339 = m_delay_19.read_linear(mul_5340);
  237. double mul_5337 = (tap_5339 * 0.625);
  238. double tap_5365 = m_delay_18.read_linear(mul_5366);
  239. double mul_5363 = (tap_5365 * 0.625);
  240. double sub_5283 = (mix_5400 - mix_5304);
  241. double sub_5280 = (mix_5298 - mix_5292);
  242. double sub_5279 = (sub_5283 - sub_5280);
  243. double mul_5262 = (sub_5279 * 0.5);
  244. double add_5278 = (sub_5283 + sub_5280);
  245. double rsub_5276 = (0 - add_5278);
  246. double mul_5261 = (rsub_5276 * 0.5);
  247. double tap_5308 = m_delay_17.read_linear(add_5323);
  248. double tap_5309 = m_delay_17.read_linear(add_5322);
  249. double tap_5310 = m_delay_17.read_linear(add_5321);
  250. double tap_5311 = m_delay_17.read_linear(add_5320);
  251. double mul_5312 = (tap_5311 * expr_5411);
  252. double add_5285 = (mul_5260 + mul_5312);
  253. double mul_5318 = (tap_5308 * expr_5414);
  254. double add_5288 = (mul_5263 + mul_5318);
  255. double mul_5316 = (tap_5309 * expr_5413);
  256. double add_5287 = (mul_5262 + mul_5316);
  257. double mul_5314 = (tap_5310 * expr_5412);
  258. double add_5286 = (mul_5261 + mul_5314);
  259. double phasor_5250 = m_phasor_37(div_5229, samples_to_seconds);
  260. double add_5243 = ((m_history_6 + phasor_5250) + 0.25);
  261. double mod_5242 = safemod(add_5243, 1);
  262. double delta_5210 = m_delta_38(mod_5242);
  263. double sah_5189 = m_sah_39(mul_5208, delta_5210, 0);
  264. double sah_5209 = m_sah_40(mstosamps_5244, delta_5210, 0);
  265. double mul_5196 = (sah_5209 * mod_5242);
  266. double sub_5241 = (mod_5242 - 0.5);
  267. double mul_5240 = (sub_5241 * 3.1415926535898);
  268. double cos_5239 = cos(mul_5240);
  269. double mul_5215 = (cos_5239 * cos_5239);
  270. double add_5228 = ((m_history_5 + phasor_5250) + 0.5);
  271. double mod_5227 = safemod(add_5228, 1);
  272. double delta_5207 = m_delta_41(mod_5227);
  273. double sah_5187 = m_sah_42(mul_5205, delta_5207, 0);
  274. double sah_5206 = m_sah_43(mstosamps_5244, delta_5207, 0);
  275. double mul_5195 = (sah_5206 * mod_5227);
  276. double sub_5226 = (mod_5227 - 0.5);
  277. double mul_5225 = (sub_5226 * 3.1415926535898);
  278. double cos_5224 = cos(mul_5225);
  279. double mul_5214 = (cos_5224 * cos_5224);
  280. double add_5222 = ((m_history_4 + phasor_5250) + 0.75);
  281. double mod_5221 = safemod(add_5222, 1);
  282. double delta_5204 = m_delta_44(mod_5221);
  283. double sah_5185 = m_sah_45(mul_5202, delta_5204, 0);
  284. double sah_5203 = m_sah_46(mstosamps_5244, delta_5204, 0);
  285. double mul_5194 = (sah_5203 * mod_5221);
  286. double sub_5220 = (mod_5221 - 0.5);
  287. double mul_5219 = (sub_5220 * 3.1415926535898);
  288. double cos_5218 = cos(mul_5219);
  289. double mul_5213 = (cos_5218 * cos_5218);
  290. double add_5249 = ((m_history_3 + phasor_5250) + 0);
  291. double mod_5248 = safemod(add_5249, 1);
  292. double delta_5192 = m_delta_47(mod_5248);
  293. double sah_5191 = m_sah_48(mul_5211, delta_5192, 0);
  294. double sah_5212 = m_sah_49(mstosamps_5244, delta_5192, 0);
  295. double mul_5197 = (sah_5212 * mod_5248);
  296. double tap_5235 = m_delay_16.read_linear(mul_5197);
  297. double tap_5236 = m_delay_16.read_linear(mul_5196);
  298. double tap_5237 = m_delay_16.read_linear(mul_5195);
  299. double tap_5238 = m_delay_16.read_linear(mul_5194);
  300. double mul_5217 = (tap_5238 * mul_5213);
  301. double mul_5223 = (tap_5237 * mul_5214);
  302. double mul_5232 = (tap_5236 * mul_5215);
  303. double sub_5247 = (mod_5248 - 0.5);
  304. double mul_5246 = (sub_5247 * 3.1415926535898);
  305. double cos_5245 = cos(mul_5246);
  306. double mul_5216 = (cos_5245 * cos_5245);
  307. double mul_5233 = (tap_5235 * mul_5216);
  308. double add_5473 = (((mul_5233 + mul_5232) + mul_5223) + mul_5217);
  309. double mix_5472 = (m_y_2 + (clamp_5180 * (add_5473 - m_y_2)));
  310. double mix_5177 = mix_5472;
  311. double mix_5474 = (in1 + (m_shimmer_27 * (mix_5177 - in1)));
  312. double mix_5251 = mix_5474;
  313. double mul_5254 = (mix_5251 * 0.707);
  314. double mix_5475 = (mul_5254 + (rsub_5405 * (m_history_1 - mul_5254)));
  315. double mix_5404 = mix_5475;
  316. double tap_5388 = m_delay_15.read_linear(mul_5389);
  317. double mul_5386 = (tap_5388 * 0.75);
  318. double sub_5385 = (mix_5404 - mul_5386);
  319. double mul_5384 = (sub_5385 * 0.75);
  320. double add_5383 = (mul_5384 + tap_5388);
  321. double tap_5346 = m_delay_14.read_linear(mul_5347);
  322. double mul_5344 = (tap_5346 * 0.625);
  323. double tap_5372 = m_delay_13.read_linear(mul_5373);
  324. double mul_5370 = (tap_5372 * 0.625);
  325. double tap_5353 = m_delay_12.read_linear(mul_5354);
  326. double mul_5351 = (tap_5353 * 0.75);
  327. double tap_5381 = m_delay_11.read_linear(mul_5382);
  328. double mul_5379 = (tap_5381 * 0.75);
  329. double mul_5275 = (mul_5263 * m_tail_33);
  330. double mul_5273 = (mul_5261 * m_tail_33);
  331. double add_5259 = (mul_5275 + mul_5273);
  332. double mul_5274 = (mul_5262 * m_tail_33);
  333. double mul_5272 = (mul_5260 * m_tail_33);
  334. double add_5258 = (mul_5274 + mul_5272);
  335. double sub_5267 = (add_5259 - add_5258);
  336. double mul_5271 = (mul_5318 * m_early_35);
  337. double mul_5269 = (mul_5314 * m_early_35);
  338. double add_5257 = (mul_5271 + mul_5269);
  339. double mul_5270 = (mul_5316 * m_early_35);
  340. double mul_5268 = (mul_5312 * m_early_35);
  341. double add_5256 = (mul_5270 + mul_5268);
  342. double sub_5266 = (add_5257 - add_5256);
  343. double add_5253 = (sub_5267 + sub_5266);
  344. double add_5255 = (add_5253 + mix_5251);
  345. double sub_5350 = (add_5255 - mul_5351);
  346. double mul_5349 = (sub_5350 * 0.75);
  347. double add_5348 = (mul_5349 + tap_5353);
  348. double sub_5343 = (add_5348 - mul_5344);
  349. double mul_5342 = (sub_5343 * 0.625);
  350. double add_5341 = (mul_5342 + tap_5346);
  351. double sub_5336 = (add_5341 - mul_5337);
  352. double mul_5335 = (sub_5336 * 0.625);
  353. double add_5334 = (mul_5335 + tap_5339);
  354. double mul_5252 = (add_5334 * m_mix_36);
  355. double out2 = (in1 + mul_5252);
  356. double add_5265 = (add_5253 + mix_5251);
  357. double sub_5378 = (add_5265 - mul_5379);
  358. double mul_5377 = (sub_5378 * 0.75);
  359. double add_5376 = (mul_5377 + tap_5381);
  360. double sub_5369 = (add_5376 - mul_5370);
  361. double mul_5368 = (sub_5369 * 0.625);
  362. double add_5367 = (mul_5368 + tap_5372);
  363. double sub_5362 = (add_5367 - mul_5363);
  364. double mul_5361 = (sub_5362 * 0.625);
  365. double add_5360 = (mul_5361 + tap_5365);
  366. double mul_5264 = (add_5360 * m_mix_36);
  367. double out1 = (in1 + mul_5264);
  368. double history_5291_next_5418 = mix_5292;
  369. double history_5399_next_5419 = mix_5400;
  370. double history_5297_next_5420 = mix_5298;
  371. double history_5303_next_5421 = mix_5304;
  372. double history_5190_next_5422 = sah_5189;
  373. double history_5188_next_5423 = sah_5187;
  374. double history_5186_next_5424 = sah_5185;
  375. double history_5193_next_5425 = sah_5191;
  376. double y0_next_5426 = mix_5177;
  377. double history_5403_next_5427 = mix_5404;
  378. m_delay_23.write(add_5285);
  379. m_delay_22.write(add_5288);
  380. m_delay_21.write(add_5286);
  381. m_delay_20.write(add_5287);
  382. m_delay_19.write(sub_5336);
  383. m_delay_18.write(sub_5362);
  384. m_delay_17.write(add_5383);
  385. m_delay_16.write(in1);
  386. m_delay_15.write(sub_5385);
  387. m_delay_14.write(sub_5343);
  388. m_delay_13.write(sub_5369);
  389. m_delay_12.write(sub_5350);
  390. m_delay_11.write(sub_5378);
  391. m_history_10 = history_5291_next_5418;
  392. m_history_9 = history_5399_next_5419;
  393. m_history_8 = history_5297_next_5420;
  394. m_history_7 = history_5303_next_5421;
  395. m_history_6 = history_5190_next_5422;
  396. m_history_5 = history_5188_next_5423;
  397. m_history_4 = history_5186_next_5424;
  398. m_history_3 = history_5193_next_5425;
  399. m_y_2 = y0_next_5426;
  400. m_history_1 = history_5403_next_5427;
  401. m_delay_11.step();
  402. m_delay_12.step();
  403. m_delay_13.step();
  404. m_delay_14.step();
  405. m_delay_15.step();
  406. m_delay_16.step();
  407. m_delay_17.step();
  408. m_delay_18.step();
  409. m_delay_19.step();
  410. m_delay_20.step();
  411. m_delay_21.step();
  412. m_delay_22.step();
  413. m_delay_23.step();
  414. // assign results to output buffer;
  415. (*(__out1++)) = out1;
  416. (*(__out2++)) = out2;
  417. };
  418. return __exception;
  419. };
  420. inline void set_ratio(double _value) {
  421. m_ratio_24 = (_value < 0.5 ? 0.5 : (_value > 2 ? 2 : _value));
  422. };
  423. inline void set_window(double _value) {
  424. m_window_25 = (_value < 0.1 ? 0.1 : (_value > 1000 ? 1000 : _value));
  425. };
  426. inline void set_decay(double _value) {
  427. m_decay_26 = (_value < 0.1 ? 0.1 : (_value > 360 ? 360 : _value));
  428. };
  429. inline void set_shimmer(double _value) {
  430. m_shimmer_27 = (_value < 0 ? 0 : (_value > 1 ? 1 : _value));
  431. };
  432. inline void set_blur(double _value) {
  433. m_blur_28 = (_value < 0.01 ? 0.01 : (_value > 0.25 ? 0.25 : _value));
  434. };
  435. inline void set_roomsize(double _value) {
  436. m_roomsize_29 = (_value < 0.1 ? 0.1 : (_value > 300 ? 300 : _value));
  437. };
  438. inline void set_damping(double _value) {
  439. m_damping_30 = (_value < 0 ? 0 : (_value > 1 ? 1 : _value));
  440. };
  441. inline void set_spread(double _value) {
  442. m_spread_31 = (_value < 0 ? 0 : (_value > 100 ? 100 : _value));
  443. };
  444. inline void set_tone(double _value) {
  445. m_tone_32 = (_value < 0 ? 0 : (_value > 1 ? 1 : _value));
  446. };
  447. inline void set_tail(double _value) {
  448. m_tail_33 = (_value < 0 ? 0 : (_value > 1 ? 1 : _value));
  449. };
  450. inline void set_cutoff(double _value) {
  451. m_cutoff_34 = (_value < 0 ? 0 : (_value > 6000 ? 6000 : _value));
  452. };
  453. inline void set_early(double _value) {
  454. m_early_35 = (_value < 0 ? 0 : (_value > 1 ? 1 : _value));
  455. };
  456. inline void set_mix(double _value) {
  457. m_mix_36 = (_value < 0 ? 0 : (_value > 1 ? 1 : _value));
  458. };
  459. } State;
  460. ///
  461. /// Configuration for the genlib API
  462. ///
  463. /// Number of signal inputs and outputs
  464. int gen_kernel_numins = 1;
  465. int gen_kernel_numouts = 2;
  466. int num_inputs() { return gen_kernel_numins; }
  467. int num_outputs() { return gen_kernel_numouts; }
  468. int num_params() { return 13; }
  469. /// Assistive lables for the signal inputs and outputs
  470. const char * gen_kernel_innames[] = { "in1" };
  471. const char * gen_kernel_outnames[] = { "out1", "out2" };
  472. /// Invoke the signal process of a State object
  473. int perform(CommonState *cself, t_sample **ins, long numins, t_sample **outs, long numouts, long n) {
  474. State * self = (State *)cself;
  475. return self->perform(ins, outs, n);
  476. }
  477. /// Reset all parameters and stateful operators of a State object
  478. void reset(CommonState *cself) {
  479. State * self = (State *)cself;
  480. self->reset(cself->sr, cself->vs);
  481. }
  482. /// Set a parameter of a State object
  483. void setparameter(CommonState *cself, long index, double value, void *ref) {
  484. State * self = (State *)cself;
  485. switch (index) {
  486. case 0: self->set_ratio(value); break;
  487. case 1: self->set_window(value); break;
  488. case 2: self->set_decay(value); break;
  489. case 3: self->set_shimmer(value); break;
  490. case 4: self->set_blur(value); break;
  491. case 5: self->set_roomsize(value); break;
  492. case 6: self->set_damping(value); break;
  493. case 7: self->set_spread(value); break;
  494. case 8: self->set_tone(value); break;
  495. case 9: self->set_tail(value); break;
  496. case 10: self->set_cutoff(value); break;
  497. case 11: self->set_early(value); break;
  498. case 12: self->set_mix(value); break;
  499. default: break;
  500. }
  501. }
  502. /// Get the value of a parameter of a State object
  503. void getparameter(CommonState *cself, long index, double *value) {
  504. State *self = (State *)cself;
  505. switch (index) {
  506. case 0: *value = self->m_ratio_24; break;
  507. case 1: *value = self->m_window_25; break;
  508. case 2: *value = self->m_decay_26; break;
  509. case 3: *value = self->m_shimmer_27; break;
  510. case 4: *value = self->m_blur_28; break;
  511. case 5: *value = self->m_roomsize_29; break;
  512. case 6: *value = self->m_damping_30; break;
  513. case 7: *value = self->m_spread_31; break;
  514. case 8: *value = self->m_tone_32; break;
  515. case 9: *value = self->m_tail_33; break;
  516. case 10: *value = self->m_cutoff_34; break;
  517. case 11: *value = self->m_early_35; break;
  518. case 12: *value = self->m_mix_36; break;
  519. default: break;
  520. }
  521. }
  522. /// Allocate and configure a new State object and it's internal CommonState:
  523. void * create(double sr, long vs) {
  524. State *self = new State;
  525. self->reset(sr, vs);
  526. ParamInfo *pi;
  527. self->__commonstate.inputnames = gen_kernel_innames;
  528. self->__commonstate.outputnames = gen_kernel_outnames;
  529. self->__commonstate.numins = gen_kernel_numins;
  530. self->__commonstate.numouts = gen_kernel_numouts;
  531. self->__commonstate.sr = sr;
  532. self->__commonstate.vs = vs;
  533. self->__commonstate.params = (ParamInfo *)genlib_sysmem_newptr(13 * sizeof(ParamInfo));
  534. self->__commonstate.numparams = 13;
  535. // initialize parameter 0 ("m_ratio_24")
  536. pi = self->__commonstate.params + 0;
  537. pi->name = "ratio";
  538. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  539. pi->defaultvalue = self->m_ratio_24;
  540. pi->defaultref = 0;
  541. pi->hasinputminmax = false;
  542. pi->inputmin = 0;
  543. pi->inputmax = 1;
  544. pi->hasminmax = true;
  545. pi->outputmin = 0.5;
  546. pi->outputmax = 2;
  547. pi->exp = 0;
  548. pi->units = ""; // no units defined
  549. // initialize parameter 1 ("m_window_25")
  550. pi = self->__commonstate.params + 1;
  551. pi->name = "window";
  552. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  553. pi->defaultvalue = self->m_window_25;
  554. pi->defaultref = 0;
  555. pi->hasinputminmax = false;
  556. pi->inputmin = 0;
  557. pi->inputmax = 1;
  558. pi->hasminmax = true;
  559. pi->outputmin = 0.1;
  560. pi->outputmax = 1000;
  561. pi->exp = 0;
  562. pi->units = ""; // no units defined
  563. // initialize parameter 2 ("m_decay_26")
  564. pi = self->__commonstate.params + 2;
  565. pi->name = "decay";
  566. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  567. pi->defaultvalue = self->m_decay_26;
  568. pi->defaultref = 0;
  569. pi->hasinputminmax = false;
  570. pi->inputmin = 0;
  571. pi->inputmax = 1;
  572. pi->hasminmax = true;
  573. pi->outputmin = 0.1;
  574. pi->outputmax = 360;
  575. pi->exp = 0;
  576. pi->units = ""; // no units defined
  577. // initialize parameter 3 ("m_shimmer_27")
  578. pi = self->__commonstate.params + 3;
  579. pi->name = "shimmer";
  580. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  581. pi->defaultvalue = self->m_shimmer_27;
  582. pi->defaultref = 0;
  583. pi->hasinputminmax = false;
  584. pi->inputmin = 0;
  585. pi->inputmax = 1;
  586. pi->hasminmax = true;
  587. pi->outputmin = 0;
  588. pi->outputmax = 1;
  589. pi->exp = 0;
  590. pi->units = ""; // no units defined
  591. // initialize parameter 4 ("m_blur_28")
  592. pi = self->__commonstate.params + 4;
  593. pi->name = "blur";
  594. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  595. pi->defaultvalue = self->m_blur_28;
  596. pi->defaultref = 0;
  597. pi->hasinputminmax = false;
  598. pi->inputmin = 0;
  599. pi->inputmax = 1;
  600. pi->hasminmax = true;
  601. pi->outputmin = 0.01;
  602. pi->outputmax = 0.25;
  603. pi->exp = 0;
  604. pi->units = ""; // no units defined
  605. // initialize parameter 5 ("m_roomsize_29")
  606. pi = self->__commonstate.params + 5;
  607. pi->name = "roomsize";
  608. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  609. pi->defaultvalue = self->m_roomsize_29;
  610. pi->defaultref = 0;
  611. pi->hasinputminmax = false;
  612. pi->inputmin = 0;
  613. pi->inputmax = 1;
  614. pi->hasminmax = true;
  615. pi->outputmin = 0.1;
  616. pi->outputmax = 300;
  617. pi->exp = 0;
  618. pi->units = ""; // no units defined
  619. // initialize parameter 6 ("m_damping_30")
  620. pi = self->__commonstate.params + 6;
  621. pi->name = "damping";
  622. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  623. pi->defaultvalue = self->m_damping_30;
  624. pi->defaultref = 0;
  625. pi->hasinputminmax = false;
  626. pi->inputmin = 0;
  627. pi->inputmax = 1;
  628. pi->hasminmax = true;
  629. pi->outputmin = 0;
  630. pi->outputmax = 1;
  631. pi->exp = 0;
  632. pi->units = ""; // no units defined
  633. // initialize parameter 7 ("m_spread_31")
  634. pi = self->__commonstate.params + 7;
  635. pi->name = "spread";
  636. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  637. pi->defaultvalue = self->m_spread_31;
  638. pi->defaultref = 0;
  639. pi->hasinputminmax = false;
  640. pi->inputmin = 0;
  641. pi->inputmax = 1;
  642. pi->hasminmax = true;
  643. pi->outputmin = 0;
  644. pi->outputmax = 100;
  645. pi->exp = 0;
  646. pi->units = ""; // no units defined
  647. // initialize parameter 8 ("m_tone_32")
  648. pi = self->__commonstate.params + 8;
  649. pi->name = "tone";
  650. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  651. pi->defaultvalue = self->m_tone_32;
  652. pi->defaultref = 0;
  653. pi->hasinputminmax = false;
  654. pi->inputmin = 0;
  655. pi->inputmax = 1;
  656. pi->hasminmax = true;
  657. pi->outputmin = 0;
  658. pi->outputmax = 1;
  659. pi->exp = 0;
  660. pi->units = ""; // no units defined
  661. // initialize parameter 9 ("m_tail_33")
  662. pi = self->__commonstate.params + 9;
  663. pi->name = "tail";
  664. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  665. pi->defaultvalue = self->m_tail_33;
  666. pi->defaultref = 0;
  667. pi->hasinputminmax = false;
  668. pi->inputmin = 0;
  669. pi->inputmax = 1;
  670. pi->hasminmax = true;
  671. pi->outputmin = 0;
  672. pi->outputmax = 1;
  673. pi->exp = 0;
  674. pi->units = ""; // no units defined
  675. // initialize parameter 10 ("m_cutoff_34")
  676. pi = self->__commonstate.params + 10;
  677. pi->name = "cutoff";
  678. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  679. pi->defaultvalue = self->m_cutoff_34;
  680. pi->defaultref = 0;
  681. pi->hasinputminmax = false;
  682. pi->inputmin = 0;
  683. pi->inputmax = 1;
  684. pi->hasminmax = true;
  685. pi->outputmin = 0;
  686. pi->outputmax = 6000;
  687. pi->exp = 0;
  688. pi->units = ""; // no units defined
  689. // initialize parameter 11 ("m_early_35")
  690. pi = self->__commonstate.params + 11;
  691. pi->name = "early";
  692. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  693. pi->defaultvalue = self->m_early_35;
  694. pi->defaultref = 0;
  695. pi->hasinputminmax = false;
  696. pi->inputmin = 0;
  697. pi->inputmax = 1;
  698. pi->hasminmax = true;
  699. pi->outputmin = 0;
  700. pi->outputmax = 1;
  701. pi->exp = 0;
  702. pi->units = ""; // no units defined
  703. // initialize parameter 12 ("m_mix_36")
  704. pi = self->__commonstate.params + 12;
  705. pi->name = "mix";
  706. pi->paramtype = GENLIB_PARAMTYPE_FLOAT;
  707. pi->defaultvalue = self->m_mix_36;
  708. pi->defaultref = 0;
  709. pi->hasinputminmax = false;
  710. pi->inputmin = 0;
  711. pi->inputmax = 1;
  712. pi->hasminmax = true;
  713. pi->outputmin = 0;
  714. pi->outputmax = 1;
  715. pi->exp = 0;
  716. pi->units = ""; // no units defined
  717. return self;
  718. }
  719. /// Release all resources and memory used by a State object:
  720. void destroy(CommonState *cself) {
  721. State * self = (State *)cself;
  722. genlib_sysmem_freeptr(cself->params);
  723. delete self;
  724. }
  725. } // gen_exported::