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 9 "bandpass_iir_1892.xml"
33
#define BANDPASS_IIR_CENTER 0
34
#define BANDPASS_IIR_WIDTH 1
35
#define BANDPASS_IIR_STAGES 2
36
#define BANDPASS_IIR_INPUT 3
37
#define BANDPASS_IIR_OUTPUT 4
39
static LADSPA_Descriptor *bandpass_iirDescriptor = NULL;
54
LADSPA_Data run_adding_gain;
58
const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) {
68
return bandpass_iirDescriptor;
74
static void activateBandpass_iir(LADSPA_Handle instance) {
75
Bandpass_iir *plugin_data = (Bandpass_iir *)instance;
76
iir_stage_t*first = plugin_data->first;
77
iir_stage_t*gt = plugin_data->gt;
78
iirf_t*iirf = plugin_data->iirf;
79
float lfc = plugin_data->lfc;
80
long sample_rate = plugin_data->sample_rate;
81
iir_stage_t*second = plugin_data->second;
82
float ufc = plugin_data->ufc;
83
#line 36 "bandpass_iir_1892.xml"
85
ufc = (*(plugin_data->center) + *(plugin_data->width)*0.5f)/(float)sample_rate;
86
lfc = (*(plugin_data->center) - *(plugin_data->width)*0.5f)/(float)sample_rate;
87
first = init_iir_stage(IIR_STAGE_LOWPASS,10,3,2);
88
second = init_iir_stage(IIR_STAGE_HIGHPASS,10,3,2);
89
gt = init_iir_stage(IIR_STAGE_BANDPASS,20,3,2);
90
iirf = init_iirf_t(gt);
91
chebyshev(iirf, first, 2*CLAMP((int)(*(plugin_data->stages)),1,10), IIR_STAGE_LOWPASS, ufc, 0.5f);
92
chebyshev(iirf, second, 2*CLAMP((int)(*(plugin_data->stages)),1,10), IIR_STAGE_HIGHPASS, lfc, 0.5f);
93
combine_iir_stages(IIR_STAGE_BANDPASS, gt, first, second,0,0);
94
plugin_data->first = first;
96
plugin_data->iirf = iirf;
97
plugin_data->lfc = lfc;
98
plugin_data->sample_rate = sample_rate;
99
plugin_data->second = second;
100
plugin_data->ufc = ufc;
104
static void cleanupBandpass_iir(LADSPA_Handle instance) {
105
#line 48 "bandpass_iir_1892.xml"
106
Bandpass_iir *plugin_data = (Bandpass_iir *)instance;
107
free_iirf_t(plugin_data->iirf, plugin_data->gt);
108
free_iir_stage(plugin_data->first);
109
free_iir_stage(plugin_data->second);
110
free_iir_stage(plugin_data->gt);
114
static void connectPortBandpass_iir(
115
LADSPA_Handle instance,
118
Bandpass_iir *plugin;
120
plugin = (Bandpass_iir *)instance;
122
case BANDPASS_IIR_CENTER:
123
plugin->center = data;
125
case BANDPASS_IIR_WIDTH:
126
plugin->width = data;
128
case BANDPASS_IIR_STAGES:
129
plugin->stages = data;
131
case BANDPASS_IIR_INPUT:
132
plugin->input = data;
134
case BANDPASS_IIR_OUTPUT:
135
plugin->output = data;
140
static LADSPA_Handle instantiateBandpass_iir(
141
const LADSPA_Descriptor *descriptor,
142
unsigned long s_rate) {
143
Bandpass_iir *plugin_data = (Bandpass_iir *)malloc(sizeof(Bandpass_iir));
144
iir_stage_t*first = NULL;
145
iir_stage_t*gt = NULL;
149
iir_stage_t*second = NULL;
152
#line 24 "bandpass_iir_1892.xml"
153
sample_rate = s_rate;
155
plugin_data->first = first;
156
plugin_data->gt = gt;
157
plugin_data->iirf = iirf;
158
plugin_data->lfc = lfc;
159
plugin_data->sample_rate = sample_rate;
160
plugin_data->second = second;
161
plugin_data->ufc = ufc;
163
return (LADSPA_Handle)plugin_data;
170
#define buffer_write(b, v) (b = v)
172
#define RUN_REPLACING 1
174
static void runBandpass_iir(LADSPA_Handle instance, unsigned long sample_count) {
175
Bandpass_iir *plugin_data = (Bandpass_iir *)instance;
177
/* Center Frequency (Hz) (float value) */
178
const LADSPA_Data center = *(plugin_data->center);
180
/* Bandwidth (Hz) (float value) */
181
const LADSPA_Data width = *(plugin_data->width);
183
/* Stages(2 poles per stage) (float value) */
184
const LADSPA_Data stages = *(plugin_data->stages);
186
/* Input (array of floats of length sample_count) */
187
const LADSPA_Data * const input = plugin_data->input;
189
/* Output (array of floats of length sample_count) */
190
LADSPA_Data * const output = plugin_data->output;
191
iir_stage_t* first = plugin_data->first;
192
iir_stage_t* gt = plugin_data->gt;
193
iirf_t* iirf = plugin_data->iirf;
194
float lfc = plugin_data->lfc;
195
long sample_rate = plugin_data->sample_rate;
196
iir_stage_t* second = plugin_data->second;
197
float ufc = plugin_data->ufc;
199
#line 27 "bandpass_iir_1892.xml"
200
ufc = (center + width*0.5f)/(float)sample_rate;
201
lfc = (center - width*0.5f)/(float)sample_rate;
202
combine_iir_stages(IIR_STAGE_BANDPASS, gt, first, second,
203
chebyshev(iirf, first, 2*CLAMP((int)stages,1,10), IIR_STAGE_LOWPASS, ufc, 0.5f),
204
chebyshev(iirf, second, 2*CLAMP((int)stages,1,10), IIR_STAGE_HIGHPASS, lfc, 0.5f));
205
iir_process_buffer_ns_5(iirf, gt, input, output, sample_count,RUN_ADDING);
211
#define buffer_write(b, v) (b += (v) * run_adding_gain)
213
#define RUN_REPLACING 0
215
static void setRunAddingGainBandpass_iir(LADSPA_Handle instance, LADSPA_Data gain) {
216
((Bandpass_iir *)instance)->run_adding_gain = gain;
219
static void runAddingBandpass_iir(LADSPA_Handle instance, unsigned long sample_count) {
220
Bandpass_iir *plugin_data = (Bandpass_iir *)instance;
221
LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;
223
/* Center Frequency (Hz) (float value) */
224
const LADSPA_Data center = *(plugin_data->center);
226
/* Bandwidth (Hz) (float value) */
227
const LADSPA_Data width = *(plugin_data->width);
229
/* Stages(2 poles per stage) (float value) */
230
const LADSPA_Data stages = *(plugin_data->stages);
232
/* Input (array of floats of length sample_count) */
233
const LADSPA_Data * const input = plugin_data->input;
235
/* Output (array of floats of length sample_count) */
236
LADSPA_Data * const output = plugin_data->output;
237
iir_stage_t* first = plugin_data->first;
238
iir_stage_t* gt = plugin_data->gt;
239
iirf_t* iirf = plugin_data->iirf;
240
float lfc = plugin_data->lfc;
241
long sample_rate = plugin_data->sample_rate;
242
iir_stage_t* second = plugin_data->second;
243
float ufc = plugin_data->ufc;
245
#line 27 "bandpass_iir_1892.xml"
246
ufc = (center + width*0.5f)/(float)sample_rate;
247
lfc = (center - width*0.5f)/(float)sample_rate;
248
combine_iir_stages(IIR_STAGE_BANDPASS, gt, first, second,
249
chebyshev(iirf, first, 2*CLAMP((int)stages,1,10), IIR_STAGE_LOWPASS, ufc, 0.5f),
250
chebyshev(iirf, second, 2*CLAMP((int)stages,1,10), IIR_STAGE_HIGHPASS, lfc, 0.5f));
251
iir_process_buffer_ns_5(iirf, gt, input, output, sample_count,RUN_ADDING);
256
LADSPA_PortDescriptor *port_descriptors;
257
LADSPA_PortRangeHint *port_range_hints;
260
#define D_(s) dgettext(PACKAGE, s)
261
setlocale(LC_ALL, "");
262
bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
268
bandpass_iirDescriptor =
269
(LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));
271
if (bandpass_iirDescriptor) {
272
bandpass_iirDescriptor->UniqueID = 1892;
273
bandpass_iirDescriptor->Label = "bandpass_iir";
274
bandpass_iirDescriptor->Properties =
275
LADSPA_PROPERTY_HARD_RT_CAPABLE;
276
bandpass_iirDescriptor->Name =
277
D_("Glame Bandpass Filter");
278
bandpass_iirDescriptor->Maker =
279
"Alexander Ehlert <mag@glame.de>";
280
bandpass_iirDescriptor->Copyright =
282
bandpass_iirDescriptor->PortCount = 5;
284
port_descriptors = (LADSPA_PortDescriptor *)calloc(5,
285
sizeof(LADSPA_PortDescriptor));
286
bandpass_iirDescriptor->PortDescriptors =
287
(const LADSPA_PortDescriptor *)port_descriptors;
289
port_range_hints = (LADSPA_PortRangeHint *)calloc(5,
290
sizeof(LADSPA_PortRangeHint));
291
bandpass_iirDescriptor->PortRangeHints =
292
(const LADSPA_PortRangeHint *)port_range_hints;
294
port_names = (char **)calloc(5, sizeof(char*));
295
bandpass_iirDescriptor->PortNames =
296
(const char **)port_names;
298
/* Parameters for Center Frequency (Hz) */
299
port_descriptors[BANDPASS_IIR_CENTER] =
300
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
301
port_names[BANDPASS_IIR_CENTER] =
302
D_("Center Frequency (Hz)");
303
port_range_hints[BANDPASS_IIR_CENTER].HintDescriptor =
304
LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE | LADSPA_HINT_SAMPLE_RATE | LADSPA_HINT_LOGARITHMIC;
305
port_range_hints[BANDPASS_IIR_CENTER].LowerBound = 0.0001;
306
port_range_hints[BANDPASS_IIR_CENTER].UpperBound = 0.45;
308
/* Parameters for Bandwidth (Hz) */
309
port_descriptors[BANDPASS_IIR_WIDTH] =
310
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
311
port_names[BANDPASS_IIR_WIDTH] =
312
D_("Bandwidth (Hz)");
313
port_range_hints[BANDPASS_IIR_WIDTH].HintDescriptor =
314
LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_MIDDLE | LADSPA_HINT_SAMPLE_RATE | LADSPA_HINT_LOGARITHMIC;
315
port_range_hints[BANDPASS_IIR_WIDTH].LowerBound = 0.0001;
316
port_range_hints[BANDPASS_IIR_WIDTH].UpperBound = 0.45;
318
/* Parameters for Stages(2 poles per stage) */
319
port_descriptors[BANDPASS_IIR_STAGES] =
320
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
321
port_names[BANDPASS_IIR_STAGES] =
322
D_("Stages(2 poles per stage)");
323
port_range_hints[BANDPASS_IIR_STAGES].HintDescriptor =
324
LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_1 | LADSPA_HINT_INTEGER;
325
port_range_hints[BANDPASS_IIR_STAGES].LowerBound = 1.0;
326
port_range_hints[BANDPASS_IIR_STAGES].UpperBound = 10.0;
328
/* Parameters for Input */
329
port_descriptors[BANDPASS_IIR_INPUT] =
330
LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
331
port_names[BANDPASS_IIR_INPUT] =
333
port_range_hints[BANDPASS_IIR_INPUT].HintDescriptor = 0;
335
/* Parameters for Output */
336
port_descriptors[BANDPASS_IIR_OUTPUT] =
337
LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
338
port_names[BANDPASS_IIR_OUTPUT] =
340
port_range_hints[BANDPASS_IIR_OUTPUT].HintDescriptor = 0;
342
bandpass_iirDescriptor->activate = activateBandpass_iir;
343
bandpass_iirDescriptor->cleanup = cleanupBandpass_iir;
344
bandpass_iirDescriptor->connect_port = connectPortBandpass_iir;
345
bandpass_iirDescriptor->deactivate = NULL;
346
bandpass_iirDescriptor->instantiate = instantiateBandpass_iir;
347
bandpass_iirDescriptor->run = runBandpass_iir;
348
bandpass_iirDescriptor->run_adding = runAddingBandpass_iir;
349
bandpass_iirDescriptor->set_run_adding_gain = setRunAddingGainBandpass_iir;
354
if (bandpass_iirDescriptor) {
355
free((LADSPA_PortDescriptor *)bandpass_iirDescriptor->PortDescriptors);
356
free((char **)bandpass_iirDescriptor->PortNames);
357
free((LADSPA_PortRangeHint *)bandpass_iirDescriptor->PortRangeHints);
358
free(bandpass_iirDescriptor);