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