1 #include <stdlib.h>
2 #include <string.h>
3 #ifndef WIN32
4 #include "config.h"
5 #endif
6 
7 #ifdef ENABLE_NLS
8 #include <libintl.h>
9 #endif
10 
11 #define         _ISOC9X_SOURCE  1
12 #define         _ISOC99_SOURCE  1
13 #define         __USE_ISOC99    1
14 #define         __USE_ISOC9X    1
15 
16 #include <math.h>
17 
18 #include "ladspa.h"
19 
20 #ifdef WIN32
21 #define _WINDOWS_DLL_EXPORT_ __declspec(dllexport)
22 int bIsFirstTime = 1;
23 static void __attribute__((constructor)) swh_init(); // forward declaration
24 #else
25 #define _WINDOWS_DLL_EXPORT_
26 #endif
27 
28 #line 10 "bode_shifter_cv_1432.xml"
29 
30 #include <math.h>
31 
32 #include "ladspa-util.h"
33 
34 #define SIN_T_SIZE 1024
35 #define D_SIZE 256
36 #define NZEROS 200
37 
38 /* The non-zero taps of the Hilbert transformer */
39 static float xcoeffs[] = {
40      +0.0008103736f, +0.0008457886f, +0.0009017196f, +0.0009793364f,
41      +0.0010798341f, +0.0012044365f, +0.0013544008f, +0.0015310235f,
42      +0.0017356466f, +0.0019696659f, +0.0022345404f, +0.0025318040f,
43      +0.0028630784f, +0.0032300896f, +0.0036346867f, +0.0040788644f,
44      +0.0045647903f, +0.0050948365f, +0.0056716186f, +0.0062980419f,
45      +0.0069773575f, +0.0077132300f, +0.0085098208f, +0.0093718901f,
46      +0.0103049226f, +0.0113152847f, +0.0124104218f, +0.0135991079f,
47      +0.0148917649f, +0.0163008758f, +0.0178415242f, +0.0195321089f,
48      +0.0213953037f, +0.0234593652f, +0.0257599469f, +0.0283426636f,
49      +0.0312667947f, +0.0346107648f, +0.0384804823f, +0.0430224431f,
50      +0.0484451086f, +0.0550553725f, +0.0633242001f, +0.0740128560f,
51      +0.0884368322f, +0.1090816773f, +0.1412745301f, +0.1988673273f,
52      +0.3326528346f, +0.9997730178f, -0.9997730178f, -0.3326528346f,
53      -0.1988673273f, -0.1412745301f, -0.1090816773f, -0.0884368322f,
54      -0.0740128560f, -0.0633242001f, -0.0550553725f, -0.0484451086f,
55      -0.0430224431f, -0.0384804823f, -0.0346107648f, -0.0312667947f,
56      -0.0283426636f, -0.0257599469f, -0.0234593652f, -0.0213953037f,
57      -0.0195321089f, -0.0178415242f, -0.0163008758f, -0.0148917649f,
58      -0.0135991079f, -0.0124104218f, -0.0113152847f, -0.0103049226f,
59      -0.0093718901f, -0.0085098208f, -0.0077132300f, -0.0069773575f,
60      -0.0062980419f, -0.0056716186f, -0.0050948365f, -0.0045647903f,
61      -0.0040788644f, -0.0036346867f, -0.0032300896f, -0.0028630784f,
62      -0.0025318040f, -0.0022345404f, -0.0019696659f, -0.0017356466f,
63      -0.0015310235f, -0.0013544008f, -0.0012044365f, -0.0010798341f,
64      -0.0009793364f, -0.0009017196f, -0.0008457886f, -0.0008103736f,
65 };
66 
67 #define BODESHIFTERCV_SHIFT_B          0
68 #define BODESHIFTERCV_MIX              1
69 #define BODESHIFTERCV_INPUT            2
70 #define BODESHIFTERCV_ATTEN            3
71 #define BODESHIFTERCV_SHIFT            4
72 #define BODESHIFTERCV_DOUT             5
73 #define BODESHIFTERCV_UOUT             6
74 #define BODESHIFTERCV_MIXOUT           7
75 #define BODESHIFTERCV_LATENCY          8
76 
77 static LADSPA_Descriptor *bodeShifterCVDescriptor = NULL;
78 
79 typedef struct {
80 	LADSPA_Data *shift_b;
81 	LADSPA_Data *mix;
82 	LADSPA_Data *input;
83 	LADSPA_Data *atten;
84 	LADSPA_Data *shift;
85 	LADSPA_Data *dout;
86 	LADSPA_Data *uout;
87 	LADSPA_Data *mixout;
88 	LADSPA_Data *latency;
89 	LADSPA_Data *delay;
90 	unsigned int dptr;
91 	float        fs;
92 	float        phi;
93 	float *      sint;
94 	LADSPA_Data run_adding_gain;
95 } BodeShifterCV;
96 
97 _WINDOWS_DLL_EXPORT_
ladspa_descriptor(unsigned long index)98 const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) {
99 
100 #ifdef WIN32
101 	if (bIsFirstTime) {
102 		swh_init();
103 		bIsFirstTime = 0;
104 	}
105 #endif
106 	switch (index) {
107 	case 0:
108 		return bodeShifterCVDescriptor;
109 	default:
110 		return NULL;
111 	}
112 }
113 
cleanupBodeShifterCV(LADSPA_Handle instance)114 static void cleanupBodeShifterCV(LADSPA_Handle instance) {
115 #line 132 "bode_shifter_cv_1432.xml"
116 	BodeShifterCV *plugin_data = (BodeShifterCV *)instance;
117 	free(plugin_data->delay);
118 	free(plugin_data->sint);
119 	free(instance);
120 }
121 
connectPortBodeShifterCV(LADSPA_Handle instance,unsigned long port,LADSPA_Data * data)122 static void connectPortBodeShifterCV(
123  LADSPA_Handle instance,
124  unsigned long port,
125  LADSPA_Data *data) {
126 	BodeShifterCV *plugin;
127 
128 	plugin = (BodeShifterCV *)instance;
129 	switch (port) {
130 	case BODESHIFTERCV_SHIFT_B:
131 		plugin->shift_b = data;
132 		break;
133 	case BODESHIFTERCV_MIX:
134 		plugin->mix = data;
135 		break;
136 	case BODESHIFTERCV_INPUT:
137 		plugin->input = data;
138 		break;
139 	case BODESHIFTERCV_ATTEN:
140 		plugin->atten = data;
141 		break;
142 	case BODESHIFTERCV_SHIFT:
143 		plugin->shift = data;
144 		break;
145 	case BODESHIFTERCV_DOUT:
146 		plugin->dout = data;
147 		break;
148 	case BODESHIFTERCV_UOUT:
149 		plugin->uout = data;
150 		break;
151 	case BODESHIFTERCV_MIXOUT:
152 		plugin->mixout = data;
153 		break;
154 	case BODESHIFTERCV_LATENCY:
155 		plugin->latency = data;
156 		break;
157 	}
158 }
159 
instantiateBodeShifterCV(const LADSPA_Descriptor * descriptor,unsigned long s_rate)160 static LADSPA_Handle instantiateBodeShifterCV(
161  const LADSPA_Descriptor *descriptor,
162  unsigned long s_rate) {
163 	BodeShifterCV *plugin_data = (BodeShifterCV *)calloc(1, sizeof(BodeShifterCV));
164 	LADSPA_Data *delay = NULL;
165 	unsigned int dptr;
166 	float fs;
167 	float phi;
168 	float *sint = NULL;
169 
170 #line 57 "bode_shifter_cv_1432.xml"
171 	unsigned int i;
172 
173 	fs = (float)s_rate;
174 
175 	delay = calloc(D_SIZE, sizeof(LADSPA_Data));
176 	sint  = calloc(SIN_T_SIZE + 4, sizeof(float));
177 
178 	dptr = 0;
179 	phi = 0.0f;
180 
181 	for (i = 0; i < SIN_T_SIZE + 4; i++) {
182 	  sint[i] = sinf(2.0f * M_PI * (float)i / (float)SIN_T_SIZE);
183 	}
184 
185 	plugin_data->delay = delay;
186 	plugin_data->dptr = dptr;
187 	plugin_data->fs = fs;
188 	plugin_data->phi = phi;
189 	plugin_data->sint = sint;
190 
191 	return (LADSPA_Handle)plugin_data;
192 }
193 
194 #undef buffer_write
195 #undef RUN_ADDING
196 #undef RUN_REPLACING
197 
198 #define buffer_write(b, v) (b = v)
199 #define RUN_ADDING    0
200 #define RUN_REPLACING 1
201 
runBodeShifterCV(LADSPA_Handle instance,unsigned long sample_count)202 static void runBodeShifterCV(LADSPA_Handle instance, unsigned long sample_count) {
203 	BodeShifterCV *plugin_data = (BodeShifterCV *)instance;
204 
205 	/* Base shift (float value) */
206 	const LADSPA_Data shift_b = *(plugin_data->shift_b);
207 
208 	/* Mix (-1=down, +1=up) (float value) */
209 	const LADSPA_Data mix = *(plugin_data->mix);
210 
211 	/* Input (array of floats of length sample_count) */
212 	const LADSPA_Data * const input = plugin_data->input;
213 
214 	/* CV Attenuation (float value) */
215 	const LADSPA_Data atten = *(plugin_data->atten);
216 
217 	/* Shift CV (array of floats of length sample_count) */
218 	const LADSPA_Data * const shift = plugin_data->shift;
219 
220 	/* Down out (array of floats of length sample_count) */
221 	LADSPA_Data * const dout = plugin_data->dout;
222 
223 	/* Up out (array of floats of length sample_count) */
224 	LADSPA_Data * const uout = plugin_data->uout;
225 
226 	/* Mix out (array of floats of length sample_count) */
227 	LADSPA_Data * const mixout = plugin_data->mixout;
228 	LADSPA_Data * delay = plugin_data->delay;
229 	unsigned int dptr = plugin_data->dptr;
230 	float fs = plugin_data->fs;
231 	float phi = plugin_data->phi;
232 	float * sint = plugin_data->sint;
233 
234 #line 73 "bode_shifter_cv_1432.xml"
235 	unsigned long pos;
236 	unsigned int i;
237 	float hilb, rm1, rm2;
238 	int int_p;
239 	float frac_p;
240 	const float freq_fix = (float)SIN_T_SIZE * 1000.0f * f_clamp(atten, 0.0f, 10.0f) / fs;
241 	const float base_ofs = (float)SIN_T_SIZE * f_clamp(shift_b, 0.0f, 10000.0f) / fs;
242 	const float mixc = mix * 0.5f + 0.5f;
243 
244 	for (pos = 0; pos < sample_count; pos++) {
245 	  delay[dptr] = input[pos];
246 
247 	  /* Perform the Hilbert FIR convolution
248 	   * (probably FFT would be faster) */
249 	  hilb = 0.0f;
250 	  for (i = 0; i < NZEROS/2; i++) {
251 	    hilb += (xcoeffs[i] * delay[(dptr - i*2) & (D_SIZE - 1)]);
252 	  }
253 
254 	  /* Calcuate the table positions for the sine modulator */
255 	  int_p = f_round(floor(phi));
256 
257 	  /* Calculate ringmod1, the transformed input modulated with a shift Hz
258 	   * sinewave. This creates a +180 degree sideband at source-shift Hz and
259 	   * a 0 degree sindeband at source+shift Hz */
260 	  frac_p = phi - int_p;
261 	  rm1 = hilb * 0.63661978f * cube_interp(frac_p, sint[int_p],
262 	                  sint[int_p+1], sint[int_p+2], sint[int_p+3]);
263 
264 	  /* Calcuate the table positions for the cosine modulator */
265 	  int_p = (int_p + SIN_T_SIZE / 4) & (SIN_T_SIZE - 1);
266 
267 	  /* Calculate ringmod2, the delayed input modulated with a shift Hz
268 	   * cosinewave. This creates a 0 degree sideband at source+shift Hz
269 	   * and a -180 degree sindeband at source-shift Hz */
270 	  rm2 = delay[(dptr - 99) & (D_SIZE - 1)] * cube_interp(frac_p,
271 	        sint[int_p], sint[int_p+1], sint[int_p+2], sint[int_p+3]);
272 
273 	  /* Output the sum and differences of the ringmods. The +/-180 degree
274 	   * sidebands cancel (more of less) and just leave the shifted
275 	   * components */
276 	  buffer_write(dout[pos], (rm2 - rm1) * 0.5f);
277 	  buffer_write(uout[pos], (rm2 + rm1) * 0.5f);
278 	  buffer_write(mixout[pos], (dout[pos] - uout[pos]) * mixc + uout[pos]);
279 
280 	  dptr = (dptr + 1) & (D_SIZE - 1);
281 	  phi += f_clamp(shift[pos], 0.0f, 10.0f) * freq_fix + base_ofs;
282 	  while (phi > SIN_T_SIZE) {
283 	    phi -= SIN_T_SIZE;
284 	  }
285 	}
286 
287 	plugin_data->dptr = dptr;
288 	plugin_data->phi = phi;
289 
290 	*(plugin_data->latency) = 99;
291 }
292 #undef buffer_write
293 #undef RUN_ADDING
294 #undef RUN_REPLACING
295 
296 #define buffer_write(b, v) (b += (v) * run_adding_gain)
297 #define RUN_ADDING    1
298 #define RUN_REPLACING 0
299 
setRunAddingGainBodeShifterCV(LADSPA_Handle instance,LADSPA_Data gain)300 static void setRunAddingGainBodeShifterCV(LADSPA_Handle instance, LADSPA_Data gain) {
301 	((BodeShifterCV *)instance)->run_adding_gain = gain;
302 }
303 
runAddingBodeShifterCV(LADSPA_Handle instance,unsigned long sample_count)304 static void runAddingBodeShifterCV(LADSPA_Handle instance, unsigned long sample_count) {
305 	BodeShifterCV *plugin_data = (BodeShifterCV *)instance;
306 	LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;
307 
308 	/* Base shift (float value) */
309 	const LADSPA_Data shift_b = *(plugin_data->shift_b);
310 
311 	/* Mix (-1=down, +1=up) (float value) */
312 	const LADSPA_Data mix = *(plugin_data->mix);
313 
314 	/* Input (array of floats of length sample_count) */
315 	const LADSPA_Data * const input = plugin_data->input;
316 
317 	/* CV Attenuation (float value) */
318 	const LADSPA_Data atten = *(plugin_data->atten);
319 
320 	/* Shift CV (array of floats of length sample_count) */
321 	const LADSPA_Data * const shift = plugin_data->shift;
322 
323 	/* Down out (array of floats of length sample_count) */
324 	LADSPA_Data * const dout = plugin_data->dout;
325 
326 	/* Up out (array of floats of length sample_count) */
327 	LADSPA_Data * const uout = plugin_data->uout;
328 
329 	/* Mix out (array of floats of length sample_count) */
330 	LADSPA_Data * const mixout = plugin_data->mixout;
331 	LADSPA_Data * delay = plugin_data->delay;
332 	unsigned int dptr = plugin_data->dptr;
333 	float fs = plugin_data->fs;
334 	float phi = plugin_data->phi;
335 	float * sint = plugin_data->sint;
336 
337 #line 73 "bode_shifter_cv_1432.xml"
338 	unsigned long pos;
339 	unsigned int i;
340 	float hilb, rm1, rm2;
341 	int int_p;
342 	float frac_p;
343 	const float freq_fix = (float)SIN_T_SIZE * 1000.0f * f_clamp(atten, 0.0f, 10.0f) / fs;
344 	const float base_ofs = (float)SIN_T_SIZE * f_clamp(shift_b, 0.0f, 10000.0f) / fs;
345 	const float mixc = mix * 0.5f + 0.5f;
346 
347 	for (pos = 0; pos < sample_count; pos++) {
348 	  delay[dptr] = input[pos];
349 
350 	  /* Perform the Hilbert FIR convolution
351 	   * (probably FFT would be faster) */
352 	  hilb = 0.0f;
353 	  for (i = 0; i < NZEROS/2; i++) {
354 	    hilb += (xcoeffs[i] * delay[(dptr - i*2) & (D_SIZE - 1)]);
355 	  }
356 
357 	  /* Calcuate the table positions for the sine modulator */
358 	  int_p = f_round(floor(phi));
359 
360 	  /* Calculate ringmod1, the transformed input modulated with a shift Hz
361 	   * sinewave. This creates a +180 degree sideband at source-shift Hz and
362 	   * a 0 degree sindeband at source+shift Hz */
363 	  frac_p = phi - int_p;
364 	  rm1 = hilb * 0.63661978f * cube_interp(frac_p, sint[int_p],
365 	                  sint[int_p+1], sint[int_p+2], sint[int_p+3]);
366 
367 	  /* Calcuate the table positions for the cosine modulator */
368 	  int_p = (int_p + SIN_T_SIZE / 4) & (SIN_T_SIZE - 1);
369 
370 	  /* Calculate ringmod2, the delayed input modulated with a shift Hz
371 	   * cosinewave. This creates a 0 degree sideband at source+shift Hz
372 	   * and a -180 degree sindeband at source-shift Hz */
373 	  rm2 = delay[(dptr - 99) & (D_SIZE - 1)] * cube_interp(frac_p,
374 	        sint[int_p], sint[int_p+1], sint[int_p+2], sint[int_p+3]);
375 
376 	  /* Output the sum and differences of the ringmods. The +/-180 degree
377 	   * sidebands cancel (more of less) and just leave the shifted
378 	   * components */
379 	  buffer_write(dout[pos], (rm2 - rm1) * 0.5f);
380 	  buffer_write(uout[pos], (rm2 + rm1) * 0.5f);
381 	  buffer_write(mixout[pos], (dout[pos] - uout[pos]) * mixc + uout[pos]);
382 
383 	  dptr = (dptr + 1) & (D_SIZE - 1);
384 	  phi += f_clamp(shift[pos], 0.0f, 10.0f) * freq_fix + base_ofs;
385 	  while (phi > SIN_T_SIZE) {
386 	    phi -= SIN_T_SIZE;
387 	  }
388 	}
389 
390 	plugin_data->dptr = dptr;
391 	plugin_data->phi = phi;
392 
393 	*(plugin_data->latency) = 99;
394 }
395 
swh_init()396 static void __attribute__((constructor)) swh_init() {
397 	char **port_names;
398 	LADSPA_PortDescriptor *port_descriptors;
399 	LADSPA_PortRangeHint *port_range_hints;
400 
401 #ifdef ENABLE_NLS
402 #define D_(s) dgettext(PACKAGE, s)
403 	bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
404 #else
405 #define D_(s) (s)
406 #endif
407 
408 
409 	bodeShifterCVDescriptor =
410 	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));
411 
412 	if (bodeShifterCVDescriptor) {
413 		bodeShifterCVDescriptor->UniqueID = 1432;
414 		bodeShifterCVDescriptor->Label = "bodeShifterCV";
415 		bodeShifterCVDescriptor->Properties =
416 		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
417 		bodeShifterCVDescriptor->Name =
418 		 D_("Bode frequency shifter (CV)");
419 		bodeShifterCVDescriptor->Maker =
420 		 "Steve Harris <steve@plugin.org.uk>";
421 		bodeShifterCVDescriptor->Copyright =
422 		 "GPL";
423 		bodeShifterCVDescriptor->PortCount = 9;
424 
425 		port_descriptors = (LADSPA_PortDescriptor *)calloc(9,
426 		 sizeof(LADSPA_PortDescriptor));
427 		bodeShifterCVDescriptor->PortDescriptors =
428 		 (const LADSPA_PortDescriptor *)port_descriptors;
429 
430 		port_range_hints = (LADSPA_PortRangeHint *)calloc(9,
431 		 sizeof(LADSPA_PortRangeHint));
432 		bodeShifterCVDescriptor->PortRangeHints =
433 		 (const LADSPA_PortRangeHint *)port_range_hints;
434 
435 		port_names = (char **)calloc(9, sizeof(char*));
436 		bodeShifterCVDescriptor->PortNames =
437 		 (const char **)port_names;
438 
439 		/* Parameters for Base shift */
440 		port_descriptors[BODESHIFTERCV_SHIFT_B] =
441 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
442 		port_names[BODESHIFTERCV_SHIFT_B] =
443 		 D_("Base shift");
444 		port_range_hints[BODESHIFTERCV_SHIFT_B].HintDescriptor =
445 		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
446 		port_range_hints[BODESHIFTERCV_SHIFT_B].LowerBound = 0;
447 		port_range_hints[BODESHIFTERCV_SHIFT_B].UpperBound = 5000;
448 
449 		/* Parameters for Mix (-1=down, +1=up) */
450 		port_descriptors[BODESHIFTERCV_MIX] =
451 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
452 		port_names[BODESHIFTERCV_MIX] =
453 		 D_("Mix (-1=down, +1=up)");
454 		port_range_hints[BODESHIFTERCV_MIX].HintDescriptor =
455 		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
456 		port_range_hints[BODESHIFTERCV_MIX].LowerBound = -1;
457 		port_range_hints[BODESHIFTERCV_MIX].UpperBound = 1;
458 
459 		/* Parameters for Input */
460 		port_descriptors[BODESHIFTERCV_INPUT] =
461 		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
462 		port_names[BODESHIFTERCV_INPUT] =
463 		 D_("Input");
464 		port_range_hints[BODESHIFTERCV_INPUT].HintDescriptor = 0;
465 
466 		/* Parameters for CV Attenuation */
467 		port_descriptors[BODESHIFTERCV_ATTEN] =
468 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
469 		port_names[BODESHIFTERCV_ATTEN] =
470 		 D_("CV Attenuation");
471 		port_range_hints[BODESHIFTERCV_ATTEN].HintDescriptor =
472 		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MAXIMUM;
473 		port_range_hints[BODESHIFTERCV_ATTEN].LowerBound = 0;
474 		port_range_hints[BODESHIFTERCV_ATTEN].UpperBound = 1;
475 
476 		/* Parameters for Shift CV */
477 		port_descriptors[BODESHIFTERCV_SHIFT] =
478 		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
479 		port_names[BODESHIFTERCV_SHIFT] =
480 		 D_("Shift CV");
481 		port_range_hints[BODESHIFTERCV_SHIFT].HintDescriptor =
482 		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
483 		port_range_hints[BODESHIFTERCV_SHIFT].LowerBound = 0;
484 		port_range_hints[BODESHIFTERCV_SHIFT].UpperBound = 5;
485 
486 		/* Parameters for Down out */
487 		port_descriptors[BODESHIFTERCV_DOUT] =
488 		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
489 		port_names[BODESHIFTERCV_DOUT] =
490 		 D_("Down out");
491 		port_range_hints[BODESHIFTERCV_DOUT].HintDescriptor = 0;
492 
493 		/* Parameters for Up out */
494 		port_descriptors[BODESHIFTERCV_UOUT] =
495 		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
496 		port_names[BODESHIFTERCV_UOUT] =
497 		 D_("Up out");
498 		port_range_hints[BODESHIFTERCV_UOUT].HintDescriptor = 0;
499 
500 		/* Parameters for Mix out */
501 		port_descriptors[BODESHIFTERCV_MIXOUT] =
502 		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
503 		port_names[BODESHIFTERCV_MIXOUT] =
504 		 D_("Mix out");
505 		port_range_hints[BODESHIFTERCV_MIXOUT].HintDescriptor = 0;
506 
507 		/* Parameters for latency */
508 		port_descriptors[BODESHIFTERCV_LATENCY] =
509 		 LADSPA_PORT_OUTPUT | LADSPA_PORT_CONTROL;
510 		port_names[BODESHIFTERCV_LATENCY] =
511 		 D_("latency");
512 		port_range_hints[BODESHIFTERCV_LATENCY].HintDescriptor = 0;
513 
514 		bodeShifterCVDescriptor->activate = NULL;
515 		bodeShifterCVDescriptor->cleanup = cleanupBodeShifterCV;
516 		bodeShifterCVDescriptor->connect_port = connectPortBodeShifterCV;
517 		bodeShifterCVDescriptor->deactivate = NULL;
518 		bodeShifterCVDescriptor->instantiate = instantiateBodeShifterCV;
519 		bodeShifterCVDescriptor->run = runBodeShifterCV;
520 		bodeShifterCVDescriptor->run_adding = runAddingBodeShifterCV;
521 		bodeShifterCVDescriptor->set_run_adding_gain = setRunAddingGainBodeShifterCV;
522 	}
523 }
524 
swh_fini()525 static void __attribute__((destructor)) swh_fini() {
526 	if (bodeShifterCVDescriptor) {
527 		free((LADSPA_PortDescriptor *)bodeShifterCVDescriptor->PortDescriptors);
528 		free((char **)bodeShifterCVDescriptor->PortNames);
529 		free((LADSPA_PortRangeHint *)bodeShifterCVDescriptor->PortRangeHints);
530 		free(bodeShifterCVDescriptor);
531 	}
532 	bodeShifterCVDescriptor = NULL;
533 
534 }
535