11
#define _ISOC9X_SOURCE 1
12
#define _ISOC99_SOURCE 1
13
#define __USE_ISOC99 1
14
#define __USE_ISOC9X 1
21
#define _WINDOWS_DLL_EXPORT_ __declspec(dllexport)
23
void _init(); // forward declaration
25
#define _WINDOWS_DLL_EXPORT_
28
#line 10 "plate_1423.xml"
30
#include "util/waveguide_nl.h"
32
#define LP_INNER 0.96f
33
#define LP_OUTER 0.983f
35
#define RUN_WG(n, junct_a, junct_b) waveguide_nl_process_lin(w[n], junct_a - out[n*2+1], junct_b - out[n*2], out+n*2, out+n*2+1)
38
#define PLATE_DAMPING 1
41
#define PLATE_OUTPUTL 4
42
#define PLATE_OUTPUTR 5
44
static LADSPA_Descriptor *plateDescriptor = NULL;
55
LADSPA_Data run_adding_gain;
59
const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) {
69
return plateDescriptor;
75
static void activatePlate(LADSPA_Handle instance) {
76
Plate *plugin_data = (Plate *)instance;
77
float *out = plugin_data->out;
78
waveguide_nl **w = plugin_data->w;
79
#line 40 "plate_1423.xml"
82
for (i = 0; i < 8; i++) {
83
waveguide_nl_reset(w[i]);
85
plugin_data->out = out;
90
static void cleanupPlate(LADSPA_Handle instance) {
91
#line 85 "plate_1423.xml"
92
Plate *plugin_data = (Plate *)instance;
95
for (i = 0; i < 8; i++) {
96
waveguide_nl_free(plugin_data->w[i]);
99
free(plugin_data->out);
103
static void connectPortPlate(
104
LADSPA_Handle instance,
109
plugin = (Plate *)instance;
115
plugin->damping = data;
121
plugin->input = data;
124
plugin->outputl = data;
127
plugin->outputr = data;
132
static LADSPA_Handle instantiatePlate(
133
const LADSPA_Descriptor *descriptor,
134
unsigned long s_rate) {
135
Plate *plugin_data = (Plate *)malloc(sizeof(Plate));
137
waveguide_nl **w = NULL;
139
#line 26 "plate_1423.xml"
140
w = malloc(8 * sizeof(waveguide_nl *));
141
w[0] = waveguide_nl_new(2389, LP_INNER, 0.04f, 0.0f);
142
w[1] = waveguide_nl_new(4742, LP_INNER, 0.17f, 0.0f);
143
w[2] = waveguide_nl_new(4623, LP_INNER, 0.52f, 0.0f);
144
w[3] = waveguide_nl_new(2142, LP_INNER, 0.48f, 0.0f);
145
w[4] = waveguide_nl_new(5597, LP_OUTER, 0.32f, 0.0f);
146
w[5] = waveguide_nl_new(3692, LP_OUTER, 0.89f, 0.0f);
147
w[6] = waveguide_nl_new(5611, LP_OUTER, 0.28f, 0.0f);
148
w[7] = waveguide_nl_new(3703, LP_OUTER, 0.29f, 0.0f);
150
out = calloc(32, sizeof(float));
152
plugin_data->out = out;
155
return (LADSPA_Handle)plugin_data;
162
#define buffer_write(b, v) (b = v)
164
#define RUN_REPLACING 1
166
static void runPlate(LADSPA_Handle instance, unsigned long sample_count) {
167
Plate *plugin_data = (Plate *)instance;
169
/* Reverb time (float value) */
170
const LADSPA_Data time = *(plugin_data->time);
172
/* Damping (float value) */
173
const LADSPA_Data damping = *(plugin_data->damping);
175
/* Dry/wet mix (float value) */
176
const LADSPA_Data wet = *(plugin_data->wet);
178
/* Input (array of floats of length sample_count) */
179
const LADSPA_Data * const input = plugin_data->input;
181
/* Left output (array of floats of length sample_count) */
182
LADSPA_Data * const outputl = plugin_data->outputl;
184
/* Right output (array of floats of length sample_count) */
185
LADSPA_Data * const outputr = plugin_data->outputr;
186
float * out = plugin_data->out;
187
waveguide_nl ** w = plugin_data->w;
189
#line 48 "plate_1423.xml"
191
const float scale = powf(time * 0.117647f, 1.34f);
192
const float lpscale = 1.0f - damping * 0.93;
194
for (pos=0; pos<8; pos++) {
195
waveguide_nl_set_delay(w[pos], w[pos]->size * scale);
197
for (pos=0; pos<4; pos++) {
198
waveguide_nl_set_fc(w[pos], LP_INNER * lpscale);
200
for (; pos<8; pos++) {
201
waveguide_nl_set_fc(w[pos], LP_OUTER * lpscale);
204
for (pos = 0; pos < sample_count; pos++) {
205
const float alpha = (out[0] + out[2] + out[4] + out[6]) * 0.5f
207
const float beta = (out[1] + out[9] + out[14]) * 0.666666666f;
208
const float gamma = (out[3] + out[8] + out[11]) * 0.666666666f;
209
const float delta = (out[5] + out[10] + out[13]) * 0.666666666f;
210
const float epsilon = (out[7] + out[12] + out[15]) * 0.666666666f;
212
RUN_WG(0, beta, alpha);
213
RUN_WG(1, gamma, alpha);
214
RUN_WG(2, delta, alpha);
215
RUN_WG(3, epsilon, alpha);
216
RUN_WG(4, beta, gamma);
217
RUN_WG(5, gamma, delta);
218
RUN_WG(6, delta, epsilon);
219
RUN_WG(7, epsilon, beta);
221
buffer_write(outputl[pos], beta * wet + input[pos] * (1.0f - wet));
222
buffer_write(outputr[pos], gamma * wet + input[pos] * (1.0f - wet));
229
#define buffer_write(b, v) (b += (v) * run_adding_gain)
231
#define RUN_REPLACING 0
233
static void setRunAddingGainPlate(LADSPA_Handle instance, LADSPA_Data gain) {
234
((Plate *)instance)->run_adding_gain = gain;
237
static void runAddingPlate(LADSPA_Handle instance, unsigned long sample_count) {
238
Plate *plugin_data = (Plate *)instance;
239
LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;
241
/* Reverb time (float value) */
242
const LADSPA_Data time = *(plugin_data->time);
244
/* Damping (float value) */
245
const LADSPA_Data damping = *(plugin_data->damping);
247
/* Dry/wet mix (float value) */
248
const LADSPA_Data wet = *(plugin_data->wet);
250
/* Input (array of floats of length sample_count) */
251
const LADSPA_Data * const input = plugin_data->input;
253
/* Left output (array of floats of length sample_count) */
254
LADSPA_Data * const outputl = plugin_data->outputl;
256
/* Right output (array of floats of length sample_count) */
257
LADSPA_Data * const outputr = plugin_data->outputr;
258
float * out = plugin_data->out;
259
waveguide_nl ** w = plugin_data->w;
261
#line 48 "plate_1423.xml"
263
const float scale = powf(time * 0.117647f, 1.34f);
264
const float lpscale = 1.0f - damping * 0.93;
266
for (pos=0; pos<8; pos++) {
267
waveguide_nl_set_delay(w[pos], w[pos]->size * scale);
269
for (pos=0; pos<4; pos++) {
270
waveguide_nl_set_fc(w[pos], LP_INNER * lpscale);
272
for (; pos<8; pos++) {
273
waveguide_nl_set_fc(w[pos], LP_OUTER * lpscale);
276
for (pos = 0; pos < sample_count; pos++) {
277
const float alpha = (out[0] + out[2] + out[4] + out[6]) * 0.5f
279
const float beta = (out[1] + out[9] + out[14]) * 0.666666666f;
280
const float gamma = (out[3] + out[8] + out[11]) * 0.666666666f;
281
const float delta = (out[5] + out[10] + out[13]) * 0.666666666f;
282
const float epsilon = (out[7] + out[12] + out[15]) * 0.666666666f;
284
RUN_WG(0, beta, alpha);
285
RUN_WG(1, gamma, alpha);
286
RUN_WG(2, delta, alpha);
287
RUN_WG(3, epsilon, alpha);
288
RUN_WG(4, beta, gamma);
289
RUN_WG(5, gamma, delta);
290
RUN_WG(6, delta, epsilon);
291
RUN_WG(7, epsilon, beta);
293
buffer_write(outputl[pos], beta * wet + input[pos] * (1.0f - wet));
294
buffer_write(outputr[pos], gamma * wet + input[pos] * (1.0f - wet));
300
LADSPA_PortDescriptor *port_descriptors;
301
LADSPA_PortRangeHint *port_range_hints;
304
#define D_(s) dgettext(PACKAGE, s)
305
setlocale(LC_ALL, "");
306
bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
313
(LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));
315
if (plateDescriptor) {
316
plateDescriptor->UniqueID = 1423;
317
plateDescriptor->Label = "plate";
318
plateDescriptor->Properties =
319
LADSPA_PROPERTY_HARD_RT_CAPABLE;
320
plateDescriptor->Name =
322
plateDescriptor->Maker =
323
"Steve Harris <steve@plugin.org.uk>";
324
plateDescriptor->Copyright =
326
plateDescriptor->PortCount = 6;
328
port_descriptors = (LADSPA_PortDescriptor *)calloc(6,
329
sizeof(LADSPA_PortDescriptor));
330
plateDescriptor->PortDescriptors =
331
(const LADSPA_PortDescriptor *)port_descriptors;
333
port_range_hints = (LADSPA_PortRangeHint *)calloc(6,
334
sizeof(LADSPA_PortRangeHint));
335
plateDescriptor->PortRangeHints =
336
(const LADSPA_PortRangeHint *)port_range_hints;
338
port_names = (char **)calloc(6, sizeof(char*));
339
plateDescriptor->PortNames =
340
(const char **)port_names;
342
/* Parameters for Reverb time */
343
port_descriptors[PLATE_TIME] =
344
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
345
port_names[PLATE_TIME] =
347
port_range_hints[PLATE_TIME].HintDescriptor =
348
LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE;
349
port_range_hints[PLATE_TIME].LowerBound = 0.01;
350
port_range_hints[PLATE_TIME].UpperBound = 8.5;
352
/* Parameters for Damping */
353
port_descriptors[PLATE_DAMPING] =
354
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
355
port_names[PLATE_DAMPING] =
357
port_range_hints[PLATE_DAMPING].HintDescriptor =
358
LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW;
359
port_range_hints[PLATE_DAMPING].LowerBound = 0;
360
port_range_hints[PLATE_DAMPING].UpperBound = 1;
362
/* Parameters for Dry/wet mix */
363
port_descriptors[PLATE_WET] =
364
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
365
port_names[PLATE_WET] =
367
port_range_hints[PLATE_WET].HintDescriptor =
368
LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW;
369
port_range_hints[PLATE_WET].LowerBound = 0;
370
port_range_hints[PLATE_WET].UpperBound = 1;
372
/* Parameters for Input */
373
port_descriptors[PLATE_INPUT] =
374
LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
375
port_names[PLATE_INPUT] =
377
port_range_hints[PLATE_INPUT].HintDescriptor = 0;
379
/* Parameters for Left output */
380
port_descriptors[PLATE_OUTPUTL] =
381
LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
382
port_names[PLATE_OUTPUTL] =
384
port_range_hints[PLATE_OUTPUTL].HintDescriptor = 0;
386
/* Parameters for Right output */
387
port_descriptors[PLATE_OUTPUTR] =
388
LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
389
port_names[PLATE_OUTPUTR] =
391
port_range_hints[PLATE_OUTPUTR].HintDescriptor = 0;
393
plateDescriptor->activate = activatePlate;
394
plateDescriptor->cleanup = cleanupPlate;
395
plateDescriptor->connect_port = connectPortPlate;
396
plateDescriptor->deactivate = NULL;
397
plateDescriptor->instantiate = instantiatePlate;
398
plateDescriptor->run = runPlate;
399
plateDescriptor->run_adding = runAddingPlate;
400
plateDescriptor->set_run_adding_gain = setRunAddingGainPlate;
405
if (plateDescriptor) {
406
free((LADSPA_PortDescriptor *)plateDescriptor->PortDescriptors);
407
free((char **)plateDescriptor->PortNames);
408
free((LADSPA_PortRangeHint *)plateDescriptor->PortRangeHints);
409
free(plateDescriptor);