1 //Spencer Jackson
2 #include<lv2.h>
3 #include<lv2/lv2plug.in/ns/ext/urid/urid.h>
4 #include<lv2/lv2plug.in/ns/ext/midi/midi.h>
5 #include<lv2/lv2plug.in/ns/ext/atom/util.h>
6 #include<lv2/lv2plug.in/ns/ext/atom/forge.h>
7 #include<lv2/lv2plug.in/ns/ext/time/time.h>
8 #include<lv2/lv2plug.in/ns/ext/buf-size/buf-size.h>
9 #include<lv2/lv2plug.in/ns/ext/options/options.h>
10 #include<lv2/lv2plug.in/ns/ext/atom/atom.h>
11 #include<lv2/lv2plug.in/ns/ext/patch/patch.h>
12 #include<lv2/lv2plug.in/ns/ext/worker/worker.h>
13 #include<lv2/lv2plug.in/ns/ext/state/state.h>
14 #include<stdlib.h>
15 #include<stdio.h>
16 #include<string.h>
17 #include<unistd.h>
18 #include<samplerate.h>
19 #include"rkrlv2.h"
20
21 #include"EQ.h"
22 #include"Compressor.h"
23 #include"Distorsion.h"
24 #include"Echo.h"
25 #include"Chorus.h"
26 #include"APhaser.h"
27 #include"Harmonizer.h"
28 #include"RecChord.h"
29 #include"RecognizeNote.h"
30 #include"Exciter.h"
31 #include"Pan.h"
32 #include"Alienwah.h"
33 #include"Reverb.h"
34 #include"Cabinet.h"
35 #include"MusicDelay.h"
36 #include"DynamicFilter.h"
37 #include"NewDist.h"
38 #include"Valve.h"
39 #include"Dual_Flange.h"
40 #include"Ring.h"
41 #include"MBDist.h"
42 #include"Arpie.h"
43 #include"Expander.h"
44 #include"Shuffle.h"
45 #include"Synthfilter.h"
46 #include"MBVvol.h"
47 #include"RyanWah.h"
48 #include"RBEcho.h"
49 #include"CoilCrafter.h"
50 #include"ShelfBoost.h"
51 #include"Vocoder.h"
52 #include"Sequence.h"
53 #include"Shifter.h"
54 #include"StompBox.h"
55 #include"Reverbtron.h"
56 #include"Echotron.h"
57 #include"StereoHarm.h"
58 #include"CompBand.h"
59 #include"Opticaltrem.h"
60 #include"Vibe.h"
61 #include"Infinity.h"
62 #include"Phaser.h"
63 #include"Gate.h"
64
65 //this is the default hopefully hosts don't use periods of more than this, or they will communicate the max bufsize
66 #define INTERMEDIATE_BUFSIZE 1024
67
68
69 typedef struct _RKRLV2
70 {
71 uint8_t nparams;
72 uint8_t effectindex;//index of effect
73 uint16_t period_max;
74 uint8_t loading_file;//flag to indicate that file load work is underway
75 uint8_t init_params; //flag to indicate to force parameter (LFO) update & sample update on first run
76 uint8_t file_changed;
77 uint8_t prev_bypass;
78 RvbFile* rvbfile;//file for reverbtron
79 DlyFile* dlyfile;//file for echotron
80
81 //ports
82 float *input_l_p;
83 float *input_r_p;
84 float *output_l_p;
85 float *output_r_p;
86 float *bypass_p;
87 const LV2_Atom_Sequence* atom_in_p;
88 LV2_Atom_Sequence* atom_out_p;
89 float *param_p[20];
90 float *dbg_p;
91
92 //various "advanced" lv2 stuffs
93 LV2_Worker_Schedule* scheduler;
94 LV2_Atom_Forge forge;
95 LV2_Atom_Forge_Frame atom_frame;
96 LV2_URID_Map *urid_map;
97
98 struct urids
99 {
100 LV2_URID midi_MidiEvent;
101 LV2_URID atom_Float;
102 LV2_URID atom_Int;
103 LV2_URID atom_Object;
104 LV2_URID atom_Path;
105 LV2_URID atom_URID;
106 LV2_URID bufsz_max;
107 LV2_URID patch_Set;
108 LV2_URID patch_Get;
109 LV2_URID patch_property;
110 LV2_URID patch_value;
111 LV2_URID filetype_rvb;
112 LV2_URID filetype_dly;
113
114 } URIDs;
115
116 //effect modules
117 EQ* eq; //0, 11
118 Compressor* comp; //1
119 Distorsion* dist; //2
120 Echo* echo; //3
121 Chorus* chorus; //4
122 Analog_Phaser* aphase;//5
123 Harmonizer* harm; //6
124 RecChord* chordID;
125 Recognize* noteID;
126 Exciter* exciter; //7
127 Pan* pan; //8
128 Alienwah* alien; //9
129 Reverb* reve; //10
130 Cabinet* cab; //12
131 MusicDelay* mdel; //13
132 DynamicFilter* wah; //14
133 NewDist* dere; //15
134 Valve* valve; //16
135 Dflange* dflange; //17
136 Ring* ring; //18
137 MBDist* mbdist; //19
138 Arpie* arp; //20
139 Expander* expand; //21
140 Shuffle* shuf; //22
141 Synthfilter* synth; //23
142 MBVvol* mbvol; //24
143 RyanWah* mutro; //25
144 RBEcho* echoverse; //26
145 CoilCrafter* coil; //27
146 ShelfBoost* shelf; //28
147 Vocoder* voc; //29
148 Sustainer* sus; //30
149 Sequence* seq; //31
150 Shifter* shift; //32
151 StompBox* stomp; //33,34
152 Reverbtron* revtron;//35
153 Echotron* echotron; //36
154 StereoHarm* sharm; //37
155 CompBand* mbcomp; //38
156 Opticaltrem* otrem; //39
157 Vibe* vibe; //40
158 Infinity* inf; //41
159 Phaser* phase; //42
160 Gate* gate; //43
161 } RKRLV2;
162
163 enum other_ports
164 {
165 //be sure to account for index of array vs lv2 port index
166 HARMONIZER_MIDI,//unassigned right now
167 VOCODER_AUX_IN = 7,
168 VOCODER_VU_LEVEL = 8
169 };
170
171 // A few helper functions taken from the RKR object
172 void
wetdry_mix(RKRLV2 * plug,float mix,uint32_t period)173 wetdry_mix (RKRLV2* plug, float mix, uint32_t period)
174 {
175 unsigned int i;
176 float v1, v2;
177
178 if (mix < 0.5f)
179 {
180 v1 = 1.0f;
181 v2 = mix * 2.0f;
182 }
183 else
184 {
185 v1 = (1.0f - mix) * 2.0f;
186 v2 = 1.0f;
187 };
188
189
190 // Reverb and musical delay are exceptions for some reason?
191 // if ((NumEffect == 8) || (NumEffect == 15))
192 // v2 *= v2;
193
194 for (i = 0; i < period; i++)
195 {
196 plug->output_l_p[i] = plug->input_l_p[i] * v2 + plug->output_l_p[i] * v1;
197 plug->output_r_p[i] = plug->input_r_p[i] * v2 + plug->output_r_p[i] * v1;
198 };
199
200 }
201
202 //this finds the peak value
203 int
have_signal(float * efxoutl,float * efxoutr,uint32_t period)204 have_signal(float* efxoutl, float* efxoutr, uint32_t period)
205 {
206 float tmp;
207 uint32_t i;
208 float il_sum = 1e-12f;
209 float ir_sum = 1e-12f;
210 for (i = 0; i <= period; i++) {
211
212 tmp = fabsf (efxoutl[i]);
213 if (tmp > il_sum) il_sum = tmp;
214 tmp = fabsf (efxoutr[i]);
215 if (tmp > ir_sum) ir_sum = tmp;
216 }
217
218
219 if ((il_sum+ir_sum) > 0.0004999f) return 1;
220 else return 0;
221 }
222
223 void
xfade_in(RKRLV2 * plug,uint32_t period)224 xfade_in (RKRLV2* plug, uint32_t period)
225 {
226 unsigned int i;
227 float v = 0;
228 float step = 1/(float)period;
229 //just a linear fade since it's (hopefully) correlated
230 for (i = 0; i < period; i++)
231 {
232 plug->output_l_p[i] = (v)*plug->output_l_p[i] + (1-v)*plug->input_l_p[i];
233 plug->output_r_p[i] = (v)*plug->output_r_p[i] + (1-v)*plug->input_r_p[i];
234 v+=step;
235 }
236 }
237
238 void
xfade_out(RKRLV2 * plug,uint32_t period)239 xfade_out (RKRLV2* plug, uint32_t period)
240 {
241 unsigned int i;
242 float v = 0;
243 float step = 1/(float)period;
244 //just a linear fade since it's (hopefully) correlated
245 for (i = 0; i < period; i++)
246 {
247 plug->output_l_p[i] = (1-v)*plug->output_l_p[i] + v*plug->input_l_p[i];
248 plug->output_r_p[i] = (1-v)*plug->output_r_p[i] + v*plug->input_r_p[i];
249 v+=step;
250 }
251 }
252
253 void
xfade_check(RKRLV2 * plug,uint32_t period)254 xfade_check (RKRLV2* plug, uint32_t period)
255 {
256 if(*plug->bypass_p)
257 {
258 plug->prev_bypass = 1;
259 xfade_out(plug,period);
260 }
261 else if(plug->prev_bypass)
262 {
263 plug->prev_bypass = 0;
264 xfade_in(plug,period);
265 }
266 }
267
268 //TODO: make this return error is required feature not supported
getFeatures(RKRLV2 * plug,const LV2_Feature * const * host_features)269 void getFeatures(RKRLV2* plug, const LV2_Feature * const* host_features)
270 {
271 uint8_t i,j;
272 plug->period_max = INTERMEDIATE_BUFSIZE;
273 plug->loading_file = 0;
274 plug->file_changed = 0;
275 plug->scheduler = 0;
276 plug->urid_map = 0;
277 for(i=0; host_features[i]; i++)
278 { if(!strcmp(host_features[i]->URI,LV2_OPTIONS__options)) { LV2_Options_Option* option; option = (LV2_Options_Option*)host_features[i]->data;
279 for(j=0; option[j].key; j++)
280 {
281 if(option[j].key == plug->URIDs.bufsz_max)
282 {
283 if(option[j].type == plug->URIDs.atom_Int)
284 {
285 plug->period_max = *(const int*)option[j].value;
286 }
287 //other types?
288 }
289 }
290 }
291 else if(!strcmp(host_features[i]->URI,LV2_WORKER__schedule))
292 {
293 plug->scheduler = (LV2_Worker_Schedule*)host_features[i]->data;
294 }
295 else if(!strcmp(host_features[i]->URI,LV2_URID__map))
296 {
297 plug->urid_map = (LV2_URID_Map *) host_features[i]->data;
298 if(plug->urid_map)
299 {
300 plug->URIDs.midi_MidiEvent = plug->urid_map->map(plug->urid_map->handle,LV2_MIDI__MidiEvent);
301 plug->URIDs.atom_Float = plug->urid_map->map(plug->urid_map->handle,LV2_ATOM__Float);
302 plug->URIDs.atom_Int = plug->urid_map->map(plug->urid_map->handle,LV2_ATOM__Int);
303 plug->URIDs.atom_Object = plug->urid_map->map(plug->urid_map->handle,LV2_ATOM__Object);
304 plug->URIDs.atom_Path = plug->urid_map->map(plug->urid_map->handle,LV2_ATOM__Path);
305 plug->URIDs.atom_URID = plug->urid_map->map(plug->urid_map->handle,LV2_ATOM__URID);
306 plug->URIDs.bufsz_max = plug->urid_map->map(plug->urid_map->handle,LV2_BUF_SIZE__maxBlockLength);
307 plug->URIDs.patch_Set = plug->urid_map->map(plug->urid_map->handle,LV2_PATCH__Set);
308 plug->URIDs.patch_Get = plug->urid_map->map(plug->urid_map->handle,LV2_PATCH__Get);
309 plug->URIDs.patch_property = plug->urid_map->map(plug->urid_map->handle,LV2_PATCH__property);
310 plug->URIDs.patch_value = plug->urid_map->map(plug->urid_map->handle,LV2_PATCH__value);
311 plug->URIDs.filetype_rvb = plug->urid_map->map(plug->urid_map->handle,RVBFILE_URI);
312 plug->URIDs.filetype_dly = plug->urid_map->map(plug->urid_map->handle,DLYFILE_URI);
313
314 }
315 }
316 }
317 }
318
319 /////////////////////////////////////////
320 // EFFECTS
321 ////////////////////////////////////////
322
323 ///// EQ /////////
init_eqlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)324 LV2_Handle init_eqlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
325 {
326 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
327
328 plug->nparams = 12;
329 plug->effectindex = IEQ;
330 plug->prev_bypass = 1;
331
332 getFeatures(plug,host_features);
333
334 plug->eq = new EQ(0,0,sample_freq, plug->period_max);
335
336 //eq has a bunch of setup stuff. Why isn't this in the EQ initalizer?
337 for (int i = 0; i <= 45; i += 5)
338 {
339 plug->eq->changepar (i + 10, 7);
340 plug->eq->changepar (i + 14, 0);
341 }
342
343 plug->eq->changepar (11, 31);
344 plug->eq->changepar (16, 63);
345 plug->eq->changepar (21, 125);
346 plug->eq->changepar (26, 250);
347 plug->eq->changepar (31, 500);
348 plug->eq->changepar (36, 1000);
349 plug->eq->changepar (41, 2000);
350 plug->eq->changepar (46, 4000);
351 plug->eq->changepar (51, 8000);
352 plug->eq->changepar (56, 16000);
353 return plug;
354 }
355
run_eqlv2(LV2_Handle handle,uint32_t nframes)356 void run_eqlv2(LV2_Handle handle, uint32_t nframes)
357 {
358 int i;
359 int val;
360
361 RKRLV2* plug = (RKRLV2*)handle;
362
363 if(*plug->bypass_p && plug->prev_bypass)
364 {
365 plug->eq->cleanup();
366 //copy dry signal
367 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
368 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
369 return;
370 }
371
372 //check and set changed parameters
373 i = 0;
374 val = (int)*plug->param_p[0]+64;//gain
375 if(plug->eq->getpar(0) != val)
376 {
377 plug->eq->changepar(0,val);
378 }
379 val = (int)*plug->param_p[1]+64;//q
380 if(plug->eq->getpar(13) != val)
381 {
382 int j;
383 for(j=0; j<10; j++)
384 {
385 plug->eq->changepar(j*5+13,val);
386 }
387 }
388 for(i=2; i<plug->nparams; i++)
389 {
390 val = (int)*plug->param_p[i]+64;//various freq. bands
391 if(plug->eq->getpar(5*i + 2) != val)
392 {
393 plug->eq->changepar(5*i+2,val);
394 }
395 }
396
397 //eq does in inline?
398 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
399 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
400
401 //now set out ports
402 plug->eq->efxoutl = plug->output_l_p;
403 plug->eq->efxoutr = plug->output_r_p;
404
405 //now run
406 plug->eq->out(plug->output_l_p,plug->output_r_p,nframes);
407
408 xfade_check(plug,nframes);
409
410 return;
411 }
412
413 ///// comp /////////
init_complv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)414 LV2_Handle init_complv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
415 {
416 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
417
418 plug->nparams = 9;
419 plug->effectindex = ICOMP;
420 plug->prev_bypass = 1;
421
422 plug->comp = new Compressor(0,0, sample_freq);
423
424 return plug;
425 }
426
run_complv2(LV2_Handle handle,uint32_t nframes)427 void run_complv2(LV2_Handle handle, uint32_t nframes)
428 {
429 int i;
430 int val;
431
432 RKRLV2* plug = (RKRLV2*)handle;
433
434 if(*plug->bypass_p && plug->prev_bypass)
435 {
436 plug->comp->cleanup();
437 //copy dry signal
438 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
439 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
440 return;
441 }
442
443 //check and set changed parameters
444 for(i=0; i<plug->nparams; i++)
445 {
446 val = (int)*plug->param_p[i];
447 if(plug->comp->getpar(i+1) != val)//this effect is 1 indexed
448 {
449 plug->comp->Compressor_Change(i+1,val);
450 }
451 }
452
453 //comp does in inline
454 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
455 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
456
457 //now set out ports
458 plug->comp->efxoutl = plug->output_l_p;
459 plug->comp->efxoutr = plug->output_r_p;
460
461 //now run
462 plug->comp->out(plug->output_l_p,plug->output_r_p,nframes);
463
464 xfade_check(plug,nframes);
465 return;
466 }
467
468 ///// dist /////////
init_distlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)469 LV2_Handle init_distlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
470 {
471 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
472
473 plug->nparams = 12;
474 plug->effectindex = IDIST;
475 plug->prev_bypass = 1;
476
477 getFeatures(plug,host_features);
478
479 plug->dist = new Distorsion(0,0, sample_freq, plug->period_max, /*oversampling*/2,
480 /*up interpolation method*/4, /*down interpolation method*/2);
481
482 return plug;
483 }
484
run_distlv2(LV2_Handle handle,uint32_t nframes)485 void run_distlv2(LV2_Handle handle, uint32_t nframes)
486 {
487 int i;
488 int val;
489
490 RKRLV2* plug = (RKRLV2*)handle;
491
492 if(*plug->bypass_p && plug->prev_bypass)
493 {
494 plug->dist->cleanup();
495 //copy dry signal
496 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
497 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
498 return;
499 }
500
501 //check and set changed parameters
502 i=0;
503 val = (int)*plug->param_p[i];//0 Wet/dry
504 if(plug->dist->getpar(i) != val)
505 {
506 plug->dist->changepar(i,val);
507 }
508 i++;
509 val = (int)*plug->param_p[i]+64;//1 pan
510 if(plug->dist->getpar(i) != val)
511 {
512 plug->dist->changepar(i,val);
513 }
514 for(i++; i<plug->nparams-1; i++) //2-10
515 {
516 val = (int)*plug->param_p[i];
517 if(plug->dist->getpar(i) != val)
518 {
519 plug->dist->changepar(i,val);
520 }
521 }
522 val = (int)*plug->param_p[i++];//skip one index, 12 octave
523 if(plug->dist->getpar(i) != val)
524 {
525 plug->dist->changepar(i,val);
526 }
527
528 //now set out ports and global period size
529 plug->dist->efxoutl = plug->output_l_p;
530 plug->dist->efxoutr = plug->output_r_p;
531
532 //now run
533 plug->dist->out(plug->input_l_p,plug->input_r_p,nframes);
534
535 //and for whatever reason we have to do the wet/dry mix ourselves
536 wetdry_mix(plug, plug->dist->outvolume, nframes);
537
538 xfade_check(plug,nframes);
539 return;
540 }
541
542 ///// echo /////////
init_echolv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)543 LV2_Handle init_echolv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
544 {
545 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
546
547 plug->nparams = 9;
548 plug->effectindex = IECHO;
549 plug->prev_bypass = 1;
550
551 plug->echo = new Echo(0,0,sample_freq);
552
553 return plug;
554 }
555
run_echolv2(LV2_Handle handle,uint32_t nframes)556 void run_echolv2(LV2_Handle handle, uint32_t nframes)
557 {
558 int i;
559 int val;
560
561 RKRLV2* plug = (RKRLV2*)handle;
562
563
564 if(*plug->bypass_p && plug->prev_bypass)
565 {
566 plug->echo->cleanup();
567 //copy dry signal
568 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
569 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
570 return;
571 }
572
573 //check and set changed parameters
574 i=0;
575 val = (int)*plug->param_p[i];//wet/dry
576 if(plug->echo->getpar(i) != val)
577 {
578 plug->echo->changepar(i,val);
579 }
580 i++;//panning is offset
581 val = (int)*plug->param_p[i]+64;
582 if(plug->echo->getpar(i) != val)
583 {
584 plug->echo->changepar(i,val);
585 }
586 i++;//delay is not offset
587 val = (int)*plug->param_p[i];
588 if(plug->echo->getpar(i) != val)
589 {
590 plug->echo->changepar(i,val);
591 }
592 i++;//LR delay is offset
593 val = (int)*plug->param_p[i]+64;
594 if(plug->echo->getpar(i) != val)
595 {
596 plug->echo->changepar(i,val);
597 }
598 for(i++; i<plug->nparams; i++)
599 {
600 val = (int)*plug->param_p[i];
601 if(plug->echo->getpar(i) != val)
602 {
603 plug->echo->changepar(i,val);
604 }
605 }
606
607 //now set out ports and global period size
608 plug->echo->efxoutl = plug->output_l_p;
609 plug->echo->efxoutr = plug->output_r_p;
610
611 //now run
612 plug->echo->out(plug->input_l_p,plug->input_r_p,nframes);
613
614 //and for whatever reason we have to do the wet/dry mix ourselves
615 wetdry_mix(plug, plug->echo->outvolume, nframes);
616
617 xfade_check(plug,nframes);
618 return;
619 }
620
621 ///// chorus/flanger /////////
init_choruslv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)622 LV2_Handle init_choruslv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
623 {
624 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
625
626 plug->nparams = 12;
627 plug->effectindex = ICHORUS;
628 plug->prev_bypass = 1;
629
630 plug->chorus = new Chorus(0,0,sample_freq);
631
632 return plug;
633 }
634
run_choruslv2(LV2_Handle handle,uint32_t nframes)635 void run_choruslv2(LV2_Handle handle, uint32_t nframes)
636 {
637 int i;
638 int val;
639
640 RKRLV2* plug = (RKRLV2*)handle;
641
642
643 if(*plug->bypass_p && plug->prev_bypass)
644 {
645 plug->chorus->cleanup();
646 //copy dry signal
647 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
648 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
649 return;
650 }
651
652 //LFO effects require period be set before setting other params
653 plug->chorus->PERIOD = nframes;
654
655 //check and set changed parameters
656 i=0;
657 val = (int)*plug->param_p[i];
658 if(plug->chorus->getpar(i) != val)
659 {
660 plug->chorus->changepar(i,val);
661 }
662 i++;
663 val = (int)*plug->param_p[i] +64;// 1 pan offset
664 if(plug->chorus->getpar(i) != val)
665 {
666 plug->chorus->changepar(i,val);
667 }
668 for(i++; i<5; i++) //2-4
669 {
670 val = (int)*plug->param_p[i];
671 if(plug->chorus->getpar(i) != val)
672 {
673 plug->chorus->changepar(i,val);
674 }
675 }
676 val = (int)*plug->param_p[i] +64;// 5 LR Del. offset
677 if(plug->chorus->getpar(i) != val)
678 {
679 plug->chorus->changepar(i,val);
680 }
681 for(i++; i<10; i++) // 6-9
682 {
683 val = (int)*plug->param_p[i];
684 if(plug->chorus->getpar(i) != val)
685 {
686 plug->chorus->changepar(i,val);
687 }
688 }
689 //skip param 10
690 for(; i<plug->nparams; i++)
691 {
692 val = (int)*plug->param_p[i];
693 if(plug->chorus->getpar(i+1) != val)
694 {
695 plug->chorus->changepar(i+1,val);
696 }
697 }
698
699 //now set out ports and global period size
700 plug->chorus->efxoutl = plug->output_l_p;
701 plug->chorus->efxoutr = plug->output_r_p;
702
703 //now run
704 plug->chorus->out(plug->input_l_p,plug->input_r_p,nframes);
705
706 //and for whatever reason we have to do the wet/dry mix ourselves
707 wetdry_mix(plug, plug->chorus->outvolume, nframes);
708
709 xfade_check(plug,nframes);
710 return;
711 }
712
713 ///// Analog Phaser /////////
init_aphaselv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)714 LV2_Handle init_aphaselv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
715 {
716 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
717
718 plug->nparams = 13;
719 plug->effectindex = IAPHASE;
720 plug->prev_bypass = 1;
721
722 plug->aphase = new Analog_Phaser(0,0,sample_freq);
723
724 return plug;
725 }
726
run_aphaselv2(LV2_Handle handle,uint32_t nframes)727 void run_aphaselv2(LV2_Handle handle, uint32_t nframes)
728 {
729 int i;
730 int val;
731
732 RKRLV2* plug = (RKRLV2*)handle;
733
734 if(*plug->bypass_p && plug->prev_bypass)
735 {
736 plug->aphase->cleanup();
737 //copy dry signal
738 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
739 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
740 return;
741 }
742
743 //LFO effects require period be set before setting other params
744 plug->aphase->PERIOD = nframes;
745
746 //check and set changed parameters
747 for(i=0; i<5; i++) //0-4
748 {
749 val = (int)*plug->param_p[i];
750 if(plug->aphase->getpar(i) != val)
751 {
752 plug->aphase->changepar(i,val);
753 }
754 }
755 val = (int)*plug->param_p[i] +64;// 5 LR Del. offset
756 if(plug->aphase->getpar(i) != val)
757 {
758 plug->aphase->changepar(i,val);
759 }
760 i++;
761 val = (int)*plug->param_p[i];// 6
762 if(plug->aphase->getpar(i) != val)
763 {
764 plug->aphase->changepar(i,val);
765 }
766 i++;
767 val = (int)*plug->param_p[i] +64;// 7 Fb offset
768 if(plug->aphase->getpar(i) != val)
769 {
770 plug->aphase->changepar(i,val);
771 }
772 for(i++; i<plug->nparams; i++)
773 {
774 val = (int)*plug->param_p[i];
775 if(plug->aphase->getpar(i) != val)
776 {
777 plug->aphase->changepar(i,val);
778 }
779 }
780
781 //now set out ports and global period size
782 plug->aphase->efxoutl = plug->output_l_p;
783 plug->aphase->efxoutr = plug->output_r_p;
784
785 //now run
786 plug->aphase->out(plug->input_l_p,plug->input_r_p,nframes);
787
788 //and for whatever reason we have to do the wet/dry mix ourselves
789 wetdry_mix(plug, plug->aphase->outvolume, nframes);
790
791 xfade_check(plug,nframes);
792 return;
793 }
794
795 //////// harmonizer /////////
init_harmnomidlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)796 LV2_Handle init_harmnomidlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
797 {
798 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
799
800 plug->nparams = 10;
801 plug->effectindex = IHARM_NM;
802 plug->prev_bypass = 1;
803
804 getFeatures(plug,host_features);
805
806 //magic numbers: shift qual 4, downsample 5, up qual 4, down qual 2,
807 plug->harm = new Harmonizer(0,0,4,5,SRC_LINEAR,SRC_SINC_FASTEST, plug->period_max, sample_freq);
808 plug->noteID = new Recognize(0,0,.6, sample_freq, 440.0, plug->period_max);//.6 is default trigger value
809 plug->chordID = new RecChord();
810
811
812
813 return plug;
814 }
815
run_harmnomidlv2(LV2_Handle handle,uint32_t nframes)816 void run_harmnomidlv2(LV2_Handle handle, uint32_t nframes)
817 {
818 int i;
819 int val;
820
821 RKRLV2* plug = (RKRLV2*)handle;
822
823 if(*plug->bypass_p && plug->prev_bypass)
824 {
825 plug->harm->cleanup();
826 //copy dry signal
827 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
828 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
829 return;
830 }
831
832 //check and set changed parameters
833 i = 0;
834 val = (int)*plug->param_p[i];// 0 wet/dry
835 if(plug->harm->getpar(i) != val)
836 {
837 plug->harm->changepar(i,val);
838 }
839 for(i++; i<3; i++) //1-2
840 {
841 val = (int)*plug->param_p[i] + 64;
842 if(plug->harm->getpar(i) != val)
843 {
844 plug->harm->changepar(i,val);
845 }
846 }
847 val = (int)*plug->param_p[i] + 12;// 3 interval
848 if(plug->harm->getpar(i) != val)
849 {
850 plug->harm->changepar(i,val);
851 }
852 i++;
853 val = (int)*plug->param_p[i];//4 filter freq
854 if(plug->harm->getpar(i) != val)
855 {
856 plug->harm->changepar(i,val);
857 }
858 i++;
859 val = (int)*plug->param_p[i];//5 select mode
860 if(plug->harm->getpar(i) != val)
861 {
862 plug->harm->changepar(i,val);
863 plug->chordID->cleanup();
864 if(!val) plug->harm->changepar(3,plug->harm->getpar(3));
865 }
866 for(i++; i<8; i++) //6-7
867 {
868 val = (int)*plug->param_p[i];
869 if(plug->harm->getpar(i) != val)
870 {
871 plug->harm->changepar(i,val);
872 plug->chordID->ctipo = plug->harm->getpar(7);//set chord type
873 plug->chordID->fundi = plug->harm->getpar(6);//set root note
874 plug->chordID->cc = 1;//mark chord has changed
875 }
876 }
877 for(; i<10; i++) // 8-9
878 {
879 val = (int)*plug->param_p[i] + 64;
880 if(plug->harm->getpar(i) != val)
881 {
882 plug->harm->changepar(i,val);
883 }
884 }
885 // midi mode, not implementing midi here
886 // val = (int)*plug->param_p[i];// 10 midi mode
887 // if(plug->aphase->getpar(i) != val)
888 // {
889 // plug->aphase->changepar(i,val);
890 // if(!val) plug->harm->changepar(3,plug->harm->getpar(3));
891 // }
892 /*
893 see Chord() in rkr.fl
894 harmonizer, need recChord and recNote.
895 see process.C ln 1507
896 */
897
898 //TODO may need to make sure input is over some threshold
899 if(plug->harm->mira && plug->harm->PSELECT)
900 // && have_signal( plug->input_l_p, plug->input_r_p, nframes))
901 {
902 plug->noteID->schmittFloat(plug->input_l_p,plug->input_r_p,nframes);
903 if(plug->noteID->reconota != -1 && plug->noteID->reconota != plug->noteID->last)
904 {
905 if(plug->noteID->afreq > 0.0)
906 {
907 plug->chordID->Vamos(0,plug->harm->Pinterval - 12,plug->noteID->reconota);
908 plug->harm->r_ratio = plug->chordID->r__ratio[0];//pass the found ratio
909 }
910 }
911 }
912 //now set out ports and global period size
913 plug->harm->efxoutl = plug->output_l_p;
914 plug->harm->efxoutr = plug->output_r_p;
915
916 //now run
917 plug->harm->out(plug->input_l_p,plug->input_r_p,nframes);
918
919 //and for whatever reason we have to do the wet/dry mix ourselves
920 wetdry_mix(plug, plug->harm->outvolume, nframes);
921
922 xfade_check(plug,nframes);
923 return;
924 }
925
926
927 ///// exciter /////////
init_exciterlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)928 LV2_Handle init_exciterlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
929 {
930 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
931
932 plug->nparams = 13;
933 plug->effectindex = IEXCITER;
934 plug->prev_bypass = 1;
935
936 getFeatures(plug,host_features);
937
938 plug->exciter = new Exciter(0,0, sample_freq, plug->period_max);
939
940 return plug;
941 }
942
run_exciterlv2(LV2_Handle handle,uint32_t nframes)943 void run_exciterlv2(LV2_Handle handle, uint32_t nframes)
944 {
945 int i;
946 int val;
947
948 RKRLV2* plug = (RKRLV2*)handle;
949
950
951 if(*plug->bypass_p && plug->prev_bypass)
952 {
953 plug->exciter->cleanup();
954 //copy dry signal
955 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
956 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
957 return;
958 }
959
960 //check and set changed parameters
961 for(i=0; i<plug->nparams; i++)
962 {
963 val = (int)*plug->param_p[i];
964 if(plug->exciter->getpar(i) != val)
965 {
966 plug->exciter->changepar(i,val);
967 }
968 }
969
970 //comp does in inline
971 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
972 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
973
974 //now set out ports
975 plug->exciter->efxoutl = plug->output_l_p;
976 plug->exciter->efxoutr = plug->output_r_p;
977
978 //now run
979 plug->exciter->out(plug->output_l_p,plug->output_r_p,nframes);
980
981 xfade_check(plug,nframes);
982 return;
983 }
984
985 ///// pan /////////
init_panlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)986 LV2_Handle init_panlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
987 {
988 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
989
990 plug->nparams = 9;
991 plug->effectindex = IPAN;
992 plug->prev_bypass = 1;
993
994 plug->pan = new Pan(0,0,sample_freq);
995
996 return plug;
997 }
998
run_panlv2(LV2_Handle handle,uint32_t nframes)999 void run_panlv2(LV2_Handle handle, uint32_t nframes)
1000 {
1001 int i;
1002 int val;
1003
1004 RKRLV2* plug = (RKRLV2*)handle;
1005
1006 if(*plug->bypass_p && plug->prev_bypass)
1007 {
1008 plug->pan->cleanup();
1009 //copy dry signal
1010 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1011 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1012 return;
1013 }
1014
1015 //LFO effects require period be set before setting other params
1016 plug->pan->PERIOD = nframes;
1017
1018 //check and set changed parameters
1019 i = 0;
1020 val = (int)*plug->param_p[i];// 0 wet/dry
1021 if(plug->pan->getpar(i) != val)
1022 {
1023 plug->pan->changepar(i,val);
1024 }
1025 i++;
1026 val = (int)*plug->param_p[i] + 64;// 1 pan
1027 if(plug->pan->getpar(i) != val)
1028 {
1029 plug->pan->changepar(i,val);
1030 }
1031 for(i++; i<5; i++) //2-4
1032 {
1033 val = (int)*plug->param_p[i];
1034 if(plug->pan->getpar(i) != val)
1035 {
1036 plug->pan->changepar(i,val);
1037 }
1038 }
1039 val = (int)*plug->param_p[i] +64;// 5 LR Del. offset
1040 if(plug->pan->getpar(i) != val)
1041 {
1042 plug->pan->changepar(i,val);
1043 }
1044 for(i++; i<plug->nparams; i++) //6-8
1045 {
1046 val = (int)*plug->param_p[i];
1047 if(plug->pan->getpar(i) != val)
1048 {
1049 plug->pan->changepar(i,val);
1050 }
1051 }
1052
1053 //now set out ports and global period size
1054 plug->pan->efxoutl = plug->output_l_p;
1055 plug->pan->efxoutr = plug->output_r_p;
1056
1057 //now run
1058 plug->pan->out(plug->input_l_p,plug->input_r_p,nframes);
1059
1060 //and for whatever reason we have to do the wet/dry mix ourselves
1061 wetdry_mix(plug, plug->pan->outvolume, nframes);
1062
1063 xfade_check(plug,nframes);
1064 return;
1065 }
1066
1067 ///// AlienWah /////////
init_alienlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1068 LV2_Handle init_alienlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1069 {
1070 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1071
1072 plug->nparams = 11;
1073 plug->effectindex = IAWAH;
1074 plug->prev_bypass = 1;
1075
1076 plug->alien = new Alienwah(0,0,sample_freq);
1077
1078 return plug;
1079 }
1080
run_alienlv2(LV2_Handle handle,uint32_t nframes)1081 void run_alienlv2(LV2_Handle handle, uint32_t nframes)
1082 {
1083 int i;
1084 int val;
1085
1086 RKRLV2* plug = (RKRLV2*)handle;
1087
1088
1089 if(*plug->bypass_p && plug->prev_bypass)
1090 {
1091 plug->alien->cleanup();
1092 //copy dry signal
1093 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1094 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1095 return;
1096 }
1097
1098 //LFO effects require period be set before setting other params
1099 plug->alien->PERIOD = nframes;
1100
1101 //check and set changed parameters
1102 i=0;
1103 val = (int)*plug->param_p[i];//0 Wet/Dry
1104 if(plug->alien->getpar(i) != val)
1105 {
1106 plug->alien->changepar(i,val);
1107 }
1108 i++;
1109 val = (int)*plug->param_p[i] +64;// 1 pan is offset
1110 if(plug->alien->getpar(i) != val)
1111 {
1112 plug->alien->changepar(i,val);
1113 }
1114 for(i++; i<5; i++) //2-4
1115 {
1116 val = (int)*plug->param_p[i];
1117 if(plug->alien->getpar(i) != val)
1118 {
1119 plug->alien->changepar(i,val);
1120 }
1121 }
1122 val = (int)*plug->param_p[i] +64;// 5 LR Del. offset
1123 if(plug->alien->getpar(i) != val)
1124 {
1125 plug->alien->changepar(i,val);
1126 }
1127 for(i++; i<plug->nparams; i++) //6-10
1128 {
1129 val = (int)*plug->param_p[i];
1130 if(plug->alien->getpar(i) != val)
1131 {
1132 plug->alien->changepar(i,val);
1133 }
1134 }
1135
1136 //now set out ports and global period size
1137 plug->alien->efxoutl = plug->output_l_p;
1138 plug->alien->efxoutr = plug->output_r_p;
1139
1140 //now run
1141 plug->alien->out(plug->input_l_p,plug->input_r_p,nframes);
1142
1143 //and for whatever reason we have to do the wet/dry mix ourselves
1144 wetdry_mix(plug, plug->alien->outvolume, nframes);
1145
1146 xfade_check(plug,nframes);
1147 return;
1148 }
1149
1150 ///// reverb /////////
init_revelv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1151 LV2_Handle init_revelv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1152 {
1153 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1154
1155 plug->nparams = 10;
1156 plug->effectindex = IREV;
1157 plug->prev_bypass = 1;
1158
1159 getFeatures(plug,host_features);
1160
1161 plug->reve = new Reverb(0,0,sample_freq,plug->period_max);
1162
1163 return plug;
1164 }
1165
run_revelv2(LV2_Handle handle,uint32_t nframes)1166 void run_revelv2(LV2_Handle handle, uint32_t nframes)
1167 {
1168 int i;
1169 int val;
1170
1171 RKRLV2* plug = (RKRLV2*)handle;
1172
1173
1174 if(*plug->bypass_p && plug->prev_bypass)
1175 {
1176 plug->reve->cleanup();
1177 //copy dry signal
1178 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1179 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1180 return;
1181 }
1182
1183 //check and set changed parameters
1184 i=0;
1185 val = (int)*plug->param_p[i];//0 Wet/Dry
1186 if(plug->reve->getpar(i) != val)
1187 {
1188 plug->reve->changepar(i,val);
1189 }
1190 i++;
1191 val = (int)*plug->param_p[i] +64;// 1 pan is offset
1192 if(plug->reve->getpar(i) != val)
1193 {
1194 plug->reve->changepar(i,val);
1195 }
1196 for(i++; i<5; i++) //2-4
1197 {
1198 val = (int)*plug->param_p[i];
1199 if(plug->reve->getpar(i) != val)
1200 {
1201 plug->reve->changepar(i,val);
1202 }
1203 }
1204 for(; i<plug->nparams; i++) //7-11 (5 and 6 are skipped
1205 {
1206 val = (int)*plug->param_p[i];
1207 if(plug->reve->getpar(i+2) != val)
1208 {
1209 plug->reve->changepar(i+2,val);
1210 }
1211 }
1212
1213 //now set out ports and global period size
1214 plug->reve->efxoutl = plug->output_l_p;
1215 plug->reve->efxoutr = plug->output_r_p;
1216
1217 //now run
1218 plug->reve->out(plug->input_l_p,plug->input_r_p,nframes);
1219
1220 //and for whatever reason we have to do the wet/dry mix ourselves
1221 wetdry_mix(plug, plug->reve->outvolume, nframes);
1222
1223 xfade_check(plug,nframes);
1224 return;
1225 }
1226
1227 ///// EQ Parametric /////////
init_eqplv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1228 LV2_Handle init_eqplv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1229 {
1230 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1231
1232 plug->nparams = 10;
1233 plug->effectindex = IEQP;
1234 plug->prev_bypass = 1;
1235
1236 getFeatures(plug,host_features);
1237
1238 plug->eq = new EQ(0,0,sample_freq, plug->period_max);
1239
1240 //eq has a bunch of setup stuff. Why isn't this in the EQ initalizer?
1241 for (int i = 0; i <= 10; i += 5)
1242 {
1243 plug->eq->changepar (i + 10, 7);
1244 plug->eq->changepar (i + 13, 64);
1245 plug->eq->changepar (i + 14, 0);
1246
1247 }
1248 return plug;
1249 }
1250
run_eqplv2(LV2_Handle handle,uint32_t nframes)1251 void run_eqplv2(LV2_Handle handle, uint32_t nframes)
1252 {
1253 int i;
1254 int val;
1255
1256 RKRLV2* plug = (RKRLV2*)handle;
1257
1258 if(*plug->bypass_p && plug->prev_bypass)
1259 {
1260 plug->eq->cleanup();
1261 //copy dry signal
1262 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1263 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1264 return;
1265 }
1266
1267 //check and set changed parameters
1268 i = 0;
1269
1270 val = (int)*plug->param_p[0]+64;//gain
1271 if(plug->eq->getpar(0) != val)
1272 {
1273 plug->eq->changepar(0,val);
1274 }
1275
1276 for(i=1; i<4; i++) //1-3 low band
1277 {
1278 val = (int)*plug->param_p[i]+64;
1279 if(plug->eq->getpar(i + 10) != val)
1280 {
1281 plug->eq->changepar(i+10,val);
1282 }
1283 }
1284 for(; i<7; i++) //4-6 mid band
1285 {
1286 val = (int)*plug->param_p[i]+64;
1287 if(plug->eq->getpar(i + 12) != val)
1288 {
1289 plug->eq->changepar(i+12,val);
1290 }
1291 }
1292 for(; i<plug->nparams; i++) //7-9 high band
1293 {
1294 val = (int)*plug->param_p[i]+64;
1295 if(plug->eq->getpar(i + 14) != val)
1296 {
1297 plug->eq->changepar(i+14,val);
1298 }
1299 }
1300
1301 //eq does it inline?
1302 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1303 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1304
1305 //now set out ports
1306 plug->eq->efxoutl = plug->output_l_p;
1307 plug->eq->efxoutr = plug->output_r_p;
1308
1309 //now run
1310 plug->eq->out(plug->output_l_p,plug->output_r_p,nframes);
1311
1312 xfade_check(plug,nframes);
1313 return;
1314 }
1315
1316 ///// Cabinet /////////
init_cablv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1317 LV2_Handle init_cablv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1318 {
1319 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1320
1321 plug->nparams = 10;
1322 plug->effectindex = ICAB;
1323 plug->prev_bypass = 1;
1324
1325 getFeatures(plug,host_features);
1326
1327 plug->cab = new Cabinet(0,0,sample_freq, plug->period_max);
1328
1329 return plug;
1330 }
1331
run_cablv2(LV2_Handle handle,uint32_t nframes)1332 void run_cablv2(LV2_Handle handle, uint32_t nframes)
1333 {
1334 int val;
1335
1336 RKRLV2* plug = (RKRLV2*)handle;
1337
1338 if(*plug->bypass_p && plug->prev_bypass)
1339 {
1340 plug->cab->cleanup();
1341 //copy dry signal
1342 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1343 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1344 return;
1345 }
1346
1347 //check and set changed parameters
1348 val = (int)*plug->param_p[0]+64;//gain
1349 if(plug->cab->getpar(0) != val)
1350 {
1351 plug->cab->changepar(0,val);
1352 }
1353
1354 val = (int)*plug->param_p[1];
1355 if(plug->cab->Cabinet_Preset != val)
1356 {
1357 plug->cab->setpreset(val);
1358 }
1359
1360 //cab does it inline?
1361 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1362 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1363
1364 //now set out ports
1365 plug->cab->efxoutl = plug->output_l_p;
1366 plug->cab->efxoutr = plug->output_r_p;
1367
1368 //now run
1369 plug->cab->out(plug->output_l_p,plug->output_r_p,nframes);
1370
1371 xfade_check(plug,nframes);
1372 return;
1373 }
1374
1375 ///// Musical Delay /////////
init_mdellv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1376 LV2_Handle init_mdellv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1377 {
1378 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1379
1380 plug->nparams = 13;
1381 plug->effectindex = IMDEL;
1382 plug->prev_bypass = 1;
1383
1384 plug->mdel = new MusicDelay (0,0,sample_freq);
1385
1386 return plug;
1387 }
1388
run_mdellv2(LV2_Handle handle,uint32_t nframes)1389 void run_mdellv2(LV2_Handle handle, uint32_t nframes)
1390 {
1391 int val;
1392 uint8_t i;
1393
1394 RKRLV2* plug = (RKRLV2*)handle;
1395
1396 if(*plug->bypass_p && plug->prev_bypass)
1397 {
1398 plug->mdel->cleanup();
1399 //copy dry signal
1400 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1401 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1402 return;
1403 }
1404
1405 //check and set changed parameters
1406 i = 0;
1407
1408 val = (int)*plug->param_p[0];//wetdry
1409 if(plug->mdel->getpar(0) != val)
1410 {
1411 plug->mdel->changepar(0,val);
1412 }
1413 val = (int)*plug->param_p[1]+64;//pan1
1414 if(plug->mdel->getpar(1) != val)
1415 {
1416 plug->mdel->changepar(1,val);
1417 }
1418
1419 for(i=2; i<7; i++) //2-6
1420 {
1421 val = (int)*plug->param_p[i];
1422 if(plug->mdel->getpar(i) != val)
1423 {
1424 plug->mdel->changepar(i,val);
1425 }
1426 }
1427 val = (int)*plug->param_p[i]+64;//pan2
1428 if(plug->mdel->getpar(i) != val)
1429 {
1430 plug->mdel->changepar(i,val);
1431 }
1432 for(i++; i<plug->nparams; i++) //8-12
1433 {
1434 val = (int)*plug->param_p[i];
1435 if(plug->mdel->getpar(i) != val)
1436 {
1437 plug->mdel->changepar(i,val);
1438 }
1439 }
1440
1441 //now set out ports and global period size
1442 plug->mdel->efxoutl = plug->output_l_p;
1443 plug->mdel->efxoutr = plug->output_r_p;
1444
1445 //now run
1446 plug->mdel->out(plug->input_l_p,plug->input_r_p,nframes);
1447
1448 //and for whatever reason we have to do the wet/dry mix ourselves
1449 wetdry_mix(plug, plug->mdel->outvolume, nframes);
1450
1451 xfade_check(plug,nframes);
1452 return;
1453 }
1454
1455 ///// wahwah /////////
init_wahlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1456 LV2_Handle init_wahlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1457 {
1458 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1459
1460 plug->nparams = 11;
1461 plug->effectindex = IWAH;
1462 plug->prev_bypass = 1;
1463
1464 getFeatures(plug,host_features);
1465
1466 plug->wah = new DynamicFilter(0,0,sample_freq, plug->period_max);
1467
1468 return plug;
1469 }
1470
run_wahlv2(LV2_Handle handle,uint32_t nframes)1471 void run_wahlv2(LV2_Handle handle, uint32_t nframes)
1472 {
1473 int i;
1474 int val;
1475
1476 RKRLV2* plug = (RKRLV2*)handle;
1477
1478 if(*plug->bypass_p && plug->prev_bypass)
1479 {
1480 plug->wah->cleanup();
1481 //copy dry signal
1482 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1483 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1484 return;
1485 }
1486
1487 //LFO effects require period be set before setting other params
1488 plug->wah->PERIOD = nframes;
1489
1490 //check and set changed parameters
1491 i=0;
1492 val = (int)*plug->param_p[i];
1493 if(plug->wah->getpar(i) != val)
1494 {
1495 plug->wah->changepar(i,val);
1496 }
1497 i++;
1498 val = (int)*plug->param_p[i] +64;// 1 pan offset
1499 if(plug->wah->getpar(i) != val)
1500 {
1501 plug->wah->changepar(i,val);
1502 }
1503 for(i++; i<5; i++) //2-4
1504 {
1505 val = (int)*plug->param_p[i];
1506 if(plug->wah->getpar(i) != val)
1507 {
1508 plug->wah->changepar(i,val);
1509 }
1510 }
1511 val = (int)*plug->param_p[i] +64;// 5 LR Del. offset
1512 if(plug->wah->getpar(i) != val)
1513 {
1514 plug->wah->changepar(i,val);
1515 }
1516 for(i++; i<plug->nparams; i++) // 6-10
1517 {
1518 val = (int)*plug->param_p[i];
1519 if(plug->wah->getpar(i) != val)
1520 {
1521 plug->wah->changepar(i,val);
1522 }
1523 }
1524
1525 //now set out ports and global period size
1526 plug->wah->efxoutl = plug->output_l_p;
1527 plug->wah->efxoutr = plug->output_r_p;
1528
1529 //now run
1530 plug->wah->out(plug->input_l_p,plug->input_r_p,nframes);
1531
1532 //and for whatever reason we have to do the wet/dry mix ourselves
1533 wetdry_mix(plug, plug->wah->outvolume, nframes);
1534
1535 xfade_check(plug,nframes);
1536 return;
1537 }
1538
1539 ///// derelict /////////
init_derelv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1540 LV2_Handle init_derelv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1541 {
1542 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1543
1544 plug->nparams = 12;
1545 plug->effectindex = IDERE;
1546 plug->prev_bypass = 1;
1547
1548 getFeatures(plug,host_features);
1549
1550 plug->dere = new NewDist(0,0, sample_freq, plug->period_max, /*oversampling*/2,
1551 /*up interpolation method*/4, /*down interpolation method*/2);
1552
1553 return plug;
1554 }
1555
run_derelv2(LV2_Handle handle,uint32_t nframes)1556 void run_derelv2(LV2_Handle handle, uint32_t nframes)
1557 {
1558 int i;
1559 int val;
1560
1561 RKRLV2* plug = (RKRLV2*)handle;
1562
1563 if(*plug->bypass_p && plug->prev_bypass)
1564 {
1565 plug->dere->cleanup();
1566 //copy dry signal
1567 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1568 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1569 return;
1570 }
1571
1572 //check and set changed parameters
1573 i=0;
1574 val = (int)*plug->param_p[i];//0 Wet/dry
1575 if(plug->dere->getpar(i) != val)
1576 {
1577 plug->dere->changepar(i,val);
1578 }
1579 i++;
1580 val = (int)*plug->param_p[i]+64;//1 pan
1581 if(plug->dere->getpar(i) != val)
1582 {
1583 plug->dere->changepar(i,val);
1584 }
1585 for(i++; i<plug->nparams; i++) //2-11
1586 {
1587 val = (int)*plug->param_p[i];
1588 if(plug->dere->getpar(i) != val)
1589 {
1590 plug->dere->changepar(i,val);
1591 }
1592 }
1593
1594 //now set out ports and global period size
1595 plug->dere->efxoutl = plug->output_l_p;
1596 plug->dere->efxoutr = plug->output_r_p;
1597
1598 //now run
1599 plug->dere->out(plug->input_l_p,plug->input_r_p,nframes);
1600
1601 //and for whatever reason we have to do the wet/dry mix ourselves
1602 wetdry_mix(plug, plug->dere->outvolume, nframes);
1603
1604 xfade_check(plug,nframes);
1605 return;
1606 }
1607
1608 ///// valve /////////
init_valvelv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1609 LV2_Handle init_valvelv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1610 {
1611 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1612
1613 plug->nparams = 13;
1614 plug->effectindex = IVALVE;
1615 plug->prev_bypass = 1;
1616
1617 getFeatures(plug,host_features);
1618
1619 plug->valve = new Valve(0,0, sample_freq, plug->period_max);
1620
1621 return plug;
1622 }
1623
run_valvelv2(LV2_Handle handle,uint32_t nframes)1624 void run_valvelv2(LV2_Handle handle, uint32_t nframes)
1625 {
1626 int i;
1627 int val;
1628
1629 RKRLV2* plug = (RKRLV2*)handle;
1630
1631 if(*plug->bypass_p && plug->prev_bypass)
1632 {
1633 plug->valve->cleanup();
1634 //copy dry signal
1635 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1636 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1637 return;
1638 }
1639
1640 //check and set changed parameters
1641 i=0;
1642 val = (int)*plug->param_p[i];//0 Wet/dry
1643 if(plug->valve->getpar(i) != val)
1644 {
1645 plug->valve->changepar(i,val);
1646 }
1647 i++;
1648 val = (int)*plug->param_p[i]+64;//1 pan
1649 if(plug->valve->getpar(i) != val)
1650 {
1651 plug->valve->changepar(i,val);
1652 }
1653 for(i++; i<plug->nparams; i++) //2-12
1654 {
1655 val = (int)*plug->param_p[i];
1656 if(plug->valve->getpar(i) != val)
1657 {
1658 plug->valve->changepar(i,val);
1659 }
1660 }
1661
1662 //now set out ports and global period size
1663 plug->valve->efxoutl = plug->output_l_p;
1664 plug->valve->efxoutr = plug->output_r_p;
1665
1666 //now run
1667 plug->valve->out(plug->input_l_p,plug->input_r_p,nframes);
1668
1669 //and for whatever reason we have to do the wet/dry mix ourselves
1670 wetdry_mix(plug, plug->valve->outvolume, nframes);
1671
1672 xfade_check(plug,nframes);
1673 return;
1674 }
1675
1676 ///// dual flange /////////
init_dflangelv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1677 LV2_Handle init_dflangelv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1678 {
1679 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1680
1681 plug->nparams = 15;
1682 plug->effectindex = IDFLANGE;
1683 plug->prev_bypass = 1;
1684
1685 plug->dflange = new Dflange(0,0, sample_freq);
1686
1687 return plug;
1688 }
1689
run_dflangelv2(LV2_Handle handle,uint32_t nframes)1690 void run_dflangelv2(LV2_Handle handle, uint32_t nframes)
1691 {
1692 int i;
1693 int val;
1694
1695 RKRLV2* plug = (RKRLV2*)handle;
1696
1697 if(*plug->bypass_p && plug->prev_bypass)
1698 {
1699 plug->dflange->cleanup();
1700 //copy dry signal
1701 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1702 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1703 return;
1704 }
1705
1706 //lfo effects must set period before params
1707 plug->dflange->PERIOD = nframes;
1708
1709 //check and set changed parameters
1710 i=0;
1711 val = (int)*plug->param_p[i]-64;//0 Wet/dry
1712 if(plug->dflange->getpar(i) != val)
1713 {
1714 plug->dflange->changepar(i,val);
1715 }
1716 for(i++; i<plug->nparams; i++) //1-14
1717 {
1718 val = (int)*plug->param_p[i];
1719 if(plug->dflange->getpar(i) != val)
1720 {
1721 plug->dflange->changepar(i,val);
1722 }
1723 }
1724
1725 //now set out ports and global period size
1726 plug->dflange->efxoutl = plug->output_l_p;
1727 plug->dflange->efxoutr = plug->output_r_p;
1728
1729 //dflange does it inline?
1730 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1731 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1732
1733 //now set out ports
1734 plug->dflange->efxoutl = plug->output_l_p;
1735 plug->dflange->efxoutr = plug->output_r_p;
1736
1737 //now run
1738 plug->dflange->out(plug->output_l_p,plug->output_r_p,nframes);
1739
1740 xfade_check(plug,nframes);
1741 return;
1742 }
1743
1744 //////// ring /////////
init_ringlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1745 LV2_Handle init_ringlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1746 {
1747 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1748
1749 plug->nparams = 13;
1750 plug->effectindex = IRING;
1751 plug->prev_bypass = 1;
1752
1753 getFeatures(plug,host_features);
1754
1755 //magic numbers: shift qual 4, downsample 5, up qual 4, down qual 2,
1756 plug->ring = new Ring(0,0, sample_freq);
1757 plug->noteID = new Recognize(0,0,.6, sample_freq, 440.0, plug->period_max);//.6 is default trigger value
1758
1759 return plug;
1760 }
1761
run_ringlv2(LV2_Handle handle,uint32_t nframes)1762 void run_ringlv2(LV2_Handle handle, uint32_t nframes)
1763 {
1764 int i;
1765 int val;
1766
1767 RKRLV2* plug = (RKRLV2*)handle;
1768
1769 if(*plug->bypass_p && plug->prev_bypass)
1770 {
1771 plug->ring->cleanup();
1772 //copy dry signal
1773 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1774 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1775 return;
1776 }
1777
1778 //check and set changed parameters
1779 i = 0;
1780 val = (int)*plug->param_p[i] - 64;// 0 wet/dry
1781 if(plug->ring->getpar(i) != val)
1782 {
1783 plug->ring->changepar(i,val);
1784 }
1785 i++;
1786 val = (int)*plug->param_p[i];// 1 pan
1787 if(plug->ring->getpar(i) != val)
1788 {
1789 plug->ring->changepar(i,val);
1790 }
1791 i++;
1792 val = (int)*plug->param_p[i] - 64;// 2 L/R cross
1793 if(plug->ring->getpar(i) != val)
1794 {
1795 plug->ring->changepar(i,val);
1796 }
1797 for(i++; i<plug->nparams; i++) //3-12
1798 {
1799 val = (int)*plug->param_p[i];
1800 if(plug->ring->getpar(i) != val)
1801 {
1802 plug->ring->changepar(i,val);
1803 }
1804 }
1805 //see process.C ln 1539
1806
1807 //TODO may need to make sure input is over some threshold
1808 if(plug->ring->Pafreq)
1809 {
1810 //copy over the data so that noteID doesn't tamper with it
1811 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1812 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1813 plug->noteID->schmittFloat(plug->output_l_p,plug->output_r_p,nframes);
1814 if(plug->noteID->reconota != -1 && plug->noteID->reconota != plug->noteID->last)
1815 {
1816 if(plug->noteID->afreq > 0.0)
1817 {
1818 plug->ring->Pfreq = lrintf(plug->noteID->lafreq);//round
1819 plug->noteID->last = plug->noteID->reconota;
1820 }
1821 }
1822 }
1823
1824 //now set out ports and global period size
1825 plug->ring->efxoutl = plug->output_l_p;
1826 plug->ring->efxoutr = plug->output_r_p;
1827
1828 //now run
1829 plug->ring->out(plug->input_l_p,plug->input_r_p,nframes);
1830
1831 //and for whatever reason we have to do the wet/dry mix ourselves
1832 wetdry_mix(plug, plug->ring->outvolume, nframes);
1833
1834 xfade_check(plug,nframes);
1835 return;
1836 }
1837
1838
1839 ///// mbdist /////////
init_mbdistlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1840 LV2_Handle init_mbdistlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1841 {
1842 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1843
1844 plug->nparams = 15;
1845 plug->effectindex = IMBDIST;
1846 plug->prev_bypass = 1;
1847
1848 getFeatures(plug,host_features);
1849
1850 plug->mbdist = new MBDist(0,0, sample_freq, plug->period_max, /*oversampling*/2,
1851 /*up interpolation method*/4, /*down interpolation method*/2);
1852
1853 return plug;
1854 }
1855
run_mbdistlv2(LV2_Handle handle,uint32_t nframes)1856 void run_mbdistlv2(LV2_Handle handle, uint32_t nframes)
1857 {
1858 int i;
1859 int val;
1860
1861 RKRLV2* plug = (RKRLV2*)handle;
1862
1863 if(*plug->bypass_p && plug->prev_bypass)
1864 {
1865 plug->mbdist->cleanup();
1866 //copy dry signal
1867 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1868 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1869 return;
1870 }
1871
1872 //check and set changed parameters
1873 i=0;
1874 val = (int)*plug->param_p[i];//0 Wet/dry
1875 if(plug->mbdist->getpar(i) != val)
1876 {
1877 plug->mbdist->changepar(i,val);
1878 }
1879 i++;
1880 val = (int)*plug->param_p[i]+64;//1 pan
1881 if(plug->mbdist->getpar(i) != val)
1882 {
1883 plug->mbdist->changepar(i,val);
1884 }
1885 for(i++; i<plug->nparams; i++) //2-12
1886 {
1887 val = (int)*plug->param_p[i];
1888 if(plug->mbdist->getpar(i) != val)
1889 {
1890 plug->mbdist->changepar(i,val);
1891 }
1892 }
1893
1894 //now set out ports and global period size
1895 plug->mbdist->efxoutl = plug->output_l_p;
1896 plug->mbdist->efxoutr = plug->output_r_p;
1897
1898 //now run
1899 plug->mbdist->out(plug->input_l_p,plug->input_r_p,nframes);
1900
1901 //and for whatever reason we have to do the wet/dry mix ourselves
1902 wetdry_mix(plug, plug->mbdist->outvolume, nframes);
1903
1904 xfade_check(plug,nframes);
1905 return;
1906 }
1907
1908 ///// arp /////////
init_arplv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1909 LV2_Handle init_arplv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1910 {
1911 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1912
1913 plug->nparams = 11;
1914 plug->effectindex = IARPIE;
1915 plug->prev_bypass = 1;
1916
1917 plug->arp = new Arpie(0,0,sample_freq);
1918
1919 return plug;
1920 }
1921
run_arplv2(LV2_Handle handle,uint32_t nframes)1922 void run_arplv2(LV2_Handle handle, uint32_t nframes)
1923 {
1924 int i;
1925 int val;
1926
1927 RKRLV2* plug = (RKRLV2*)handle;
1928
1929 if(*plug->bypass_p && plug->prev_bypass)
1930 {
1931 plug->arp->cleanup();
1932 //copy dry signal
1933 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
1934 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
1935 return;
1936 }
1937
1938 //check and set changed parameters
1939 i=0;
1940 val = (int)*plug->param_p[i];//w/d
1941 if(plug->arp->getpar(i) != val)
1942 {
1943 plug->arp->changepar(i,val);
1944 }
1945 i++;//panning is offset
1946 val = (int)*plug->param_p[i]+64;
1947 if(plug->arp->getpar(i) != val)
1948 {
1949 plug->arp->changepar(i,val);
1950 }
1951 i++;//delay is not offset
1952 val = (int)*plug->param_p[i];
1953 if(plug->arp->getpar(i) != val)
1954 {
1955 plug->arp->changepar(i,val);
1956 }
1957 i++;//LR delay is offset
1958 val = (int)*plug->param_p[i]+64;
1959 if(plug->arp->getpar(i) != val)
1960 {
1961 plug->arp->changepar(i,val);
1962 }
1963 for(i++; i<plug->nparams; i++) //rest are not offset
1964 {
1965 val = (int)*plug->param_p[i];
1966 if(plug->arp->getpar(i) != val)
1967 {
1968 plug->arp->changepar(i,val);
1969 }
1970 }
1971
1972 //now set out ports and global period size
1973 plug->arp->efxoutl = plug->output_l_p;
1974 plug->arp->efxoutr = plug->output_r_p;
1975
1976 //now run
1977 plug->arp->out(plug->input_l_p,plug->input_r_p,nframes);
1978
1979 //and for whatever reason we have to do the wet/dry mix ourselves
1980 wetdry_mix(plug, plug->arp->outvolume, nframes);
1981
1982 xfade_check(plug,nframes);
1983 return;
1984 }
1985
1986 ///// expand /////////
init_expandlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)1987 LV2_Handle init_expandlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
1988 {
1989 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
1990
1991 plug->nparams = 7;
1992 plug->effectindex = IEXPAND;
1993 plug->prev_bypass = 1;
1994
1995 getFeatures(plug,host_features);
1996
1997 plug->expand = new Expander(0,0, sample_freq, plug->period_max);
1998
1999 return plug;
2000 }
2001
run_expandlv2(LV2_Handle handle,uint32_t nframes)2002 void run_expandlv2(LV2_Handle handle, uint32_t nframes)
2003 {
2004 int i;
2005 int val;
2006
2007 RKRLV2* plug = (RKRLV2*)handle;
2008
2009 if(*plug->bypass_p && plug->prev_bypass)
2010 {
2011 plug->expand->cleanup();
2012 //copy dry signal
2013 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2014 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2015 return;
2016 }
2017
2018 //check and set changed parameters
2019 for(i=0; i<plug->nparams; i++)
2020 {
2021 val = (int)*plug->param_p[i];
2022 if(plug->expand->getpar(i+1) != val)//this effect is 1 indexed
2023 {
2024 plug->expand->Expander_Change(i+1,val);
2025 }
2026 }
2027
2028 //comp does in inline
2029 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2030 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2031
2032 //now set out ports
2033 plug->expand->efxoutl = plug->output_l_p;
2034 plug->expand->efxoutr = plug->output_r_p;
2035
2036 //now run
2037 plug->expand->out(plug->output_l_p,plug->output_r_p,nframes);
2038
2039 xfade_check(plug,nframes);
2040 return;
2041 }
2042
2043 ///// shuffle /////////
init_shuflv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2044 LV2_Handle init_shuflv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2045 {
2046 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2047
2048 plug->nparams = 11;
2049 plug->effectindex = ISHUFF;
2050 plug->prev_bypass = 1;
2051
2052 getFeatures(plug,host_features);
2053
2054 plug->shuf = new Shuffle(0,0,sample_freq,plug->period_max);
2055
2056 return plug;
2057 }
2058
run_shuflv2(LV2_Handle handle,uint32_t nframes)2059 void run_shuflv2(LV2_Handle handle, uint32_t nframes)
2060 {
2061 int i;
2062 int val;
2063
2064 RKRLV2* plug = (RKRLV2*)handle;
2065
2066 if(*plug->bypass_p && plug->prev_bypass)
2067 {
2068 plug->shuf->cleanup();
2069 //copy dry signal
2070 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2071 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2072 return;
2073 }
2074
2075 //check and set changed parameters
2076 for(i=0; i<plug->nparams; i++) //rest are not offset
2077 {
2078 val = (int)*plug->param_p[i];
2079 if(plug->shuf->getpar(i) != val)
2080 {
2081 plug->shuf->changepar(i,val);
2082 }
2083 }
2084
2085 //now set out ports and global period size
2086 plug->shuf->efxoutl = plug->output_l_p;
2087 plug->shuf->efxoutr = plug->output_r_p;
2088
2089 //now run
2090 plug->shuf->out(plug->input_l_p,plug->input_r_p,nframes);
2091
2092 //and for whatever reason we have to do the wet/dry mix ourselves
2093 wetdry_mix(plug, plug->shuf->outvolume, nframes);
2094
2095 xfade_check(plug,nframes);
2096 return;
2097 }
2098
2099
2100 ///// synth /////////
init_synthlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2101 LV2_Handle init_synthlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2102 {
2103 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2104
2105 plug->nparams = 16;
2106 plug->effectindex = ISYNTH;
2107 plug->prev_bypass = 1;
2108
2109 plug->synth = new Synthfilter(0,0,sample_freq);
2110
2111 return plug;
2112 }
2113
run_synthlv2(LV2_Handle handle,uint32_t nframes)2114 void run_synthlv2(LV2_Handle handle, uint32_t nframes)
2115 {
2116 unsigned int i;
2117 int val;
2118
2119 RKRLV2* plug = (RKRLV2*)handle;
2120
2121 if(*plug->bypass_p && plug->prev_bypass)
2122 {
2123 plug->synth->cleanup();
2124 //copy dry signal
2125 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2126 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2127 return;
2128 }
2129
2130 //LFO effects require period be set before setting other params
2131 plug->synth->PERIOD = nframes;
2132
2133 //check and set changed parameters
2134 for(i=0; i<5; i++) //0-4
2135 {
2136 val = (int)*plug->param_p[i];
2137 if(plug->synth->getpar(i) != val)
2138 {
2139 plug->synth->changepar(i,val);
2140 }
2141 }
2142 val = (int)*plug->param_p[i] +64;// 5 LR Del. offset
2143 if(plug->synth->getpar(i) != val)
2144 {
2145 plug->synth->changepar(i,val);
2146 }
2147 for(i++; i<plug->nparams; i++) //6-10
2148 {
2149 val = (int)*plug->param_p[i];
2150 if(plug->synth->getpar(i) != val)
2151 {
2152 plug->synth->changepar(i,val);
2153 }
2154 }
2155
2156 //now set out ports and global period size
2157 plug->synth->efxoutl = plug->output_l_p;
2158 plug->synth->efxoutr = plug->output_r_p;
2159
2160 //now run
2161 plug->synth->out(plug->input_l_p,plug->input_r_p,nframes);
2162
2163 //and for whatever reason we have to do the wet/dry mix ourselves
2164 wetdry_mix(plug, plug->synth->outvolume, nframes);
2165
2166 xfade_check(plug,nframes);
2167 return;
2168 }
2169
2170 ///// mbvol /////////
init_mbvollv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2171 LV2_Handle init_mbvollv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2172 {
2173 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2174
2175 plug->nparams = 14;
2176 plug->effectindex = IMBVOL;
2177 plug->prev_bypass = 1;
2178
2179 getFeatures(plug,host_features);
2180
2181 plug->mbvol = new MBVvol(0,0,sample_freq,plug->period_max);
2182
2183 return plug;
2184 }
2185
run_mbvollv2(LV2_Handle handle,uint32_t nframes)2186 void run_mbvollv2(LV2_Handle handle, uint32_t nframes)
2187 {
2188 int i;
2189 int val;
2190
2191 RKRLV2* plug = (RKRLV2*)handle;
2192
2193 if(*plug->bypass_p && plug->prev_bypass)
2194 {
2195 plug->mbvol->cleanup();
2196 //copy dry signal
2197 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2198 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2199 return;
2200 }
2201
2202 plug->mbvol->PERIOD = nframes;
2203
2204 //check and set changed parameters
2205 for(i=0; i<3; i++)
2206 {
2207 val = (int)*plug->param_p[i];
2208 if(plug->mbvol->getpar(i) != val)
2209 {
2210 plug->mbvol->changepar(i,val);
2211 }
2212 }
2213 val = (int)*plug->param_p[i] +64;//3 LR delay
2214 if(plug->mbvol->getpar(i) != val)
2215 {
2216 plug->mbvol->changepar(i,val);
2217 }
2218 for(i++; i<6; i++)
2219 {
2220 val = (int)*plug->param_p[i];
2221 if(plug->mbvol->getpar(i) != val)
2222 {
2223 plug->mbvol->changepar(i,val);
2224 }
2225 }
2226 val = (int)*plug->param_p[i] +64;//6 LR delay
2227 if(plug->mbvol->getpar(i) != val)
2228 {
2229 plug->mbvol->changepar(i,val);
2230 }
2231 for(i++; i<plug->nparams; i++) //skip legacy combi setting
2232 {
2233 val = (int)*plug->param_p[i];
2234 if(plug->mbvol->getpar(i+1) != val)
2235 {
2236 plug->mbvol->changepar(i+1,val);
2237 }
2238 }
2239
2240 //now set out ports and global period size
2241 plug->mbvol->efxoutl = plug->output_l_p;
2242 plug->mbvol->efxoutr = plug->output_r_p;
2243
2244 //now run
2245 plug->mbvol->out(plug->input_l_p,plug->input_r_p,nframes);
2246
2247 //and for whatever reason we have to do the wet/dry mix ourselves
2248 wetdry_mix(plug, plug->mbvol->outvolume, nframes);
2249
2250 xfade_check(plug,nframes);
2251 return;
2252 }
2253
2254 ///// mutro /////////
init_mutrolv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2255 LV2_Handle init_mutrolv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2256 {
2257 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2258
2259 plug->nparams = 19;
2260 plug->effectindex = IMUTRO;
2261 plug->prev_bypass = 1;
2262
2263 getFeatures(plug,host_features);
2264
2265 plug->mutro = new RyanWah(0,0,sample_freq, plug->period_max);
2266
2267 return plug;
2268 }
2269
run_mutrolv2(LV2_Handle handle,uint32_t nframes)2270 void run_mutrolv2(LV2_Handle handle, uint32_t nframes)
2271 {
2272 int i;
2273 int val;
2274
2275 RKRLV2* plug = (RKRLV2*)handle;
2276
2277 if(*plug->bypass_p && plug->prev_bypass)
2278 {
2279 plug->mutro->cleanup();
2280 //copy dry signal
2281 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2282 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2283 return;
2284 }
2285
2286 plug->mutro->PERIOD = nframes;
2287
2288 //check and set changed parameters
2289 for(i=0; i<5; i++)
2290 {
2291 val = (int)*plug->param_p[i];
2292 if(plug->mutro->getpar(i) != val)
2293 {
2294 plug->mutro->changepar(i,val);
2295 }
2296 }
2297 val = (int)*plug->param_p[i] +64;//5 LR delay
2298 if(plug->mutro->getpar(i) != val)
2299 {
2300 plug->mutro->changepar(i,val);
2301 }
2302 for(i++; i<17; i++)
2303 {
2304 val = (int)*plug->param_p[i];
2305 if(plug->mutro->getpar(i) != val)
2306 {
2307 plug->mutro->changepar(i,val);
2308 }
2309 }
2310 for(; i<plug->nparams; i++) //skip legacy mode and preset setting
2311 {
2312 val = (int)*plug->param_p[i];
2313 if(plug->mutro->getpar(i+2) != val)
2314 {
2315 plug->mutro->changepar(i+2,val);
2316 }
2317 }
2318
2319 //now set out ports and global period size
2320 plug->mutro->efxoutl = plug->output_l_p;
2321 plug->mutro->efxoutr = plug->output_r_p;
2322
2323 //now run
2324 plug->mutro->out(plug->input_l_p,plug->input_r_p,nframes);
2325
2326 //and for whatever reason we have to do the wet/dry mix ourselves
2327 wetdry_mix(plug, plug->mutro->outvolume, nframes);
2328
2329 xfade_check(plug,nframes);
2330 return;
2331 }
2332
2333 ///// echoverse /////////
init_echoverselv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2334 LV2_Handle init_echoverselv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2335 {
2336 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2337
2338 plug->nparams = 10;
2339 plug->effectindex = IECHOVERSE;
2340 plug->prev_bypass = 1;
2341
2342 plug->echoverse = new RBEcho(0,0,sample_freq);
2343
2344 return plug;
2345 }
2346
run_echoverselv2(LV2_Handle handle,uint32_t nframes)2347 void run_echoverselv2(LV2_Handle handle, uint32_t nframes)
2348 {
2349 int i;
2350 int val;
2351
2352 RKRLV2* plug = (RKRLV2*)handle;
2353
2354 if(*plug->bypass_p && plug->prev_bypass)
2355 {
2356 plug->echoverse->cleanup();
2357 //copy dry signal
2358 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2359 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2360 return;
2361 }
2362
2363 //check and set changed parameters
2364 i=0;
2365 val = (int)*plug->param_p[i];//wet/dry
2366 if(plug->echoverse->getpar(i) != val)
2367 {
2368 plug->echoverse->changepar(i,val);
2369 }
2370 i++;//1 panning is offset
2371 val = (int)*plug->param_p[i]+64;
2372 if(plug->echoverse->getpar(i) != val)
2373 {
2374 plug->echoverse->changepar(i,val);
2375 }
2376 i++;//2 delay is not offset
2377 val = (int)*plug->param_p[i];
2378 if(plug->echoverse->getpar(i) != val)
2379 {
2380 plug->echoverse->changepar(i,val);
2381 }
2382 for(i++; i<5; i++) //3,4 LR delay and angle is offset
2383 {
2384 val = (int)*plug->param_p[i]+64;
2385 if(plug->echoverse->getpar(i) != val)
2386 {
2387 plug->echoverse->changepar(i,val);
2388 }
2389 }
2390 for( ; i<plug->nparams; i++)
2391 {
2392 val = (int)*plug->param_p[i];
2393 if(plug->echoverse->getpar(i) != val)
2394 {
2395 plug->echoverse->changepar(i,val);
2396 }
2397 }
2398
2399 //now set out ports and global period size
2400 plug->echoverse->efxoutl = plug->output_l_p;
2401 plug->echoverse->efxoutr = plug->output_r_p;
2402
2403 //now run
2404 plug->echoverse->out(plug->input_l_p,plug->input_r_p,nframes);
2405
2406 //and for whatever reason we have to do the wet/dry mix ourselves
2407 wetdry_mix(plug, plug->echoverse->outvolume, nframes);
2408
2409 xfade_check(plug,nframes);
2410 return;
2411 }
2412
2413 ///// coilcrafter /////////
init_coillv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2414 LV2_Handle init_coillv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2415 {
2416 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2417
2418 plug->nparams = 7;
2419 plug->effectindex = ICOIL;
2420 plug->prev_bypass = 1;
2421
2422 getFeatures(plug,host_features);
2423
2424 plug->coil = new CoilCrafter(0,0,sample_freq,plug->period_max);
2425
2426 return plug;
2427 }
2428
run_coillv2(LV2_Handle handle,uint32_t nframes)2429 void run_coillv2(LV2_Handle handle, uint32_t nframes)
2430 {
2431 int i;
2432 int val;
2433
2434 RKRLV2* plug = (RKRLV2*)handle;
2435
2436 if(*plug->bypass_p && plug->prev_bypass)
2437 {
2438 plug->coil->cleanup();
2439 //copy dry signal
2440 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2441 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2442 return;
2443 }
2444
2445 //check and set changed parameters
2446 i=0;
2447 val = (int)*plug->param_p[i];//wet/dry
2448 if(plug->coil->getpar(i) != val)
2449 {
2450 plug->coil->changepar(i,val);
2451 }
2452 for(i++; i<plug->nparams; i++) //skip origin and destinations
2453 {
2454 val = (int)*plug->param_p[i];
2455 if(plug->coil->getpar(i+2) != val)
2456 {
2457 plug->coil->changepar(i+2,val);
2458 }
2459 }
2460 //coilcrafter does it inline
2461 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2462 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2463
2464 //now set out ports
2465 plug->coil->efxoutl = plug->output_l_p;
2466 plug->coil->efxoutr = plug->output_r_p;
2467
2468 //now run
2469 plug->coil->out(plug->output_l_p,plug->output_r_p,nframes);
2470
2471 xfade_check(plug,nframes);
2472 return;
2473 }
2474
2475 ///// shelfboost /////////
init_shelflv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2476 LV2_Handle init_shelflv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2477 {
2478 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2479
2480 plug->nparams = 5;
2481 plug->effectindex = ISHELF;
2482 plug->prev_bypass = 1;
2483
2484 getFeatures(plug,host_features);
2485
2486 plug->shelf = new ShelfBoost(0,0,sample_freq, plug->period_max);
2487
2488 return plug;
2489 }
2490
run_shelflv2(LV2_Handle handle,uint32_t nframes)2491 void run_shelflv2(LV2_Handle handle, uint32_t nframes)
2492 {
2493 int i;
2494 int val;
2495
2496 RKRLV2* plug = (RKRLV2*)handle;
2497
2498 if(*plug->bypass_p && plug->prev_bypass)
2499 {
2500 plug->shelf->cleanup();
2501 //copy dry signal
2502 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2503 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2504 return;
2505 }
2506
2507 //check and set changed parameters
2508 for(i=0; i<plug->nparams; i++)
2509 {
2510 val = (int)*plug->param_p[i];
2511 if(plug->shelf->getpar(i) != val)
2512 {
2513 plug->shelf->changepar(i,val);
2514 }
2515 }
2516 //coilcrafter does it inline
2517 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2518 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2519
2520 //now set out ports
2521 plug->shelf->efxoutl = plug->output_l_p;
2522 plug->shelf->efxoutr = plug->output_r_p;
2523
2524 //now run
2525 plug->shelf->out(plug->output_l_p,plug->output_r_p,nframes);
2526
2527 xfade_check(plug,nframes);
2528 return;
2529 }
2530
2531 ///// Vocoder /////////
init_voclv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2532 LV2_Handle init_voclv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2533 {
2534 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2535
2536 plug->nparams = 7;
2537 plug->effectindex = IVOC;
2538 plug->prev_bypass = 1;
2539
2540 getFeatures(plug,host_features);
2541
2542 plug->voc = new Vocoder(0,0,0,/*bands*/32,/*downsamplex2*/5,/*upsample quality*/4,
2543 /*downsample quality*/ 2,sample_freq,plug->period_max);
2544
2545 return plug;
2546 }
2547
run_voclv2(LV2_Handle handle,uint32_t nframes)2548 void run_voclv2(LV2_Handle handle, uint32_t nframes)
2549 {
2550 int i;
2551 int val;
2552
2553 RKRLV2* plug = (RKRLV2*)handle;
2554
2555 if(*plug->bypass_p && plug->prev_bypass)
2556 {
2557 plug->voc->cleanup();
2558 //copy dry signal
2559 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2560 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2561 return;
2562 }
2563
2564 //check and set changed parameters
2565 i=0;
2566 val = (int)*plug->param_p[i];//wet/dry
2567 if(plug->voc->getpar(i) != val)
2568 {
2569 plug->voc->changepar(i,val);
2570 }
2571 i++;
2572 val = (int)*plug->param_p[i]+64;//pan
2573 if(plug->voc->getpar(i) != val)
2574 {
2575 plug->voc->changepar(i,val);
2576 }
2577 for(i++; i<plug->nparams; i++)
2578 {
2579 val = (int)*plug->param_p[i];
2580 if(plug->voc->getpar(i) != val)
2581 {
2582 plug->voc->changepar(i,val);
2583 }
2584 }
2585
2586 //set aux input and out ports
2587 plug->voc->auxresampled = plug->param_p[VOCODER_AUX_IN];
2588 plug->voc->efxoutl = plug->output_l_p;
2589 plug->voc->efxoutr = plug->output_r_p;
2590
2591 //now run
2592 plug->voc->out(plug->input_l_p,plug->input_r_p,nframes);
2593
2594 //and for whatever reason we have to do the wet/dry mix ourselves
2595 wetdry_mix(plug, plug->voc->outvolume, nframes);
2596
2597 //and set VU meter
2598 *plug->param_p[VOCODER_VU_LEVEL] = plug->voc->vulevel;
2599
2600 xfade_check(plug,nframes);
2601 return;
2602 }
2603
2604 ///// Sustainer /////////
init_suslv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2605 LV2_Handle init_suslv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2606 {
2607 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2608
2609 plug->nparams = 2;
2610 plug->effectindex = ISUS;
2611 plug->prev_bypass = 1;
2612
2613
2614 plug->sus = new Sustainer(0,0,sample_freq);
2615
2616 return plug;
2617 }
2618
run_suslv2(LV2_Handle handle,uint32_t nframes)2619 void run_suslv2(LV2_Handle handle, uint32_t nframes)
2620 {
2621 int i;
2622 int val;
2623
2624 RKRLV2* plug = (RKRLV2*)handle;
2625
2626 if(*plug->bypass_p && plug->prev_bypass)
2627 {
2628 plug->sus->cleanup();
2629 //copy dry signal
2630 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2631 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2632 return;
2633 }
2634
2635 //check and set changed parameters
2636 for(i=0; i<plug->nparams; i++)
2637 {
2638 val = (int)*plug->param_p[i];
2639 if(plug->sus->getpar(i) != val)
2640 {
2641 plug->sus->changepar(i,val);
2642 }
2643 }
2644
2645 //sustainer does it inline
2646 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2647 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2648
2649 //now set out ports
2650 plug->sus->efxoutl = plug->output_l_p;
2651 plug->sus->efxoutr = plug->output_r_p;
2652
2653 //now run
2654 plug->sus->out(plug->output_l_p,plug->output_r_p,nframes);
2655
2656 xfade_check(plug,nframes);
2657 return;
2658 }
2659
2660 ///// Sequence /////////
init_seqlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2661 LV2_Handle init_seqlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2662 {
2663 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2664
2665 plug->nparams = 15;
2666 plug->effectindex = ISEQ;
2667 plug->prev_bypass = 1;
2668
2669 getFeatures(plug,host_features);
2670
2671 plug->seq = new Sequence(0,0,/*shifter quality*/4,/*downsamplex2*/5,/*upsample quality*/4,
2672 /*downsample quality*/ 2,sample_freq,plug->period_max);
2673
2674 return plug;
2675 }
2676
run_seqlv2(LV2_Handle handle,uint32_t nframes)2677 void run_seqlv2(LV2_Handle handle, uint32_t nframes)
2678 {
2679 int i;
2680 int val;
2681
2682 RKRLV2* plug = (RKRLV2*)handle;
2683
2684 if(*plug->bypass_p && plug->prev_bypass)
2685 {
2686 plug->seq->cleanup();
2687 //copy dry signal
2688 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2689 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2690 return;
2691 }
2692
2693 //check and set changed parameters
2694 for(i=0; i<10; i++)
2695 {
2696 val = (int)*plug->param_p[i];
2697 if(plug->seq->getpar(i) != val)
2698 {
2699 plug->seq->changepar(i,val);
2700 }
2701 }
2702 val = (int)*plug->param_p[i]+64;//Q or panning
2703 if(plug->seq->getpar(i) != val)
2704 {
2705 plug->seq->changepar(i,val);
2706 }
2707 for(i++; i<plug->nparams; i++)
2708 {
2709 val = (int)*plug->param_p[i];
2710 if(plug->seq->getpar(i) != val)
2711 {
2712 plug->seq->changepar(i,val);
2713 }
2714 }
2715
2716 //set out ports
2717 plug->seq->efxoutl = plug->output_l_p;
2718 plug->seq->efxoutr = plug->output_r_p;
2719
2720 //now run
2721 plug->seq->out(plug->input_l_p,plug->input_r_p,nframes);
2722
2723 //and for whatever reason we have to do the wet/dry mix ourselves
2724 wetdry_mix(plug, plug->seq->outvolume, nframes);
2725
2726 xfade_check(plug,nframes);
2727 return;
2728 }
2729
2730 ///// Shifter /////////
init_shiftlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2731 LV2_Handle init_shiftlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2732 {
2733 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2734
2735 plug->nparams = 10;
2736 plug->effectindex = ISHIFT;
2737 plug->prev_bypass = 1;
2738
2739 getFeatures(plug,host_features);
2740
2741 plug->shift = new Shifter(0,0,/*shifter quality*/4,/*downsamplex2*/5,/*upsample quality*/4,
2742 /*downsample quality*/ 2,sample_freq,plug->period_max);
2743
2744 return plug;
2745 }
2746
run_shiftlv2(LV2_Handle handle,uint32_t nframes)2747 void run_shiftlv2(LV2_Handle handle, uint32_t nframes)
2748 {
2749 int i;
2750 int val;
2751
2752 RKRLV2* plug = (RKRLV2*)handle;
2753
2754 if(*plug->bypass_p && plug->prev_bypass)
2755 {
2756 plug->shift->cleanup();
2757 //copy dry signal
2758 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2759 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2760 return;
2761 }
2762
2763 //check and set changed parameters
2764 i=0;
2765 val = (int)*plug->param_p[i];//wet/dry
2766 if(plug->shift->getpar(i) != val)
2767 {
2768 plug->shift->changepar(i,val);
2769 }
2770 for(i++; i<3; i++) //pan, gain
2771 {
2772 val = (int)*plug->param_p[i]+64;
2773 if(plug->shift->getpar(i) != val)
2774 {
2775 plug->shift->changepar(i,val);
2776 }
2777 }
2778 for(; i<plug->nparams; i++)
2779 {
2780 val = (int)*plug->param_p[i];
2781 if(plug->shift->getpar(i) != val)
2782 {
2783 plug->shift->changepar(i,val);
2784 }
2785 }
2786
2787 //set out ports
2788 plug->shift->efxoutl = plug->output_l_p;
2789 plug->shift->efxoutr = plug->output_r_p;
2790
2791 //now run
2792 plug->shift->out(plug->input_l_p,plug->input_r_p,nframes);
2793
2794 //and for whatever reason we have to do the wet/dry mix ourselves
2795 wetdry_mix(plug, plug->shift->outvolume, nframes);
2796
2797 xfade_check(plug,nframes);
2798 return;
2799 }
2800
2801 ///// StompBox /////////
init_stomplv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2802 LV2_Handle init_stomplv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2803 {
2804 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2805
2806 plug->nparams = 6;
2807 plug->effectindex = ISTOMP;
2808 plug->prev_bypass = 1;
2809
2810 getFeatures(plug,host_features);
2811
2812 plug->stomp = new StompBox(0,0, sample_freq, plug->period_max, /*oversampling*/2,
2813 /*up interpolation method*/SRC_LINEAR, /*down interpolation method*/SRC_SINC_FASTEST);
2814
2815 return plug;
2816 }
2817
run_stomplv2(LV2_Handle handle,uint32_t nframes)2818 void run_stomplv2(LV2_Handle handle, uint32_t nframes)
2819 {
2820 int i;
2821 int val;
2822
2823 RKRLV2* plug = (RKRLV2*)handle;
2824
2825 if(*plug->bypass_p && plug->prev_bypass)
2826 {
2827 plug->stomp->cleanup();
2828 //copy dry signal
2829 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2830 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2831 return;
2832 }
2833
2834 //check and set changed parameters
2835 for(i=0; i<plug->nparams; i++)
2836 {
2837 val = (int)*plug->param_p[i];
2838 if(plug->stomp->getpar(i) != val)
2839 {
2840 plug->stomp->changepar(i,val);
2841 }
2842 }
2843
2844 //stompbox does it inline
2845 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2846 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2847
2848 //now set out ports
2849 plug->stomp->efxoutl = plug->output_l_p;
2850 plug->stomp->efxoutr = plug->output_r_p;
2851
2852 //now run
2853 plug->stomp->out(plug->output_l_p,plug->output_r_p,nframes);
2854
2855 xfade_check(plug,nframes);
2856 return;
2857 }
2858 ///// StompBox Fuzz /////////
init_stomp_fuzzlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2859 LV2_Handle init_stomp_fuzzlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2860 {
2861 //this is the same but has better labeling as controls act differently
2862 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2863
2864 plug->nparams = 5;
2865 plug->effectindex = IFUZZ;
2866 plug->prev_bypass = 1;
2867
2868 getFeatures(plug,host_features);
2869
2870 plug->stomp = new StompBox(0,0, sample_freq, plug->period_max, /*oversampling*/1,
2871 /*up interpolation method*/SRC_LINEAR, /*down interpolation method*/SRC_LINEAR);
2872 plug->stomp->changepar(5,7);//set to fuzz
2873
2874 return plug;
2875 }
2876
2877 ///// Reverbtron /////////
init_revtronlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)2878 LV2_Handle init_revtronlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
2879 {
2880 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
2881
2882 plug->nparams = 14;
2883 plug->effectindex = IREVTRON;
2884 plug->prev_bypass = 1;
2885
2886 getFeatures(plug,host_features);
2887 if(!plug->scheduler || !plug->urid_map)
2888 {
2889 //a required feature was not supported by host
2890 free(plug);
2891 return 0;
2892 }
2893 lv2_atom_forge_init(&plug->forge, plug->urid_map);
2894
2895 plug->revtron = new Reverbtron(0,0, sample_freq, plug->period_max, /*downsample*/5, /*up interpolation method*/SRC_LINEAR, /*down interpolation method*/SRC_SINC_FASTEST);
2896 plug->revtron->changepar(4,1);//set to user selected files
2897 plug->rvbfile = new RvbFile;
2898
2899 return plug;
2900 }
2901
run_revtronlv2(LV2_Handle handle,uint32_t nframes)2902 void run_revtronlv2(LV2_Handle handle, uint32_t nframes)
2903 {
2904 int i;
2905 int val;
2906
2907 RKRLV2* plug = (RKRLV2*)handle;
2908
2909 if(*plug->bypass_p && plug->prev_bypass)
2910 {
2911 plug->revtron->cleanup();
2912 //copy dry signal
2913 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
2914 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
2915 return;
2916 }
2917
2918 //check and set changed parameters
2919 for(i=0; i<4; i++)//skip user
2920 {
2921 val = (int)*plug->param_p[i];
2922 if(plug->revtron->getpar(i) != val)
2923 {
2924 plug->revtron->changepar(i,val);
2925 }
2926 }
2927 for(; i+1<8; i++)//skip file num
2928 {
2929 val = (int)*plug->param_p[i];
2930 if(plug->revtron->getpar(i+1) != val)
2931 {
2932 plug->revtron->changepar(i+1,val);
2933 }
2934 }
2935 for(; i+2<11; i++)
2936 {
2937 val = (int)*plug->param_p[i];
2938 if(plug->revtron->getpar(i+2) != val)
2939 {
2940 plug->revtron->changepar(i+2,val);
2941 }
2942 }
2943 val = (int)*plug->param_p[i]+64;//11 panning
2944 if(plug->revtron->getpar(i+2) != val)
2945 {
2946 plug->revtron->changepar(i+2,val);
2947 }
2948 for(i++; i<plug->nparams; i++)
2949 {
2950 val = (int)*plug->param_p[i];
2951 if(plug->revtron->getpar(i+2) != val)
2952 {
2953 plug->revtron->changepar(i+2,val);
2954 }
2955 }
2956
2957 // Set up forge to write directly to notify output port.
2958 const uint32_t notify_capacity = plug->atom_out_p->atom.size;
2959 lv2_atom_forge_set_buffer(&plug->forge, (uint8_t*)plug->atom_out_p, notify_capacity);
2960
2961 // Start a sequence in the notify output port.
2962 lv2_atom_forge_sequence_head(&plug->forge, &plug->atom_frame, 0);
2963
2964 //if we loaded a state, send the new file name to the host to display
2965 if(plug->file_changed)
2966 {
2967 plug->file_changed = 0;
2968 lv2_atom_forge_frame_time(&plug->forge, 0);
2969 LV2_Atom_Forge_Frame frame;
2970 lv2_atom_forge_object( &plug->forge, &frame, 0, plug->URIDs.patch_Set);
2971
2972 lv2_atom_forge_key(&plug->forge, plug->URIDs.patch_property);
2973 lv2_atom_forge_urid(&plug->forge, plug->URIDs.filetype_rvb);
2974 lv2_atom_forge_key(&plug->forge, plug->URIDs.patch_value);
2975 lv2_atom_forge_path(&plug->forge, plug->revtron->File.Filename, strlen(plug->revtron->File.Filename)+1);
2976
2977 lv2_atom_forge_pop(&plug->forge, &frame);
2978 }
2979
2980
2981 //see if there's a file
2982 LV2_ATOM_SEQUENCE_FOREACH( plug->atom_in_p, ev)
2983 {
2984 if (ev->body.type == plug->URIDs.atom_Object)
2985 {
2986 const LV2_Atom_Object* obj = (const LV2_Atom_Object*)&ev->body;
2987 if (obj->body.otype == plug->URIDs.patch_Set)
2988 {
2989 // Get the property the set message is setting
2990 const LV2_Atom* property = NULL;
2991 lv2_atom_object_get(obj, plug->URIDs.patch_property, &property, 0);
2992 if (property && property->type == plug->URIDs.atom_URID)
2993 {
2994 const uint32_t key = ((const LV2_Atom_URID*)property)->body;
2995 if (key == plug->URIDs.filetype_rvb)
2996 {
2997 // a new file! pass the atom to the worker thread to load it
2998 plug->scheduler->schedule_work(plug->scheduler->handle, lv2_atom_total_size(&ev->body), &ev->body);
2999 }//property is rvb file
3000 }//property is URID
3001 }
3002 else if (obj->body.otype == plug->URIDs.patch_Get)
3003 {
3004 // Received a get message, emit our state (probably to UI)
3005 lv2_atom_forge_frame_time(&plug->forge, ev->time.frames );//use current event's time
3006 LV2_Atom_Forge_Frame frame;
3007 lv2_atom_forge_object( &plug->forge, &frame, 0, plug->URIDs.patch_Set);
3008
3009 lv2_atom_forge_key(&plug->forge, plug->URIDs.patch_property);
3010 lv2_atom_forge_urid(&plug->forge, plug->URIDs.filetype_rvb);
3011 lv2_atom_forge_key(&plug->forge, plug->URIDs.patch_value);
3012 lv2_atom_forge_path(&plug->forge, plug->revtron->File.Filename, strlen(plug->revtron->File.Filename)+1);
3013
3014 lv2_atom_forge_pop(&plug->forge, &frame);
3015 }
3016 }//atom is object
3017 }//each atom in sequence
3018
3019 //now set out ports
3020 plug->revtron->efxoutl = plug->output_l_p;
3021 plug->revtron->efxoutr = plug->output_r_p;
3022
3023 //now run
3024 plug->revtron->out(plug->input_l_p,plug->input_r_p,nframes);
3025
3026 //and for whatever reason we have to do the wet/dry mix ourselves
3027 wetdry_mix(plug, plug->revtron->outvolume, nframes);
3028
3029 xfade_check(plug,nframes);
3030 return;
3031 }
3032
revwork(LV2_Handle handle,LV2_Worker_Respond_Function respond,LV2_Worker_Respond_Handle rhandle,uint32_t size,const void * data)3033 static LV2_Worker_Status revwork(LV2_Handle handle, LV2_Worker_Respond_Function respond, LV2_Worker_Respond_Handle rhandle, uint32_t size, const void* data)
3034 {
3035
3036 RKRLV2* plug = (RKRLV2*)handle;
3037 LV2_Atom_Object* obj = (LV2_Atom_Object*)data;
3038 const LV2_Atom* file_path;
3039
3040 //work was scheduled to load a new file
3041 lv2_atom_object_get(obj, plug->URIDs.patch_value, &file_path, 0);
3042 if (file_path && file_path->type == plug->URIDs.atom_Path)
3043 {
3044 // Load file.
3045 char* path = (char*)LV2_ATOM_BODY_CONST(file_path);
3046 //the file is too large for a host's circular buffer
3047 //so store it in the plugin for the response to use
3048 //to prevent threading issues, we'll use a simple
3049 //flag as a crude mutex
3050 while(plug->loading_file)
3051 usleep(1000);
3052 plug->loading_file = 1;
3053 *plug->rvbfile = plug->revtron->loadfile(path);
3054 respond(rhandle,0,0);
3055 }//got file
3056 else
3057 return LV2_WORKER_ERR_UNKNOWN;
3058
3059 return LV2_WORKER_SUCCESS;
3060 }
3061
revwork_response(LV2_Handle handle,uint32_t size,const void * data)3062 static LV2_Worker_Status revwork_response(LV2_Handle handle, uint32_t size, const void* data)
3063 {
3064 RKRLV2* plug = (RKRLV2*)handle;
3065 plug->revtron->applyfile(*plug->rvbfile);
3066 plug->loading_file = 0;//clear flag for next file load
3067 return LV2_WORKER_SUCCESS;
3068 }
3069
revsave(LV2_Handle handle,LV2_State_Store_Function store,LV2_State_Handle state_handle,uint32_t flags,const LV2_Feature * const * features)3070 static LV2_State_Status revsave(LV2_Handle handle, LV2_State_Store_Function store, LV2_State_Handle state_handle,
3071 uint32_t flags, const LV2_Feature* const* features)
3072 {
3073 RKRLV2* plug = (RKRLV2*)handle;
3074
3075 LV2_State_Map_Path* map_path = NULL;
3076 for (int i = 0; features[i]; ++i)
3077 {
3078 if (!strcmp(features[i]->URI, LV2_STATE__mapPath))
3079 {
3080 map_path = (LV2_State_Map_Path*)features[i]->data;
3081 }
3082 }
3083
3084 char* abstractpath = map_path->abstract_path(map_path->handle, plug->revtron->File.Filename);
3085
3086 store(state_handle, plug->URIDs.filetype_rvb, abstractpath, strlen(plug->revtron->File.Filename) + 1,
3087 plug->URIDs.atom_Path, LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
3088
3089 free(abstractpath);
3090
3091 return LV2_STATE_SUCCESS;
3092 }
3093
revrestore(LV2_Handle handle,LV2_State_Retrieve_Function retrieve,LV2_State_Handle state_handle,uint32_t flags,const LV2_Feature * const * features)3094 static LV2_State_Status revrestore(LV2_Handle handle, LV2_State_Retrieve_Function retrieve,
3095 LV2_State_Handle state_handle, uint32_t flags, const LV2_Feature* const* features)
3096 {
3097 RKRLV2* plug = (RKRLV2*)handle;
3098
3099 size_t size;
3100 uint32_t type;
3101 uint32_t valflags;
3102
3103 const void* value = retrieve( state_handle, plug->URIDs.filetype_rvb, &size, &type, &valflags);
3104
3105 if (value)
3106 {
3107 char* path = (char*)value;
3108 RvbFile f = plug->revtron->loadfile(path);
3109 plug->revtron->applyfile(f);
3110 plug->file_changed = 1;
3111 }
3112
3113 return LV2_STATE_SUCCESS;
3114 }
3115
revtron_extension_data(const char * uri)3116 static const void* revtron_extension_data(const char* uri)
3117 {
3118 static const LV2_Worker_Interface worker = { revwork, revwork_response, NULL };
3119 static const LV2_State_Interface state_iface = { revsave, revrestore };
3120 if (!strcmp(uri, LV2_STATE__interface))
3121 {
3122 return &state_iface;
3123 }
3124 else if (!strcmp(uri, LV2_WORKER__interface))
3125 {
3126 return &worker;
3127 }
3128 return NULL;
3129 }
3130
3131 ///// Echotron /////////
init_echotronlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)3132 LV2_Handle init_echotronlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
3133 {
3134 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
3135
3136 plug->nparams = 13;
3137 plug->effectindex = IECHOTRON;
3138 plug->prev_bypass = 1;
3139
3140 getFeatures(plug,host_features);
3141 if(!plug->scheduler || !plug->urid_map)
3142 {
3143 //a required feature was not supported by host
3144 free(plug);
3145 return 0;
3146 }
3147 lv2_atom_forge_init(&plug->forge, plug->urid_map);
3148
3149 plug->echotron = new Echotron(0,0, sample_freq, plug->period_max);
3150 plug->echotron->changepar(4,1);//set to user selected files
3151 plug->dlyfile = new DlyFile;
3152
3153 return plug;
3154 }
3155
run_echotronlv2(LV2_Handle handle,uint32_t nframes)3156 void run_echotronlv2(LV2_Handle handle, uint32_t nframes)
3157 {
3158 int i;
3159 int val;
3160
3161 RKRLV2* plug = (RKRLV2*)handle;
3162
3163 if(*plug->bypass_p && plug->prev_bypass)
3164 {
3165 plug->echotron->cleanup();
3166 //copy dry signal
3167 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
3168 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
3169 return;
3170 }
3171
3172 //check and set changed parameters
3173 i=0;
3174 val = (int)*plug->param_p[i];//0 w/d
3175 if(plug->echotron->getpar(i) != val)
3176 {
3177 plug->echotron->changepar(i,val);
3178 }
3179 i++;
3180 val = (int)*plug->param_p[i]+64;//1 fliter depth
3181 if(plug->echotron->getpar(i) != val)
3182 {
3183 plug->echotron->changepar(i,val);
3184 }
3185 for(i++; i<4; i++)//skip user
3186 {
3187 val = (int)*plug->param_p[i];
3188 if(plug->echotron->getpar(i) != val)
3189 {
3190 plug->echotron->changepar(i,val);
3191 }
3192 }
3193 for(; i+1<7; i++)
3194 {
3195 val = (int)*plug->param_p[i];
3196 if(plug->echotron->getpar(i+1) != val)
3197 {
3198 plug->echotron->changepar(i+1,val);
3199 }
3200 }
3201 val = (int)*plug->param_p[i]+64;//7 l/R cross
3202 if(plug->echotron->getpar(i+1) != val)
3203 {
3204 plug->echotron->changepar(i+1,val);
3205 }
3206 for(i++; i+2<11; i++)//skip file num
3207 {
3208 val = (int)*plug->param_p[i];
3209 if(plug->echotron->getpar(i+2) != val)
3210 {
3211 plug->echotron->changepar(i+2,val);
3212 }
3213 }
3214 val = (int)*plug->param_p[i]+64;//11 panning
3215 if(plug->echotron->getpar(i+2) != val)
3216 {
3217 plug->echotron->changepar(i+2,val);
3218 }
3219 for(i++; i<plug->nparams; i++)
3220 {
3221 val = (int)*plug->param_p[i];
3222 if(plug->echotron->getpar(i+2) != val)
3223 {
3224 plug->echotron->changepar(i+2,val);
3225 }
3226 }
3227
3228 // Set up forge to write directly to notify output port.
3229 const uint32_t notify_capacity = plug->atom_out_p->atom.size;
3230 lv2_atom_forge_set_buffer(&plug->forge, (uint8_t*)plug->atom_out_p, notify_capacity);
3231
3232 // Start a sequence in the notify output port.
3233 lv2_atom_forge_sequence_head(&plug->forge, &plug->atom_frame, 0);
3234
3235 //if we loaded a state, send the new file name to the host to display
3236 if(plug->file_changed)
3237 {
3238 plug->file_changed = 0;
3239 lv2_atom_forge_frame_time(&plug->forge, 0);
3240 LV2_Atom_Forge_Frame frame;
3241 lv2_atom_forge_object( &plug->forge, &frame, 0, plug->URIDs.patch_Set);
3242
3243 lv2_atom_forge_key(&plug->forge, plug->URIDs.patch_property);
3244 lv2_atom_forge_urid(&plug->forge, plug->URIDs.filetype_dly);
3245 lv2_atom_forge_key(&plug->forge, plug->URIDs.patch_value);
3246 lv2_atom_forge_path(&plug->forge, plug->echotron->File.Filename, strlen(plug->echotron->File.Filename)+1);
3247
3248 lv2_atom_forge_pop(&plug->forge, &frame);
3249 }
3250
3251
3252 //see if there's a file
3253 LV2_ATOM_SEQUENCE_FOREACH( plug->atom_in_p, ev)
3254 {
3255 if (ev->body.type == plug->URIDs.atom_Object)
3256 {
3257 const LV2_Atom_Object* obj = (const LV2_Atom_Object*)&ev->body;
3258 if (obj->body.otype == plug->URIDs.patch_Set)
3259 {
3260 // Get the property the set message is setting
3261 const LV2_Atom* property = NULL;
3262 lv2_atom_object_get(obj, plug->URIDs.patch_property, &property, 0);
3263 if (property && property->type == plug->URIDs.atom_URID)
3264 {
3265 const uint32_t key = ((const LV2_Atom_URID*)property)->body;
3266 if (key == plug->URIDs.filetype_dly)
3267 {
3268 // a new file! pass the atom to the worker thread to load it
3269 plug->scheduler->schedule_work(plug->scheduler->handle, lv2_atom_total_size(&ev->body), &ev->body);
3270 }//property is dly file
3271 }//property is URID
3272 }
3273 else if (obj->body.otype == plug->URIDs.patch_Get)
3274 {
3275 // Received a get message, emit our state (probably to UI)
3276 lv2_atom_forge_frame_time(&plug->forge, ev->time.frames );//use current event's time
3277 LV2_Atom_Forge_Frame frame;
3278 lv2_atom_forge_object( &plug->forge, &frame, 0, plug->URIDs.patch_Set);
3279
3280 lv2_atom_forge_key(&plug->forge, plug->URIDs.patch_property);
3281 lv2_atom_forge_urid(&plug->forge, plug->URIDs.filetype_dly);
3282 lv2_atom_forge_key(&plug->forge, plug->URIDs.patch_value);
3283 lv2_atom_forge_path(&plug->forge, plug->echotron->File.Filename, strlen(plug->echotron->File.Filename)+1);
3284
3285 lv2_atom_forge_pop(&plug->forge, &frame);
3286 }
3287 }//atom is object
3288 }//each atom in sequence
3289
3290 //now set out ports
3291 plug->echotron->efxoutl = plug->output_l_p;
3292 plug->echotron->efxoutr = plug->output_r_p;
3293
3294 //now run
3295 plug->echotron->out(plug->input_l_p,plug->input_r_p,nframes);
3296
3297 //and for whatever reason we have to do the wet/dry mix ourselves
3298 wetdry_mix(plug, plug->echotron->outvolume, nframes);
3299
3300 xfade_check(plug,nframes);
3301 return;
3302 }
3303
echowork(LV2_Handle handle,LV2_Worker_Respond_Function respond,LV2_Worker_Respond_Handle rhandle,uint32_t size,const void * data)3304 static LV2_Worker_Status echowork(LV2_Handle handle, LV2_Worker_Respond_Function respond, LV2_Worker_Respond_Handle rhandle, uint32_t size, const void* data)
3305 {
3306
3307 RKRLV2* plug = (RKRLV2*)handle;
3308 LV2_Atom_Object* obj = (LV2_Atom_Object*)data;
3309 const LV2_Atom* file_path;
3310
3311 //work was scheduled to load a new file
3312 lv2_atom_object_get(obj, plug->URIDs.patch_value, &file_path, 0);
3313 if (file_path && file_path->type == plug->URIDs.atom_Path)
3314 {
3315 // Load file.
3316 char* path = (char*)LV2_ATOM_BODY_CONST(file_path);
3317 //the file is too large for a host's circular buffer
3318 //so store it in the plugin for the response to use
3319 //to prevent threading issues, we'll use a simple
3320 //flag as a crude mutex
3321 while(plug->loading_file)
3322 usleep(1000);
3323 plug->loading_file = 1;
3324 *plug->dlyfile = plug->echotron->loadfile(path);
3325 respond(rhandle,0,0);
3326 }//got file
3327 else
3328 return LV2_WORKER_ERR_UNKNOWN;
3329
3330 return LV2_WORKER_SUCCESS;
3331 }
3332
echowork_response(LV2_Handle handle,uint32_t size,const void * data)3333 static LV2_Worker_Status echowork_response(LV2_Handle handle, uint32_t size, const void* data)
3334 {
3335 RKRLV2* plug = (RKRLV2*)handle;
3336 plug->echotron->applyfile(*plug->dlyfile);
3337 plug->loading_file = 0;//clear flag for next file load
3338 return LV2_WORKER_SUCCESS;
3339 }
3340
echosave(LV2_Handle handle,LV2_State_Store_Function store,LV2_State_Handle state_handle,uint32_t flags,const LV2_Feature * const * features)3341 static LV2_State_Status echosave(LV2_Handle handle, LV2_State_Store_Function store, LV2_State_Handle state_handle,
3342 uint32_t flags, const LV2_Feature* const* features)
3343 {
3344 RKRLV2* plug = (RKRLV2*)handle;
3345
3346 LV2_State_Map_Path* map_path = NULL;
3347 for (int i = 0; features[i]; ++i)
3348 {
3349 if (!strcmp(features[i]->URI, LV2_STATE__mapPath))
3350 {
3351 map_path = (LV2_State_Map_Path*)features[i]->data;
3352 }
3353 }
3354
3355 char* abstractpath = map_path->abstract_path(map_path->handle, plug->echotron->File.Filename);
3356
3357 store(state_handle, plug->URIDs.filetype_dly, abstractpath, strlen(plug->echotron->File.Filename) + 1,
3358 plug->URIDs.atom_Path, LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
3359
3360 free(abstractpath);
3361
3362 return LV2_STATE_SUCCESS;
3363 }
3364
echorestore(LV2_Handle handle,LV2_State_Retrieve_Function retrieve,LV2_State_Handle state_handle,uint32_t flags,const LV2_Feature * const * features)3365 static LV2_State_Status echorestore(LV2_Handle handle, LV2_State_Retrieve_Function retrieve,
3366 LV2_State_Handle state_handle, uint32_t flags, const LV2_Feature* const* features)
3367 {
3368 RKRLV2* plug = (RKRLV2*)handle;
3369
3370 size_t size;
3371 uint32_t type;
3372 uint32_t valflags;
3373
3374 const void* value = retrieve( state_handle, plug->URIDs.filetype_dly, &size, &type, &valflags);
3375
3376 if (value)
3377 {
3378 char* path = (char*)value;
3379 DlyFile f = plug->echotron->loadfile(path);
3380 plug->echotron->applyfile(f);
3381 plug->file_changed = 1;
3382 }
3383
3384 return LV2_STATE_SUCCESS;
3385 }
3386
echotron_extension_data(const char * uri)3387 static const void* echotron_extension_data(const char* uri)
3388 {
3389 static const LV2_Worker_Interface worker = { echowork, echowork_response, NULL };
3390 static const LV2_State_Interface state_iface = { echosave, echorestore };
3391 if (!strcmp(uri, LV2_STATE__interface))
3392 {
3393 return &state_iface;
3394 }
3395 else if (!strcmp(uri, LV2_WORKER__interface))
3396 {
3397 return &worker;
3398 }
3399 return NULL;
3400 }
3401
3402
3403 //////// stereo harmonizer /////////
init_sharmnomidlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)3404 LV2_Handle init_sharmnomidlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
3405 {
3406 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
3407
3408 plug->nparams = 11;
3409 plug->effectindex = ISHARM_NM;
3410 plug->prev_bypass = 1;
3411
3412 getFeatures(plug,host_features);
3413
3414 //magic numbers: shift qual 4, downsample 5, up qual 4, down qual 2,
3415 plug->sharm = new StereoHarm(0,0,4,5,4,2, plug->period_max, sample_freq);
3416 plug->noteID = new Recognize(0,0,.6, sample_freq, 440.0, plug->period_max);//.6 is default trigger value
3417 plug->chordID = new RecChord();
3418
3419
3420
3421 return plug;
3422 }
3423
run_sharmnomidlv2(LV2_Handle handle,uint32_t nframes)3424 void run_sharmnomidlv2(LV2_Handle handle, uint32_t nframes)
3425 {
3426 int i;
3427 int val;
3428
3429 RKRLV2* plug = (RKRLV2*)handle;
3430
3431 if(*plug->bypass_p && plug->prev_bypass)
3432 {
3433 plug->sharm->cleanup();
3434 //copy dry signal
3435 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
3436 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
3437 return;
3438 }
3439
3440 //check and set changed parameters
3441 i = 0;
3442 val = (int)*plug->param_p[i];// 0 wet/dry
3443 if(plug->sharm->getpar(i) != val)
3444 {
3445 plug->sharm->changepar(i,val);
3446 }
3447 i++;
3448 val = (int)*plug->param_p[i] + 64;// 1 gain l
3449 if(plug->sharm->getpar(i) != val)
3450 {
3451 plug->sharm->changepar(i,val);
3452 }
3453 i++;
3454 val = (int)*plug->param_p[i] + 12;// 2 interval l
3455 if(plug->sharm->getpar(i) != val)
3456 {
3457 plug->sharm->changepar(i,val);
3458 }
3459 i++;
3460 val = (int)*plug->param_p[i];// 3 chroma l
3461 if(plug->sharm->getpar(i) != val)
3462 {
3463 plug->sharm->changepar(i,val);
3464 }
3465 i++;
3466 val = (int)*plug->param_p[i] + 64;// 4 gain r
3467 if(plug->sharm->getpar(i) != val)
3468 {
3469 plug->sharm->changepar(i,val);
3470 }
3471 i++;
3472 val = (int)*plug->param_p[i] + 12;// 5 interval r
3473 if(plug->sharm->getpar(i) != val)
3474 {
3475 plug->sharm->changepar(i,val);
3476 }
3477 for(i++; i<10; i++) // 6-11
3478 {
3479 val = (int)*plug->param_p[i];
3480 if(plug->sharm->getpar(i) != val)
3481 {
3482 plug->sharm->changepar(i,val);
3483 }
3484 }
3485 // skip midi mode, not implementing midi here
3486 // val = (int)*plug->param_p[i];// 10 midi mode
3487 // if(plug->aphase->getpar(i) != val)
3488 // {
3489 // plug->aphase->changepar(i,val);
3490 // if(!val) plug->harm->changepar(3,plug->harm->getpar(3));
3491 // }
3492 val = (int)*plug->param_p[i];// 11 lr cr.
3493 if(plug->sharm->getpar(i+1) != val)
3494 {
3495 plug->sharm->changepar(i+1,val);
3496 }
3497 /*
3498 see Chord() in rkr.fl
3499 harmonizer, need recChord and recNote.
3500 see process.C ln 1507
3501 */
3502
3503 //TODO may need to make sure input is over some threshold
3504 if(plug->sharm->mira && plug->sharm->PSELECT)
3505 {
3506 plug->noteID->schmittFloat(plug->input_l_p,plug->input_r_p,nframes);
3507 if(plug->noteID->reconota != -1 && plug->noteID->reconota != plug->noteID->last)
3508 {
3509 if(plug->noteID->afreq > 0.0)
3510 {
3511 plug->chordID->Vamos(1,plug->sharm->Pintervall - 12,plug->noteID->reconota);
3512 plug->chordID->Vamos(2,plug->sharm->Pintervalr - 12,plug->noteID->reconota);
3513 plug->sharm->r_ratiol = plug->chordID->r__ratio[1];//pass the found ratio
3514 plug->sharm->r_ratior = plug->chordID->r__ratio[2];//pass the found ratio
3515 }
3516 }
3517 }
3518 //now set out ports and global period size
3519 plug->sharm->efxoutl = plug->output_l_p;
3520 plug->sharm->efxoutr = plug->output_r_p;
3521
3522 //now run
3523 plug->sharm->out(plug->input_l_p,plug->input_r_p,nframes);
3524
3525 //and for whatever reason we have to do the wet/dry mix ourselves
3526 wetdry_mix(plug, plug->sharm->outvolume, nframes);
3527
3528 xfade_check(plug,nframes);
3529 return;
3530 }
3531
3532 ///// MB comp /////////
init_mbcomplv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)3533 LV2_Handle init_mbcomplv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
3534 {
3535 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
3536
3537 plug->nparams = 13;
3538 plug->effectindex = IMBCOMP;
3539 plug->prev_bypass = 1;
3540
3541 getFeatures(plug,host_features);
3542
3543 plug->mbcomp = new CompBand(0,0, sample_freq, plug->period_max);
3544
3545 return plug;
3546 }
3547
run_mbcomplv2(LV2_Handle handle,uint32_t nframes)3548 void run_mbcomplv2(LV2_Handle handle, uint32_t nframes)
3549 {
3550 int i;
3551 int val;
3552
3553 RKRLV2* plug = (RKRLV2*)handle;
3554
3555 if(*plug->bypass_p && plug->prev_bypass)
3556 {
3557 plug->mbcomp->cleanup();
3558 //copy dry signal
3559 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
3560 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
3561 return;
3562 }
3563
3564 //check and set changed parameters
3565 for(i=0; i<plug->nparams; i++)
3566 {
3567 val = (int)*plug->param_p[i];
3568 if(plug->mbcomp->getpar(i) != val)
3569 {
3570 plug->mbcomp->changepar(i,val);
3571 }
3572 }
3573
3574 //now set out ports
3575 plug->mbcomp->efxoutl = plug->output_l_p;
3576 plug->mbcomp->efxoutr = plug->output_r_p;
3577
3578 //now run
3579 plug->mbcomp->out(plug->output_l_p,plug->output_r_p,nframes);
3580
3581 //and for whatever reason we have to do the wet/dry mix ourselves
3582 wetdry_mix(plug, plug->mbcomp->outvolume, nframes);
3583
3584 xfade_check(plug,nframes);
3585 return;
3586 }
3587
3588 ///// OptTrem /////////
init_otremlv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)3589 LV2_Handle init_otremlv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
3590 {
3591 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
3592
3593 plug->nparams = 6;
3594 plug->effectindex = IOPTTREM;
3595 plug->prev_bypass = 1;
3596
3597 plug->otrem = new Opticaltrem(0,0, sample_freq);
3598
3599 return plug;
3600 }
3601
run_otremlv2(LV2_Handle handle,uint32_t nframes)3602 void run_otremlv2(LV2_Handle handle, uint32_t nframes)
3603 {
3604 int i;
3605 int val;
3606
3607 RKRLV2* plug = (RKRLV2*)handle;
3608
3609 if(*plug->bypass_p && plug->prev_bypass)
3610 {
3611 plug->otrem->cleanup();
3612 //copy dry signal
3613 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
3614 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
3615 return;
3616 }
3617
3618 //LFO effects require period be set before setting other params
3619 plug->otrem->PERIOD = nframes;
3620
3621 //check and set changed parameters
3622 for(i=0; i<4; i++)//0-4
3623 {
3624 val = (int)*plug->param_p[i];
3625 if(plug->otrem->getpar(i) != val)
3626 {
3627 plug->otrem->changepar(i,val);
3628 }
3629 }
3630 for(; i<6; i++)//4-5 pan and st del
3631 {
3632 val = (int)*plug->param_p[i]+64;
3633 if(plug->otrem->getpar(i) != val)
3634 {
3635 plug->otrem->changepar(i,val);
3636 }
3637 }
3638 val = (int)*plug->param_p[i];//6 invert
3639 if(plug->otrem->getpar(i) != val)
3640 {
3641 plug->otrem->changepar(i,val);
3642 }
3643
3644 //optotrem does it inline
3645 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
3646 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
3647
3648 //now set out ports
3649 plug->otrem->efxoutl = plug->output_l_p;
3650 plug->otrem->efxoutr = plug->output_r_p;
3651
3652 //now run
3653 plug->otrem->out(plug->output_l_p,plug->output_r_p,nframes);
3654
3655 xfade_check(plug,nframes);
3656 return;
3657 }
3658
3659 ///// Vibe /////////
init_vibelv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)3660 LV2_Handle init_vibelv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
3661 {
3662 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
3663
3664 plug->nparams = 11;
3665 plug->effectindex = IVIBE;
3666 plug->prev_bypass = 1;
3667
3668 plug->vibe = new Vibe(0,0, sample_freq);
3669
3670 return plug;
3671 }
3672
run_vibelv2(LV2_Handle handle,uint32_t nframes)3673 void run_vibelv2(LV2_Handle handle, uint32_t nframes)
3674 {
3675 int i;
3676 int val;
3677
3678 RKRLV2* plug = (RKRLV2*)handle;
3679
3680 if(*plug->bypass_p && plug->prev_bypass)
3681 {
3682 plug->vibe->cleanup();
3683 //copy dry signal
3684 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
3685 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
3686 return;
3687 }
3688
3689 //LFO effects require period be set before setting other params
3690 plug->vibe->PERIOD = nframes;
3691
3692 //check and set changed parameters
3693 for(i=0; i<4; i++)//0-4
3694 {
3695 val = (int)*plug->param_p[i];
3696 if(plug->vibe->getpar(i) != val)
3697 {
3698 plug->vibe->changepar(i,val);
3699 }
3700 }
3701 for(; i<6; i++)//4-5 pan and st del
3702 {
3703 val = (int)*plug->param_p[i]+64;
3704 if(plug->vibe->getpar(i) != val)
3705 {
3706 plug->vibe->changepar(i,val);
3707 }
3708 }
3709 val = (int)*plug->param_p[i];//6 wet/dry
3710 if(plug->vibe->getpar(i) != val)
3711 {
3712 plug->vibe->changepar(i,val);
3713 }
3714 i++;
3715 val = (int)*plug->param_p[i]+64;//7 FB
3716 if(plug->vibe->getpar(i) != val)
3717 {
3718 plug->vibe->changepar(i,val);
3719 }
3720 for(i++; i<plug->nparams; i++)//8-11 the rest
3721 {
3722 val = (int)*plug->param_p[i];
3723 if(plug->vibe->getpar(i) != val)
3724 {
3725 plug->vibe->changepar(i,val);
3726 }
3727 }
3728
3729 //now set out ports
3730 plug->vibe->efxoutl = plug->output_l_p;
3731 plug->vibe->efxoutr = plug->output_r_p;
3732
3733 //now run
3734 plug->vibe->out(plug->output_l_p,plug->output_r_p,nframes);
3735
3736 //and for whatever reason we have to do the wet/dry mix ourselves
3737 wetdry_mix(plug, plug->vibe->outvolume, nframes);
3738
3739 xfade_check(plug,nframes);
3740 return;
3741 }
3742
3743 ///// Infinity /////////
init_inflv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)3744 LV2_Handle init_inflv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
3745 {
3746 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
3747
3748 plug->nparams = 18;
3749 plug->effectindex = IINF;
3750 plug->prev_bypass = 1;
3751
3752 getFeatures(plug,host_features);
3753
3754 plug->inf = new Infinity(0,0, sample_freq, plug->period_max);
3755
3756 return plug;
3757 }
3758
run_inflv2(LV2_Handle handle,uint32_t nframes)3759 void run_inflv2(LV2_Handle handle, uint32_t nframes)
3760 {
3761 int i;
3762 int val;
3763
3764 RKRLV2* plug = (RKRLV2*)handle;
3765
3766 if(*plug->bypass_p && plug->prev_bypass)
3767 {
3768 plug->inf->cleanup();
3769 //copy dry signal
3770 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
3771 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
3772 return;
3773 }
3774
3775 //check and set changed parameters
3776 for(i=0; i<plug->nparams; i++)//0-17
3777 {
3778 val = (int)*plug->param_p[i];
3779 if(plug->inf->getpar(i) != val)
3780 {
3781 plug->inf->changepar(i,val);
3782 }
3783 }
3784
3785 //now set out ports
3786 plug->inf->efxoutl = plug->output_l_p;
3787 plug->inf->efxoutr = plug->output_r_p;
3788
3789 //now run
3790 plug->inf->out(plug->output_l_p,plug->output_r_p,nframes);
3791
3792 //and for whatever reason we have to do the wet/dry mix ourselves
3793 wetdry_mix(plug, plug->inf->outvolume, nframes);
3794
3795 xfade_check(plug,nframes);
3796 return;
3797 }
3798
3799 ///// Phaser /////////
init_phaselv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)3800 LV2_Handle init_phaselv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
3801 {
3802 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
3803
3804 plug->nparams = 12;
3805 plug->effectindex = IPHASE;
3806 plug->prev_bypass = 1;
3807
3808 plug->phase = new Phaser(0,0,sample_freq);
3809 plug->init_params = 1; // LFO init
3810
3811 return plug;
3812 }
3813
run_phaselv2(LV2_Handle handle,uint32_t nframes)3814 void run_phaselv2(LV2_Handle handle, uint32_t nframes)
3815 {
3816 int i;
3817 int val;
3818
3819 RKRLV2* plug = (RKRLV2*)handle;
3820
3821 if(*plug->bypass_p && plug->prev_bypass)
3822 {
3823 plug->phase->cleanup();
3824 //copy dry signal
3825 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
3826 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
3827 return;
3828 }
3829
3830 //LFO effects require period be set before setting other params
3831 if(plug->init_params)
3832 {
3833 plug->phase->PERIOD = nframes;
3834 plug->phase->lfo->updateparams(nframes);
3835 plug->init_params = 0; // so we only do this once
3836 }
3837
3838 //check and set changed parameters
3839 for(i=0; i<1; i++) //0-4
3840 {
3841 val = (int)*plug->param_p[i];
3842 if(plug->phase->getpar(i) != val)
3843 {
3844 plug->phase->changepar(i,val);
3845 }
3846 }
3847 val = (int)*plug->param_p[i] +64;// 1 Pan offset
3848 if(plug->phase->getpar(i) != val)
3849 {
3850 plug->phase->changepar(i,val);
3851 }
3852 for(i++; i<9; i++)
3853 {
3854 val = (int)*plug->param_p[i];
3855 if(plug->phase->getpar(i) != val)
3856 {
3857 plug->phase->changepar(i,val);
3858 }
3859 }
3860 val = (int)*plug->param_p[i] +64 ;// 9 l/r cross offset
3861 if(plug->phase->getpar(i) != val)
3862 {
3863 plug->phase->changepar(i,val);
3864 }
3865 for(i++; i<plug->nparams; i++)
3866 {
3867 val = (int)*plug->param_p[i];
3868 if(plug->phase->getpar(i) != val)
3869 {
3870 plug->phase->changepar(i,val);
3871 }
3872 }
3873
3874 //now set out ports and global period size
3875 plug->phase->efxoutl = plug->output_l_p;
3876 plug->phase->efxoutr = plug->output_r_p;
3877
3878 //now run
3879 plug->phase->out(plug->input_l_p,plug->input_r_p,nframes);
3880
3881 //and for whatever reason we have to do the wet/dry mix ourselves
3882 wetdry_mix(plug, plug->phase->outvolume, nframes);
3883
3884 xfade_check(plug,nframes);
3885 return;
3886 }
3887
3888 ///// NoiseGate /////////
init_gatelv2(const LV2_Descriptor * descriptor,double sample_freq,const char * bundle_path,const LV2_Feature * const * host_features)3889 LV2_Handle init_gatelv2(const LV2_Descriptor *descriptor,double sample_freq, const char *bundle_path,const LV2_Feature * const* host_features)
3890 {
3891 RKRLV2* plug = (RKRLV2*)malloc(sizeof(RKRLV2));
3892
3893 plug->nparams = 7;
3894 plug->effectindex = IGATE;
3895 plug->prev_bypass = 1;
3896
3897 getFeatures(plug,host_features);
3898
3899 plug->gate = new Gate(0,0, sample_freq, plug->period_max);
3900
3901 return plug;
3902 }
3903
run_gatelv2(LV2_Handle handle,uint32_t nframes)3904 void run_gatelv2(LV2_Handle handle, uint32_t nframes)
3905 {
3906 int i;
3907 int val;
3908
3909 RKRLV2* plug = (RKRLV2*)handle;
3910
3911 if(*plug->bypass_p && plug->prev_bypass)
3912 {
3913 plug->gate->cleanup();
3914 //copy dry signal
3915 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
3916 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
3917 return;
3918 }
3919
3920 //check and set changed parameters
3921 for(i=0; i<plug->nparams; i++)
3922 {
3923 val = (int)*plug->param_p[i];
3924 if(plug->gate->getpar(i+1) != val)//this effect is 1 indexed
3925 {
3926 plug->gate->Gate_Change(i+1,val);
3927 }
3928 }
3929
3930 //gate does inline
3931 memcpy(plug->output_l_p,plug->input_l_p,sizeof(float)*nframes);
3932 memcpy(plug->output_r_p,plug->input_r_p,sizeof(float)*nframes);
3933
3934 //now set out ports
3935 plug->gate->efxoutl = plug->output_l_p;
3936 plug->gate->efxoutr = plug->output_r_p;
3937
3938 //now run
3939 plug->gate->out(plug->output_l_p,plug->output_r_p,nframes);
3940
3941 xfade_check(plug,nframes);
3942 return;
3943 }
3944
3945 /////////////////////////////////
3946 // END OF FX
3947 /////////////////////////////////
3948
3949
3950
cleanup_rkrlv2(LV2_Handle handle)3951 void cleanup_rkrlv2(LV2_Handle handle)
3952 {
3953 RKRLV2* plug = (RKRLV2*)handle;
3954 switch(plug->effectindex)
3955 {
3956 case IEQ:
3957 case IEQP:
3958 delete plug->eq;//eql, eqp, cabinet
3959 break;
3960 case ICOMP:
3961 delete plug->comp;
3962 break;
3963 case IDIST:
3964 delete plug->dist;
3965 break;
3966 case IECHO:
3967 delete plug->echo;
3968 break;
3969 case ICHORUS:
3970 delete plug->chorus;
3971 break;
3972 case IAPHASE:
3973 delete plug->aphase;
3974 break;
3975 case IHARM_NM:
3976 delete plug->harm;
3977 delete plug->noteID;
3978 delete plug->chordID;
3979 break;
3980 case IEXCITER:
3981 delete plug->exciter;
3982 break;
3983 case IPAN:
3984 delete plug->pan;
3985 break;
3986 case IAWAH:
3987 delete plug->alien;
3988 break;
3989 case IREV:
3990 delete plug->reve;
3991 break;
3992 case ICAB:
3993 delete plug->cab;
3994 break;
3995 case IMDEL:
3996 delete plug->mdel;
3997 break;
3998 case IWAH:
3999 delete plug->wah;
4000 break;
4001 case IDERE:
4002 delete plug->dere;
4003 break;
4004 case IVALVE:
4005 delete plug->valve;
4006 break;
4007 case IDFLANGE:
4008 delete plug->dflange;
4009 break;
4010 case IRING:
4011 delete plug->noteID;
4012 delete plug->ring;
4013 break;
4014 case IMBDIST:
4015 delete plug->mbdist;
4016 break;
4017 case IARPIE:
4018 delete plug->arp;
4019 break;
4020 case IEXPAND:
4021 delete plug->expand;
4022 break;
4023 case ISHUFF:
4024 delete plug->shuf;
4025 break;
4026 case ISYNTH:
4027 delete plug->synth;
4028 break;
4029 case IMBVOL:
4030 delete plug->mbvol;
4031 break;
4032 case IMUTRO:
4033 delete plug->mutro;
4034 break;
4035 case IECHOVERSE:
4036 delete plug->echoverse;
4037 break;
4038 case ICOIL:
4039 delete plug->coil;
4040 break;
4041 case ISHELF:
4042 delete plug->shelf;
4043 break;
4044 case IVOC:
4045 delete plug->voc;
4046 break;
4047 case ISUS:
4048 delete plug->sus;
4049 break;
4050 case ISEQ:
4051 delete plug->seq;
4052 break;
4053 case ISHIFT:
4054 delete plug->shift;
4055 break;
4056 case ISTOMP:
4057 case IFUZZ:
4058 delete plug->stomp;
4059 break;
4060 case IREVTRON:
4061 delete plug->revtron;
4062 delete plug->rvbfile;
4063 break;
4064 case IECHOTRON:
4065 delete plug->echotron;
4066 delete plug->dlyfile;
4067 break;
4068 case ISHARM_NM:
4069 delete plug->sharm;
4070 delete plug->noteID;
4071 delete plug->chordID;
4072 break;
4073 case IMBCOMP:
4074 delete plug->mbcomp;
4075 break;
4076 case IOPTTREM:
4077 delete plug->otrem;
4078 break;
4079 case IVIBE:
4080 delete plug->vibe;
4081 break;
4082 case IINF:
4083 delete plug->inf;
4084 break;
4085 case IPHASE:
4086 delete plug->phase;
4087 break;
4088 case IGATE:
4089 delete plug->gate;
4090 break;
4091 }
4092 free(plug);
4093 }
4094
connect_rkrlv2_ports_w_atom(LV2_Handle handle,uint32_t port,void * data)4095 void connect_rkrlv2_ports_w_atom(LV2_Handle handle, uint32_t port, void *data)
4096 {
4097 RKRLV2* plug = (RKRLV2*)handle;
4098 switch(port)
4099 {
4100 case INL:
4101 plug->input_l_p = (float*)data;
4102 break;
4103 case INR:
4104 plug->input_r_p = (float*)data;
4105 break;
4106 case OUTL:
4107 plug->output_l_p = (float*)data;
4108 break;
4109 case OUTR:
4110 plug->output_r_p = (float*)data;
4111 break;
4112 case BYPASS:
4113 plug->atom_in_p = (const LV2_Atom_Sequence*)data;
4114 break;
4115 case PARAM0:
4116 plug->atom_out_p = (LV2_Atom_Sequence*)data;
4117 break;
4118 case PARAM1:
4119 plug->bypass_p = (float*)data;
4120 break;
4121 case PARAM2:
4122 plug->param_p[0] = (float*)data;
4123 break;
4124 case PARAM3:
4125 plug->param_p[1] = (float*)data;
4126 break;
4127 case PARAM4:
4128 plug->param_p[2] = (float*)data;
4129 break;
4130 case PARAM5:
4131 plug->param_p[3] = (float*)data;
4132 break;
4133 case PARAM6:
4134 plug->param_p[4] = (float*)data;
4135 break;
4136 case PARAM7:
4137 plug->param_p[5] = (float*)data;
4138 break;
4139 case PARAM8:
4140 plug->param_p[6] = (float*)data;
4141 break;
4142 case PARAM9:
4143 plug->param_p[7] = (float*)data;
4144 break;
4145 case PARAM10:
4146 plug->param_p[8] = (float*)data;
4147 break;
4148 case PARAM11:
4149 plug->param_p[9] = (float*)data;
4150 break;
4151 case PARAM12:
4152 plug->param_p[10] = (float*)data;
4153 break;
4154 case PARAM13:
4155 plug->param_p[11] = (float*)data;
4156 break;
4157 case PARAM14:
4158 plug->param_p[12] = (float*)data;
4159 break;
4160 case PARAM15:
4161 plug->param_p[13] = (float*)data;
4162 break;
4163 case PARAM16:
4164 plug->param_p[14] = (float*)data;
4165 break;
4166 case PARAM17:
4167 plug->param_p[15] = (float*)data;
4168 break;
4169 case PARAM18:
4170 plug->param_p[16] = (float*)data;
4171 break;
4172 case DBG:
4173 plug->param_p[17] = (float*)data;
4174 break;
4175 case EXTRA:
4176 plug->param_p[18] = (float*)data;
4177 break;
4178 default:
4179 puts("UNKNOWN PORT YO!!");
4180 }
4181 }
4182
connect_rkrlv2_ports(LV2_Handle handle,uint32_t port,void * data)4183 void connect_rkrlv2_ports(LV2_Handle handle, uint32_t port, void *data)
4184 {
4185 RKRLV2* plug = (RKRLV2*)handle;
4186 switch(port)
4187 {
4188 case INL:
4189 plug->input_l_p = (float*)data;
4190 break;
4191 case INR:
4192 plug->input_r_p = (float*)data;
4193 break;
4194 case OUTL:
4195 plug->output_l_p = (float*)data;
4196 break;
4197 case OUTR:
4198 plug->output_r_p = (float*)data;
4199 break;
4200 case BYPASS:
4201 plug->bypass_p = (float*)data;
4202 break;
4203 case PARAM0:
4204 plug->param_p[0] = (float*)data;
4205 break;
4206 case PARAM1:
4207 plug->param_p[1] = (float*)data;
4208 break;
4209 case PARAM2:
4210 plug->param_p[2] = (float*)data;
4211 break;
4212 case PARAM3:
4213 plug->param_p[3] = (float*)data;
4214 break;
4215 case PARAM4:
4216 plug->param_p[4] = (float*)data;
4217 break;
4218 case PARAM5:
4219 plug->param_p[5] = (float*)data;
4220 break;
4221 case PARAM6:
4222 plug->param_p[6] = (float*)data;
4223 break;
4224 case PARAM7:
4225 plug->param_p[7] = (float*)data;
4226 break;
4227 case PARAM8:
4228 plug->param_p[8] = (float*)data;
4229 break;
4230 case PARAM9:
4231 plug->param_p[9] = (float*)data;
4232 break;
4233 case PARAM10:
4234 plug->param_p[10] = (float*)data;
4235 break;
4236 case PARAM11:
4237 plug->param_p[11] = (float*)data;
4238 break;
4239 case PARAM12:
4240 plug->param_p[12] = (float*)data;
4241 break;
4242 case PARAM13:
4243 plug->param_p[13] = (float*)data;
4244 break;
4245 case PARAM14:
4246 plug->param_p[14] = (float*)data;
4247 break;
4248 case PARAM15:
4249 plug->param_p[15] = (float*)data;
4250 break;
4251 case PARAM16:
4252 plug->param_p[16] = (float*)data;
4253 break;
4254 case PARAM17:
4255 plug->param_p[17] = (float*)data;
4256 break;
4257 case PARAM18:
4258 plug->param_p[18] = (float*)data;
4259 break;
4260 case DBG:
4261 plug->dbg_p = (float*)data;
4262 break;
4263 default:
4264 puts("UNKNOWN PORT YO!!");
4265 }
4266 }
4267
4268
4269 /////////////////////////////////
4270 // Plugin Descriptors
4271 ////////////////////////////////
4272
4273 static const LV2_Descriptor eqlv2_descriptor=
4274 {
4275 EQLV2_URI,
4276 init_eqlv2,
4277 connect_rkrlv2_ports,
4278 0,//activate
4279 run_eqlv2,
4280 0,//deactivate
4281 cleanup_rkrlv2,
4282 0//extension
4283 };
4284
4285 static const LV2_Descriptor complv2_descriptor=
4286 {
4287 COMPLV2_URI,
4288 init_complv2,
4289 connect_rkrlv2_ports,
4290 0,//activate
4291 run_complv2,
4292 0,//deactivate
4293 cleanup_rkrlv2,
4294 0//extension
4295 };
4296
4297 static const LV2_Descriptor distlv2_descriptor=
4298 {
4299 DISTLV2_URI,
4300 init_distlv2,
4301 connect_rkrlv2_ports,
4302 0,//activate
4303 run_distlv2,
4304 0,//deactivate
4305 cleanup_rkrlv2,
4306 0//extension
4307 };
4308
4309 static const LV2_Descriptor echolv2_descriptor=
4310 {
4311 ECHOLV2_URI,
4312 init_echolv2,
4313 connect_rkrlv2_ports,
4314 0,//activate
4315 run_echolv2,
4316 0,//deactivate
4317 cleanup_rkrlv2,
4318 0//extension
4319 };
4320
4321 static const LV2_Descriptor choruslv2_descriptor=
4322 {
4323 CHORUSLV2_URI,
4324 init_choruslv2,
4325 connect_rkrlv2_ports,
4326 0,//activate
4327 run_choruslv2,
4328 0,//deactivate
4329 cleanup_rkrlv2,
4330 0//extension
4331 };
4332
4333 static const LV2_Descriptor aphaselv2_descriptor=
4334 {
4335 APHASELV2_URI,
4336 init_aphaselv2,
4337 connect_rkrlv2_ports,
4338 0,//activate
4339 run_aphaselv2,
4340 0,//deactivate
4341 cleanup_rkrlv2,
4342 0//extension
4343 };
4344
4345 static const LV2_Descriptor harmnomidlv2_descriptor=
4346 {
4347 HARMNOMIDLV2_URI,
4348 init_harmnomidlv2,
4349 connect_rkrlv2_ports,
4350 0,//activate
4351 run_harmnomidlv2,
4352 0,//deactivate
4353 cleanup_rkrlv2,
4354 0//extension
4355 };
4356
4357 static const LV2_Descriptor exciterlv2_descriptor=
4358 {
4359 EXCITERLV2_URI,
4360 init_exciterlv2,
4361 connect_rkrlv2_ports,
4362 0,//activate
4363 run_exciterlv2,
4364 0,//deactivate
4365 cleanup_rkrlv2,
4366 0//extension
4367 };
4368
4369 static const LV2_Descriptor panlv2_descriptor=
4370 {
4371 PANLV2_URI,
4372 init_panlv2,
4373 connect_rkrlv2_ports,
4374 0,//activate
4375 run_panlv2,
4376 0,//deactivate
4377 cleanup_rkrlv2,
4378 0//extension
4379 };
4380
4381 static const LV2_Descriptor alienlv2_descriptor=
4382 {
4383 ALIENLV2_URI,
4384 init_alienlv2,
4385 connect_rkrlv2_ports,
4386 0,//activate
4387 run_alienlv2,
4388 0,//deactivate
4389 cleanup_rkrlv2,
4390 0//extension
4391 };
4392
4393 static const LV2_Descriptor revelv2_descriptor=
4394 {
4395 REVELV2_URI,
4396 init_revelv2,
4397 connect_rkrlv2_ports,
4398 0,//activate
4399 run_revelv2,
4400 0,//deactivate
4401 cleanup_rkrlv2,
4402 0//extension
4403 };
4404
4405 static const LV2_Descriptor eqplv2_descriptor=
4406 {
4407 EQPLV2_URI,
4408 init_eqplv2,
4409 connect_rkrlv2_ports,
4410 0,//activate
4411 run_eqplv2,
4412 0,//deactivate
4413 cleanup_rkrlv2,
4414 0//extension
4415 };
4416
4417 static const LV2_Descriptor cablv2_descriptor=
4418 {
4419 CABLV2_URI,
4420 init_cablv2,
4421 connect_rkrlv2_ports,
4422 0,//activate
4423 run_cablv2,
4424 0,//deactivate
4425 cleanup_rkrlv2,
4426 0//extension
4427 };
4428
4429 static const LV2_Descriptor mdellv2_descriptor=
4430 {
4431 MDELLV2_URI,
4432 init_mdellv2,
4433 connect_rkrlv2_ports,
4434 0,//activate
4435 run_mdellv2,
4436 0,//deactivate
4437 cleanup_rkrlv2,
4438 0//extension
4439 };
4440
4441 static const LV2_Descriptor wahlv2_descriptor=
4442 {
4443 WAHLV2_URI,
4444 init_wahlv2,
4445 connect_rkrlv2_ports,
4446 0,//activate
4447 run_wahlv2,
4448 0,//deactivate
4449 cleanup_rkrlv2,
4450 0//extension
4451 };
4452
4453 static const LV2_Descriptor derelv2_descriptor=
4454 {
4455 DERELV2_URI,
4456 init_derelv2,
4457 connect_rkrlv2_ports,
4458 0,//activate
4459 run_derelv2,
4460 0,//deactivate
4461 cleanup_rkrlv2,
4462 0//extension
4463 };
4464
4465 static const LV2_Descriptor valvelv2_descriptor=
4466 {
4467 VALVELV2_URI,
4468 init_valvelv2,
4469 connect_rkrlv2_ports,
4470 0,//activate
4471 run_valvelv2,
4472 0,//deactivate
4473 cleanup_rkrlv2,
4474 0//extension
4475 };
4476
4477 static const LV2_Descriptor dflangelv2_descriptor=
4478 {
4479 DFLANGELV2_URI,
4480 init_dflangelv2,
4481 connect_rkrlv2_ports,
4482 0,//activate
4483 run_dflangelv2,
4484 0,//deactivate
4485 cleanup_rkrlv2,
4486 0//extension
4487 };
4488
4489 static const LV2_Descriptor ringlv2_descriptor=
4490 {
4491 RINGLV2_URI,
4492 init_ringlv2,
4493 connect_rkrlv2_ports,
4494 0,//activate
4495 run_ringlv2,
4496 0,//deactivate
4497 cleanup_rkrlv2,
4498 0//extension
4499 };
4500
4501 static const LV2_Descriptor mbdistlv2_descriptor=
4502 {
4503 MBDISTLV2_URI,
4504 init_mbdistlv2,
4505 connect_rkrlv2_ports,
4506 0,//activate
4507 run_mbdistlv2,
4508 0,//deactivate
4509 cleanup_rkrlv2,
4510 0//extension
4511 };
4512
4513 static const LV2_Descriptor arplv2_descriptor=
4514 {
4515 ARPIELV2_URI,
4516 init_arplv2,
4517 connect_rkrlv2_ports,
4518 0,//activate
4519 run_arplv2,
4520 0,//deactivate
4521 cleanup_rkrlv2,
4522 0//extension
4523 };
4524
4525 static const LV2_Descriptor expandlv2_descriptor=
4526 {
4527 EXPANDLV2_URI,
4528 init_expandlv2,
4529 connect_rkrlv2_ports,
4530 0,//activate
4531 run_expandlv2,
4532 0,//deactivate
4533 cleanup_rkrlv2,
4534 0//extension
4535 };
4536
4537 static const LV2_Descriptor shuflv2_descriptor=
4538 {
4539 SHUFFLELV2_URI,
4540 init_shuflv2,
4541 connect_rkrlv2_ports,
4542 0,//activate
4543 run_shuflv2,
4544 0,//deactivate
4545 cleanup_rkrlv2,
4546 0//extension
4547 };
4548
4549 static const LV2_Descriptor synthlv2_descriptor=
4550 {
4551 SYNTHLV2_URI,
4552 init_synthlv2,
4553 connect_rkrlv2_ports,
4554 0,//activate
4555 run_synthlv2,
4556 0,//deactivate
4557 cleanup_rkrlv2,
4558 0//extension
4559 };
4560
4561 static const LV2_Descriptor mbvollv2_descriptor=
4562 {
4563 MBVOLLV2_URI,
4564 init_mbvollv2,
4565 connect_rkrlv2_ports,
4566 0,//activate
4567 run_mbvollv2,
4568 0,//deactivate
4569 cleanup_rkrlv2,
4570 0//extension
4571 };
4572
4573 static const LV2_Descriptor mutrolv2_descriptor=
4574 {
4575 MUTROLV2_URI,
4576 init_mutrolv2,
4577 connect_rkrlv2_ports,
4578 0,//activate
4579 run_mutrolv2,
4580 0,//deactivate
4581 cleanup_rkrlv2,
4582 0//extension
4583 };
4584
4585 static const LV2_Descriptor echoverselv2_descriptor=
4586 {
4587 ECHOVERSELV2_URI,
4588 init_echoverselv2,
4589 connect_rkrlv2_ports,
4590 0,//activate
4591 run_echoverselv2,
4592 0,//deactivate
4593 cleanup_rkrlv2,
4594 0//extension
4595 };
4596
4597 static const LV2_Descriptor coillv2_descriptor=
4598 {
4599 COILLV2_URI,
4600 init_coillv2,
4601 connect_rkrlv2_ports,
4602 0,//activate
4603 run_coillv2,
4604 0,//deactivate
4605 cleanup_rkrlv2,
4606 0//extension
4607 };
4608
4609 static const LV2_Descriptor shelflv2_descriptor=
4610 {
4611 SHELFLV2_URI,
4612 init_shelflv2,
4613 connect_rkrlv2_ports,
4614 0,//activate
4615 run_shelflv2,
4616 0,//deactivate
4617 cleanup_rkrlv2,
4618 0//extension
4619 };
4620
4621 static const LV2_Descriptor voclv2_descriptor=
4622 {
4623 VOCODERLV2_URI,
4624 init_voclv2,
4625 connect_rkrlv2_ports,
4626 0,//activate
4627 run_voclv2,
4628 0,//deactivate
4629 cleanup_rkrlv2,
4630 0//extension
4631 };
4632
4633 static const LV2_Descriptor suslv2_descriptor=
4634 {
4635 SUSTAINLV2_URI,
4636 init_suslv2,
4637 connect_rkrlv2_ports,
4638 0,//activate
4639 run_suslv2,
4640 0,//deactivate
4641 cleanup_rkrlv2,
4642 0//extension
4643 };
4644
4645 static const LV2_Descriptor seqlv2_descriptor=
4646 {
4647 SEQUENCELV2_URI,
4648 init_seqlv2,
4649 connect_rkrlv2_ports,
4650 0,//activate
4651 run_seqlv2,
4652 0,//deactivate
4653 cleanup_rkrlv2,
4654 0//extension
4655 };
4656
4657 static const LV2_Descriptor shiftlv2_descriptor=
4658 {
4659 SHIFTERLV2_URI,
4660 init_shiftlv2,
4661 connect_rkrlv2_ports,
4662 0,//activate
4663 run_shiftlv2,
4664 0,//deactivate
4665 cleanup_rkrlv2,
4666 0//extension
4667 };
4668
4669 static const LV2_Descriptor stomplv2_descriptor=
4670 {
4671 STOMPLV2_URI,
4672 init_stomplv2,
4673 connect_rkrlv2_ports,
4674 0,//activate
4675 run_stomplv2,
4676 0,//deactivate
4677 cleanup_rkrlv2,
4678 0//extension
4679 };
4680
4681 static const LV2_Descriptor stompfuzzlv2_descriptor=
4682 {
4683 STOMPFUZZLV2_URI,
4684 init_stomp_fuzzlv2,
4685 connect_rkrlv2_ports,
4686 0,//activate
4687 run_stomplv2,
4688 0,//deactivate
4689 cleanup_rkrlv2,
4690 0//extension
4691 };
4692
4693
4694 static const LV2_Descriptor revtronlv2_descriptor=
4695 {
4696 REVTRONLV2_URI,
4697 init_revtronlv2,
4698 connect_rkrlv2_ports_w_atom,
4699 0,//activate
4700 run_revtronlv2,
4701 0,//deactivate
4702 cleanup_rkrlv2,
4703 revtron_extension_data
4704 };
4705
4706 static const LV2_Descriptor echotronlv2_descriptor=
4707 {
4708 ECHOTRONLV2_URI,
4709 init_echotronlv2,
4710 connect_rkrlv2_ports_w_atom,
4711 0,//activate
4712 run_echotronlv2,
4713 0,//deactivate
4714 cleanup_rkrlv2,
4715 echotron_extension_data
4716 };
4717
4718 static const LV2_Descriptor sharmnomidlv2_descriptor=
4719 {
4720 SHARMNOMIDLV2_URI,
4721 init_sharmnomidlv2,
4722 connect_rkrlv2_ports,
4723 0,//activate
4724 run_sharmnomidlv2,
4725 0,//deactivate
4726 cleanup_rkrlv2
4727 };
4728
4729 static const LV2_Descriptor mbcomplv2_descriptor=
4730 {
4731 MBCOMPLV2_URI,
4732 init_mbcomplv2,
4733 connect_rkrlv2_ports,
4734 0,//activate
4735 run_mbcomplv2,
4736 0,//deactivate
4737 cleanup_rkrlv2
4738 };
4739
4740 static const LV2_Descriptor otremlv2_descriptor=
4741 {
4742 OPTTREMLV2_URI,
4743 init_otremlv2,
4744 connect_rkrlv2_ports,
4745 0,//activate
4746 run_otremlv2,
4747 0,//deactivate
4748 cleanup_rkrlv2
4749 };
4750
4751 static const LV2_Descriptor vibelv2_descriptor=
4752 {
4753 VIBELV2_URI,
4754 init_vibelv2,
4755 connect_rkrlv2_ports,
4756 0,//activate
4757 run_vibelv2,
4758 0,//deactivate
4759 cleanup_rkrlv2
4760 };
4761
4762 static const LV2_Descriptor inflv2_descriptor=
4763 {
4764 INFLV2_URI,
4765 init_inflv2,
4766 connect_rkrlv2_ports,
4767 0,//activate
4768 run_inflv2,
4769 0,//deactivate
4770 cleanup_rkrlv2
4771 };
4772
4773 static const LV2_Descriptor phaselv2_descriptor=
4774 {
4775 PHASELV2_URI,
4776 init_phaselv2,
4777 connect_rkrlv2_ports,
4778 0,//activate
4779 run_phaselv2,
4780 0,//deactivate
4781 cleanup_rkrlv2,
4782 0//extension
4783 };
4784
4785 static const LV2_Descriptor gatelv2_descriptor=
4786 {
4787 GATELV2_URI,
4788 init_gatelv2,
4789 connect_rkrlv2_ports,
4790 0,//activate
4791 run_gatelv2,
4792 0,//deactivate
4793 cleanup_rkrlv2,
4794 0//extension
4795 };
4796
4797 LV2_SYMBOL_EXPORT
lv2_descriptor(uint32_t index)4798 const LV2_Descriptor* lv2_descriptor(uint32_t index)
4799 {
4800 switch (index)
4801 {
4802 case IEQ:
4803 return &eqlv2_descriptor ;
4804 case ICOMP:
4805 return &complv2_descriptor ;
4806 case IDIST:
4807 return &distlv2_descriptor ;
4808 case IECHO:
4809 return &echolv2_descriptor ;
4810 case ICHORUS:
4811 return &choruslv2_descriptor ;
4812 case IAPHASE:
4813 return &aphaselv2_descriptor ;
4814 case IHARM_NM:
4815 return &harmnomidlv2_descriptor ;
4816 case IEXCITER:
4817 return &exciterlv2_descriptor ;
4818 case IPAN:
4819 return &panlv2_descriptor ;
4820 case IAWAH:
4821 return &alienlv2_descriptor ;
4822 case IREV:
4823 return &revelv2_descriptor ;
4824 case IEQP:
4825 return &eqplv2_descriptor ;
4826 case ICAB:
4827 return &cablv2_descriptor ;
4828 case IMDEL:
4829 return &mdellv2_descriptor ;
4830 case IWAH:
4831 return &wahlv2_descriptor ;
4832 case IDERE:
4833 return &derelv2_descriptor ;
4834 case IVALVE:
4835 return &valvelv2_descriptor ;
4836 case IDFLANGE:
4837 return &dflangelv2_descriptor ;
4838 case IRING:
4839 return &ringlv2_descriptor ;
4840 case IMBDIST:
4841 return &mbdistlv2_descriptor ;
4842 case IARPIE:
4843 return &arplv2_descriptor ;
4844 case IEXPAND:
4845 return &expandlv2_descriptor ;
4846 case ISHUFF:
4847 return &shuflv2_descriptor ;
4848 case ISYNTH:
4849 return &synthlv2_descriptor ;
4850 case IMBVOL:
4851 return &mbvollv2_descriptor ;
4852 case IMUTRO:
4853 return &mutrolv2_descriptor ;
4854 case IECHOVERSE:
4855 return &echoverselv2_descriptor ;
4856 case ICOIL:
4857 return &coillv2_descriptor ;
4858 case ISHELF:
4859 return &shelflv2_descriptor ;
4860 case IVOC:
4861 return &voclv2_descriptor ;
4862 case ISUS:
4863 return &suslv2_descriptor ;
4864 case ISEQ:
4865 return &seqlv2_descriptor ;
4866 case ISHIFT:
4867 return &shiftlv2_descriptor ;
4868 case ISTOMP:
4869 return &stomplv2_descriptor ;
4870 case IFUZZ:
4871 return &stompfuzzlv2_descriptor ;
4872 case IREVTRON:
4873 return &revtronlv2_descriptor ;
4874 case IECHOTRON:
4875 return &echotronlv2_descriptor ;
4876 case ISHARM_NM:
4877 return &sharmnomidlv2_descriptor ;
4878 case IMBCOMP:
4879 return &mbcomplv2_descriptor ;
4880 case IOPTTREM:
4881 return &otremlv2_descriptor ;
4882 case IVIBE:
4883 return &vibelv2_descriptor ;
4884 case IINF:
4885 return &inflv2_descriptor ;
4886 case IPHASE:
4887 return &phaselv2_descriptor ;
4888 case IGATE:
4889 return &gatelv2_descriptor ;
4890 default:
4891 return 0;
4892 }
4893 }
4894