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 "allpass_1895.xml"
29 
30 #include "ladspa-util.h"
31 
32 #define MIN(a,b) ((a) < (b) ? (a) : (b))
33 #define CALC_DELAY(delaytime) \
34   (f_clamp (delaytime * sample_rate, 1.f, (float)(buffer_mask + 1)))
35 
36 #define LOG001 -6.9077552789f
37 
38 static inline float
calc_feedback(float delaytime,float decaytime)39 calc_feedback (float delaytime, float decaytime)
40 {
41   if (delaytime == 0.f)
42     return 0.f;
43   else if (decaytime > 0.f)
44     return exp(LOG001 * delaytime / decaytime);
45   else if (decaytime < 0.f)
46     return -exp(LOG001 * delaytime / -decaytime);
47   else
48     return 0.f;
49 }
50 
ignore(LADSPA_Data some_var)51 void ignore(LADSPA_Data some_var)
52 { }
53 
54 #define ALLPASS_N_IN                   0
55 #define ALLPASS_N_OUT                  1
56 #define ALLPASS_N_MAX_DELAY            2
57 #define ALLPASS_N_DELAY_TIME           3
58 #define ALLPASS_N_DECAY_TIME           4
59 #define ALLPASS_L_IN                   0
60 #define ALLPASS_L_OUT                  1
61 #define ALLPASS_L_MAX_DELAY            2
62 #define ALLPASS_L_DELAY_TIME           3
63 #define ALLPASS_L_DECAY_TIME           4
64 #define ALLPASS_C_IN                   0
65 #define ALLPASS_C_OUT                  1
66 #define ALLPASS_C_MAX_DELAY            2
67 #define ALLPASS_C_DELAY_TIME           3
68 #define ALLPASS_C_DECAY_TIME           4
69 
70 static LADSPA_Descriptor *allpass_nDescriptor = NULL;
71 
72 typedef struct {
73 	LADSPA_Data *in;
74 	LADSPA_Data *out;
75 	LADSPA_Data *max_delay;
76 	LADSPA_Data *delay_time;
77 	LADSPA_Data *decay_time;
78 	LADSPA_Data *buffer;
79 	unsigned int buffer_mask;
80 	LADSPA_Data  delay_samples;
81 	LADSPA_Data  feedback;
82 	LADSPA_Data  last_decay_time;
83 	LADSPA_Data  last_delay_time;
84 	unsigned int sample_rate;
85 	long         write_phase;
86 	LADSPA_Data run_adding_gain;
87 } Allpass_n;
88 
89 static LADSPA_Descriptor *allpass_lDescriptor = NULL;
90 
91 typedef struct {
92 	LADSPA_Data *in;
93 	LADSPA_Data *out;
94 	LADSPA_Data *max_delay;
95 	LADSPA_Data *delay_time;
96 	LADSPA_Data *decay_time;
97 	LADSPA_Data *buffer;
98 	unsigned int buffer_mask;
99 	LADSPA_Data  delay_samples;
100 	LADSPA_Data  feedback;
101 	LADSPA_Data  last_decay_time;
102 	LADSPA_Data  last_delay_time;
103 	unsigned int sample_rate;
104 	long         write_phase;
105 	LADSPA_Data run_adding_gain;
106 } Allpass_l;
107 
108 static LADSPA_Descriptor *allpass_cDescriptor = NULL;
109 
110 typedef struct {
111 	LADSPA_Data *in;
112 	LADSPA_Data *out;
113 	LADSPA_Data *max_delay;
114 	LADSPA_Data *delay_time;
115 	LADSPA_Data *decay_time;
116 	LADSPA_Data *buffer;
117 	unsigned int buffer_mask;
118 	LADSPA_Data  delay_samples;
119 	LADSPA_Data  feedback;
120 	LADSPA_Data  last_decay_time;
121 	LADSPA_Data  last_delay_time;
122 	unsigned int sample_rate;
123 	long         write_phase;
124 	LADSPA_Data run_adding_gain;
125 } Allpass_c;
126 
127 _WINDOWS_DLL_EXPORT_
ladspa_descriptor(unsigned long index)128 const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) {
129 
130 #ifdef WIN32
131 	if (bIsFirstTime) {
132 		swh_init();
133 		bIsFirstTime = 0;
134 	}
135 #endif
136 	switch (index) {
137 	case 0:
138 		return allpass_nDescriptor;
139 	case 1:
140 		return allpass_lDescriptor;
141 	case 2:
142 		return allpass_cDescriptor;
143 	default:
144 		return NULL;
145 	}
146 }
147 
activateAllpass_n(LADSPA_Handle instance)148 static void activateAllpass_n(LADSPA_Handle instance) {
149 	Allpass_n *plugin_data = (Allpass_n *)instance;
150 	LADSPA_Data *buffer = plugin_data->buffer;
151 	unsigned int buffer_mask = plugin_data->buffer_mask;
152 	LADSPA_Data delay_samples = plugin_data->delay_samples;
153 	LADSPA_Data feedback = plugin_data->feedback;
154 	LADSPA_Data last_decay_time = plugin_data->last_decay_time;
155 	LADSPA_Data last_delay_time = plugin_data->last_delay_time;
156 	unsigned int sample_rate = plugin_data->sample_rate;
157 	long write_phase = plugin_data->write_phase;
158 #line 56 "allpass_1895.xml"
159 	unsigned int minsize, size;
160 
161 	if (plugin_data->max_delay && *plugin_data->max_delay > 0)
162 	  minsize = sample_rate * *plugin_data->max_delay;
163 	else if (plugin_data->delay_time)
164 	  minsize = sample_rate * *plugin_data->delay_time;
165 	else
166 	  minsize = sample_rate; /* 1 second default */
167 
168 	size = 1;
169 	while (size < minsize) size <<= 1;
170 
171 	/* calloc sets the buffer to zero. */
172 	buffer = calloc(size, sizeof(LADSPA_Data));
173 	if (buffer)
174 	  buffer_mask = size - 1;
175 	else
176 	  buffer_mask = 0;
177 	write_phase = 0;
178 	plugin_data->buffer = buffer;
179 	plugin_data->buffer_mask = buffer_mask;
180 	plugin_data->delay_samples = delay_samples;
181 	plugin_data->feedback = feedback;
182 	plugin_data->last_decay_time = last_decay_time;
183 	plugin_data->last_delay_time = last_delay_time;
184 	plugin_data->sample_rate = sample_rate;
185 	plugin_data->write_phase = write_phase;
186 
187 }
188 
cleanupAllpass_n(LADSPA_Handle instance)189 static void cleanupAllpass_n(LADSPA_Handle instance) {
190 #line 78 "allpass_1895.xml"
191 	Allpass_n *plugin_data = (Allpass_n *)instance;
192 	free(plugin_data->buffer);
193 	free(instance);
194 }
195 
connectPortAllpass_n(LADSPA_Handle instance,unsigned long port,LADSPA_Data * data)196 static void connectPortAllpass_n(
197  LADSPA_Handle instance,
198  unsigned long port,
199  LADSPA_Data *data) {
200 	Allpass_n *plugin;
201 
202 	plugin = (Allpass_n *)instance;
203 	switch (port) {
204 	case ALLPASS_N_IN:
205 		plugin->in = data;
206 		break;
207 	case ALLPASS_N_OUT:
208 		plugin->out = data;
209 		break;
210 	case ALLPASS_N_MAX_DELAY:
211 		plugin->max_delay = data;
212 		break;
213 	case ALLPASS_N_DELAY_TIME:
214 		plugin->delay_time = data;
215 		break;
216 	case ALLPASS_N_DECAY_TIME:
217 		plugin->decay_time = data;
218 		break;
219 	}
220 }
221 
instantiateAllpass_n(const LADSPA_Descriptor * descriptor,unsigned long s_rate)222 static LADSPA_Handle instantiateAllpass_n(
223  const LADSPA_Descriptor *descriptor,
224  unsigned long s_rate) {
225 	Allpass_n *plugin_data = (Allpass_n *)calloc(1, sizeof(Allpass_n));
226 	LADSPA_Data *buffer = NULL;
227 	unsigned int buffer_mask;
228 	LADSPA_Data delay_samples;
229 	LADSPA_Data feedback;
230 	LADSPA_Data last_decay_time;
231 	LADSPA_Data last_delay_time;
232 	unsigned int sample_rate;
233 	long write_phase;
234 
235 #line 44 "allpass_1895.xml"
236 	sample_rate = s_rate;
237 
238 	// Uninitialized variables
239 	buffer_mask = 0;
240 	delay_samples = 0;
241 	feedback = 0;
242 	last_decay_time = 0;
243 	last_delay_time = 0;
244 	write_phase = 0;
245 
246 	plugin_data->buffer = buffer;
247 	plugin_data->buffer_mask = buffer_mask;
248 	plugin_data->delay_samples = delay_samples;
249 	plugin_data->feedback = feedback;
250 	plugin_data->last_decay_time = last_decay_time;
251 	plugin_data->last_delay_time = last_delay_time;
252 	plugin_data->sample_rate = sample_rate;
253 	plugin_data->write_phase = write_phase;
254 
255 	return (LADSPA_Handle)plugin_data;
256 }
257 
258 #undef buffer_write
259 #undef RUN_ADDING
260 #undef RUN_REPLACING
261 
262 #define buffer_write(b, v) (b = v)
263 #define RUN_ADDING    0
264 #define RUN_REPLACING 1
265 
runAllpass_n(LADSPA_Handle instance,unsigned long sample_count)266 static void runAllpass_n(LADSPA_Handle instance, unsigned long sample_count) {
267 	Allpass_n *plugin_data = (Allpass_n *)instance;
268 
269 	/* Input (array of floats of length sample_count) */
270 	const LADSPA_Data * const in = plugin_data->in;
271 
272 	/* Output (array of floats of length sample_count) */
273 	LADSPA_Data * const out = plugin_data->out;
274 
275 	/* Max Delay (s) (float value) */
276 	const LADSPA_Data max_delay = *(plugin_data->max_delay);
277 
278 	/* Delay Time (s) (float value) */
279 	const LADSPA_Data delay_time = *(plugin_data->delay_time);
280 
281 	/* Decay Time (s) (float value) */
282 	const LADSPA_Data decay_time = *(plugin_data->decay_time);
283 	LADSPA_Data * buffer = plugin_data->buffer;
284 	unsigned int buffer_mask = plugin_data->buffer_mask;
285 	LADSPA_Data delay_samples = plugin_data->delay_samples;
286 	LADSPA_Data feedback = plugin_data->feedback;
287 	LADSPA_Data last_decay_time = plugin_data->last_decay_time;
288 	LADSPA_Data last_delay_time = plugin_data->last_delay_time;
289 	unsigned int sample_rate = plugin_data->sample_rate;
290 	long write_phase = plugin_data->write_phase;
291 
292 #line 82 "allpass_1895.xml"
293 	int i;
294 
295 	ignore(max_delay);
296 
297 	if (write_phase == 0) {
298 	  plugin_data->last_delay_time = delay_time;
299 	  plugin_data->last_decay_time = decay_time;
300 	  plugin_data->delay_samples = delay_samples = CALC_DELAY (delay_time);
301 	  plugin_data->feedback = feedback = calc_feedback (delay_time, decay_time);
302 	}
303 
304 	if (delay_time == last_delay_time) {
305 	  long read_phase = write_phase - (long)delay_samples;
306 	  LADSPA_Data *readptr = buffer + (read_phase & buffer_mask);
307 	  LADSPA_Data *writeptr = buffer + (write_phase & buffer_mask);
308 	  LADSPA_Data *lastptr = buffer + buffer_mask + 1;
309 
310 	  if (decay_time == last_decay_time) {
311 	    long remain = sample_count;
312 
313 	    while (remain) {
314 	      long read_space = lastptr - readptr;
315 	      long write_space = lastptr - writeptr;
316 	      long to_process = MIN (MIN (read_space, remain), write_space);
317 
318 	      if (to_process == 0)
319 	        return; // buffer not allocated.
320 
321 	      remain -= to_process;
322 
323 	      for (i=0; i<to_process; i++) {
324 	        LADSPA_Data read = *(readptr++);
325 	        LADSPA_Data written = read * feedback + in[i];
326 	        *(writeptr++) = written;
327 	        buffer_write(out[i], read - feedback * written);
328 	      }
329 
330 	      if (readptr == lastptr) readptr = buffer;
331 	      if (writeptr == lastptr) writeptr = buffer;
332 	    }
333 	  } else {
334 	    float next_feedback = calc_feedback (delay_time, decay_time);
335 	    float feedback_slope = (next_feedback - feedback) / sample_count;
336 	    long remain = sample_count;
337 
338 	    while (remain) {
339 	      long read_space = lastptr - readptr;
340 	      long write_space = lastptr - writeptr;
341 	      long to_process = MIN (MIN (read_space, remain), write_space);
342 
343 	      if (to_process == 0)
344 	        return; // buffer not allocated.
345 
346 	      remain -= to_process;
347 
348 	      for (i=0; i<to_process; i++) {
349 	        LADSPA_Data read = *(readptr++);
350 	        LADSPA_Data written = read * feedback + in[i];
351 	        *(writeptr++) = written;
352 	        buffer_write(out[i], read - feedback * written);
353 	        feedback += feedback_slope;
354 	      }
355 
356 	      if (readptr == lastptr) readptr = buffer;
357 	      if (writeptr == lastptr) writeptr = buffer;
358 	    }
359 
360 	    plugin_data->last_decay_time = decay_time;
361 	    plugin_data->feedback = feedback;
362 	  }
363 
364 	  write_phase += sample_count;
365 	} else {
366 	  float next_delay_samples = CALC_DELAY (delay_time);
367 	  float delay_samples_slope = (next_delay_samples - delay_samples) / sample_count;
368 	  float next_feedback = calc_feedback (delay_time, decay_time);
369 	  float feedback_slope = (next_feedback - feedback) / sample_count;
370 
371 	  for (i=0; i<sample_count; i++) {
372 	    long read_phase;
373 	    LADSPA_Data read, written;
374 
375 	    delay_samples += delay_samples_slope;
376 	    write_phase++;
377 	    read_phase = write_phase - (long)delay_samples;
378 	    read = buffer[read_phase & buffer_mask];
379 
380 	    written = read * feedback + in[i];
381 	    buffer[write_phase & buffer_mask] = written;
382 	    buffer_write(out[i], read - feedback * written);
383 
384 	    feedback += feedback_slope;
385 	  }
386 
387 	  plugin_data->last_delay_time = delay_time;
388 	  plugin_data->last_decay_time = decay_time;
389 	  plugin_data->feedback = feedback;
390 	  plugin_data->delay_samples = delay_samples;
391 	}
392 
393 	plugin_data->write_phase = write_phase;
394 }
395 #undef buffer_write
396 #undef RUN_ADDING
397 #undef RUN_REPLACING
398 
399 #define buffer_write(b, v) (b += (v) * run_adding_gain)
400 #define RUN_ADDING    1
401 #define RUN_REPLACING 0
402 
setRunAddingGainAllpass_n(LADSPA_Handle instance,LADSPA_Data gain)403 static void setRunAddingGainAllpass_n(LADSPA_Handle instance, LADSPA_Data gain) {
404 	((Allpass_n *)instance)->run_adding_gain = gain;
405 }
406 
runAddingAllpass_n(LADSPA_Handle instance,unsigned long sample_count)407 static void runAddingAllpass_n(LADSPA_Handle instance, unsigned long sample_count) {
408 	Allpass_n *plugin_data = (Allpass_n *)instance;
409 	LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;
410 
411 	/* Input (array of floats of length sample_count) */
412 	const LADSPA_Data * const in = plugin_data->in;
413 
414 	/* Output (array of floats of length sample_count) */
415 	LADSPA_Data * const out = plugin_data->out;
416 
417 	/* Max Delay (s) (float value) */
418 	const LADSPA_Data max_delay = *(plugin_data->max_delay);
419 
420 	/* Delay Time (s) (float value) */
421 	const LADSPA_Data delay_time = *(plugin_data->delay_time);
422 
423 	/* Decay Time (s) (float value) */
424 	const LADSPA_Data decay_time = *(plugin_data->decay_time);
425 	LADSPA_Data * buffer = plugin_data->buffer;
426 	unsigned int buffer_mask = plugin_data->buffer_mask;
427 	LADSPA_Data delay_samples = plugin_data->delay_samples;
428 	LADSPA_Data feedback = plugin_data->feedback;
429 	LADSPA_Data last_decay_time = plugin_data->last_decay_time;
430 	LADSPA_Data last_delay_time = plugin_data->last_delay_time;
431 	unsigned int sample_rate = plugin_data->sample_rate;
432 	long write_phase = plugin_data->write_phase;
433 
434 #line 82 "allpass_1895.xml"
435 	int i;
436 
437 	ignore(max_delay);
438 
439 	if (write_phase == 0) {
440 	  plugin_data->last_delay_time = delay_time;
441 	  plugin_data->last_decay_time = decay_time;
442 	  plugin_data->delay_samples = delay_samples = CALC_DELAY (delay_time);
443 	  plugin_data->feedback = feedback = calc_feedback (delay_time, decay_time);
444 	}
445 
446 	if (delay_time == last_delay_time) {
447 	  long read_phase = write_phase - (long)delay_samples;
448 	  LADSPA_Data *readptr = buffer + (read_phase & buffer_mask);
449 	  LADSPA_Data *writeptr = buffer + (write_phase & buffer_mask);
450 	  LADSPA_Data *lastptr = buffer + buffer_mask + 1;
451 
452 	  if (decay_time == last_decay_time) {
453 	    long remain = sample_count;
454 
455 	    while (remain) {
456 	      long read_space = lastptr - readptr;
457 	      long write_space = lastptr - writeptr;
458 	      long to_process = MIN (MIN (read_space, remain), write_space);
459 
460 	      if (to_process == 0)
461 	        return; // buffer not allocated.
462 
463 	      remain -= to_process;
464 
465 	      for (i=0; i<to_process; i++) {
466 	        LADSPA_Data read = *(readptr++);
467 	        LADSPA_Data written = read * feedback + in[i];
468 	        *(writeptr++) = written;
469 	        buffer_write(out[i], read - feedback * written);
470 	      }
471 
472 	      if (readptr == lastptr) readptr = buffer;
473 	      if (writeptr == lastptr) writeptr = buffer;
474 	    }
475 	  } else {
476 	    float next_feedback = calc_feedback (delay_time, decay_time);
477 	    float feedback_slope = (next_feedback - feedback) / sample_count;
478 	    long remain = sample_count;
479 
480 	    while (remain) {
481 	      long read_space = lastptr - readptr;
482 	      long write_space = lastptr - writeptr;
483 	      long to_process = MIN (MIN (read_space, remain), write_space);
484 
485 	      if (to_process == 0)
486 	        return; // buffer not allocated.
487 
488 	      remain -= to_process;
489 
490 	      for (i=0; i<to_process; i++) {
491 	        LADSPA_Data read = *(readptr++);
492 	        LADSPA_Data written = read * feedback + in[i];
493 	        *(writeptr++) = written;
494 	        buffer_write(out[i], read - feedback * written);
495 	        feedback += feedback_slope;
496 	      }
497 
498 	      if (readptr == lastptr) readptr = buffer;
499 	      if (writeptr == lastptr) writeptr = buffer;
500 	    }
501 
502 	    plugin_data->last_decay_time = decay_time;
503 	    plugin_data->feedback = feedback;
504 	  }
505 
506 	  write_phase += sample_count;
507 	} else {
508 	  float next_delay_samples = CALC_DELAY (delay_time);
509 	  float delay_samples_slope = (next_delay_samples - delay_samples) / sample_count;
510 	  float next_feedback = calc_feedback (delay_time, decay_time);
511 	  float feedback_slope = (next_feedback - feedback) / sample_count;
512 
513 	  for (i=0; i<sample_count; i++) {
514 	    long read_phase;
515 	    LADSPA_Data read, written;
516 
517 	    delay_samples += delay_samples_slope;
518 	    write_phase++;
519 	    read_phase = write_phase - (long)delay_samples;
520 	    read = buffer[read_phase & buffer_mask];
521 
522 	    written = read * feedback + in[i];
523 	    buffer[write_phase & buffer_mask] = written;
524 	    buffer_write(out[i], read - feedback * written);
525 
526 	    feedback += feedback_slope;
527 	  }
528 
529 	  plugin_data->last_delay_time = delay_time;
530 	  plugin_data->last_decay_time = decay_time;
531 	  plugin_data->feedback = feedback;
532 	  plugin_data->delay_samples = delay_samples;
533 	}
534 
535 	plugin_data->write_phase = write_phase;
536 }
537 
activateAllpass_l(LADSPA_Handle instance)538 static void activateAllpass_l(LADSPA_Handle instance) {
539 	Allpass_l *plugin_data = (Allpass_l *)instance;
540 	LADSPA_Data *buffer = plugin_data->buffer;
541 	unsigned int buffer_mask = plugin_data->buffer_mask;
542 	LADSPA_Data delay_samples = plugin_data->delay_samples;
543 	LADSPA_Data feedback = plugin_data->feedback;
544 	LADSPA_Data last_decay_time = plugin_data->last_decay_time;
545 	LADSPA_Data last_delay_time = plugin_data->last_delay_time;
546 	unsigned int sample_rate = plugin_data->sample_rate;
547 	long write_phase = plugin_data->write_phase;
548 #line 56 "allpass_1895.xml"
549 	unsigned int minsize, size;
550 
551 	if (plugin_data->max_delay && *plugin_data->max_delay > 0)
552 	  minsize = sample_rate * *plugin_data->max_delay;
553 	else if (plugin_data->delay_time)
554 	  minsize = sample_rate * *plugin_data->delay_time;
555 	else
556 	  minsize = sample_rate; /* 1 second default */
557 
558 	size = 1;
559 	while (size < minsize) size <<= 1;
560 
561 	/* calloc sets the buffer to zero. */
562 	buffer = calloc(size, sizeof(LADSPA_Data));
563 	if (buffer)
564 	  buffer_mask = size - 1;
565 	else
566 	  buffer_mask = 0;
567 	write_phase = 0;
568 	plugin_data->buffer = buffer;
569 	plugin_data->buffer_mask = buffer_mask;
570 	plugin_data->delay_samples = delay_samples;
571 	plugin_data->feedback = feedback;
572 	plugin_data->last_decay_time = last_decay_time;
573 	plugin_data->last_delay_time = last_delay_time;
574 	plugin_data->sample_rate = sample_rate;
575 	plugin_data->write_phase = write_phase;
576 
577 }
578 
cleanupAllpass_l(LADSPA_Handle instance)579 static void cleanupAllpass_l(LADSPA_Handle instance) {
580 #line 78 "allpass_1895.xml"
581 	Allpass_l *plugin_data = (Allpass_l *)instance;
582 	free(plugin_data->buffer);
583 	free(instance);
584 }
585 
connectPortAllpass_l(LADSPA_Handle instance,unsigned long port,LADSPA_Data * data)586 static void connectPortAllpass_l(
587  LADSPA_Handle instance,
588  unsigned long port,
589  LADSPA_Data *data) {
590 	Allpass_l *plugin;
591 
592 	plugin = (Allpass_l *)instance;
593 	switch (port) {
594 	case ALLPASS_L_IN:
595 		plugin->in = data;
596 		break;
597 	case ALLPASS_L_OUT:
598 		plugin->out = data;
599 		break;
600 	case ALLPASS_L_MAX_DELAY:
601 		plugin->max_delay = data;
602 		break;
603 	case ALLPASS_L_DELAY_TIME:
604 		plugin->delay_time = data;
605 		break;
606 	case ALLPASS_L_DECAY_TIME:
607 		plugin->decay_time = data;
608 		break;
609 	}
610 }
611 
instantiateAllpass_l(const LADSPA_Descriptor * descriptor,unsigned long s_rate)612 static LADSPA_Handle instantiateAllpass_l(
613  const LADSPA_Descriptor *descriptor,
614  unsigned long s_rate) {
615 	Allpass_l *plugin_data = (Allpass_l *)calloc(1, sizeof(Allpass_l));
616 	LADSPA_Data *buffer = NULL;
617 	unsigned int buffer_mask;
618 	LADSPA_Data delay_samples;
619 	LADSPA_Data feedback;
620 	LADSPA_Data last_decay_time;
621 	LADSPA_Data last_delay_time;
622 	unsigned int sample_rate;
623 	long write_phase;
624 
625 #line 44 "allpass_1895.xml"
626 	sample_rate = s_rate;
627 
628 	// Uninitialized variables
629 	buffer_mask = 0;
630 	delay_samples = 0;
631 	feedback = 0;
632 	last_decay_time = 0;
633 	last_delay_time = 0;
634 	write_phase = 0;
635 
636 	plugin_data->buffer = buffer;
637 	plugin_data->buffer_mask = buffer_mask;
638 	plugin_data->delay_samples = delay_samples;
639 	plugin_data->feedback = feedback;
640 	plugin_data->last_decay_time = last_decay_time;
641 	plugin_data->last_delay_time = last_delay_time;
642 	plugin_data->sample_rate = sample_rate;
643 	plugin_data->write_phase = write_phase;
644 
645 	return (LADSPA_Handle)plugin_data;
646 }
647 
648 #undef buffer_write
649 #undef RUN_ADDING
650 #undef RUN_REPLACING
651 
652 #define buffer_write(b, v) (b = v)
653 #define RUN_ADDING    0
654 #define RUN_REPLACING 1
655 
runAllpass_l(LADSPA_Handle instance,unsigned long sample_count)656 static void runAllpass_l(LADSPA_Handle instance, unsigned long sample_count) {
657 	Allpass_l *plugin_data = (Allpass_l *)instance;
658 
659 	/* Input (array of floats of length sample_count) */
660 	const LADSPA_Data * const in = plugin_data->in;
661 
662 	/* Output (array of floats of length sample_count) */
663 	LADSPA_Data * const out = plugin_data->out;
664 
665 	/* Max Delay (s) (float value) */
666 	const LADSPA_Data max_delay = *(plugin_data->max_delay);
667 
668 	/* Delay Time (s) (float value) */
669 	const LADSPA_Data delay_time = *(plugin_data->delay_time);
670 
671 	/* Decay Time (s) (float value) */
672 	const LADSPA_Data decay_time = *(plugin_data->decay_time);
673 	LADSPA_Data * buffer = plugin_data->buffer;
674 	unsigned int buffer_mask = plugin_data->buffer_mask;
675 	LADSPA_Data delay_samples = plugin_data->delay_samples;
676 	LADSPA_Data feedback = plugin_data->feedback;
677 	LADSPA_Data last_decay_time = plugin_data->last_decay_time;
678 	LADSPA_Data last_delay_time = plugin_data->last_delay_time;
679 	unsigned int sample_rate = plugin_data->sample_rate;
680 	long write_phase = plugin_data->write_phase;
681 
682 #line 82 "allpass_1895.xml"
683 	int i;
684 
685 	ignore(max_delay);
686 
687 	if (write_phase == 0) {
688 	  plugin_data->last_delay_time = delay_time;
689 	  plugin_data->last_decay_time = decay_time;
690 	  plugin_data->delay_samples = delay_samples = CALC_DELAY (delay_time);
691 	  plugin_data->feedback = feedback = calc_feedback (delay_time, decay_time);
692 	}
693 
694 	if (delay_time == last_delay_time && decay_time == last_decay_time) {
695 	  long idelay_samples = (long)delay_samples;
696 	  LADSPA_Data frac = delay_samples - idelay_samples;
697 
698 	  for (i=0; i<sample_count; i++) {
699 	    long read_phase = write_phase - (long)delay_samples;
700 	    LADSPA_Data r1 = buffer[read_phase & buffer_mask];
701 	    LADSPA_Data r2 = buffer[(read_phase-1) & buffer_mask];
702 	    LADSPA_Data read = LIN_INTERP (frac, r1, r2);
703 	    LADSPA_Data written = read * feedback + in[i];
704 
705 	    buffer[write_phase++ & buffer_mask] = written;
706 	    buffer_write(out[i], read - feedback * written);
707 	    write_phase++;
708 	  }
709 	} else {
710 	  float next_delay_samples = CALC_DELAY (delay_time);
711 	  float delay_samples_slope = (next_delay_samples - delay_samples) / sample_count;
712 	  float next_feedback = calc_feedback (delay_time, decay_time);
713 	  float feedback_slope = (next_feedback - feedback) / sample_count;
714 
715 	  for (i=0; i<sample_count; i++) {
716 	    long read_phase, idelay_samples;
717 	    LADSPA_Data read, written, frac;
718 
719 	    delay_samples += delay_samples_slope;
720 	    write_phase++;
721 	    read_phase = write_phase - (long)delay_samples;
722 	    idelay_samples = (long)delay_samples;
723 	    frac = delay_samples - idelay_samples;
724 	    read = LIN_INTERP (frac,
725 	                       buffer[read_phase & buffer_mask],
726 	                       buffer[(read_phase-1) & buffer_mask]);
727 	    written = read * feedback + in[i];
728 	    buffer[write_phase & buffer_mask] = written;
729 	    buffer_write(out[i], read - feedback * written);
730 
731 	    feedback += feedback_slope;
732 	  }
733 
734 	  plugin_data->last_delay_time = delay_time;
735 	  plugin_data->last_decay_time = decay_time;
736 	  plugin_data->feedback = feedback;
737 	  plugin_data->delay_samples = delay_samples;
738 	}
739 
740 	plugin_data->write_phase = write_phase;
741 }
742 #undef buffer_write
743 #undef RUN_ADDING
744 #undef RUN_REPLACING
745 
746 #define buffer_write(b, v) (b += (v) * run_adding_gain)
747 #define RUN_ADDING    1
748 #define RUN_REPLACING 0
749 
setRunAddingGainAllpass_l(LADSPA_Handle instance,LADSPA_Data gain)750 static void setRunAddingGainAllpass_l(LADSPA_Handle instance, LADSPA_Data gain) {
751 	((Allpass_l *)instance)->run_adding_gain = gain;
752 }
753 
runAddingAllpass_l(LADSPA_Handle instance,unsigned long sample_count)754 static void runAddingAllpass_l(LADSPA_Handle instance, unsigned long sample_count) {
755 	Allpass_l *plugin_data = (Allpass_l *)instance;
756 	LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;
757 
758 	/* Input (array of floats of length sample_count) */
759 	const LADSPA_Data * const in = plugin_data->in;
760 
761 	/* Output (array of floats of length sample_count) */
762 	LADSPA_Data * const out = plugin_data->out;
763 
764 	/* Max Delay (s) (float value) */
765 	const LADSPA_Data max_delay = *(plugin_data->max_delay);
766 
767 	/* Delay Time (s) (float value) */
768 	const LADSPA_Data delay_time = *(plugin_data->delay_time);
769 
770 	/* Decay Time (s) (float value) */
771 	const LADSPA_Data decay_time = *(plugin_data->decay_time);
772 	LADSPA_Data * buffer = plugin_data->buffer;
773 	unsigned int buffer_mask = plugin_data->buffer_mask;
774 	LADSPA_Data delay_samples = plugin_data->delay_samples;
775 	LADSPA_Data feedback = plugin_data->feedback;
776 	LADSPA_Data last_decay_time = plugin_data->last_decay_time;
777 	LADSPA_Data last_delay_time = plugin_data->last_delay_time;
778 	unsigned int sample_rate = plugin_data->sample_rate;
779 	long write_phase = plugin_data->write_phase;
780 
781 #line 82 "allpass_1895.xml"
782 	int i;
783 
784 	ignore(max_delay);
785 
786 	if (write_phase == 0) {
787 	  plugin_data->last_delay_time = delay_time;
788 	  plugin_data->last_decay_time = decay_time;
789 	  plugin_data->delay_samples = delay_samples = CALC_DELAY (delay_time);
790 	  plugin_data->feedback = feedback = calc_feedback (delay_time, decay_time);
791 	}
792 
793 	if (delay_time == last_delay_time && decay_time == last_decay_time) {
794 	  long idelay_samples = (long)delay_samples;
795 	  LADSPA_Data frac = delay_samples - idelay_samples;
796 
797 	  for (i=0; i<sample_count; i++) {
798 	    long read_phase = write_phase - (long)delay_samples;
799 	    LADSPA_Data r1 = buffer[read_phase & buffer_mask];
800 	    LADSPA_Data r2 = buffer[(read_phase-1) & buffer_mask];
801 	    LADSPA_Data read = LIN_INTERP (frac, r1, r2);
802 	    LADSPA_Data written = read * feedback + in[i];
803 
804 	    buffer[write_phase++ & buffer_mask] = written;
805 	    buffer_write(out[i], read - feedback * written);
806 	    write_phase++;
807 	  }
808 	} else {
809 	  float next_delay_samples = CALC_DELAY (delay_time);
810 	  float delay_samples_slope = (next_delay_samples - delay_samples) / sample_count;
811 	  float next_feedback = calc_feedback (delay_time, decay_time);
812 	  float feedback_slope = (next_feedback - feedback) / sample_count;
813 
814 	  for (i=0; i<sample_count; i++) {
815 	    long read_phase, idelay_samples;
816 	    LADSPA_Data read, written, frac;
817 
818 	    delay_samples += delay_samples_slope;
819 	    write_phase++;
820 	    read_phase = write_phase - (long)delay_samples;
821 	    idelay_samples = (long)delay_samples;
822 	    frac = delay_samples - idelay_samples;
823 	    read = LIN_INTERP (frac,
824 	                       buffer[read_phase & buffer_mask],
825 	                       buffer[(read_phase-1) & buffer_mask]);
826 	    written = read * feedback + in[i];
827 	    buffer[write_phase & buffer_mask] = written;
828 	    buffer_write(out[i], read - feedback * written);
829 
830 	    feedback += feedback_slope;
831 	  }
832 
833 	  plugin_data->last_delay_time = delay_time;
834 	  plugin_data->last_decay_time = decay_time;
835 	  plugin_data->feedback = feedback;
836 	  plugin_data->delay_samples = delay_samples;
837 	}
838 
839 	plugin_data->write_phase = write_phase;
840 }
841 
activateAllpass_c(LADSPA_Handle instance)842 static void activateAllpass_c(LADSPA_Handle instance) {
843 	Allpass_c *plugin_data = (Allpass_c *)instance;
844 	LADSPA_Data *buffer = plugin_data->buffer;
845 	unsigned int buffer_mask = plugin_data->buffer_mask;
846 	LADSPA_Data delay_samples = plugin_data->delay_samples;
847 	LADSPA_Data feedback = plugin_data->feedback;
848 	LADSPA_Data last_decay_time = plugin_data->last_decay_time;
849 	LADSPA_Data last_delay_time = plugin_data->last_delay_time;
850 	unsigned int sample_rate = plugin_data->sample_rate;
851 	long write_phase = plugin_data->write_phase;
852 #line 56 "allpass_1895.xml"
853 	unsigned int minsize, size;
854 
855 	if (plugin_data->max_delay && *plugin_data->max_delay > 0)
856 	  minsize = sample_rate * *plugin_data->max_delay;
857 	else if (plugin_data->delay_time)
858 	  minsize = sample_rate * *plugin_data->delay_time;
859 	else
860 	  minsize = sample_rate; /* 1 second default */
861 
862 	size = 1;
863 	while (size < minsize) size <<= 1;
864 
865 	/* calloc sets the buffer to zero. */
866 	buffer = calloc(size, sizeof(LADSPA_Data));
867 	if (buffer)
868 	  buffer_mask = size - 1;
869 	else
870 	  buffer_mask = 0;
871 	write_phase = 0;
872 	plugin_data->buffer = buffer;
873 	plugin_data->buffer_mask = buffer_mask;
874 	plugin_data->delay_samples = delay_samples;
875 	plugin_data->feedback = feedback;
876 	plugin_data->last_decay_time = last_decay_time;
877 	plugin_data->last_delay_time = last_delay_time;
878 	plugin_data->sample_rate = sample_rate;
879 	plugin_data->write_phase = write_phase;
880 
881 }
882 
cleanupAllpass_c(LADSPA_Handle instance)883 static void cleanupAllpass_c(LADSPA_Handle instance) {
884 #line 78 "allpass_1895.xml"
885 	Allpass_c *plugin_data = (Allpass_c *)instance;
886 	free(plugin_data->buffer);
887 	free(instance);
888 }
889 
connectPortAllpass_c(LADSPA_Handle instance,unsigned long port,LADSPA_Data * data)890 static void connectPortAllpass_c(
891  LADSPA_Handle instance,
892  unsigned long port,
893  LADSPA_Data *data) {
894 	Allpass_c *plugin;
895 
896 	plugin = (Allpass_c *)instance;
897 	switch (port) {
898 	case ALLPASS_C_IN:
899 		plugin->in = data;
900 		break;
901 	case ALLPASS_C_OUT:
902 		plugin->out = data;
903 		break;
904 	case ALLPASS_C_MAX_DELAY:
905 		plugin->max_delay = data;
906 		break;
907 	case ALLPASS_C_DELAY_TIME:
908 		plugin->delay_time = data;
909 		break;
910 	case ALLPASS_C_DECAY_TIME:
911 		plugin->decay_time = data;
912 		break;
913 	}
914 }
915 
instantiateAllpass_c(const LADSPA_Descriptor * descriptor,unsigned long s_rate)916 static LADSPA_Handle instantiateAllpass_c(
917  const LADSPA_Descriptor *descriptor,
918  unsigned long s_rate) {
919 	Allpass_c *plugin_data = (Allpass_c *)calloc(1, sizeof(Allpass_c));
920 	LADSPA_Data *buffer = NULL;
921 	unsigned int buffer_mask;
922 	LADSPA_Data delay_samples;
923 	LADSPA_Data feedback;
924 	LADSPA_Data last_decay_time;
925 	LADSPA_Data last_delay_time;
926 	unsigned int sample_rate;
927 	long write_phase;
928 
929 #line 44 "allpass_1895.xml"
930 	sample_rate = s_rate;
931 
932 	// Uninitialized variables
933 	buffer_mask = 0;
934 	delay_samples = 0;
935 	feedback = 0;
936 	last_decay_time = 0;
937 	last_delay_time = 0;
938 	write_phase = 0;
939 
940 	plugin_data->buffer = buffer;
941 	plugin_data->buffer_mask = buffer_mask;
942 	plugin_data->delay_samples = delay_samples;
943 	plugin_data->feedback = feedback;
944 	plugin_data->last_decay_time = last_decay_time;
945 	plugin_data->last_delay_time = last_delay_time;
946 	plugin_data->sample_rate = sample_rate;
947 	plugin_data->write_phase = write_phase;
948 
949 	return (LADSPA_Handle)plugin_data;
950 }
951 
952 #undef buffer_write
953 #undef RUN_ADDING
954 #undef RUN_REPLACING
955 
956 #define buffer_write(b, v) (b = v)
957 #define RUN_ADDING    0
958 #define RUN_REPLACING 1
959 
runAllpass_c(LADSPA_Handle instance,unsigned long sample_count)960 static void runAllpass_c(LADSPA_Handle instance, unsigned long sample_count) {
961 	Allpass_c *plugin_data = (Allpass_c *)instance;
962 
963 	/* Input (array of floats of length sample_count) */
964 	const LADSPA_Data * const in = plugin_data->in;
965 
966 	/* Output (array of floats of length sample_count) */
967 	LADSPA_Data * const out = plugin_data->out;
968 
969 	/* Max Delay (s) (float value) */
970 	const LADSPA_Data max_delay = *(plugin_data->max_delay);
971 
972 	/* Delay Time (s) (float value) */
973 	const LADSPA_Data delay_time = *(plugin_data->delay_time);
974 
975 	/* Decay Time (s) (float value) */
976 	const LADSPA_Data decay_time = *(plugin_data->decay_time);
977 	LADSPA_Data * buffer = plugin_data->buffer;
978 	unsigned int buffer_mask = plugin_data->buffer_mask;
979 	LADSPA_Data delay_samples = plugin_data->delay_samples;
980 	LADSPA_Data feedback = plugin_data->feedback;
981 	LADSPA_Data last_decay_time = plugin_data->last_decay_time;
982 	LADSPA_Data last_delay_time = plugin_data->last_delay_time;
983 	unsigned int sample_rate = plugin_data->sample_rate;
984 	long write_phase = plugin_data->write_phase;
985 
986 #line 82 "allpass_1895.xml"
987 	int i;
988 
989 	ignore(max_delay);
990 
991 	if (write_phase == 0) {
992 	  plugin_data->last_delay_time = delay_time;
993 	  plugin_data->last_decay_time = decay_time;
994 	  plugin_data->delay_samples = delay_samples = CALC_DELAY (delay_time);
995 	  plugin_data->feedback = feedback = calc_feedback (delay_time, decay_time);
996 	}
997 
998 	if (delay_time == last_delay_time && decay_time == last_decay_time) {
999 	  long idelay_samples = (long)delay_samples;
1000 	  LADSPA_Data frac = delay_samples - idelay_samples;
1001 
1002 	  for (i=0; i<sample_count; i++) {
1003 	    long read_phase = write_phase - (long)delay_samples;
1004 	    LADSPA_Data read = cube_interp (frac,
1005 	                                    buffer[(read_phase-1) & buffer_mask],
1006 	                                    buffer[read_phase & buffer_mask],
1007 	                                    buffer[(read_phase+1) & buffer_mask],
1008 	                                    buffer[(read_phase+2) & buffer_mask]);
1009 	    LADSPA_Data written = read * feedback + in[i];
1010 
1011 	    buffer[write_phase++ & buffer_mask] = written;
1012 	    buffer_write(out[i], read - feedback * written);
1013 	  }
1014 	} else {
1015 	  float next_delay_samples = CALC_DELAY (delay_time);
1016 	  float delay_samples_slope = (next_delay_samples - delay_samples) / sample_count;
1017 	  float next_feedback = calc_feedback (delay_time, decay_time);
1018 	  float feedback_slope = (next_feedback - feedback) / sample_count;
1019 
1020 	  for (i=0; i<sample_count; i++) {
1021 	    long read_phase, idelay_samples;
1022 	    LADSPA_Data read, written, frac;
1023 
1024 	    delay_samples += delay_samples_slope;
1025 	    write_phase++;
1026 	    read_phase = write_phase - (long)delay_samples;
1027 	    idelay_samples = (long)delay_samples;
1028 	    frac = delay_samples - idelay_samples;
1029 	    read = cube_interp (frac,
1030 	                        buffer[(read_phase-1) & buffer_mask],
1031 	                        buffer[read_phase & buffer_mask],
1032 	                        buffer[(read_phase+1) & buffer_mask],
1033 	                        buffer[(read_phase+2) & buffer_mask]);
1034 	    written = read * feedback + in[i];
1035 	    buffer[write_phase & buffer_mask] = written;
1036 	    buffer_write(out[i], read - feedback * written);
1037 
1038 	    feedback += feedback_slope;
1039 	  }
1040 
1041 	  plugin_data->last_delay_time = delay_time;
1042 	  plugin_data->last_decay_time = decay_time;
1043 	  plugin_data->feedback = feedback;
1044 	  plugin_data->delay_samples = delay_samples;
1045 	}
1046 
1047 	plugin_data->write_phase = write_phase;
1048 }
1049 #undef buffer_write
1050 #undef RUN_ADDING
1051 #undef RUN_REPLACING
1052 
1053 #define buffer_write(b, v) (b += (v) * run_adding_gain)
1054 #define RUN_ADDING    1
1055 #define RUN_REPLACING 0
1056 
setRunAddingGainAllpass_c(LADSPA_Handle instance,LADSPA_Data gain)1057 static void setRunAddingGainAllpass_c(LADSPA_Handle instance, LADSPA_Data gain) {
1058 	((Allpass_c *)instance)->run_adding_gain = gain;
1059 }
1060 
runAddingAllpass_c(LADSPA_Handle instance,unsigned long sample_count)1061 static void runAddingAllpass_c(LADSPA_Handle instance, unsigned long sample_count) {
1062 	Allpass_c *plugin_data = (Allpass_c *)instance;
1063 	LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;
1064 
1065 	/* Input (array of floats of length sample_count) */
1066 	const LADSPA_Data * const in = plugin_data->in;
1067 
1068 	/* Output (array of floats of length sample_count) */
1069 	LADSPA_Data * const out = plugin_data->out;
1070 
1071 	/* Max Delay (s) (float value) */
1072 	const LADSPA_Data max_delay = *(plugin_data->max_delay);
1073 
1074 	/* Delay Time (s) (float value) */
1075 	const LADSPA_Data delay_time = *(plugin_data->delay_time);
1076 
1077 	/* Decay Time (s) (float value) */
1078 	const LADSPA_Data decay_time = *(plugin_data->decay_time);
1079 	LADSPA_Data * buffer = plugin_data->buffer;
1080 	unsigned int buffer_mask = plugin_data->buffer_mask;
1081 	LADSPA_Data delay_samples = plugin_data->delay_samples;
1082 	LADSPA_Data feedback = plugin_data->feedback;
1083 	LADSPA_Data last_decay_time = plugin_data->last_decay_time;
1084 	LADSPA_Data last_delay_time = plugin_data->last_delay_time;
1085 	unsigned int sample_rate = plugin_data->sample_rate;
1086 	long write_phase = plugin_data->write_phase;
1087 
1088 #line 82 "allpass_1895.xml"
1089 	int i;
1090 
1091 	ignore(max_delay);
1092 
1093 	if (write_phase == 0) {
1094 	  plugin_data->last_delay_time = delay_time;
1095 	  plugin_data->last_decay_time = decay_time;
1096 	  plugin_data->delay_samples = delay_samples = CALC_DELAY (delay_time);
1097 	  plugin_data->feedback = feedback = calc_feedback (delay_time, decay_time);
1098 	}
1099 
1100 	if (delay_time == last_delay_time && decay_time == last_decay_time) {
1101 	  long idelay_samples = (long)delay_samples;
1102 	  LADSPA_Data frac = delay_samples - idelay_samples;
1103 
1104 	  for (i=0; i<sample_count; i++) {
1105 	    long read_phase = write_phase - (long)delay_samples;
1106 	    LADSPA_Data read = cube_interp (frac,
1107 	                                    buffer[(read_phase-1) & buffer_mask],
1108 	                                    buffer[read_phase & buffer_mask],
1109 	                                    buffer[(read_phase+1) & buffer_mask],
1110 	                                    buffer[(read_phase+2) & buffer_mask]);
1111 	    LADSPA_Data written = read * feedback + in[i];
1112 
1113 	    buffer[write_phase++ & buffer_mask] = written;
1114 	    buffer_write(out[i], read - feedback * written);
1115 	  }
1116 	} else {
1117 	  float next_delay_samples = CALC_DELAY (delay_time);
1118 	  float delay_samples_slope = (next_delay_samples - delay_samples) / sample_count;
1119 	  float next_feedback = calc_feedback (delay_time, decay_time);
1120 	  float feedback_slope = (next_feedback - feedback) / sample_count;
1121 
1122 	  for (i=0; i<sample_count; i++) {
1123 	    long read_phase, idelay_samples;
1124 	    LADSPA_Data read, written, frac;
1125 
1126 	    delay_samples += delay_samples_slope;
1127 	    write_phase++;
1128 	    read_phase = write_phase - (long)delay_samples;
1129 	    idelay_samples = (long)delay_samples;
1130 	    frac = delay_samples - idelay_samples;
1131 	    read = cube_interp (frac,
1132 	                        buffer[(read_phase-1) & buffer_mask],
1133 	                        buffer[read_phase & buffer_mask],
1134 	                        buffer[(read_phase+1) & buffer_mask],
1135 	                        buffer[(read_phase+2) & buffer_mask]);
1136 	    written = read * feedback + in[i];
1137 	    buffer[write_phase & buffer_mask] = written;
1138 	    buffer_write(out[i], read - feedback * written);
1139 
1140 	    feedback += feedback_slope;
1141 	  }
1142 
1143 	  plugin_data->last_delay_time = delay_time;
1144 	  plugin_data->last_decay_time = decay_time;
1145 	  plugin_data->feedback = feedback;
1146 	  plugin_data->delay_samples = delay_samples;
1147 	}
1148 
1149 	plugin_data->write_phase = write_phase;
1150 }
1151 
swh_init()1152 static void __attribute__((constructor)) swh_init() {
1153 	char **port_names;
1154 	LADSPA_PortDescriptor *port_descriptors;
1155 	LADSPA_PortRangeHint *port_range_hints;
1156 
1157 #ifdef ENABLE_NLS
1158 #define D_(s) dgettext(PACKAGE, s)
1159 	bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
1160 #else
1161 #define D_(s) (s)
1162 #endif
1163 
1164 
1165 	allpass_nDescriptor =
1166 	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));
1167 
1168 	if (allpass_nDescriptor) {
1169 		allpass_nDescriptor->UniqueID = 1895;
1170 		allpass_nDescriptor->Label = "allpass_n";
1171 		allpass_nDescriptor->Properties =
1172 		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
1173 		allpass_nDescriptor->Name =
1174 		 D_("Allpass delay line, noninterpolating");
1175 		allpass_nDescriptor->Maker =
1176 		 "Andy Wingo <wingo at pobox dot com>";
1177 		allpass_nDescriptor->Copyright =
1178 		 "GPL";
1179 		allpass_nDescriptor->PortCount = 5;
1180 
1181 		port_descriptors = (LADSPA_PortDescriptor *)calloc(5,
1182 		 sizeof(LADSPA_PortDescriptor));
1183 		allpass_nDescriptor->PortDescriptors =
1184 		 (const LADSPA_PortDescriptor *)port_descriptors;
1185 
1186 		port_range_hints = (LADSPA_PortRangeHint *)calloc(5,
1187 		 sizeof(LADSPA_PortRangeHint));
1188 		allpass_nDescriptor->PortRangeHints =
1189 		 (const LADSPA_PortRangeHint *)port_range_hints;
1190 
1191 		port_names = (char **)calloc(5, sizeof(char*));
1192 		allpass_nDescriptor->PortNames =
1193 		 (const char **)port_names;
1194 
1195 		/* Parameters for Input */
1196 		port_descriptors[ALLPASS_N_IN] =
1197 		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
1198 		port_names[ALLPASS_N_IN] =
1199 		 D_("Input");
1200 		port_range_hints[ALLPASS_N_IN].HintDescriptor = 0;
1201 
1202 		/* Parameters for Output */
1203 		port_descriptors[ALLPASS_N_OUT] =
1204 		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
1205 		port_names[ALLPASS_N_OUT] =
1206 		 D_("Output");
1207 		port_range_hints[ALLPASS_N_OUT].HintDescriptor = 0;
1208 
1209 		/* Parameters for Max Delay (s) */
1210 		port_descriptors[ALLPASS_N_MAX_DELAY] =
1211 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
1212 		port_names[ALLPASS_N_MAX_DELAY] =
1213 		 D_("Max Delay (s)");
1214 		port_range_hints[ALLPASS_N_MAX_DELAY].HintDescriptor =
1215 		 LADSPA_HINT_BOUNDED_BELOW;
1216 		port_range_hints[ALLPASS_N_MAX_DELAY].LowerBound = 0;
1217 
1218 		/* Parameters for Delay Time (s) */
1219 		port_descriptors[ALLPASS_N_DELAY_TIME] =
1220 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
1221 		port_names[ALLPASS_N_DELAY_TIME] =
1222 		 D_("Delay Time (s)");
1223 		port_range_hints[ALLPASS_N_DELAY_TIME].HintDescriptor =
1224 		 LADSPA_HINT_BOUNDED_BELOW;
1225 		port_range_hints[ALLPASS_N_DELAY_TIME].LowerBound = 0;
1226 
1227 		/* Parameters for Decay Time (s) */
1228 		port_descriptors[ALLPASS_N_DECAY_TIME] =
1229 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
1230 		port_names[ALLPASS_N_DECAY_TIME] =
1231 		 D_("Decay Time (s)");
1232 		port_range_hints[ALLPASS_N_DECAY_TIME].HintDescriptor =
1233 		 LADSPA_HINT_BOUNDED_BELOW;
1234 		port_range_hints[ALLPASS_N_DECAY_TIME].LowerBound = 0;
1235 
1236 		allpass_nDescriptor->activate = activateAllpass_n;
1237 		allpass_nDescriptor->cleanup = cleanupAllpass_n;
1238 		allpass_nDescriptor->connect_port = connectPortAllpass_n;
1239 		allpass_nDescriptor->deactivate = NULL;
1240 		allpass_nDescriptor->instantiate = instantiateAllpass_n;
1241 		allpass_nDescriptor->run = runAllpass_n;
1242 		allpass_nDescriptor->run_adding = runAddingAllpass_n;
1243 		allpass_nDescriptor->set_run_adding_gain = setRunAddingGainAllpass_n;
1244 	}
1245 
1246 	allpass_lDescriptor =
1247 	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));
1248 
1249 	if (allpass_lDescriptor) {
1250 		allpass_lDescriptor->UniqueID = 1896;
1251 		allpass_lDescriptor->Label = "allpass_l";
1252 		allpass_lDescriptor->Properties =
1253 		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
1254 		allpass_lDescriptor->Name =
1255 		 D_("Allpass delay line, linear interpolation");
1256 		allpass_lDescriptor->Maker =
1257 		 "Andy Wingo <wingo at pobox dot com>";
1258 		allpass_lDescriptor->Copyright =
1259 		 "GPL";
1260 		allpass_lDescriptor->PortCount = 5;
1261 
1262 		port_descriptors = (LADSPA_PortDescriptor *)calloc(5,
1263 		 sizeof(LADSPA_PortDescriptor));
1264 		allpass_lDescriptor->PortDescriptors =
1265 		 (const LADSPA_PortDescriptor *)port_descriptors;
1266 
1267 		port_range_hints = (LADSPA_PortRangeHint *)calloc(5,
1268 		 sizeof(LADSPA_PortRangeHint));
1269 		allpass_lDescriptor->PortRangeHints =
1270 		 (const LADSPA_PortRangeHint *)port_range_hints;
1271 
1272 		port_names = (char **)calloc(5, sizeof(char*));
1273 		allpass_lDescriptor->PortNames =
1274 		 (const char **)port_names;
1275 
1276 		/* Parameters for Input */
1277 		port_descriptors[ALLPASS_L_IN] =
1278 		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
1279 		port_names[ALLPASS_L_IN] =
1280 		 D_("Input");
1281 		port_range_hints[ALLPASS_L_IN].HintDescriptor = 0;
1282 
1283 		/* Parameters for Output */
1284 		port_descriptors[ALLPASS_L_OUT] =
1285 		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
1286 		port_names[ALLPASS_L_OUT] =
1287 		 D_("Output");
1288 		port_range_hints[ALLPASS_L_OUT].HintDescriptor = 0;
1289 
1290 		/* Parameters for Max Delay (s) */
1291 		port_descriptors[ALLPASS_L_MAX_DELAY] =
1292 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
1293 		port_names[ALLPASS_L_MAX_DELAY] =
1294 		 D_("Max Delay (s)");
1295 		port_range_hints[ALLPASS_L_MAX_DELAY].HintDescriptor =
1296 		 LADSPA_HINT_BOUNDED_BELOW;
1297 		port_range_hints[ALLPASS_L_MAX_DELAY].LowerBound = 0;
1298 
1299 		/* Parameters for Delay Time (s) */
1300 		port_descriptors[ALLPASS_L_DELAY_TIME] =
1301 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
1302 		port_names[ALLPASS_L_DELAY_TIME] =
1303 		 D_("Delay Time (s)");
1304 		port_range_hints[ALLPASS_L_DELAY_TIME].HintDescriptor =
1305 		 LADSPA_HINT_BOUNDED_BELOW;
1306 		port_range_hints[ALLPASS_L_DELAY_TIME].LowerBound = 0;
1307 
1308 		/* Parameters for Decay Time (s) */
1309 		port_descriptors[ALLPASS_L_DECAY_TIME] =
1310 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
1311 		port_names[ALLPASS_L_DECAY_TIME] =
1312 		 D_("Decay Time (s)");
1313 		port_range_hints[ALLPASS_L_DECAY_TIME].HintDescriptor =
1314 		 LADSPA_HINT_BOUNDED_BELOW;
1315 		port_range_hints[ALLPASS_L_DECAY_TIME].LowerBound = 0;
1316 
1317 		allpass_lDescriptor->activate = activateAllpass_l;
1318 		allpass_lDescriptor->cleanup = cleanupAllpass_l;
1319 		allpass_lDescriptor->connect_port = connectPortAllpass_l;
1320 		allpass_lDescriptor->deactivate = NULL;
1321 		allpass_lDescriptor->instantiate = instantiateAllpass_l;
1322 		allpass_lDescriptor->run = runAllpass_l;
1323 		allpass_lDescriptor->run_adding = runAddingAllpass_l;
1324 		allpass_lDescriptor->set_run_adding_gain = setRunAddingGainAllpass_l;
1325 	}
1326 
1327 	allpass_cDescriptor =
1328 	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));
1329 
1330 	if (allpass_cDescriptor) {
1331 		allpass_cDescriptor->UniqueID = 1897;
1332 		allpass_cDescriptor->Label = "allpass_c";
1333 		allpass_cDescriptor->Properties =
1334 		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
1335 		allpass_cDescriptor->Name =
1336 		 D_("Allpass delay line, cubic spline interpolation");
1337 		allpass_cDescriptor->Maker =
1338 		 "Andy Wingo <wingo at pobox dot com>";
1339 		allpass_cDescriptor->Copyright =
1340 		 "GPL";
1341 		allpass_cDescriptor->PortCount = 5;
1342 
1343 		port_descriptors = (LADSPA_PortDescriptor *)calloc(5,
1344 		 sizeof(LADSPA_PortDescriptor));
1345 		allpass_cDescriptor->PortDescriptors =
1346 		 (const LADSPA_PortDescriptor *)port_descriptors;
1347 
1348 		port_range_hints = (LADSPA_PortRangeHint *)calloc(5,
1349 		 sizeof(LADSPA_PortRangeHint));
1350 		allpass_cDescriptor->PortRangeHints =
1351 		 (const LADSPA_PortRangeHint *)port_range_hints;
1352 
1353 		port_names = (char **)calloc(5, sizeof(char*));
1354 		allpass_cDescriptor->PortNames =
1355 		 (const char **)port_names;
1356 
1357 		/* Parameters for Input */
1358 		port_descriptors[ALLPASS_C_IN] =
1359 		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
1360 		port_names[ALLPASS_C_IN] =
1361 		 D_("Input");
1362 		port_range_hints[ALLPASS_C_IN].HintDescriptor = 0;
1363 
1364 		/* Parameters for Output */
1365 		port_descriptors[ALLPASS_C_OUT] =
1366 		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
1367 		port_names[ALLPASS_C_OUT] =
1368 		 D_("Output");
1369 		port_range_hints[ALLPASS_C_OUT].HintDescriptor = 0;
1370 
1371 		/* Parameters for Max Delay (s) */
1372 		port_descriptors[ALLPASS_C_MAX_DELAY] =
1373 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
1374 		port_names[ALLPASS_C_MAX_DELAY] =
1375 		 D_("Max Delay (s)");
1376 		port_range_hints[ALLPASS_C_MAX_DELAY].HintDescriptor =
1377 		 LADSPA_HINT_BOUNDED_BELOW;
1378 		port_range_hints[ALLPASS_C_MAX_DELAY].LowerBound = 0;
1379 
1380 		/* Parameters for Delay Time (s) */
1381 		port_descriptors[ALLPASS_C_DELAY_TIME] =
1382 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
1383 		port_names[ALLPASS_C_DELAY_TIME] =
1384 		 D_("Delay Time (s)");
1385 		port_range_hints[ALLPASS_C_DELAY_TIME].HintDescriptor =
1386 		 LADSPA_HINT_BOUNDED_BELOW;
1387 		port_range_hints[ALLPASS_C_DELAY_TIME].LowerBound = 0;
1388 
1389 		/* Parameters for Decay Time (s) */
1390 		port_descriptors[ALLPASS_C_DECAY_TIME] =
1391 		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
1392 		port_names[ALLPASS_C_DECAY_TIME] =
1393 		 D_("Decay Time (s)");
1394 		port_range_hints[ALLPASS_C_DECAY_TIME].HintDescriptor =
1395 		 LADSPA_HINT_BOUNDED_BELOW;
1396 		port_range_hints[ALLPASS_C_DECAY_TIME].LowerBound = 0;
1397 
1398 		allpass_cDescriptor->activate = activateAllpass_c;
1399 		allpass_cDescriptor->cleanup = cleanupAllpass_c;
1400 		allpass_cDescriptor->connect_port = connectPortAllpass_c;
1401 		allpass_cDescriptor->deactivate = NULL;
1402 		allpass_cDescriptor->instantiate = instantiateAllpass_c;
1403 		allpass_cDescriptor->run = runAllpass_c;
1404 		allpass_cDescriptor->run_adding = runAddingAllpass_c;
1405 		allpass_cDescriptor->set_run_adding_gain = setRunAddingGainAllpass_c;
1406 	}
1407 }
1408 
swh_fini()1409 static void __attribute__((destructor)) swh_fini() {
1410 	if (allpass_nDescriptor) {
1411 		free((LADSPA_PortDescriptor *)allpass_nDescriptor->PortDescriptors);
1412 		free((char **)allpass_nDescriptor->PortNames);
1413 		free((LADSPA_PortRangeHint *)allpass_nDescriptor->PortRangeHints);
1414 		free(allpass_nDescriptor);
1415 	}
1416 	allpass_nDescriptor = NULL;
1417 	if (allpass_lDescriptor) {
1418 		free((LADSPA_PortDescriptor *)allpass_lDescriptor->PortDescriptors);
1419 		free((char **)allpass_lDescriptor->PortNames);
1420 		free((LADSPA_PortRangeHint *)allpass_lDescriptor->PortRangeHints);
1421 		free(allpass_lDescriptor);
1422 	}
1423 	allpass_lDescriptor = NULL;
1424 	if (allpass_cDescriptor) {
1425 		free((LADSPA_PortDescriptor *)allpass_cDescriptor->PortDescriptors);
1426 		free((char **)allpass_cDescriptor->PortNames);
1427 		free((LADSPA_PortRangeHint *)allpass_cDescriptor->PortRangeHints);
1428 		free(allpass_cDescriptor);
1429 	}
1430 	allpass_cDescriptor = NULL;
1431 
1432 }
1433