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

« back to all changes in this revision

Viewing changes to plugins/ladspa_effect/swh/tape_delay_1211.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 8 "tape_delay_1211.xml"
 
29
 
 
30
#include "ladspa-util.h"
 
31
 
 
32
#define BASE_BUFFER 8 // Tape length (inches)
 
33
 
 
34
#define TAPEDELAY_SPEED                0
 
35
#define TAPEDELAY_DA_DB                1
 
36
#define TAPEDELAY_T1D                  2
 
37
#define TAPEDELAY_T1A_DB               3
 
38
#define TAPEDELAY_T2D                  4
 
39
#define TAPEDELAY_T2A_DB               5
 
40
#define TAPEDELAY_T3D                  6
 
41
#define TAPEDELAY_T3A_DB               7
 
42
#define TAPEDELAY_T4D                  8
 
43
#define TAPEDELAY_T4A_DB               9
 
44
#define TAPEDELAY_INPUT                10
 
45
#define TAPEDELAY_OUTPUT               11
 
46
 
 
47
static LADSPA_Descriptor *tapeDelayDescriptor = NULL;
 
48
 
 
49
typedef struct {
 
50
        LADSPA_Data *speed;
 
51
        LADSPA_Data *da_db;
 
52
        LADSPA_Data *t1d;
 
53
        LADSPA_Data *t1a_db;
 
54
        LADSPA_Data *t2d;
 
55
        LADSPA_Data *t2a_db;
 
56
        LADSPA_Data *t3d;
 
57
        LADSPA_Data *t3a_db;
 
58
        LADSPA_Data *t4d;
 
59
        LADSPA_Data *t4a_db;
 
60
        LADSPA_Data *input;
 
61
        LADSPA_Data *output;
 
62
        LADSPA_Data *buffer;
 
63
        unsigned int buffer_mask;
 
64
        unsigned int buffer_size;
 
65
        LADSPA_Data  last2_in;
 
66
        LADSPA_Data  last3_in;
 
67
        LADSPA_Data  last_in;
 
68
        unsigned int last_phase;
 
69
        float        phase;
 
70
        int          sample_rate;
 
71
        LADSPA_Data  z0;
 
72
        LADSPA_Data  z1;
 
73
        LADSPA_Data  z2;
 
74
        LADSPA_Data run_adding_gain;
 
75
} TapeDelay;
 
76
 
 
77
_WINDOWS_DLL_EXPORT_
 
78
const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) {
 
79
 
 
80
#ifdef WIN32
 
81
        if (bIsFirstTime) {
 
82
                _init();
 
83
                bIsFirstTime = 0;
 
84
        }
 
85
#endif
 
86
        switch (index) {
 
87
        case 0:
 
88
                return tapeDelayDescriptor;
 
89
        default:
 
90
                return NULL;
 
91
        }
 
92
}
 
93
 
 
94
static void activateTapeDelay(LADSPA_Handle instance) {
 
95
        TapeDelay *plugin_data = (TapeDelay *)instance;
 
96
        LADSPA_Data *buffer = plugin_data->buffer;
 
97
        unsigned int buffer_mask = plugin_data->buffer_mask;
 
98
        unsigned int buffer_size = plugin_data->buffer_size;
 
99
        LADSPA_Data last2_in = plugin_data->last2_in;
 
100
        LADSPA_Data last3_in = plugin_data->last3_in;
 
101
        LADSPA_Data last_in = plugin_data->last_in;
 
102
        unsigned int last_phase = plugin_data->last_phase;
 
103
        float phase = plugin_data->phase;
 
104
        int sample_rate = plugin_data->sample_rate;
 
105
        LADSPA_Data z0 = plugin_data->z0;
 
106
        LADSPA_Data z1 = plugin_data->z1;
 
107
        LADSPA_Data z2 = plugin_data->z2;
 
108
#line 38 "tape_delay_1211.xml"
 
109
        int i;
 
110
 
 
111
        for (i = 0; i < buffer_size; i++) {
 
112
                buffer[i] = 0;
 
113
        }
 
114
        phase = 0;
 
115
        last_phase = 0;
 
116
        last_in = 0.0f;
 
117
        last2_in = 0.0f;
 
118
        last3_in = 0.0f;
 
119
        sample_rate = sample_rate;
 
120
        z0 = 0.0f;
 
121
        z1 = 0.0f;
 
122
        z2 = 0.0f;
 
123
        plugin_data->buffer = buffer;
 
124
        plugin_data->buffer_mask = buffer_mask;
 
125
        plugin_data->buffer_size = buffer_size;
 
126
        plugin_data->last2_in = last2_in;
 
127
        plugin_data->last3_in = last3_in;
 
128
        plugin_data->last_in = last_in;
 
129
        plugin_data->last_phase = last_phase;
 
130
        plugin_data->phase = phase;
 
131
        plugin_data->sample_rate = sample_rate;
 
132
        plugin_data->z0 = z0;
 
133
        plugin_data->z1 = z1;
 
134
        plugin_data->z2 = z2;
 
135
 
 
136
}
 
137
 
 
138
static void cleanupTapeDelay(LADSPA_Handle instance) {
 
139
#line 55 "tape_delay_1211.xml"
 
140
        TapeDelay *plugin_data = (TapeDelay *)instance;
 
141
        free(plugin_data->buffer);
 
142
        free(instance);
 
143
}
 
144
 
 
145
static void connectPortTapeDelay(
 
146
 LADSPA_Handle instance,
 
147
 unsigned long port,
 
148
 LADSPA_Data *data) {
 
149
        TapeDelay *plugin;
 
150
 
 
151
        plugin = (TapeDelay *)instance;
 
152
        switch (port) {
 
153
        case TAPEDELAY_SPEED:
 
154
                plugin->speed = data;
 
155
                break;
 
156
        case TAPEDELAY_DA_DB:
 
157
                plugin->da_db = data;
 
158
                break;
 
159
        case TAPEDELAY_T1D:
 
160
                plugin->t1d = data;
 
161
                break;
 
162
        case TAPEDELAY_T1A_DB:
 
163
                plugin->t1a_db = data;
 
164
                break;
 
165
        case TAPEDELAY_T2D:
 
166
                plugin->t2d = data;
 
167
                break;
 
168
        case TAPEDELAY_T2A_DB:
 
169
                plugin->t2a_db = data;
 
170
                break;
 
171
        case TAPEDELAY_T3D:
 
172
                plugin->t3d = data;
 
173
                break;
 
174
        case TAPEDELAY_T3A_DB:
 
175
                plugin->t3a_db = data;
 
176
                break;
 
177
        case TAPEDELAY_T4D:
 
178
                plugin->t4d = data;
 
179
                break;
 
180
        case TAPEDELAY_T4A_DB:
 
181
                plugin->t4a_db = data;
 
182
                break;
 
183
        case TAPEDELAY_INPUT:
 
184
                plugin->input = data;
 
185
                break;
 
186
        case TAPEDELAY_OUTPUT:
 
187
                plugin->output = data;
 
188
                break;
 
189
        }
 
190
}
 
191
 
 
192
static LADSPA_Handle instantiateTapeDelay(
 
193
 const LADSPA_Descriptor *descriptor,
 
194
 unsigned long s_rate) {
 
195
        TapeDelay *plugin_data = (TapeDelay *)malloc(sizeof(TapeDelay));
 
196
        LADSPA_Data *buffer = NULL;
 
197
        unsigned int buffer_mask;
 
198
        unsigned int buffer_size;
 
199
        LADSPA_Data last2_in;
 
200
        LADSPA_Data last3_in;
 
201
        LADSPA_Data last_in;
 
202
        unsigned int last_phase;
 
203
        float phase;
 
204
        int sample_rate;
 
205
        LADSPA_Data z0;
 
206
        LADSPA_Data z1;
 
207
        LADSPA_Data z2;
 
208
 
 
209
#line 21 "tape_delay_1211.xml"
 
210
        unsigned int mbs = BASE_BUFFER * s_rate;
 
211
        sample_rate = s_rate;
 
212
        for (buffer_size = 4096; buffer_size < mbs;
 
213
             buffer_size *= 2);
 
214
        buffer = malloc(buffer_size * sizeof(LADSPA_Data));
 
215
        buffer_mask = buffer_size - 1;
 
216
        phase = 0;
 
217
        last_phase = 0;
 
218
        last_in = 0.0f;
 
219
        last2_in = 0.0f;
 
220
        last3_in = 0.0f;
 
221
        z0 = 0.0f;
 
222
        z1 = 0.0f;
 
223
        z2 = 0.0f;
 
224
 
 
225
        plugin_data->buffer = buffer;
 
226
        plugin_data->buffer_mask = buffer_mask;
 
227
        plugin_data->buffer_size = buffer_size;
 
228
        plugin_data->last2_in = last2_in;
 
229
        plugin_data->last3_in = last3_in;
 
230
        plugin_data->last_in = last_in;
 
231
        plugin_data->last_phase = last_phase;
 
232
        plugin_data->phase = phase;
 
233
        plugin_data->sample_rate = sample_rate;
 
234
        plugin_data->z0 = z0;
 
235
        plugin_data->z1 = z1;
 
236
        plugin_data->z2 = z2;
 
237
 
 
238
        return (LADSPA_Handle)plugin_data;
 
239
}
 
240
 
 
241
#undef buffer_write
 
242
#undef RUN_ADDING
 
243
#undef RUN_REPLACING
 
244
 
 
245
#define buffer_write(b, v) (b = v)
 
246
#define RUN_ADDING    0
 
247
#define RUN_REPLACING 1
 
248
 
 
249
static void runTapeDelay(LADSPA_Handle instance, unsigned long sample_count) {
 
250
        TapeDelay *plugin_data = (TapeDelay *)instance;
 
251
 
 
252
        /* Tape speed (inches/sec, 1=normal) (float value) */
 
253
        const LADSPA_Data speed = *(plugin_data->speed);
 
254
 
 
255
        /* Dry level (dB) (float value) */
 
256
        const LADSPA_Data da_db = *(plugin_data->da_db);
 
257
 
 
258
        /* Tap 1 distance (inches) (float value) */
 
259
        const LADSPA_Data t1d = *(plugin_data->t1d);
 
260
 
 
261
        /* Tap 1 level (dB) (float value) */
 
262
        const LADSPA_Data t1a_db = *(plugin_data->t1a_db);
 
263
 
 
264
        /* Tap 2 distance (inches) (float value) */
 
265
        const LADSPA_Data t2d = *(plugin_data->t2d);
 
266
 
 
267
        /* Tap 2 level (dB) (float value) */
 
268
        const LADSPA_Data t2a_db = *(plugin_data->t2a_db);
 
269
 
 
270
        /* Tap 3 distance (inches) (float value) */
 
271
        const LADSPA_Data t3d = *(plugin_data->t3d);
 
272
 
 
273
        /* Tap 3 level (dB) (float value) */
 
274
        const LADSPA_Data t3a_db = *(plugin_data->t3a_db);
 
275
 
 
276
        /* Tap 4 distance (inches) (float value) */
 
277
        const LADSPA_Data t4d = *(plugin_data->t4d);
 
278
 
 
279
        /* Tap 4 level (dB) (float value) */
 
280
        const LADSPA_Data t4a_db = *(plugin_data->t4a_db);
 
281
 
 
282
        /* Input (array of floats of length sample_count) */
 
283
        const LADSPA_Data * const input = plugin_data->input;
 
284
 
 
285
        /* Output (array of floats of length sample_count) */
 
286
        LADSPA_Data * const output = plugin_data->output;
 
287
        LADSPA_Data * buffer = plugin_data->buffer;
 
288
        unsigned int buffer_mask = plugin_data->buffer_mask;
 
289
        unsigned int buffer_size = plugin_data->buffer_size;
 
290
        LADSPA_Data last2_in = plugin_data->last2_in;
 
291
        LADSPA_Data last3_in = plugin_data->last3_in;
 
292
        LADSPA_Data last_in = plugin_data->last_in;
 
293
        unsigned int last_phase = plugin_data->last_phase;
 
294
        float phase = plugin_data->phase;
 
295
        int sample_rate = plugin_data->sample_rate;
 
296
        LADSPA_Data z0 = plugin_data->z0;
 
297
        LADSPA_Data z1 = plugin_data->z1;
 
298
        LADSPA_Data z2 = plugin_data->z2;
 
299
 
 
300
#line 59 "tape_delay_1211.xml"
 
301
        unsigned int pos;
 
302
        float increment = f_clamp(speed, 0.0f, 40.0f);
 
303
        float lin_int, lin_inc;
 
304
        unsigned int track;
 
305
        unsigned int fph;
 
306
        LADSPA_Data out;
 
307
        
 
308
        const float da = DB_CO(da_db);
 
309
        const float t1a = DB_CO(t1a_db);
 
310
        const float t2a = DB_CO(t2a_db);
 
311
        const float t3a = DB_CO(t3a_db);
 
312
        const float t4a = DB_CO(t4a_db);
 
313
        const unsigned int t1d_s = f_round(t1d * sample_rate);
 
314
        const unsigned int t2d_s = f_round(t2d * sample_rate);
 
315
        const unsigned int t3d_s = f_round(t3d * sample_rate);
 
316
        const unsigned int t4d_s = f_round(t4d * sample_rate);
 
317
        
 
318
        for (pos = 0; pos < sample_count; pos++) {
 
319
                fph = f_trunc(phase);
 
320
                last_phase = fph;
 
321
                lin_int = phase - (float)fph;
 
322
        
 
323
                out = buffer[(unsigned int)(fph - t1d_s) & buffer_mask] * t1a;
 
324
                out += buffer[(unsigned int)(fph - t2d_s) & buffer_mask] * t2a;
 
325
                out += buffer[(unsigned int)(fph - t3d_s) & buffer_mask] * t3a;
 
326
                out += buffer[(unsigned int)(fph - t4d_s) & buffer_mask] * t4a;
 
327
        
 
328
                phase += increment;
 
329
                lin_inc = 1.0f / (floor(phase) - last_phase + 1);
 
330
                lin_inc = lin_inc > 1.0f ? 1.0f : lin_inc;
 
331
                lin_int = 0.0f;
 
332
                for (track = last_phase; track < phase; track++) {
 
333
                        lin_int += lin_inc;
 
334
                        buffer[track & buffer_mask] =
 
335
                         cube_interp(lin_int, last3_in, last2_in, last_in, input[pos]);
 
336
                }
 
337
                last3_in = last2_in;
 
338
                last2_in = last_in;
 
339
                last_in = input[pos];
 
340
                out += input[pos] * da;
 
341
                buffer_write(output[pos], out);
 
342
                if (phase >= buffer_size) {
 
343
                        phase -= buffer_size;
 
344
                }
 
345
        }
 
346
        
 
347
        // Store current phase in instance
 
348
        plugin_data->phase = phase;
 
349
        plugin_data->last_phase = last_phase;
 
350
        plugin_data->last_in = last_in;
 
351
        plugin_data->last2_in = last2_in;
 
352
        plugin_data->last3_in = last3_in;
 
353
        plugin_data->z0 = z0;
 
354
        plugin_data->z1 = z1;
 
355
        plugin_data->z2 = z2;
 
356
}
 
357
#undef buffer_write
 
358
#undef RUN_ADDING
 
359
#undef RUN_REPLACING
 
360
 
 
361
#define buffer_write(b, v) (b += (v) * run_adding_gain)
 
362
#define RUN_ADDING    1
 
363
#define RUN_REPLACING 0
 
364
 
 
365
static void setRunAddingGainTapeDelay(LADSPA_Handle instance, LADSPA_Data gain) {
 
366
        ((TapeDelay *)instance)->run_adding_gain = gain;
 
367
}
 
368
 
 
369
static void runAddingTapeDelay(LADSPA_Handle instance, unsigned long sample_count) {
 
370
        TapeDelay *plugin_data = (TapeDelay *)instance;
 
371
        LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;
 
372
 
 
373
        /* Tape speed (inches/sec, 1=normal) (float value) */
 
374
        const LADSPA_Data speed = *(plugin_data->speed);
 
375
 
 
376
        /* Dry level (dB) (float value) */
 
377
        const LADSPA_Data da_db = *(plugin_data->da_db);
 
378
 
 
379
        /* Tap 1 distance (inches) (float value) */
 
380
        const LADSPA_Data t1d = *(plugin_data->t1d);
 
381
 
 
382
        /* Tap 1 level (dB) (float value) */
 
383
        const LADSPA_Data t1a_db = *(plugin_data->t1a_db);
 
384
 
 
385
        /* Tap 2 distance (inches) (float value) */
 
386
        const LADSPA_Data t2d = *(plugin_data->t2d);
 
387
 
 
388
        /* Tap 2 level (dB) (float value) */
 
389
        const LADSPA_Data t2a_db = *(plugin_data->t2a_db);
 
390
 
 
391
        /* Tap 3 distance (inches) (float value) */
 
392
        const LADSPA_Data t3d = *(plugin_data->t3d);
 
393
 
 
394
        /* Tap 3 level (dB) (float value) */
 
395
        const LADSPA_Data t3a_db = *(plugin_data->t3a_db);
 
396
 
 
397
        /* Tap 4 distance (inches) (float value) */
 
398
        const LADSPA_Data t4d = *(plugin_data->t4d);
 
399
 
 
400
        /* Tap 4 level (dB) (float value) */
 
401
        const LADSPA_Data t4a_db = *(plugin_data->t4a_db);
 
402
 
 
403
        /* Input (array of floats of length sample_count) */
 
404
        const LADSPA_Data * const input = plugin_data->input;
 
405
 
 
406
        /* Output (array of floats of length sample_count) */
 
407
        LADSPA_Data * const output = plugin_data->output;
 
408
        LADSPA_Data * buffer = plugin_data->buffer;
 
409
        unsigned int buffer_mask = plugin_data->buffer_mask;
 
410
        unsigned int buffer_size = plugin_data->buffer_size;
 
411
        LADSPA_Data last2_in = plugin_data->last2_in;
 
412
        LADSPA_Data last3_in = plugin_data->last3_in;
 
413
        LADSPA_Data last_in = plugin_data->last_in;
 
414
        unsigned int last_phase = plugin_data->last_phase;
 
415
        float phase = plugin_data->phase;
 
416
        int sample_rate = plugin_data->sample_rate;
 
417
        LADSPA_Data z0 = plugin_data->z0;
 
418
        LADSPA_Data z1 = plugin_data->z1;
 
419
        LADSPA_Data z2 = plugin_data->z2;
 
420
 
 
421
#line 59 "tape_delay_1211.xml"
 
422
        unsigned int pos;
 
423
        float increment = f_clamp(speed, 0.0f, 40.0f);
 
424
        float lin_int, lin_inc;
 
425
        unsigned int track;
 
426
        unsigned int fph;
 
427
        LADSPA_Data out;
 
428
        
 
429
        const float da = DB_CO(da_db);
 
430
        const float t1a = DB_CO(t1a_db);
 
431
        const float t2a = DB_CO(t2a_db);
 
432
        const float t3a = DB_CO(t3a_db);
 
433
        const float t4a = DB_CO(t4a_db);
 
434
        const unsigned int t1d_s = f_round(t1d * sample_rate);
 
435
        const unsigned int t2d_s = f_round(t2d * sample_rate);
 
436
        const unsigned int t3d_s = f_round(t3d * sample_rate);
 
437
        const unsigned int t4d_s = f_round(t4d * sample_rate);
 
438
        
 
439
        for (pos = 0; pos < sample_count; pos++) {
 
440
                fph = f_trunc(phase);
 
441
                last_phase = fph;
 
442
                lin_int = phase - (float)fph;
 
443
        
 
444
                out = buffer[(unsigned int)(fph - t1d_s) & buffer_mask] * t1a;
 
445
                out += buffer[(unsigned int)(fph - t2d_s) & buffer_mask] * t2a;
 
446
                out += buffer[(unsigned int)(fph - t3d_s) & buffer_mask] * t3a;
 
447
                out += buffer[(unsigned int)(fph - t4d_s) & buffer_mask] * t4a;
 
448
        
 
449
                phase += increment;
 
450
                lin_inc = 1.0f / (floor(phase) - last_phase + 1);
 
451
                lin_inc = lin_inc > 1.0f ? 1.0f : lin_inc;
 
452
                lin_int = 0.0f;
 
453
                for (track = last_phase; track < phase; track++) {
 
454
                        lin_int += lin_inc;
 
455
                        buffer[track & buffer_mask] =
 
456
                         cube_interp(lin_int, last3_in, last2_in, last_in, input[pos]);
 
457
                }
 
458
                last3_in = last2_in;
 
459
                last2_in = last_in;
 
460
                last_in = input[pos];
 
461
                out += input[pos] * da;
 
462
                buffer_write(output[pos], out);
 
463
                if (phase >= buffer_size) {
 
464
                        phase -= buffer_size;
 
465
                }
 
466
        }
 
467
        
 
468
        // Store current phase in instance
 
469
        plugin_data->phase = phase;
 
470
        plugin_data->last_phase = last_phase;
 
471
        plugin_data->last_in = last_in;
 
472
        plugin_data->last2_in = last2_in;
 
473
        plugin_data->last3_in = last3_in;
 
474
        plugin_data->z0 = z0;
 
475
        plugin_data->z1 = z1;
 
476
        plugin_data->z2 = z2;
 
477
}
 
478
 
 
479
void _init() {
 
480
        char **port_names;
 
481
        LADSPA_PortDescriptor *port_descriptors;
 
482
        LADSPA_PortRangeHint *port_range_hints;
 
483
 
 
484
#ifdef ENABLE_NLS
 
485
#define D_(s) dgettext(PACKAGE, s)
 
486
        setlocale(LC_ALL, "");
 
487
        bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
 
488
#else
 
489
#define D_(s) (s)
 
490
#endif
 
491
 
 
492
 
 
493
        tapeDelayDescriptor =
 
494
         (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));
 
495
 
 
496
        if (tapeDelayDescriptor) {
 
497
                tapeDelayDescriptor->UniqueID = 1211;
 
498
                tapeDelayDescriptor->Label = "tapeDelay";
 
499
                tapeDelayDescriptor->Properties =
 
500
                 0;
 
501
                tapeDelayDescriptor->Name =
 
502
                 D_("Tape Delay Simulation");
 
503
                tapeDelayDescriptor->Maker =
 
504
                 "Steve Harris <steve@plugin.org.uk>";
 
505
                tapeDelayDescriptor->Copyright =
 
506
                 "GPL";
 
507
                tapeDelayDescriptor->PortCount = 12;
 
508
 
 
509
                port_descriptors = (LADSPA_PortDescriptor *)calloc(12,
 
510
                 sizeof(LADSPA_PortDescriptor));
 
511
                tapeDelayDescriptor->PortDescriptors =
 
512
                 (const LADSPA_PortDescriptor *)port_descriptors;
 
513
 
 
514
                port_range_hints = (LADSPA_PortRangeHint *)calloc(12,
 
515
                 sizeof(LADSPA_PortRangeHint));
 
516
                tapeDelayDescriptor->PortRangeHints =
 
517
                 (const LADSPA_PortRangeHint *)port_range_hints;
 
518
 
 
519
                port_names = (char **)calloc(12, sizeof(char*));
 
520
                tapeDelayDescriptor->PortNames =
 
521
                 (const char **)port_names;
 
522
 
 
523
                /* Parameters for Tape speed (inches/sec, 1=normal) */
 
524
                port_descriptors[TAPEDELAY_SPEED] =
 
525
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
526
                port_names[TAPEDELAY_SPEED] =
 
527
                 D_("Tape speed (inches/sec, 1=normal)");
 
528
                port_range_hints[TAPEDELAY_SPEED].HintDescriptor =
 
529
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_1;
 
530
                port_range_hints[TAPEDELAY_SPEED].LowerBound = 0;
 
531
                port_range_hints[TAPEDELAY_SPEED].UpperBound = 10;
 
532
 
 
533
                /* Parameters for Dry level (dB) */
 
534
                port_descriptors[TAPEDELAY_DA_DB] =
 
535
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
536
                port_names[TAPEDELAY_DA_DB] =
 
537
                 D_("Dry level (dB)");
 
538
                port_range_hints[TAPEDELAY_DA_DB].HintDescriptor =
 
539
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MINIMUM;
 
540
                port_range_hints[TAPEDELAY_DA_DB].LowerBound = -90;
 
541
                port_range_hints[TAPEDELAY_DA_DB].UpperBound = 0;
 
542
 
 
543
                /* Parameters for Tap 1 distance (inches) */
 
544
                port_descriptors[TAPEDELAY_T1D] =
 
545
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
546
                port_names[TAPEDELAY_T1D] =
 
547
                 D_("Tap 1 distance (inches)");
 
548
                port_range_hints[TAPEDELAY_T1D].HintDescriptor =
 
549
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
 
550
                port_range_hints[TAPEDELAY_T1D].LowerBound = 0;
 
551
                port_range_hints[TAPEDELAY_T1D].UpperBound = 4;
 
552
 
 
553
                /* Parameters for Tap 1 level (dB) */
 
554
                port_descriptors[TAPEDELAY_T1A_DB] =
 
555
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
556
                port_names[TAPEDELAY_T1A_DB] =
 
557
                 D_("Tap 1 level (dB)");
 
558
                port_range_hints[TAPEDELAY_T1A_DB].HintDescriptor =
 
559
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
 
560
                port_range_hints[TAPEDELAY_T1A_DB].LowerBound = -90;
 
561
                port_range_hints[TAPEDELAY_T1A_DB].UpperBound = 0;
 
562
 
 
563
                /* Parameters for Tap 2 distance (inches) */
 
564
                port_descriptors[TAPEDELAY_T2D] =
 
565
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
566
                port_names[TAPEDELAY_T2D] =
 
567
                 D_("Tap 2 distance (inches)");
 
568
                port_range_hints[TAPEDELAY_T2D].HintDescriptor =
 
569
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW;
 
570
                port_range_hints[TAPEDELAY_T2D].LowerBound = 0;
 
571
                port_range_hints[TAPEDELAY_T2D].UpperBound = 4;
 
572
 
 
573
                /* Parameters for Tap 2 level (dB) */
 
574
                port_descriptors[TAPEDELAY_T2A_DB] =
 
575
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
576
                port_names[TAPEDELAY_T2A_DB] =
 
577
                 D_("Tap 2 level (dB)");
 
578
                port_range_hints[TAPEDELAY_T2A_DB].HintDescriptor =
 
579
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MINIMUM;
 
580
                port_range_hints[TAPEDELAY_T2A_DB].LowerBound = -90;
 
581
                port_range_hints[TAPEDELAY_T2A_DB].UpperBound = 0;
 
582
 
 
583
                /* Parameters for Tap 3 distance (inches) */
 
584
                port_descriptors[TAPEDELAY_T3D] =
 
585
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
586
                port_names[TAPEDELAY_T3D] =
 
587
                 D_("Tap 3 distance (inches)");
 
588
                port_range_hints[TAPEDELAY_T3D].HintDescriptor =
 
589
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE;
 
590
                port_range_hints[TAPEDELAY_T3D].LowerBound = 0;
 
591
                port_range_hints[TAPEDELAY_T3D].UpperBound = 4;
 
592
 
 
593
                /* Parameters for Tap 3 level (dB) */
 
594
                port_descriptors[TAPEDELAY_T3A_DB] =
 
595
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
596
                port_names[TAPEDELAY_T3A_DB] =
 
597
                 D_("Tap 3 level (dB)");
 
598
                port_range_hints[TAPEDELAY_T3A_DB].HintDescriptor =
 
599
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MINIMUM;
 
600
                port_range_hints[TAPEDELAY_T3A_DB].LowerBound = -90;
 
601
                port_range_hints[TAPEDELAY_T3A_DB].UpperBound = 0;
 
602
 
 
603
                /* Parameters for Tap 4 distance (inches) */
 
604
                port_descriptors[TAPEDELAY_T4D] =
 
605
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
606
                port_names[TAPEDELAY_T4D] =
 
607
                 D_("Tap 4 distance (inches)");
 
608
                port_range_hints[TAPEDELAY_T4D].HintDescriptor =
 
609
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_HIGH;
 
610
                port_range_hints[TAPEDELAY_T4D].LowerBound = 0;
 
611
                port_range_hints[TAPEDELAY_T4D].UpperBound = 4;
 
612
 
 
613
                /* Parameters for Tap 4 level (dB) */
 
614
                port_descriptors[TAPEDELAY_T4A_DB] =
 
615
                 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
 
616
                port_names[TAPEDELAY_T4A_DB] =
 
617
                 D_("Tap 4 level (dB)");
 
618
                port_range_hints[TAPEDELAY_T4A_DB].HintDescriptor =
 
619
                 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MINIMUM;
 
620
                port_range_hints[TAPEDELAY_T4A_DB].LowerBound = -90;
 
621
                port_range_hints[TAPEDELAY_T4A_DB].UpperBound = 0;
 
622
 
 
623
                /* Parameters for Input */
 
624
                port_descriptors[TAPEDELAY_INPUT] =
 
625
                 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
 
626
                port_names[TAPEDELAY_INPUT] =
 
627
                 D_("Input");
 
628
                port_range_hints[TAPEDELAY_INPUT].HintDescriptor = 0;
 
629
 
 
630
                /* Parameters for Output */
 
631
                port_descriptors[TAPEDELAY_OUTPUT] =
 
632
                 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
 
633
                port_names[TAPEDELAY_OUTPUT] =
 
634
                 D_("Output");
 
635
                port_range_hints[TAPEDELAY_OUTPUT].HintDescriptor = 0;
 
636
 
 
637
                tapeDelayDescriptor->activate = activateTapeDelay;
 
638
                tapeDelayDescriptor->cleanup = cleanupTapeDelay;
 
639
                tapeDelayDescriptor->connect_port = connectPortTapeDelay;
 
640
                tapeDelayDescriptor->deactivate = NULL;
 
641
                tapeDelayDescriptor->instantiate = instantiateTapeDelay;
 
642
                tapeDelayDescriptor->run = runTapeDelay;
 
643
                tapeDelayDescriptor->run_adding = runAddingTapeDelay;
 
644
                tapeDelayDescriptor->set_run_adding_gain = setRunAddingGainTapeDelay;
 
645
        }
 
646
}
 
647
 
 
648
void _fini() {
 
649
        if (tapeDelayDescriptor) {
 
650
                free((LADSPA_PortDescriptor *)tapeDelayDescriptor->PortDescriptors);
 
651
                free((char **)tapeDelayDescriptor->PortNames);
 
652
                free((LADSPA_PortRangeHint *)tapeDelayDescriptor->PortRangeHints);
 
653
                free(tapeDelayDescriptor);
 
654
        }
 
655
 
 
656
}