~ubuntu-branches/ubuntu/raring/lmms/raring-proposed

« back to all changes in this revision

Viewing changes to plugins/ladspa_effect/swh/retro_flange_1208.c

  • Committer: Charlie Smotherman
  • Date: 2012-12-05 22:08:38 UTC
  • mfrom: (33.1.7 lmms_0.4.13)
  • Revision ID: cjsmo@cableone.net-20121205220838-09pjfzew9m5023hr
* New  Upstream release.
  - Minor tweaking to ZynAddSubFX, CALF, SWH plugins  and Stefan Fendt's RC
    filters.
  - Added UI fixes: Magnentic effect of knobs and Piano-roll fixes
  - Updated German localization and copyright year
* debian/lmms-common.install:
  - added /usr/share/applications so the lmms.desktop file will correctly
    install (LP: #863366)
  - This should also fix the Software Center not displaying lmms in sound
    and video (LP: #824231)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
void _init(); // forward declaration
 
24
#else
 
25
#define _WINDOWS_DLL_EXPORT_ 
 
26
#endif
 
27
 
 
28
#line 10 "retro_flange_1208.xml"
 
29
 
 
30
#include "ladspa-util.h"
 
31
 
 
32
#define BASE_BUFFER 0.001 // Base buffer length (s)
 
33
 
 
34
inline LADSPA_Data sat(LADSPA_Data x, float q,  float dist) {
 
35
        if (x == q) {
 
36
                return 1.0f / dist + q / (1.0f - f_exp(dist * q));
 
37
        }
 
38
        return ((x - q) / (1.0f - f_exp(-dist * (x - q))) + q /
 
39
         (1.0f - f_exp(dist * q)));
 
40
}
 
41
 
 
42
#define RETROFLANGE_DELAY_DEPTH_AVG    0
 
43
#define RETROFLANGE_LAW_FREQ           1
 
44
#define RETROFLANGE_INPUT              2
 
45
#define RETROFLANGE_OUTPUT             3
 
46
 
 
47
static LADSPA_Descriptor *retroFlangeDescriptor = NULL;
 
48
 
 
49
typedef struct {
 
50
        LADSPA_Data *delay_depth_avg;
 
51
        LADSPA_Data *law_freq;
 
52
        LADSPA_Data *input;
 
53
        LADSPA_Data *output;
 
54
        LADSPA_Data *buffer;
 
55
        long         buffer_size;
 
56
        long         count;
 
57
        LADSPA_Data *delay_line;
 
58
        int          delay_line_length;
 
59
        int          delay_pos;
 
60
        LADSPA_Data  last_in;
 
61
        int          last_law_p;
 
62
        int          last_phase;
 
63
        int          max_law_p;
 
64
        float        next_law_peak;
 
65
        int          next_law_pos;
 
66
        float        phase;
 
67
        float        prev_law_peak;
 
68
        int          prev_law_pos;
 
69
        long         sample_rate;
 
70
        LADSPA_Data  z0;
 
71
        LADSPA_Data  z1;
 
72
        LADSPA_Data  z2;
 
73
        LADSPA_Data run_adding_gain;
 
74
} RetroFlange;
 
75
 
 
76
_WINDOWS_DLL_EXPORT_
 
77
const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) {
 
78
 
 
79
#ifdef WIN32
 
80
        if (bIsFirstTime) {
 
81
                _init();
 
82
                bIsFirstTime = 0;
 
83
        }
 
84
#endif
 
85
        switch (index) {
 
86
        case 0:
 
87
                return retroFlangeDescriptor;
 
88
        default:
 
89
                return NULL;
 
90
        }
 
91
}
 
92
 
 
93
static void activateRetroFlange(LADSPA_Handle instance) {
 
94
        RetroFlange *plugin_data = (RetroFlange *)instance;
 
95
        LADSPA_Data *buffer = plugin_data->buffer;
 
96
        long buffer_size = plugin_data->buffer_size;
 
97
        long count = plugin_data->count;
 
98
        LADSPA_Data *delay_line = plugin_data->delay_line;
 
99
        int delay_line_length = plugin_data->delay_line_length;
 
100
        int delay_pos = plugin_data->delay_pos;
 
101
        LADSPA_Data last_in = plugin_data->last_in;
 
102
        int last_law_p = plugin_data->last_law_p;
 
103
        int last_phase = plugin_data->last_phase;
 
104
        int max_law_p = plugin_data->max_law_p;
 
105
        float next_law_peak = plugin_data->next_law_peak;
 
106
        int next_law_pos = plugin_data->next_law_pos;
 
107
        float phase = plugin_data->phase;
 
108
        float prev_law_peak = plugin_data->prev_law_peak;
 
109
        int prev_law_pos = plugin_data->prev_law_pos;
 
110
        long sample_rate = plugin_data->sample_rate;
 
111
        LADSPA_Data z0 = plugin_data->z0;
 
112
        LADSPA_Data z1 = plugin_data->z1;
 
113
        LADSPA_Data z2 = plugin_data->z2;
 
114
#line 57 "retro_flange_1208.xml"
 
115
        memset(delay_line, 0, sizeof(float) * delay_line_length);
 
116
        memset(buffer, 0, sizeof(LADSPA_Data) * buffer_size);
 
117
        z0 = 0.0f;
 
118
        z1 = 0.0f;
 
119
        z2 = 0.0f;
 
120
        
 
121
        prev_law_peak = 0.0f;
 
122
        next_law_peak = 1.0f;
 
123
        prev_law_pos = 0;
 
124
        next_law_pos = 10;
 
125
        plugin_data->buffer = buffer;
 
126
        plugin_data->buffer_size = buffer_size;
 
127
        plugin_data->count = count;
 
128
        plugin_data->delay_line = delay_line;
 
129
        plugin_data->delay_line_length = delay_line_length;
 
130
        plugin_data->delay_pos = delay_pos;
 
131
        plugin_data->last_in = last_in;
 
132
        plugin_data->last_law_p = last_law_p;
 
133
        plugin_data->last_phase = last_phase;
 
134
        plugin_data->max_law_p = max_law_p;
 
135
        plugin_data->next_law_peak = next_law_peak;
 
136
        plugin_data->next_law_pos = next_law_pos;
 
137
        plugin_data->phase = phase;
 
138
        plugin_data->prev_law_peak = prev_law_peak;
 
139
        plugin_data->prev_law_pos = prev_law_pos;
 
140
        plugin_data->sample_rate = sample_rate;
 
141
        plugin_data->z0 = z0;
 
142
        plugin_data->z1 = z1;
 
143
        plugin_data->z2 = z2;
 
144
 
 
145
}
 
146
 
 
147
static void cleanupRetroFlange(LADSPA_Handle instance) {
 
148
#line 70 "retro_flange_1208.xml"
 
149
        RetroFlange *plugin_data = (RetroFlange *)instance;
 
150
        free(plugin_data->delay_line);
 
151
        free(plugin_data->buffer);
 
152
        free(instance);
 
153
}
 
154
 
 
155
static void connectPortRetroFlange(
 
156
 LADSPA_Handle instance,
 
157
 unsigned long port,
 
158
 LADSPA_Data *data) {
 
159
        RetroFlange *plugin;
 
160
 
 
161
        plugin = (RetroFlange *)instance;
 
162
        switch (port) {
 
163
        case RETROFLANGE_DELAY_DEPTH_AVG:
 
164
                plugin->delay_depth_avg = data;
 
165
                break;
 
166
        case RETROFLANGE_LAW_FREQ:
 
167
                plugin->law_freq = data;
 
168
                break;
 
169
        case RETROFLANGE_INPUT:
 
170
                plugin->input = data;
 
171
                break;
 
172
        case RETROFLANGE_OUTPUT:
 
173
                plugin->output = data;
 
174
                break;
 
175
        }
 
176
}
 
177
 
 
178
static LADSPA_Handle instantiateRetroFlange(
 
179
 const LADSPA_Descriptor *descriptor,
 
180
 unsigned long s_rate) {
 
181
        RetroFlange *plugin_data = (RetroFlange *)malloc(sizeof(RetroFlange));
 
182
        LADSPA_Data *buffer = NULL;
 
183
        long buffer_size;
 
184
        long count;
 
185
        LADSPA_Data *delay_line = NULL;
 
186
        int delay_line_length;
 
187
        int delay_pos;
 
188
        LADSPA_Data last_in;
 
189
        int last_law_p;
 
190
        int last_phase;
 
191
        int max_law_p;
 
192
        float next_law_peak;
 
193
        int next_law_pos;
 
194
        float phase;
 
195
        float prev_law_peak;
 
196
        int prev_law_pos;
 
197
        long sample_rate;
 
198
        LADSPA_Data z0;
 
199
        LADSPA_Data z1;
 
200
        LADSPA_Data z2;
 
201
 
 
202
#line 32 "retro_flange_1208.xml"
 
203
        sample_rate = s_rate;
 
204
        buffer_size = BASE_BUFFER * s_rate;
 
205
        buffer = calloc(buffer_size, sizeof(LADSPA_Data));
 
206
        phase = 0;
 
207
        last_phase = 0;
 
208
        last_in = 0.0f;
 
209
        max_law_p = s_rate*2;
 
210
        last_law_p = -1;
 
211
        delay_line_length = sample_rate * 0.01f;
 
212
        delay_line = calloc(sizeof(float), delay_line_length);
 
213
        
 
214
        delay_pos = 0;
 
215
        count = 0;
 
216
        
 
217
        prev_law_peak = 0.0f;
 
218
        next_law_peak = 1.0f;
 
219
        prev_law_pos = 0;
 
220
        next_law_pos = 10;
 
221
        
 
222
        z0 = 0.0f;
 
223
        z1 = 0.0f;
 
224
        z2 = 0.0f;
 
225
 
 
226
        plugin_data->buffer = buffer;
 
227
        plugin_data->buffer_size = buffer_size;
 
228
        plugin_data->count = count;
 
229
        plugin_data->delay_line = delay_line;
 
230
        plugin_data->delay_line_length = delay_line_length;
 
231
        plugin_data->delay_pos = delay_pos;
 
232
        plugin_data->last_in = last_in;
 
233
        plugin_data->last_law_p = last_law_p;
 
234
        plugin_data->last_phase = last_phase;
 
235
        plugin_data->max_law_p = max_law_p;
 
236
        plugin_data->next_law_peak = next_law_peak;
 
237
        plugin_data->next_law_pos = next_law_pos;
 
238
        plugin_data->phase = phase;
 
239
        plugin_data->prev_law_peak = prev_law_peak;
 
240
        plugin_data->prev_law_pos = prev_law_pos;
 
241
        plugin_data->sample_rate = sample_rate;
 
242
        plugin_data->z0 = z0;
 
243
        plugin_data->z1 = z1;
 
244
        plugin_data->z2 = z2;
 
245
 
 
246
        return (LADSPA_Handle)plugin_data;
 
247
}
 
248
 
 
249
#undef buffer_write
 
250
#undef RUN_ADDING
 
251
#undef RUN_REPLACING
 
252
 
 
253
#define buffer_write(b, v) (b = v)
 
254
#define RUN_ADDING    0
 
255
#define RUN_REPLACING 1
 
256
 
 
257
static void runRetroFlange(LADSPA_Handle instance, unsigned long sample_count) {
 
258
        RetroFlange *plugin_data = (RetroFlange *)instance;
 
259
 
 
260
        /* Average stall (ms) (float value) */
 
261
        const LADSPA_Data delay_depth_avg = *(plugin_data->delay_depth_avg);
 
262
 
 
263
        /* Flange frequency (Hz) (float value) */
 
264
        const LADSPA_Data law_freq = *(plugin_data->law_freq);
 
265
 
 
266
        /* Input (array of floats of length sample_count) */
 
267
        const LADSPA_Data * const input = plugin_data->input;
 
268
 
 
269
        /* Output (array of floats of length sample_count) */
 
270
        LADSPA_Data * const output = plugin_data->output;
 
271
        LADSPA_Data * buffer = plugin_data->buffer;
 
272
        long buffer_size = plugin_data->buffer_size;
 
273
        long count = plugin_data->count;
 
274
        LADSPA_Data * delay_line = plugin_data->delay_line;
 
275
        int delay_line_length = plugin_data->delay_line_length;
 
276
        int delay_pos = plugin_data->delay_pos;
 
277
        LADSPA_Data last_in = plugin_data->last_in;
 
278
        int last_law_p = plugin_data->last_law_p;
 
279
        int last_phase = plugin_data->last_phase;
 
280
        int max_law_p = plugin_data->max_law_p;
 
281
        float next_law_peak = plugin_data->next_law_peak;
 
282
        int next_law_pos = plugin_data->next_law_pos;
 
283
        float phase = plugin_data->phase;
 
284
        float prev_law_peak = plugin_data->prev_law_peak;
 
285
        int prev_law_pos = plugin_data->prev_law_pos;
 
286
        long sample_rate = plugin_data->sample_rate;
 
287
        LADSPA_Data z0 = plugin_data->z0;
 
288
        LADSPA_Data z1 = plugin_data->z1;
 
289
        LADSPA_Data z2 = plugin_data->z2;
 
290
 
 
291
#line 75 "retro_flange_1208.xml"
 
292
        long int pos;
 
293
        int law_p = f_trunc(LIMIT(sample_rate / f_clamp(law_freq, 0.0001f, 100.0f), 1, max_law_p));
 
294
        float increment;
 
295
        float lin_int, lin_inc;
 
296
        int track;
 
297
        int fph;
 
298
        LADSPA_Data out = 0.0f;
 
299
        const float dda_c = f_clamp(delay_depth_avg, 0.0f, 10.0f);
 
300
        int dl_used = (dda_c * sample_rate) / 1000;
 
301
        float inc_base = 1000.0f * (float)BASE_BUFFER;
 
302
        const float delay_depth = 2.0f * dda_c;
 
303
        float n_ph, p_ph, law;
 
304
        
 
305
        for (pos = 0; pos < sample_count; pos++) {
 
306
                // Write into the delay line
 
307
                delay_line[delay_pos] = input[pos];
 
308
                z0 = delay_line[MOD(delay_pos - dl_used, delay_line_length)] + 0.12919609397f*z1 - 0.31050847f*z2;
 
309
                out = sat(z0*0.20466966f + z1*0.40933933f + z2*0.40933933f,
 
310
                                -0.23f, 3.3f);
 
311
                z2 = z1; z1 = z0;
 
312
                delay_pos = (delay_pos + 1) % delay_line_length;
 
313
        
 
314
                if ((count++ % law_p) == 0) {
 
315
                        // Value for amplitude of law peak
 
316
                        next_law_peak = (float)rand() / (float)RAND_MAX;
 
317
                        next_law_pos = count + law_p;
 
318
                } else if (count % law_p == law_p / 2) {
 
319
                        // Value for amplitude of law peak
 
320
                        prev_law_peak = (float)rand() / (float)RAND_MAX;
 
321
                        prev_law_pos = count + law_p;
 
322
                }
 
323
        
 
324
                n_ph = (float)(law_p - abs(next_law_pos - count))/(float)law_p;
 
325
                p_ph = n_ph + 0.5f;
 
326
                if (p_ph > 1.0f) {
 
327
                        p_ph -= 1.0f;
 
328
                }
 
329
                law = f_sin_sq(3.1415926f*p_ph)*prev_law_peak +
 
330
                        f_sin_sq(3.1415926f*n_ph)*next_law_peak;
 
331
        
 
332
                increment = inc_base / (delay_depth * law + 0.2);
 
333
                fph = f_trunc(phase);
 
334
                last_phase = fph;
 
335
                lin_int = phase - (float)fph;
 
336
                out += LIN_INTERP(lin_int, buffer[(fph+1) % buffer_size],
 
337
                 buffer[(fph+2) % buffer_size]);
 
338
                phase += increment;
 
339
                lin_inc = 1.0f / (floor(phase) - last_phase + 1);
 
340
                lin_inc = lin_inc > 1.0f ? 1.0f : lin_inc;
 
341
                lin_int = 0.0f;
 
342
                for (track = last_phase; track < phase; track++) {
 
343
                        lin_int += lin_inc;
 
344
                        buffer[track % buffer_size] =
 
345
                         LIN_INTERP(lin_int, last_in, input[pos]);
 
346
                }
 
347
                last_in = input[pos];
 
348
                buffer_write(output[pos], out * 0.707f);
 
349
                if (phase >= buffer_size) {
 
350
                        phase -= buffer_size;
 
351
                }
 
352
        }
 
353
        
 
354
        // Store current phase in instance
 
355
        plugin_data->phase = phase;
 
356
        plugin_data->prev_law_peak = prev_law_peak;
 
357
        plugin_data->next_law_peak = next_law_peak;
 
358
        plugin_data->prev_law_pos = prev_law_pos;
 
359
        plugin_data->next_law_pos = next_law_pos;
 
360
        plugin_data->last_phase = last_phase;
 
361
        plugin_data->last_in = last_in;
 
362
        plugin_data->count = count;
 
363
        plugin_data->last_law_p = last_law_p;
 
364
        plugin_data->delay_pos = delay_pos;
 
365
        plugin_data->z0 = z0;
 
366
        plugin_data->z1 = z1;
 
367
        plugin_data->z2 = z2;
 
368
}
 
369
#undef buffer_write
 
370
#undef RUN_ADDING
 
371
#undef RUN_REPLACING
 
372
 
 
373
#define buffer_write(b, v) (b += (v) * run_adding_gain)
 
374
#define RUN_ADDING    1
 
375
#define RUN_REPLACING 0
 
376
 
 
377
static void setRunAddingGainRetroFlange(LADSPA_Handle instance, LADSPA_Data gain) {
 
378
        ((RetroFlange *)instance)->run_adding_gain = gain;
 
379
}
 
380
 
 
381
static void runAddingRetroFlange(LADSPA_Handle instance, unsigned long sample_count) {
 
382
        RetroFlange *plugin_data = (RetroFlange *)instance;
 
383
        LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;
 
384
 
 
385
        /* Average stall (ms) (float value) */
 
386
        const LADSPA_Data delay_depth_avg = *(plugin_data->delay_depth_avg);
 
387
 
 
388
        /* Flange frequency (Hz) (float value) */
 
389
        const LADSPA_Data law_freq = *(plugin_data->law_freq);
 
390
 
 
391
        /* Input (array of floats of length sample_count) */
 
392
        const LADSPA_Data * const input = plugin_data->input;
 
393
 
 
394
        /* Output (array of floats of length sample_count) */
 
395
        LADSPA_Data * const output = plugin_data->output;
 
396
        LADSPA_Data * buffer = plugin_data->buffer;
 
397
        long buffer_size = plugin_data->buffer_size;
 
398
        long count = plugin_data->count;
 
399
        LADSPA_Data * delay_line = plugin_data->delay_line;
 
400
        int delay_line_length = plugin_data->delay_line_length;
 
401
        int delay_pos = plugin_data->delay_pos;
 
402
        LADSPA_Data last_in = plugin_data->last_in;
 
403
        int last_law_p = plugin_data->last_law_p;
 
404
        int last_phase = plugin_data->last_phase;
 
405
        int max_law_p = plugin_data->max_law_p;
 
406
        float next_law_peak = plugin_data->next_law_peak;
 
407
        int next_law_pos = plugin_data->next_law_pos;
 
408
        float phase = plugin_data->phase;
 
409
        float prev_law_peak = plugin_data->prev_law_peak;
 
410
        int prev_law_pos = plugin_data->prev_law_pos;
 
411
        long sample_rate = plugin_data->sample_rate;
 
412
        LADSPA_Data z0 = plugin_data->z0;
 
413
        LADSPA_Data z1 = plugin_data->z1;
 
414
        LADSPA_Data z2 = plugin_data->z2;
 
415
 
 
416
#line 75 "retro_flange_1208.xml"
 
417
        long int pos;
 
418
        int law_p = f_trunc(LIMIT(sample_rate / f_clamp(law_freq, 0.0001f, 100.0f), 1, max_law_p));
 
419
        float increment;
 
420
        float lin_int, lin_inc;
 
421
        int track;
 
422
        int fph;
 
423
        LADSPA_Data out = 0.0f;
 
424
        const float dda_c = f_clamp(delay_depth_avg, 0.0f, 10.0f);
 
425
        int dl_used = (dda_c * sample_rate) / 1000;
 
426
        float inc_base = 1000.0f * (float)BASE_BUFFER;
 
427
        const float delay_depth = 2.0f * dda_c;
 
428
        float n_ph, p_ph, law;
 
429
        
 
430
        for (pos = 0; pos < sample_count; pos++) {
 
431
                // Write into the delay line
 
432
                delay_line[delay_pos] = input[pos];
 
433
                z0 = delay_line[MOD(delay_pos - dl_used, delay_line_length)] + 0.12919609397f*z1 - 0.31050847f*z2;
 
434
                out = sat(z0*0.20466966f + z1*0.40933933f + z2*0.40933933f,
 
435
                                -0.23f, 3.3f);
 
436
                z2 = z1; z1 = z0;
 
437
                delay_pos = (delay_pos + 1) % delay_line_length;
 
438
        
 
439
                if ((count++ % law_p) == 0) {
 
440
                        // Value for amplitude of law peak
 
441
                        next_law_peak = (float)rand() / (float)RAND_MAX;
 
442
                        next_law_pos = count + law_p;
 
443
                } else if (count % law_p == law_p / 2) {
 
444
                        // Value for amplitude of law peak
 
445
                        prev_law_peak = (float)rand() / (float)RAND_MAX;
 
446
                        prev_law_pos = count + law_p;
 
447
                }
 
448
        
 
449
                n_ph = (float)(law_p - abs(next_law_pos - count))/(float)law_p;
 
450
                p_ph = n_ph + 0.5f;
 
451
                if (p_ph > 1.0f) {
 
452
                        p_ph -= 1.0f;
 
453
                }
 
454
                law = f_sin_sq(3.1415926f*p_ph)*prev_law_peak +
 
455
                        f_sin_sq(3.1415926f*n_ph)*next_law_peak;
 
456
        
 
457
                increment = inc_base / (delay_depth * law + 0.2);
 
458
                fph = f_trunc(phase);
 
459
                last_phase = fph;
 
460
                lin_int = phase - (float)fph;
 
461
                out += LIN_INTERP(lin_int, buffer[(fph+1) % buffer_size],
 
462
                 buffer[(fph+2) % buffer_size]);
 
463
                phase += increment;
 
464
                lin_inc = 1.0f / (floor(phase) - last_phase + 1);
 
465
                lin_inc = lin_inc > 1.0f ? 1.0f : lin_inc;
 
466
                lin_int = 0.0f;
 
467
                for (track = last_phase; track < phase; track++) {
 
468
                        lin_int += lin_inc;
 
469
                        buffer[track % buffer_size] =
 
470
                         LIN_INTERP(lin_int, last_in, input[pos]);
 
471
                }
 
472
                last_in = input[pos];
 
473
                buffer_write(output[pos], out * 0.707f);
 
474
                if (phase >= buffer_size) {
 
475
                        phase -= buffer_size;
 
476
                }
 
477
        }
 
478
        
 
479
        // Store current phase in instance
 
480
        plugin_data->phase = phase;
 
481
        plugin_data->prev_law_peak = prev_law_peak;
 
482
        plugin_data->next_law_peak = next_law_peak;
 
483
        plugin_data->prev_law_pos = prev_law_pos;
 
484
        plugin_data->next_law_pos = next_law_pos;
 
485
        plugin_data->last_phase = last_phase;
 
486
        plugin_data->last_in = last_in;
 
487
        plugin_data->count = count;
 
488
        plugin_data->last_law_p = last_law_p;
 
489
        plugin_data->delay_pos = delay_pos;
 
490
        plugin_data->z0 = z0;
 
491
        plugin_data->z1 = z1;
 
492
        plugin_data->z2 = z2;
 
493
}
 
494
 
 
495
void _init() {
 
496
        char **port_names;
 
497
        LADSPA_PortDescriptor *port_descriptors;
 
498
        LADSPA_PortRangeHint *port_range_hints;
 
499
 
 
500
#ifdef ENABLE_NLS
 
501
#define D_(s) dgettext(PACKAGE, s)
 
502
        setlocale(LC_ALL, "");
 
503
        bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
 
504
#else
 
505
#define D_(s) (s)
 
506
#endif
 
507
 
 
508
 
 
509
        retroFlangeDescriptor =
 
510
         (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));
 
511
 
 
512
        if (retroFlangeDescriptor) {
 
513
                retroFlangeDescriptor->UniqueID = 1208;
 
514
                retroFlangeDescriptor->Label = "retroFlange";
 
515
                retroFlangeDescriptor->Properties =
 
516
                 LADSPA_PROPERTY_HARD_RT_CAPABLE;
 
517
                retroFlangeDescriptor->Name =
 
518
                 D_("Retro Flanger");
 
519
                retroFlangeDescriptor->Maker =
 
520
                 "Steve Harris <steve@plugin.org.uk>";
 
521
                retroFlangeDescriptor->Copyright =
 
522
                 "GPL";
 
523
                retroFlangeDescriptor->PortCount = 4;
 
524
 
 
525
                port_descriptors = (LADSPA_PortDescriptor *)calloc(4,
 
526
                 sizeof(LADSPA_PortDescriptor));
 
527
                retroFlangeDescriptor->PortDescriptors =
 
528
                 (const LADSPA_PortDescriptor *)port_descriptors;
 
529
 
 
530
                port_range_hints = (LADSPA_PortRangeHint *)calloc(4,
 
531
                 sizeof(LADSPA_PortRangeHint));
 
532
                retroFlangeDescriptor->PortRangeHints =
 
533
                 (const LADSPA_PortRangeHint *)port_range_hints;
 
534
 
 
535
                port_names = (char **)calloc(4, sizeof(char*));
 
536
                retroFlangeDescriptor->PortNames =
 
537
                 (const char **)port_names;
 
538
 
 
539
                /* Parameters for Average stall (ms) */
 
540
                port_descriptors[RETROFLANGE_DELAY_DEPTH_AVG] =
 
541
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
542
                port_names[RETROFLANGE_DELAY_DEPTH_AVG] =
 
543
                 D_("Average stall (ms)");
 
544
                port_range_hints[RETROFLANGE_DELAY_DEPTH_AVG].HintDescriptor =
 
545
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW;
 
546
                port_range_hints[RETROFLANGE_DELAY_DEPTH_AVG].LowerBound = 0;
 
547
                port_range_hints[RETROFLANGE_DELAY_DEPTH_AVG].UpperBound = 10;
 
548
 
 
549
                /* Parameters for Flange frequency (Hz) */
 
550
                port_descriptors[RETROFLANGE_LAW_FREQ] =
 
551
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
552
                port_names[RETROFLANGE_LAW_FREQ] =
 
553
                 D_("Flange frequency (Hz)");
 
554
                port_range_hints[RETROFLANGE_LAW_FREQ].HintDescriptor =
 
555
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_1;
 
556
                port_range_hints[RETROFLANGE_LAW_FREQ].LowerBound = 0.5;
 
557
                port_range_hints[RETROFLANGE_LAW_FREQ].UpperBound = 8;
 
558
 
 
559
                /* Parameters for Input */
 
560
                port_descriptors[RETROFLANGE_INPUT] =
 
561
                 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
 
562
                port_names[RETROFLANGE_INPUT] =
 
563
                 D_("Input");
 
564
                port_range_hints[RETROFLANGE_INPUT].HintDescriptor = 0;
 
565
 
 
566
                /* Parameters for Output */
 
567
                port_descriptors[RETROFLANGE_OUTPUT] =
 
568
                 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
 
569
                port_names[RETROFLANGE_OUTPUT] =
 
570
                 D_("Output");
 
571
                port_range_hints[RETROFLANGE_OUTPUT].HintDescriptor = 0;
 
572
 
 
573
                retroFlangeDescriptor->activate = activateRetroFlange;
 
574
                retroFlangeDescriptor->cleanup = cleanupRetroFlange;
 
575
                retroFlangeDescriptor->connect_port = connectPortRetroFlange;
 
576
                retroFlangeDescriptor->deactivate = NULL;
 
577
                retroFlangeDescriptor->instantiate = instantiateRetroFlange;
 
578
                retroFlangeDescriptor->run = runRetroFlange;
 
579
                retroFlangeDescriptor->run_adding = runAddingRetroFlange;
 
580
                retroFlangeDescriptor->set_run_adding_gain = setRunAddingGainRetroFlange;
 
581
        }
 
582
}
 
583
 
 
584
void _fini() {
 
585
        if (retroFlangeDescriptor) {
 
586
                free((LADSPA_PortDescriptor *)retroFlangeDescriptor->PortDescriptors);
 
587
                free((char **)retroFlangeDescriptor->PortNames);
 
588
                free((LADSPA_PortRangeHint *)retroFlangeDescriptor->PortRangeHints);
 
589
                free(retroFlangeDescriptor);
 
590
        }
 
591
 
 
592
}