File: lookahead_limiter_const_1906.so.c

package info (click to toggle)
swh-plugins 0.4.15%2B1-4
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 8,268 kB
  • ctags: 12,249
  • sloc: ansic: 72,074; sh: 28,183; xml: 12,247; perl: 769; makefile: 212; sed: 16
file content (580 lines) | stat: -rw-r--r-- 17,822 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
#include <stdlib.h>
#include <string.h>
#ifndef WIN32
#include "config.h"
#endif

#ifdef ENABLE_NLS
#include <libintl.h>
#endif

#define         _ISOC9X_SOURCE  1
#define         _ISOC99_SOURCE  1
#define         __USE_ISOC99    1
#define         __USE_ISOC9X    1

#include <math.h>

#include "ladspa.h"

#ifdef WIN32
#define _WINDOWS_DLL_EXPORT_ __declspec(dllexport)
int bIsFirstTime = 1; 
void _init(); // forward declaration
#else
#define _WINDOWS_DLL_EXPORT_ 
#endif

#line 10 "lookahead_limiter_const_1906.xml"

#include "ladspa-util.h"
#include "util/db.h"

/* Minimum buffer size in seconds */
#define BUFFER_TIME 0.15f

#define LOOKAHEADLIMITERCONST_LIMIT    0
#define LOOKAHEADLIMITERCONST_DELAY_S  1
#define LOOKAHEADLIMITERCONST_ATTENUATION 2
#define LOOKAHEADLIMITERCONST_IN_1     3
#define LOOKAHEADLIMITERCONST_IN_2     4
#define LOOKAHEADLIMITERCONST_OUT_1    5
#define LOOKAHEADLIMITERCONST_OUT_2    6
#define LOOKAHEADLIMITERCONST_LATENCY  7

static LADSPA_Descriptor *lookaheadLimiterConstDescriptor = NULL;

typedef struct {
	LADSPA_Data *limit;
	LADSPA_Data *delay_s;
	LADSPA_Data *attenuation;
	LADSPA_Data *in_1;
	LADSPA_Data *in_2;
	LADSPA_Data *out_1;
	LADSPA_Data *out_2;
	LADSPA_Data *latency;
	float *      amp_buffer;
	float        atten;
	LADSPA_Data *buffer;
	unsigned int buffer_len;
	unsigned int buffer_mask;
	unsigned int buffer_pos;
	unsigned int fs;
	float        last_delay;
	float        peak;
	unsigned int peak_dist;
	LADSPA_Data run_adding_gain;
} LookaheadLimiterConst;

_WINDOWS_DLL_EXPORT_
const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) {

#ifdef WIN32
	if (bIsFirstTime) {
		_init();
		bIsFirstTime = 0;
	}
#endif
	switch (index) {
	case 0:
		return lookaheadLimiterConstDescriptor;
	default:
		return NULL;
	}
}

static void activateLookaheadLimiterConst(LADSPA_Handle instance) {
	LookaheadLimiterConst *plugin_data = (LookaheadLimiterConst *)instance;
	float *amp_buffer = plugin_data->amp_buffer;
	float atten = plugin_data->atten;
	LADSPA_Data *buffer = plugin_data->buffer;
	unsigned int buffer_len = plugin_data->buffer_len;
	unsigned int buffer_mask = plugin_data->buffer_mask;
	unsigned int buffer_pos = plugin_data->buffer_pos;
	unsigned int fs = plugin_data->fs;
	float last_delay = plugin_data->last_delay;
	float peak = plugin_data->peak;
	unsigned int peak_dist = plugin_data->peak_dist;
#line 47 "lookahead_limiter_const_1906.xml"
	int i;

	memset(buffer, 0, buffer_len * 2 * sizeof(float));
	for (i=0; i<buffer_len; i++) amp_buffer[i] = 1.0f;

	buffer_pos = 0;
	peak = 0.0f;
	peak_dist = 1;
	atten = 0.0f;
	last_delay = 0.001 * fs;
	plugin_data->amp_buffer = amp_buffer;
	plugin_data->atten = atten;
	plugin_data->buffer = buffer;
	plugin_data->buffer_len = buffer_len;
	plugin_data->buffer_mask = buffer_mask;
	plugin_data->buffer_pos = buffer_pos;
	plugin_data->fs = fs;
	plugin_data->last_delay = last_delay;
	plugin_data->peak = peak;
	plugin_data->peak_dist = peak_dist;

}

static void cleanupLookaheadLimiterConst(LADSPA_Handle instance) {
#line 138 "lookahead_limiter_const_1906.xml"
	LookaheadLimiterConst *plugin_data = (LookaheadLimiterConst *)instance;
	free(plugin_data->buffer);
	free(plugin_data->amp_buffer);
	free(instance);
}

static void connectPortLookaheadLimiterConst(
 LADSPA_Handle instance,
 unsigned long port,
 LADSPA_Data *data) {
	LookaheadLimiterConst *plugin;

	plugin = (LookaheadLimiterConst *)instance;
	switch (port) {
	case LOOKAHEADLIMITERCONST_LIMIT:
		plugin->limit = data;
		break;
	case LOOKAHEADLIMITERCONST_DELAY_S:
		plugin->delay_s = data;
		break;
	case LOOKAHEADLIMITERCONST_ATTENUATION:
		plugin->attenuation = data;
		break;
	case LOOKAHEADLIMITERCONST_IN_1:
		plugin->in_1 = data;
		break;
	case LOOKAHEADLIMITERCONST_IN_2:
		plugin->in_2 = data;
		break;
	case LOOKAHEADLIMITERCONST_OUT_1:
		plugin->out_1 = data;
		break;
	case LOOKAHEADLIMITERCONST_OUT_2:
		plugin->out_2 = data;
		break;
	case LOOKAHEADLIMITERCONST_LATENCY:
		plugin->latency = data;
		break;
	}
}

static LADSPA_Handle instantiateLookaheadLimiterConst(
 const LADSPA_Descriptor *descriptor,
 unsigned long s_rate) {
	LookaheadLimiterConst *plugin_data = (LookaheadLimiterConst *)malloc(sizeof(LookaheadLimiterConst));
	float *amp_buffer = NULL;
	float atten;
	LADSPA_Data *buffer = NULL;
	unsigned int buffer_len;
	unsigned int buffer_mask;
	unsigned int buffer_pos;
	unsigned int fs;
	float last_delay;
	float peak;
	unsigned int peak_dist;

#line 26 "lookahead_limiter_const_1906.xml"
	buffer_len = 4096;
	buffer_pos = 0;
	fs = s_rate;

	db_init();

	/* Find size for power-of-two interleaved delay buffer */
	while(buffer_len < s_rate * BUFFER_TIME) {
	  buffer_len *= 2;
	}
	buffer_mask = buffer_len * 2 - 1;
	buffer = calloc(buffer_len * 2, sizeof(LADSPA_Data));
	amp_buffer = calloc(buffer_len, sizeof(float));

	peak = 0.0f;
	peak_dist = 1;
	atten = 0.0f;
	last_delay = 0.001 * fs;

	plugin_data->amp_buffer = amp_buffer;
	plugin_data->atten = atten;
	plugin_data->buffer = buffer;
	plugin_data->buffer_len = buffer_len;
	plugin_data->buffer_mask = buffer_mask;
	plugin_data->buffer_pos = buffer_pos;
	plugin_data->fs = fs;
	plugin_data->last_delay = last_delay;
	plugin_data->peak = peak;
	plugin_data->peak_dist = peak_dist;

	return (LADSPA_Handle)plugin_data;
}

#undef buffer_write
#undef RUN_ADDING
#undef RUN_REPLACING

#define buffer_write(b, v) (b = v)
#define RUN_ADDING    0
#define RUN_REPLACING 1

static void runLookaheadLimiterConst(LADSPA_Handle instance, unsigned long sample_count) {
	LookaheadLimiterConst *plugin_data = (LookaheadLimiterConst *)instance;

	/* Limit (dB) (float value) */
	const LADSPA_Data limit = *(plugin_data->limit);

	/* Lookahead time (s) (float value) */
	const LADSPA_Data delay_s = *(plugin_data->delay_s);

	/* Input 1 (array of floats of length sample_count) */
	const LADSPA_Data * const in_1 = plugin_data->in_1;

	/* Input 2 (array of floats of length sample_count) */
	const LADSPA_Data * const in_2 = plugin_data->in_2;

	/* Output 1 (array of floats of length sample_count) */
	LADSPA_Data * const out_1 = plugin_data->out_1;

	/* Output 2 (array of floats of length sample_count) */
	LADSPA_Data * const out_2 = plugin_data->out_2;
	float * amp_buffer = plugin_data->amp_buffer;
	float atten = plugin_data->atten;
	LADSPA_Data * buffer = plugin_data->buffer;
	unsigned int buffer_len = plugin_data->buffer_len;
	unsigned int buffer_mask = plugin_data->buffer_mask;
	unsigned int buffer_pos = plugin_data->buffer_pos;
	unsigned int fs = plugin_data->fs;
	float last_delay = plugin_data->last_delay;
	float peak = plugin_data->peak;
	unsigned int peak_dist = plugin_data->peak_dist;

#line 60 "lookahead_limiter_const_1906.xml"
	unsigned long pos;
	const float max = DB_CO(limit);
	float sig, gain;
	float delay = last_delay;
	const float delay_delta = (delay_s * fs - last_delay) / (sample_count - 1);
	const unsigned int full_delay = f_round(BUFFER_TIME * fs);
	float a, b;

	for (pos = 0; pos < sample_count; pos++) {
	  delay += delay_delta;
	  buffer[(buffer_pos * 2) & buffer_mask] = in_1[pos];
	  buffer[(buffer_pos * 2 + 1) & buffer_mask] = in_2[pos];

	  a = fabs(buffer[((buffer_pos + f_round(delay)) * 2) & buffer_mask]);
	  b = fabs(buffer[((buffer_pos + f_round(delay)) * 2 + 1) & buffer_mask]);

	  sig = a > b ? a : b;

	  if (sig > max) {
	    sig = lin2db(sig) - limit;
	    if (sig / delay > peak / (float)peak_dist) {
	      peak_dist = delay;
	      peak = sig;
	    }
	  }
	  if (sig > 0.0f && sig / (float)delay > peak / (float)peak_dist) {
	    peak_dist = delay;
	    peak = sig;
	  }

	  /* Incremenatlly approach the correct attenuation for the next peak */
	  atten -= (atten - peak) / (float)(peak_dist + 1);

	  if (peak_dist-- == 0) {
	          peak_dist = delay;
	          peak = 0.0f;
	  }

	  /* Cacluate the apropriate gain reduction and write it back into the
	   * buffer */
	  gain = 1.0f / db2lin(atten);
	  amp_buffer[(buffer_pos - f_round(delay)) & (buffer_len - 1)] = gain;

	  buffer_write(out_1[pos], buffer[(buffer_pos * 2 - 2) & buffer_mask] *
	          gain);
	  buffer_write(out_2[pos], buffer[(buffer_pos * 2 - 1) & buffer_mask] *
	          gain);

	  /* Ensure that the signal really can't be over the limit,
	   * changes in the lookahead time can cause us to miss peaks */

	  if (out_1[pos] < -max) {
	    buffer_write(out_1[pos], -max);
//printf("c\n");
	  } else if (out_1[pos] > max) {
//printf("c\n");
	    buffer_write(out_1[pos], max);
	  }
	  if (out_2[pos] < -max) {
	    buffer_write(out_2[pos], -max);
	  } else if (out_2[pos] > max) {
	    buffer_write(out_2[pos], max);
	  }

	  buffer_pos++;
	}

	plugin_data->buffer_pos = buffer_pos;
	plugin_data->peak = peak;
	plugin_data->peak_dist = peak_dist;
	plugin_data->atten = atten;
	plugin_data->last_delay = delay;

	*(plugin_data->attenuation) = atten;
	*(plugin_data->latency) = buffer_len;
}
#undef buffer_write
#undef RUN_ADDING
#undef RUN_REPLACING

#define buffer_write(b, v) (b += (v) * run_adding_gain)
#define RUN_ADDING    1
#define RUN_REPLACING 0

static void setRunAddingGainLookaheadLimiterConst(LADSPA_Handle instance, LADSPA_Data gain) {
	((LookaheadLimiterConst *)instance)->run_adding_gain = gain;
}

static void runAddingLookaheadLimiterConst(LADSPA_Handle instance, unsigned long sample_count) {
	LookaheadLimiterConst *plugin_data = (LookaheadLimiterConst *)instance;
	LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;

	/* Limit (dB) (float value) */
	const LADSPA_Data limit = *(plugin_data->limit);

	/* Lookahead time (s) (float value) */
	const LADSPA_Data delay_s = *(plugin_data->delay_s);

	/* Input 1 (array of floats of length sample_count) */
	const LADSPA_Data * const in_1 = plugin_data->in_1;

	/* Input 2 (array of floats of length sample_count) */
	const LADSPA_Data * const in_2 = plugin_data->in_2;

	/* Output 1 (array of floats of length sample_count) */
	LADSPA_Data * const out_1 = plugin_data->out_1;

	/* Output 2 (array of floats of length sample_count) */
	LADSPA_Data * const out_2 = plugin_data->out_2;
	float * amp_buffer = plugin_data->amp_buffer;
	float atten = plugin_data->atten;
	LADSPA_Data * buffer = plugin_data->buffer;
	unsigned int buffer_len = plugin_data->buffer_len;
	unsigned int buffer_mask = plugin_data->buffer_mask;
	unsigned int buffer_pos = plugin_data->buffer_pos;
	unsigned int fs = plugin_data->fs;
	float last_delay = plugin_data->last_delay;
	float peak = plugin_data->peak;
	unsigned int peak_dist = plugin_data->peak_dist;

#line 60 "lookahead_limiter_const_1906.xml"
	unsigned long pos;
	const float max = DB_CO(limit);
	float sig, gain;
	float delay = last_delay;
	const float delay_delta = (delay_s * fs - last_delay) / (sample_count - 1);
	const unsigned int full_delay = f_round(BUFFER_TIME * fs);
	float a, b;

	for (pos = 0; pos < sample_count; pos++) {
	  delay += delay_delta;
	  buffer[(buffer_pos * 2) & buffer_mask] = in_1[pos];
	  buffer[(buffer_pos * 2 + 1) & buffer_mask] = in_2[pos];

	  a = fabs(buffer[((buffer_pos + f_round(delay)) * 2) & buffer_mask]);
	  b = fabs(buffer[((buffer_pos + f_round(delay)) * 2 + 1) & buffer_mask]);

	  sig = a > b ? a : b;

	  if (sig > max) {
	    sig = lin2db(sig) - limit;
	    if (sig / delay > peak / (float)peak_dist) {
	      peak_dist = delay;
	      peak = sig;
	    }
	  }
	  if (sig > 0.0f && sig / (float)delay > peak / (float)peak_dist) {
	    peak_dist = delay;
	    peak = sig;
	  }

	  /* Incremenatlly approach the correct attenuation for the next peak */
	  atten -= (atten - peak) / (float)(peak_dist + 1);

	  if (peak_dist-- == 0) {
	          peak_dist = delay;
	          peak = 0.0f;
	  }

	  /* Cacluate the apropriate gain reduction and write it back into the
	   * buffer */
	  gain = 1.0f / db2lin(atten);
	  amp_buffer[(buffer_pos - f_round(delay)) & (buffer_len - 1)] = gain;

	  buffer_write(out_1[pos], buffer[(buffer_pos * 2 - 2) & buffer_mask] *
	          gain);
	  buffer_write(out_2[pos], buffer[(buffer_pos * 2 - 1) & buffer_mask] *
	          gain);

	  /* Ensure that the signal really can't be over the limit,
	   * changes in the lookahead time can cause us to miss peaks */

	  if (out_1[pos] < -max) {
	    buffer_write(out_1[pos], -max);
//printf("c\n");
	  } else if (out_1[pos] > max) {
//printf("c\n");
	    buffer_write(out_1[pos], max);
	  }
	  if (out_2[pos] < -max) {
	    buffer_write(out_2[pos], -max);
	  } else if (out_2[pos] > max) {
	    buffer_write(out_2[pos], max);
	  }

	  buffer_pos++;
	}

	plugin_data->buffer_pos = buffer_pos;
	plugin_data->peak = peak;
	plugin_data->peak_dist = peak_dist;
	plugin_data->atten = atten;
	plugin_data->last_delay = delay;

	*(plugin_data->attenuation) = atten;
	*(plugin_data->latency) = buffer_len;
}

void _init() {
	char **port_names;
	LADSPA_PortDescriptor *port_descriptors;
	LADSPA_PortRangeHint *port_range_hints;

#ifdef ENABLE_NLS
#define D_(s) dgettext(PACKAGE, s)
	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
#else
#define D_(s) (s)
#endif


	lookaheadLimiterConstDescriptor =
	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));

	if (lookaheadLimiterConstDescriptor) {
		lookaheadLimiterConstDescriptor->UniqueID = 1906;
		lookaheadLimiterConstDescriptor->Label = "lookaheadLimiterConst";
		lookaheadLimiterConstDescriptor->Properties =
		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
		lookaheadLimiterConstDescriptor->Name =
		 D_("Lookahead limiter (fixed latency)");
		lookaheadLimiterConstDescriptor->Maker =
		 "Steve Harris <steve@plugin.org.uk>";
		lookaheadLimiterConstDescriptor->Copyright =
		 "GPL";
		lookaheadLimiterConstDescriptor->PortCount = 8;

		port_descriptors = (LADSPA_PortDescriptor *)calloc(8,
		 sizeof(LADSPA_PortDescriptor));
		lookaheadLimiterConstDescriptor->PortDescriptors =
		 (const LADSPA_PortDescriptor *)port_descriptors;

		port_range_hints = (LADSPA_PortRangeHint *)calloc(8,
		 sizeof(LADSPA_PortRangeHint));
		lookaheadLimiterConstDescriptor->PortRangeHints =
		 (const LADSPA_PortRangeHint *)port_range_hints;

		port_names = (char **)calloc(8, sizeof(char*));
		lookaheadLimiterConstDescriptor->PortNames =
		 (const char **)port_names;

		/* Parameters for Limit (dB) */
		port_descriptors[LOOKAHEADLIMITERCONST_LIMIT] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[LOOKAHEADLIMITERCONST_LIMIT] =
		 D_("Limit (dB)");
		port_range_hints[LOOKAHEADLIMITERCONST_LIMIT].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
		port_range_hints[LOOKAHEADLIMITERCONST_LIMIT].LowerBound = -20;
		port_range_hints[LOOKAHEADLIMITERCONST_LIMIT].UpperBound = 0;

		/* Parameters for Lookahead time (s) */
		port_descriptors[LOOKAHEADLIMITERCONST_DELAY_S] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[LOOKAHEADLIMITERCONST_DELAY_S] =
		 D_("Lookahead time (s)");
		port_range_hints[LOOKAHEADLIMITERCONST_DELAY_S].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE;
		port_range_hints[LOOKAHEADLIMITERCONST_DELAY_S].LowerBound = 0.001;
		port_range_hints[LOOKAHEADLIMITERCONST_DELAY_S].UpperBound = 0.15;

		/* Parameters for Attenuation (dB) */
		port_descriptors[LOOKAHEADLIMITERCONST_ATTENUATION] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_CONTROL;
		port_names[LOOKAHEADLIMITERCONST_ATTENUATION] =
		 D_("Attenuation (dB)");
		port_range_hints[LOOKAHEADLIMITERCONST_ATTENUATION].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE;
		port_range_hints[LOOKAHEADLIMITERCONST_ATTENUATION].LowerBound = 0;
		port_range_hints[LOOKAHEADLIMITERCONST_ATTENUATION].UpperBound = 12;

		/* Parameters for Input 1 */
		port_descriptors[LOOKAHEADLIMITERCONST_IN_1] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[LOOKAHEADLIMITERCONST_IN_1] =
		 D_("Input 1");
		port_range_hints[LOOKAHEADLIMITERCONST_IN_1].HintDescriptor = 0;

		/* Parameters for Input 2 */
		port_descriptors[LOOKAHEADLIMITERCONST_IN_2] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[LOOKAHEADLIMITERCONST_IN_2] =
		 D_("Input 2");
		port_range_hints[LOOKAHEADLIMITERCONST_IN_2].HintDescriptor = 0;

		/* Parameters for Output 1 */
		port_descriptors[LOOKAHEADLIMITERCONST_OUT_1] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[LOOKAHEADLIMITERCONST_OUT_1] =
		 D_("Output 1");
		port_range_hints[LOOKAHEADLIMITERCONST_OUT_1].HintDescriptor = 0;

		/* Parameters for Output 2 */
		port_descriptors[LOOKAHEADLIMITERCONST_OUT_2] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[LOOKAHEADLIMITERCONST_OUT_2] =
		 D_("Output 2");
		port_range_hints[LOOKAHEADLIMITERCONST_OUT_2].HintDescriptor = 0;

		/* Parameters for latency */
		port_descriptors[LOOKAHEADLIMITERCONST_LATENCY] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_CONTROL;
		port_names[LOOKAHEADLIMITERCONST_LATENCY] =
		 D_("latency");
		port_range_hints[LOOKAHEADLIMITERCONST_LATENCY].HintDescriptor = 0;

		lookaheadLimiterConstDescriptor->activate = activateLookaheadLimiterConst;
		lookaheadLimiterConstDescriptor->cleanup = cleanupLookaheadLimiterConst;
		lookaheadLimiterConstDescriptor->connect_port = connectPortLookaheadLimiterConst;
		lookaheadLimiterConstDescriptor->deactivate = NULL;
		lookaheadLimiterConstDescriptor->instantiate = instantiateLookaheadLimiterConst;
		lookaheadLimiterConstDescriptor->run = runLookaheadLimiterConst;
		lookaheadLimiterConstDescriptor->run_adding = runAddingLookaheadLimiterConst;
		lookaheadLimiterConstDescriptor->set_run_adding_gain = setRunAddingGainLookaheadLimiterConst;
	}
}

void _fini() {
	if (lookaheadLimiterConstDescriptor) {
		free((LADSPA_PortDescriptor *)lookaheadLimiterConstDescriptor->PortDescriptors);
		free((char **)lookaheadLimiterConstDescriptor->PortNames);
		free((LADSPA_PortRangeHint *)lookaheadLimiterConstDescriptor->PortRangeHints);
		free(lookaheadLimiterConstDescriptor);
	}

}