diff --git a/plugins/LadspaEffect/swh/CMakeLists.txt b/plugins/LadspaEffect/swh/CMakeLists.txt index 2d8aa2b26..8166dc3b3 100644 --- a/plugins/LadspaEffect/swh/CMakeLists.txt +++ b/plugins/LadspaEffect/swh/CMakeLists.txt @@ -59,6 +59,8 @@ TARGET_LINK_LIBRARIES(gverb_1216 gverb) ADD_LIBRARY(blo STATIC util/blo.c) SET_TARGET_PROPERTIES(blo PROPERTIES COMPILE_FLAGS "${PIC_FLAGS}") +TARGET_LINK_LIBRARIES(analogue_osc_1416 blo) +TARGET_LINK_LIBRARIES(fm_osc_1415 blo) TARGET_LINK_LIBRARIES(hermes_filter_1200 blo) ADD_LIBRARY(rms STATIC util/rms.c) diff --git a/plugins/LadspaEffect/swh/alias_1407.c b/plugins/LadspaEffect/swh/alias_1407.c index c3190e36c..28454a3fc 100644 --- a/plugins/LadspaEffect/swh/alias_1407.c +++ b/plugins/LadspaEffect/swh/alias_1407.c @@ -19,10 +19,10 @@ #ifdef WIN32 #define _WINDOWS_DLL_EXPORT_ __declspec(dllexport) -int bIsFirstTime = 1; +int bIsFirstTime = 1; void __attribute__((constructor)) swh_init(); // forward declaration #else -#define _WINDOWS_DLL_EXPORT_ +#define _WINDOWS_DLL_EXPORT_ #endif @@ -83,7 +83,7 @@ static void connectPortAlias( static LADSPA_Handle instantiateAlias( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Alias *plugin_data = (Alias *)malloc(sizeof(Alias)); + Alias *plugin_data = (Alias *)calloc(1, sizeof(Alias)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -168,7 +168,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -240,12 +239,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (aliasDescriptor) { free((LADSPA_PortDescriptor *)aliasDescriptor->PortDescriptors); free((char **)aliasDescriptor->PortNames); free((LADSPA_PortRangeHint *)aliasDescriptor->PortRangeHints); free(aliasDescriptor); } + aliasDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/allpass_1895.c b/plugins/LadspaEffect/swh/allpass_1895.c index 8bbf534b0..a75182089 100644 --- a/plugins/LadspaEffect/swh/allpass_1895.c +++ b/plugins/LadspaEffect/swh/allpass_1895.c @@ -19,12 +19,14 @@ #ifdef WIN32 #define _WINDOWS_DLL_EXPORT_ __declspec(dllexport) -int bIsFirstTime = 1; +int bIsFirstTime = 1; void __attribute__((constructor)) swh_init(); // forward declaration #else -#define _WINDOWS_DLL_EXPORT_ +#define _WINDOWS_DLL_EXPORT_ #endif +#line 10 "allpass_1895.xml" + #include "ladspa-util.h" #define MIN(a,b) ((a) < (b) ? (a) : (b)) @@ -153,18 +155,19 @@ static void activateAllpass_n(LADSPA_Handle instance) { LADSPA_Data last_delay_time = plugin_data->last_delay_time; unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 56 "allpass_1895.xml" unsigned int minsize, size; - + if (plugin_data->max_delay && *plugin_data->max_delay > 0) minsize = sample_rate * *plugin_data->max_delay; else if (plugin_data->delay_time) minsize = sample_rate * *plugin_data->delay_time; else minsize = sample_rate; /* 1 second default */ - + size = 1; while (size < minsize) size <<= 1; - + /* calloc sets the buffer to zero. */ buffer = calloc(size, sizeof(LADSPA_Data)); if (buffer) @@ -184,6 +187,7 @@ static void activateAllpass_n(LADSPA_Handle instance) { } static void cleanupAllpass_n(LADSPA_Handle instance) { +#line 78 "allpass_1895.xml" Allpass_n *plugin_data = (Allpass_n *)instance; free(plugin_data->buffer); free(instance); @@ -218,18 +222,27 @@ static void connectPortAllpass_n( static LADSPA_Handle instantiateAllpass_n( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Allpass_n *plugin_data = (Allpass_n *)malloc(sizeof(Allpass_n)); + Allpass_n *plugin_data = (Allpass_n *)calloc(1, sizeof(Allpass_n)); LADSPA_Data *buffer = NULL; - unsigned int buffer_mask = 0; - LADSPA_Data delay_samples = 0; - LADSPA_Data feedback = 0; - LADSPA_Data last_decay_time = 0; - LADSPA_Data last_delay_time = 0; - unsigned int sample_rate = 0; - long write_phase = 0; + unsigned int buffer_mask; + LADSPA_Data delay_samples; + LADSPA_Data feedback; + LADSPA_Data last_decay_time; + LADSPA_Data last_delay_time; + unsigned int sample_rate; + long write_phase; +#line 44 "allpass_1895.xml" sample_rate = s_rate; + // Uninitialized variables + buffer_mask = 0; + delay_samples = 0; + feedback = 0; + last_decay_time = 0; + last_delay_time = 0; + write_phase = 0; + plugin_data->buffer = buffer; plugin_data->buffer_mask = buffer_mask; plugin_data->delay_samples = delay_samples; @@ -276,7 +289,8 @@ static void runAllpass_n(LADSPA_Handle instance, unsigned long sample_count) { unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 82 "allpass_1895.xml" + int i; ignore(max_delay); @@ -286,7 +300,7 @@ static void runAllpass_n(LADSPA_Handle instance, unsigned long sample_count) { plugin_data->delay_samples = delay_samples = CALC_DELAY (delay_time); plugin_data->feedback = feedback = calc_feedback (delay_time, decay_time); } - + if (delay_time == last_delay_time) { long read_phase = write_phase - (long)delay_samples; LADSPA_Data *readptr = buffer + (read_phase & buffer_mask); @@ -417,7 +431,8 @@ static void runAddingAllpass_n(LADSPA_Handle instance, unsigned long sample_coun unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 82 "allpass_1895.xml" + int i; ignore(max_delay); @@ -530,6 +545,7 @@ static void activateAllpass_l(LADSPA_Handle instance) { LADSPA_Data last_delay_time = plugin_data->last_delay_time; unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 56 "allpass_1895.xml" unsigned int minsize, size; if (plugin_data->max_delay && *plugin_data->max_delay > 0) @@ -561,6 +577,7 @@ static void activateAllpass_l(LADSPA_Handle instance) { } static void cleanupAllpass_l(LADSPA_Handle instance) { +#line 78 "allpass_1895.xml" Allpass_l *plugin_data = (Allpass_l *)instance; free(plugin_data->buffer); free(instance); @@ -595,18 +612,27 @@ static void connectPortAllpass_l( static LADSPA_Handle instantiateAllpass_l( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Allpass_l *plugin_data = (Allpass_l *)malloc(sizeof(Allpass_l)); + Allpass_l *plugin_data = (Allpass_l *)calloc(1, sizeof(Allpass_l)); LADSPA_Data *buffer = NULL; - unsigned int buffer_mask = 0; - LADSPA_Data delay_samples = 0; - LADSPA_Data feedback = 0; - LADSPA_Data last_decay_time = 0; - LADSPA_Data last_delay_time = 0; - unsigned int sample_rate = 0; - long write_phase = 0; + unsigned int buffer_mask; + LADSPA_Data delay_samples; + LADSPA_Data feedback; + LADSPA_Data last_decay_time; + LADSPA_Data last_delay_time; + unsigned int sample_rate; + long write_phase; +#line 44 "allpass_1895.xml" sample_rate = s_rate; + // Uninitialized variables + buffer_mask = 0; + delay_samples = 0; + feedback = 0; + last_decay_time = 0; + last_delay_time = 0; + write_phase = 0; + plugin_data->buffer = buffer; plugin_data->buffer_mask = buffer_mask; plugin_data->delay_samples = delay_samples; @@ -636,6 +662,9 @@ static void runAllpass_l(LADSPA_Handle instance, unsigned long sample_count) { /* Output (array of floats of length sample_count) */ LADSPA_Data * const out = plugin_data->out; + /* Max Delay (s) (float value) */ + const LADSPA_Data max_delay = *(plugin_data->max_delay); + /* Delay Time (s) (float value) */ const LADSPA_Data delay_time = *(plugin_data->delay_time); @@ -650,7 +679,10 @@ static void runAllpass_l(LADSPA_Handle instance, unsigned long sample_count) { unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 82 "allpass_1895.xml" + int i; + + ignore(max_delay); if (write_phase == 0) { plugin_data->last_delay_time = delay_time; @@ -729,6 +761,9 @@ static void runAddingAllpass_l(LADSPA_Handle instance, unsigned long sample_coun /* Output (array of floats of length sample_count) */ LADSPA_Data * const out = plugin_data->out; + /* Max Delay (s) (float value) */ + const LADSPA_Data max_delay = *(plugin_data->max_delay); + /* Delay Time (s) (float value) */ const LADSPA_Data delay_time = *(plugin_data->delay_time); @@ -743,7 +778,10 @@ static void runAddingAllpass_l(LADSPA_Handle instance, unsigned long sample_coun unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 82 "allpass_1895.xml" + int i; + + ignore(max_delay); if (write_phase == 0) { plugin_data->last_delay_time = delay_time; @@ -811,6 +849,7 @@ static void activateAllpass_c(LADSPA_Handle instance) { LADSPA_Data last_delay_time = plugin_data->last_delay_time; unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 56 "allpass_1895.xml" unsigned int minsize, size; if (plugin_data->max_delay && *plugin_data->max_delay > 0) @@ -842,6 +881,7 @@ static void activateAllpass_c(LADSPA_Handle instance) { } static void cleanupAllpass_c(LADSPA_Handle instance) { +#line 78 "allpass_1895.xml" Allpass_c *plugin_data = (Allpass_c *)instance; free(plugin_data->buffer); free(instance); @@ -876,18 +916,27 @@ static void connectPortAllpass_c( static LADSPA_Handle instantiateAllpass_c( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Allpass_c *plugin_data = (Allpass_c *)malloc(sizeof(Allpass_c)); + Allpass_c *plugin_data = (Allpass_c *)calloc(1, sizeof(Allpass_c)); LADSPA_Data *buffer = NULL; - unsigned int buffer_mask = 0; - LADSPA_Data delay_samples = 0; - LADSPA_Data feedback = 0; - LADSPA_Data last_decay_time = 0; - LADSPA_Data last_delay_time = 0; - unsigned int sample_rate = 0; - long write_phase = 0; + unsigned int buffer_mask; + LADSPA_Data delay_samples; + LADSPA_Data feedback; + LADSPA_Data last_decay_time; + LADSPA_Data last_delay_time; + unsigned int sample_rate; + long write_phase; +#line 44 "allpass_1895.xml" sample_rate = s_rate; + // Uninitialized variables + buffer_mask = 0; + delay_samples = 0; + feedback = 0; + last_decay_time = 0; + last_delay_time = 0; + write_phase = 0; + plugin_data->buffer = buffer; plugin_data->buffer_mask = buffer_mask; plugin_data->delay_samples = delay_samples; @@ -917,6 +966,9 @@ static void runAllpass_c(LADSPA_Handle instance, unsigned long sample_count) { /* Output (array of floats of length sample_count) */ LADSPA_Data * const out = plugin_data->out; + /* Max Delay (s) (float value) */ + const LADSPA_Data max_delay = *(plugin_data->max_delay); + /* Delay Time (s) (float value) */ const LADSPA_Data delay_time = *(plugin_data->delay_time); @@ -931,7 +983,10 @@ static void runAllpass_c(LADSPA_Handle instance, unsigned long sample_count) { unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 82 "allpass_1895.xml" + int i; + + ignore(max_delay); if (write_phase == 0) { plugin_data->last_delay_time = delay_time; @@ -1013,6 +1068,9 @@ static void runAddingAllpass_c(LADSPA_Handle instance, unsigned long sample_coun /* Output (array of floats of length sample_count) */ LADSPA_Data * const out = plugin_data->out; + /* Max Delay (s) (float value) */ + const LADSPA_Data max_delay = *(plugin_data->max_delay); + /* Delay Time (s) (float value) */ const LADSPA_Data delay_time = *(plugin_data->delay_time); @@ -1027,7 +1085,10 @@ static void runAddingAllpass_c(LADSPA_Handle instance, unsigned long sample_coun unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 82 "allpass_1895.xml" + int i; + + ignore(max_delay); if (write_phase == 0) { plugin_data->last_delay_time = delay_time; @@ -1095,7 +1156,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -1346,24 +1406,27 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (allpass_nDescriptor) { free((LADSPA_PortDescriptor *)allpass_nDescriptor->PortDescriptors); free((char **)allpass_nDescriptor->PortNames); free((LADSPA_PortRangeHint *)allpass_nDescriptor->PortRangeHints); free(allpass_nDescriptor); } + allpass_nDescriptor = NULL; if (allpass_lDescriptor) { free((LADSPA_PortDescriptor *)allpass_lDescriptor->PortDescriptors); free((char **)allpass_lDescriptor->PortNames); free((LADSPA_PortRangeHint *)allpass_lDescriptor->PortRangeHints); free(allpass_lDescriptor); } + allpass_lDescriptor = NULL; if (allpass_cDescriptor) { free((LADSPA_PortDescriptor *)allpass_cDescriptor->PortDescriptors); free((char **)allpass_cDescriptor->PortNames); free((LADSPA_PortRangeHint *)allpass_cDescriptor->PortRangeHints); free(allpass_cDescriptor); } + allpass_cDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/am_pitchshift_1433.c b/plugins/LadspaEffect/swh/am_pitchshift_1433.c index 65130c6df..33db768fe 100644 --- a/plugins/LadspaEffect/swh/am_pitchshift_1433.c +++ b/plugins/LadspaEffect/swh/am_pitchshift_1433.c @@ -114,7 +114,7 @@ static void connectPortAmPitchshift( static LADSPA_Handle instantiateAmPitchshift( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - AmPitchshift *plugin_data = (AmPitchshift *)malloc(sizeof(AmPitchshift)); + AmPitchshift *plugin_data = (AmPitchshift *)calloc(1, sizeof(AmPitchshift)); unsigned int count; LADSPA_Data *delay = NULL; unsigned int delay_mask; @@ -366,7 +366,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -455,12 +454,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (amPitchshiftDescriptor) { free((LADSPA_PortDescriptor *)amPitchshiftDescriptor->PortDescriptors); free((char **)amPitchshiftDescriptor->PortNames); free((LADSPA_PortRangeHint *)amPitchshiftDescriptor->PortRangeHints); free(amPitchshiftDescriptor); } + amPitchshiftDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/amp_1181.c b/plugins/LadspaEffect/swh/amp_1181.c index 30e870538..a8f2d924f 100644 --- a/plugins/LadspaEffect/swh/amp_1181.c +++ b/plugins/LadspaEffect/swh/amp_1181.c @@ -86,7 +86,7 @@ static void connectPortAmp( static LADSPA_Handle instantiateAmp( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Amp *plugin_data = (Amp *)malloc(sizeof(Amp)); + Amp *plugin_data = (Amp *)calloc(1, sizeof(Amp)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -161,7 +161,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -233,12 +232,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (ampDescriptor) { free((LADSPA_PortDescriptor *)ampDescriptor->PortDescriptors); free((char **)ampDescriptor->PortNames); free((LADSPA_PortRangeHint *)ampDescriptor->PortRangeHints); free(ampDescriptor); } + ampDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/analogue_osc_1416.c b/plugins/LadspaEffect/swh/analogue_osc_1416.c new file mode 100644 index 000000000..899143e4a --- /dev/null +++ b/plugins/LadspaEffect/swh/analogue_osc_1416.c @@ -0,0 +1,410 @@ +#include +#include +#ifndef WIN32 +#include "config.h" +#endif + +#ifdef ENABLE_NLS +#include +#endif + +#define _ISOC9X_SOURCE 1 +#define _ISOC99_SOURCE 1 +#define __USE_ISOC99 1 +#define __USE_ISOC9X 1 + +#include + +#include "ladspa.h" + +#ifdef WIN32 +#define _WINDOWS_DLL_EXPORT_ __declspec(dllexport) +int bIsFirstTime = 1; +void __attribute__((constructor)) swh_init(); // forward declaration +#else +#define _WINDOWS_DLL_EXPORT_ +#endif + +#line 10 "analogue_osc_1416.xml" + +#include + +#include "ladspa-util.h" +#include "util/blo.h" + +#define ANALOGUEOSC_WAVE 0 +#define ANALOGUEOSC_FREQ 1 +#define ANALOGUEOSC_WARM 2 +#define ANALOGUEOSC_INSTAB 3 +#define ANALOGUEOSC_OUTPUT 4 + +static LADSPA_Descriptor *analogueOscDescriptor = NULL; + +typedef struct { + LADSPA_Data *wave; + LADSPA_Data *freq; + LADSPA_Data *warm; + LADSPA_Data *instab; + LADSPA_Data *output; + float fs; + float itm1; + blo_h_osc * osc; + float otm1; + float otm2; + unsigned int rnda; + unsigned int rndb; + blo_h_tables *tables; + LADSPA_Data run_adding_gain; +} AnalogueOsc; + +_WINDOWS_DLL_EXPORT_ +const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) { + +#ifdef WIN32 + if (bIsFirstTime) { + swh_init(); + bIsFirstTime = 0; + } +#endif + switch (index) { + case 0: + return analogueOscDescriptor; + default: + return NULL; + } +} + +static void cleanupAnalogueOsc(LADSPA_Handle instance) { +#line 37 "analogue_osc_1416.xml" + AnalogueOsc *plugin_data = (AnalogueOsc *)instance; + blo_h_tables_free(plugin_data->tables); + blo_h_free(plugin_data->osc); + free(instance); +} + +static void connectPortAnalogueOsc( + LADSPA_Handle instance, + unsigned long port, + LADSPA_Data *data) { + AnalogueOsc *plugin; + + plugin = (AnalogueOsc *)instance; + switch (port) { + case ANALOGUEOSC_WAVE: + plugin->wave = data; + break; + case ANALOGUEOSC_FREQ: + plugin->freq = data; + break; + case ANALOGUEOSC_WARM: + plugin->warm = data; + break; + case ANALOGUEOSC_INSTAB: + plugin->instab = data; + break; + case ANALOGUEOSC_OUTPUT: + plugin->output = data; + break; + } +} + +static LADSPA_Handle instantiateAnalogueOsc( + const LADSPA_Descriptor *descriptor, + unsigned long s_rate) { + AnalogueOsc *plugin_data = (AnalogueOsc *)calloc(1, sizeof(AnalogueOsc)); + float fs; + float itm1; + blo_h_osc *osc = NULL; + float otm1; + float otm2; + unsigned int rnda; + unsigned int rndb; + blo_h_tables *tables = NULL; + +#line 26 "analogue_osc_1416.xml" + tables = blo_h_tables_new(512); + osc = blo_h_new(tables, BLO_SINE, (float)s_rate); + fs = (float)s_rate; + itm1 = 0.0f; + otm1 = 0.0f; + otm2 = 0.0f; + rnda = 43437; + rndb = 111145; + + plugin_data->fs = fs; + plugin_data->itm1 = itm1; + plugin_data->osc = osc; + plugin_data->otm1 = otm1; + plugin_data->otm2 = otm2; + plugin_data->rnda = rnda; + plugin_data->rndb = rndb; + plugin_data->tables = tables; + + return (LADSPA_Handle)plugin_data; +} + +#undef buffer_write +#undef RUN_ADDING +#undef RUN_REPLACING + +#define buffer_write(b, v) (b = v) +#define RUN_ADDING 0 +#define RUN_REPLACING 1 + +static void runAnalogueOsc(LADSPA_Handle instance, unsigned long sample_count) { + AnalogueOsc *plugin_data = (AnalogueOsc *)instance; + + /* Waveform (1=sin, 2=tri, 3=squ, 4=saw) (float value) */ + const LADSPA_Data wave = *(plugin_data->wave); + + /* Frequency (Hz) (float value) */ + const LADSPA_Data freq = *(plugin_data->freq); + + /* Warmth (float value) */ + const LADSPA_Data warm = *(plugin_data->warm); + + /* Instability (float value) */ + const LADSPA_Data instab = *(plugin_data->instab); + + /* Output (array of floats of length sample_count) */ + LADSPA_Data * const output = plugin_data->output; + float fs = plugin_data->fs; + float itm1 = plugin_data->itm1; + blo_h_osc * osc = plugin_data->osc; + float otm1 = plugin_data->otm1; + float otm2 = plugin_data->otm2; + unsigned int rnda = plugin_data->rnda; + unsigned int rndb = plugin_data->rndb; + blo_h_tables * tables = plugin_data->tables; + +#line 42 "analogue_osc_1416.xml" + unsigned long pos; + LADSPA_Data x, y; + const float q = warm - 0.999f; + const float leak = 1.0f - warm * 0.02f; + const unsigned int max_jump = (unsigned int)f_round(instab * 30000.0f) + 1; + + osc->wave = LIMIT(f_round(wave) - 1, 0, BLO_N_WAVES-1); + osc->nyquist = fs * (0.47f - f_clamp(warm, 0.0f, 1.0f) * 0.41f); + blo_hd_set_freq(osc, freq); + + tables = tables; // So gcc doesn't think it's unused + + for (pos = 0; pos < sample_count; pos++) { + x = blo_hd_run_cub(osc); + rnda += 432577; + rnda *= 47; + rndb += 7643113; + rnda *= 59; + osc->ph.all += (((rnda + rndb)/2) % max_jump) - max_jump/2; + osc->ph.all &= osc->ph_mask; + y = (x - q) / (1.0f - f_exp(-1.2f * (x - q))) + + q / (1.0f - f_exp(1.2f * q)); + /* Catch the case where x ~= q */ + if (fabs(y) > 1.0f) { + y = 0.83333f + q / (1.0f - f_exp(1.2f * q)); + } + otm2 = otm1; + otm1 = leak * otm1 + y - itm1; + itm1 = y; + + buffer_write(output[pos], (otm1 + otm2) * 0.5f); + } + + plugin_data->itm1 = itm1; + plugin_data->otm1 = otm1; + plugin_data->otm2 = otm2; + plugin_data->rnda = rnda; + plugin_data->rndb = rndb; +} +#undef buffer_write +#undef RUN_ADDING +#undef RUN_REPLACING + +#define buffer_write(b, v) (b += (v) * run_adding_gain) +#define RUN_ADDING 1 +#define RUN_REPLACING 0 + +static void setRunAddingGainAnalogueOsc(LADSPA_Handle instance, LADSPA_Data gain) { + ((AnalogueOsc *)instance)->run_adding_gain = gain; +} + +static void runAddingAnalogueOsc(LADSPA_Handle instance, unsigned long sample_count) { + AnalogueOsc *plugin_data = (AnalogueOsc *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; + + /* Waveform (1=sin, 2=tri, 3=squ, 4=saw) (float value) */ + const LADSPA_Data wave = *(plugin_data->wave); + + /* Frequency (Hz) (float value) */ + const LADSPA_Data freq = *(plugin_data->freq); + + /* Warmth (float value) */ + const LADSPA_Data warm = *(plugin_data->warm); + + /* Instability (float value) */ + const LADSPA_Data instab = *(plugin_data->instab); + + /* Output (array of floats of length sample_count) */ + LADSPA_Data * const output = plugin_data->output; + float fs = plugin_data->fs; + float itm1 = plugin_data->itm1; + blo_h_osc * osc = plugin_data->osc; + float otm1 = plugin_data->otm1; + float otm2 = plugin_data->otm2; + unsigned int rnda = plugin_data->rnda; + unsigned int rndb = plugin_data->rndb; + blo_h_tables * tables = plugin_data->tables; + +#line 42 "analogue_osc_1416.xml" + unsigned long pos; + LADSPA_Data x, y; + const float q = warm - 0.999f; + const float leak = 1.0f - warm * 0.02f; + const unsigned int max_jump = (unsigned int)f_round(instab * 30000.0f) + 1; + + osc->wave = LIMIT(f_round(wave) - 1, 0, BLO_N_WAVES-1); + osc->nyquist = fs * (0.47f - f_clamp(warm, 0.0f, 1.0f) * 0.41f); + blo_hd_set_freq(osc, freq); + + tables = tables; // So gcc doesn't think it's unused + + for (pos = 0; pos < sample_count; pos++) { + x = blo_hd_run_cub(osc); + rnda += 432577; + rnda *= 47; + rndb += 7643113; + rnda *= 59; + osc->ph.all += (((rnda + rndb)/2) % max_jump) - max_jump/2; + osc->ph.all &= osc->ph_mask; + y = (x - q) / (1.0f - f_exp(-1.2f * (x - q))) + + q / (1.0f - f_exp(1.2f * q)); + /* Catch the case where x ~= q */ + if (fabs(y) > 1.0f) { + y = 0.83333f + q / (1.0f - f_exp(1.2f * q)); + } + otm2 = otm1; + otm1 = leak * otm1 + y - itm1; + itm1 = y; + + buffer_write(output[pos], (otm1 + otm2) * 0.5f); + } + + plugin_data->itm1 = itm1; + plugin_data->otm1 = otm1; + plugin_data->otm2 = otm2; + plugin_data->rnda = rnda; + plugin_data->rndb = rndb; +} + +void __attribute__((constructor)) swh_init() { + char **port_names; + LADSPA_PortDescriptor *port_descriptors; + LADSPA_PortRangeHint *port_range_hints; + +#ifdef ENABLE_NLS +#define D_(s) dgettext(PACKAGE, s) + bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); +#else +#define D_(s) (s) +#endif + + + analogueOscDescriptor = + (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); + + if (analogueOscDescriptor) { + analogueOscDescriptor->UniqueID = 1416; + analogueOscDescriptor->Label = "analogueOsc"; + analogueOscDescriptor->Properties = + LADSPA_PROPERTY_HARD_RT_CAPABLE; + analogueOscDescriptor->Name = + D_("Analogue Oscillator"); + analogueOscDescriptor->Maker = + "Steve Harris "; + analogueOscDescriptor->Copyright = + "GPL"; + analogueOscDescriptor->PortCount = 5; + + port_descriptors = (LADSPA_PortDescriptor *)calloc(5, + sizeof(LADSPA_PortDescriptor)); + analogueOscDescriptor->PortDescriptors = + (const LADSPA_PortDescriptor *)port_descriptors; + + port_range_hints = (LADSPA_PortRangeHint *)calloc(5, + sizeof(LADSPA_PortRangeHint)); + analogueOscDescriptor->PortRangeHints = + (const LADSPA_PortRangeHint *)port_range_hints; + + port_names = (char **)calloc(5, sizeof(char*)); + analogueOscDescriptor->PortNames = + (const char **)port_names; + + /* Parameters for Waveform (1=sin, 2=tri, 3=squ, 4=saw) */ + port_descriptors[ANALOGUEOSC_WAVE] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[ANALOGUEOSC_WAVE] = + D_("Waveform (1=sin, 2=tri, 3=squ, 4=saw)"); + port_range_hints[ANALOGUEOSC_WAVE].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_INTEGER | LADSPA_HINT_DEFAULT_1; + port_range_hints[ANALOGUEOSC_WAVE].LowerBound = 1; + port_range_hints[ANALOGUEOSC_WAVE].UpperBound = BLO_N_WAVES; + + /* Parameters for Frequency (Hz) */ + port_descriptors[ANALOGUEOSC_FREQ] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[ANALOGUEOSC_FREQ] = + D_("Frequency (Hz)"); + port_range_hints[ANALOGUEOSC_FREQ].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_SAMPLE_RATE | LADSPA_HINT_DEFAULT_440 | LADSPA_HINT_LOGARITHMIC; + port_range_hints[ANALOGUEOSC_FREQ].LowerBound = 0.000001; + port_range_hints[ANALOGUEOSC_FREQ].UpperBound = 0.499; + + /* Parameters for Warmth */ + port_descriptors[ANALOGUEOSC_WARM] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[ANALOGUEOSC_WARM] = + D_("Warmth"); + port_range_hints[ANALOGUEOSC_WARM].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0; + port_range_hints[ANALOGUEOSC_WARM].LowerBound = 0; + port_range_hints[ANALOGUEOSC_WARM].UpperBound = 1; + + /* Parameters for Instability */ + port_descriptors[ANALOGUEOSC_INSTAB] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[ANALOGUEOSC_INSTAB] = + D_("Instability"); + port_range_hints[ANALOGUEOSC_INSTAB].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0; + port_range_hints[ANALOGUEOSC_INSTAB].LowerBound = 0; + port_range_hints[ANALOGUEOSC_INSTAB].UpperBound = 1; + + /* Parameters for Output */ + port_descriptors[ANALOGUEOSC_OUTPUT] = + LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; + port_names[ANALOGUEOSC_OUTPUT] = + D_("Output"); + port_range_hints[ANALOGUEOSC_OUTPUT].HintDescriptor = 0; + + analogueOscDescriptor->activate = NULL; + analogueOscDescriptor->cleanup = cleanupAnalogueOsc; + analogueOscDescriptor->connect_port = connectPortAnalogueOsc; + analogueOscDescriptor->deactivate = NULL; + analogueOscDescriptor->instantiate = instantiateAnalogueOsc; + analogueOscDescriptor->run = runAnalogueOsc; + analogueOscDescriptor->run_adding = runAddingAnalogueOsc; + analogueOscDescriptor->set_run_adding_gain = setRunAddingGainAnalogueOsc; + } +} + +void __attribute__((destructor)) swh_fini() { + if (analogueOscDescriptor) { + free((LADSPA_PortDescriptor *)analogueOscDescriptor->PortDescriptors); + free((char **)analogueOscDescriptor->PortNames); + free((LADSPA_PortRangeHint *)analogueOscDescriptor->PortRangeHints); + free(analogueOscDescriptor); + } + analogueOscDescriptor = NULL; + +} diff --git a/plugins/LadspaEffect/swh/bandpass_a_iir_1893.c b/plugins/LadspaEffect/swh/bandpass_a_iir_1893.c index e46f06511..f663718e3 100644 --- a/plugins/LadspaEffect/swh/bandpass_a_iir_1893.c +++ b/plugins/LadspaEffect/swh/bandpass_a_iir_1893.c @@ -25,6 +25,8 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 9 "bandpass_a_iir_1893.xml" + #include "config.h" #include "util/iir.h" @@ -68,6 +70,7 @@ static void activateBandpass_a_iir(LADSPA_Handle instance) { iir_stage_t*gt = plugin_data->gt; iirf_t*iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 33 "bandpass_a_iir_1893.xml" gt = init_iir_stage(IIR_STAGE_LOWPASS,1,3,2); iirf = init_iirf_t(gt); @@ -79,6 +82,7 @@ static void activateBandpass_a_iir(LADSPA_Handle instance) { } static void cleanupBandpass_a_iir(LADSPA_Handle instance) { +#line 39 "bandpass_a_iir_1893.xml" Bandpass_a_iir *plugin_data = (Bandpass_a_iir *)instance; free_iirf_t(plugin_data->iirf, plugin_data->gt); free_iir_stage(plugin_data->gt); @@ -111,11 +115,12 @@ static void connectPortBandpass_a_iir( static LADSPA_Handle instantiateBandpass_a_iir( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Bandpass_a_iir *plugin_data = (Bandpass_a_iir *)malloc(sizeof(Bandpass_a_iir)); + Bandpass_a_iir *plugin_data = (Bandpass_a_iir *)calloc(1, sizeof(Bandpass_a_iir)); iir_stage_t*gt = NULL; iirf_t*iirf = NULL; long sample_rate; +#line 22 "bandpass_a_iir_1893.xml" sample_rate = s_rate; plugin_data->gt = gt; @@ -135,6 +140,7 @@ static LADSPA_Handle instantiateBandpass_a_iir( static void runBandpass_a_iir(LADSPA_Handle instance, unsigned long sample_count) { Bandpass_a_iir *plugin_data = (Bandpass_a_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Center Frequency (Hz) (float value) */ const LADSPA_Data center = *(plugin_data->center); @@ -151,8 +157,12 @@ static void runBandpass_a_iir(LADSPA_Handle instance, unsigned long sample_count iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 25 "bandpass_a_iir_1893.xml" calc_2polebandpass(iirf, gt, center, width, sample_rate); iir_process_buffer_1s_5(iirf, gt, input, output, sample_count,0); + + // Unused variable + (void)(run_adding_gain); } #undef buffer_write #undef RUN_ADDING @@ -168,6 +178,7 @@ static void setRunAddingGainBandpass_a_iir(LADSPA_Handle instance, LADSPA_Data g static void runAddingBandpass_a_iir(LADSPA_Handle instance, unsigned long sample_count) { Bandpass_a_iir *plugin_data = (Bandpass_a_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Center Frequency (Hz) (float value) */ const LADSPA_Data center = *(plugin_data->center); @@ -184,8 +195,12 @@ static void runAddingBandpass_a_iir(LADSPA_Handle instance, unsigned long sample iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 25 "bandpass_a_iir_1893.xml" calc_2polebandpass(iirf, gt, center, width, sample_rate); iir_process_buffer_1s_5(iirf, gt, input, output, sample_count,0); + + // Unused variable + (void)(run_adding_gain); } void __attribute__((constructor)) swh_init() { @@ -195,7 +210,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -277,12 +291,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (bandpass_a_iirDescriptor) { free((LADSPA_PortDescriptor *)bandpass_a_iirDescriptor->PortDescriptors); free((char **)bandpass_a_iirDescriptor->PortNames); free((LADSPA_PortRangeHint *)bandpass_a_iirDescriptor->PortRangeHints); free(bandpass_a_iirDescriptor); } + bandpass_a_iirDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/bandpass_iir_1892.c b/plugins/LadspaEffect/swh/bandpass_iir_1892.c index b723b8717..a137b899e 100644 --- a/plugins/LadspaEffect/swh/bandpass_iir_1892.c +++ b/plugins/LadspaEffect/swh/bandpass_iir_1892.c @@ -25,6 +25,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 9 "bandpass_iir_1892.xml" #include "config.h" #include "util/iir.h" @@ -79,6 +80,7 @@ static void activateBandpass_iir(LADSPA_Handle instance) { long sample_rate = plugin_data->sample_rate; iir_stage_t*second = plugin_data->second; float ufc = plugin_data->ufc; +#line 43 "bandpass_iir_1892.xml" ufc = (*(plugin_data->center) + *(plugin_data->width)*0.5f)/(float)sample_rate; lfc = (*(plugin_data->center) - *(plugin_data->width)*0.5f)/(float)sample_rate; @@ -100,6 +102,7 @@ static void activateBandpass_iir(LADSPA_Handle instance) { } static void cleanupBandpass_iir(LADSPA_Handle instance) { +#line 55 "bandpass_iir_1892.xml" Bandpass_iir *plugin_data = (Bandpass_iir *)instance; free_iirf_t(plugin_data->iirf, plugin_data->gt); free_iir_stage(plugin_data->first); @@ -137,17 +140,22 @@ static void connectPortBandpass_iir( static LADSPA_Handle instantiateBandpass_iir( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Bandpass_iir *plugin_data = (Bandpass_iir *)malloc(sizeof(Bandpass_iir)); + Bandpass_iir *plugin_data = (Bandpass_iir *)calloc(1, sizeof(Bandpass_iir)); iir_stage_t*first = NULL; iir_stage_t*gt = NULL; iirf_t*iirf = NULL; - float lfc = 0; - long sample_rate = 0; + float lfc; + long sample_rate; iir_stage_t*second = NULL; - float ufc = 0; + float ufc; +#line 24 "bandpass_iir_1892.xml" sample_rate = s_rate; + // Uninitialized variables + lfc = 0; + ufc = 0; + plugin_data->first = first; plugin_data->gt = gt; plugin_data->iirf = iirf; @@ -169,6 +177,7 @@ static LADSPA_Handle instantiateBandpass_iir( static void runBandpass_iir(LADSPA_Handle instance, unsigned long sample_count) { Bandpass_iir *plugin_data = (Bandpass_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Center Frequency (Hz) (float value) */ const LADSPA_Data center = *(plugin_data->center); @@ -192,12 +201,16 @@ static void runBandpass_iir(LADSPA_Handle instance, unsigned long sample_count) iir_stage_t* second = plugin_data->second; float ufc = plugin_data->ufc; +#line 31 "bandpass_iir_1892.xml" ufc = (center + width*0.5f)/(float)sample_rate; lfc = (center - width*0.5f)/(float)sample_rate; combine_iir_stages(IIR_STAGE_BANDPASS, gt, first, second, chebyshev(iirf, first, 2*CLAMP((int)stages,1,10), IIR_STAGE_LOWPASS, ufc, 0.5f), chebyshev(iirf, second, 2*CLAMP((int)stages,1,10), IIR_STAGE_HIGHPASS, lfc, 0.5f)); iir_process_buffer_ns_5(iirf, gt, input, output, sample_count,RUN_ADDING); + + // Unused variable + (void)(run_adding_gain); } #undef buffer_write #undef RUN_ADDING @@ -213,6 +226,7 @@ static void setRunAddingGainBandpass_iir(LADSPA_Handle instance, LADSPA_Data gai static void runAddingBandpass_iir(LADSPA_Handle instance, unsigned long sample_count) { Bandpass_iir *plugin_data = (Bandpass_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Center Frequency (Hz) (float value) */ const LADSPA_Data center = *(plugin_data->center); @@ -236,12 +250,16 @@ static void runAddingBandpass_iir(LADSPA_Handle instance, unsigned long sample_c iir_stage_t* second = plugin_data->second; float ufc = plugin_data->ufc; +#line 31 "bandpass_iir_1892.xml" ufc = (center + width*0.5f)/(float)sample_rate; lfc = (center - width*0.5f)/(float)sample_rate; combine_iir_stages(IIR_STAGE_BANDPASS, gt, first, second, chebyshev(iirf, first, 2*CLAMP((int)stages,1,10), IIR_STAGE_LOWPASS, ufc, 0.5f), chebyshev(iirf, second, 2*CLAMP((int)stages,1,10), IIR_STAGE_HIGHPASS, lfc, 0.5f)); iir_process_buffer_ns_5(iirf, gt, input, output, sample_count,RUN_ADDING); + + // Unused variable + (void)(run_adding_gain); } void __attribute__((constructor)) swh_init() { @@ -251,7 +269,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -343,12 +360,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (bandpass_iirDescriptor) { free((LADSPA_PortDescriptor *)bandpass_iirDescriptor->PortDescriptors); free((char **)bandpass_iirDescriptor->PortNames); free((LADSPA_PortRangeHint *)bandpass_iirDescriptor->PortRangeHints); free(bandpass_iirDescriptor); } + bandpass_iirDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/bode_shifter_1431.c b/plugins/LadspaEffect/swh/bode_shifter_1431.c index 4c48355c6..107a6ec40 100644 --- a/plugins/LadspaEffect/swh/bode_shifter_1431.c +++ b/plugins/LadspaEffect/swh/bode_shifter_1431.c @@ -141,7 +141,7 @@ static void connectPortBodeShifter( static LADSPA_Handle instantiateBodeShifter( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - BodeShifter *plugin_data = (BodeShifter *)malloc(sizeof(BodeShifter)); + BodeShifter *plugin_data = (BodeShifter *)calloc(1, sizeof(BodeShifter)); LADSPA_Data *delay = NULL; unsigned int dptr; float fs; @@ -372,7 +372,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -458,12 +457,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (bodeShifterDescriptor) { free((LADSPA_PortDescriptor *)bodeShifterDescriptor->PortDescriptors); free((char **)bodeShifterDescriptor->PortNames); free((LADSPA_PortRangeHint *)bodeShifterDescriptor->PortRangeHints); free(bodeShifterDescriptor); } + bodeShifterDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/bode_shifter_cv_1432.c b/plugins/LadspaEffect/swh/bode_shifter_cv_1432.c index a9c764e59..ffbc03322 100644 --- a/plugins/LadspaEffect/swh/bode_shifter_cv_1432.c +++ b/plugins/LadspaEffect/swh/bode_shifter_cv_1432.c @@ -160,7 +160,7 @@ static void connectPortBodeShifterCV( static LADSPA_Handle instantiateBodeShifterCV( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - BodeShifterCV *plugin_data = (BodeShifterCV *)malloc(sizeof(BodeShifterCV)); + BodeShifterCV *plugin_data = (BodeShifterCV *)calloc(1, sizeof(BodeShifterCV)); LADSPA_Data *delay = NULL; unsigned int dptr; float fs; @@ -400,7 +400,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -523,12 +522,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (bodeShifterCVDescriptor) { free((LADSPA_PortDescriptor *)bodeShifterCVDescriptor->PortDescriptors); free((char **)bodeShifterCVDescriptor->PortNames); free((LADSPA_PortRangeHint *)bodeShifterCVDescriptor->PortRangeHints); free(bodeShifterCVDescriptor); } + bodeShifterCVDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/butterworth_1902.c b/plugins/LadspaEffect/swh/butterworth_1902.c index 0e218babe..3fc099c66 100644 --- a/plugins/LadspaEffect/swh/butterworth_1902.c +++ b/plugins/LadspaEffect/swh/butterworth_1902.c @@ -25,6 +25,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 9 "butterworth_1902.xml" #include "config.h" #include "util/iir.h" @@ -110,6 +111,7 @@ static void activateBwxover_iir(LADSPA_Handle instance) { iir_stage_t*gt = plugin_data->gt; iirf_t*iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 34 "butterworth_1902.xml" gt = init_iir_stage(IIR_STAGE_LOWPASS,1,3,2); iirf = init_iirf_t(gt); @@ -123,6 +125,7 @@ static void activateBwxover_iir(LADSPA_Handle instance) { } static void cleanupBwxover_iir(LADSPA_Handle instance) { +#line 42 "butterworth_1902.xml" Bwxover_iir *plugin_data = (Bwxover_iir *)instance; free_iirf_t(plugin_data->iirf, plugin_data->gt); free_iir_stage(plugin_data->gt); @@ -158,11 +161,12 @@ static void connectPortBwxover_iir( static LADSPA_Handle instantiateBwxover_iir( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Bwxover_iir *plugin_data = (Bwxover_iir *)malloc(sizeof(Bwxover_iir)); + Bwxover_iir *plugin_data = (Bwxover_iir *)calloc(1, sizeof(Bwxover_iir)); iir_stage_t*gt = NULL; iirf_t*iirf = NULL; long sample_rate; +#line 22 "butterworth_1902.xml" sample_rate = s_rate; plugin_data->gt = gt; @@ -182,6 +186,7 @@ static LADSPA_Handle instantiateBwxover_iir( static void runBwxover_iir(LADSPA_Handle instance, unsigned long sample_count) { Bwxover_iir *plugin_data = (Bwxover_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Cutoff Frequency (Hz) (float value) */ const LADSPA_Data cutoff = *(plugin_data->cutoff); @@ -201,9 +206,13 @@ static void runBwxover_iir(LADSPA_Handle instance, unsigned long sample_count) { iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 25 "butterworth_1902.xml" butterworth_stage(gt, 0, cutoff, resonance, sample_rate); iir_process_buffer_1s_5(iirf, gt, input, lpoutput, sample_count,0); buffer_sub(input, lpoutput, hpoutput, sample_count); + + // Unused variable + (void)(run_adding_gain); } #undef buffer_write #undef RUN_ADDING @@ -219,6 +228,7 @@ static void setRunAddingGainBwxover_iir(LADSPA_Handle instance, LADSPA_Data gain static void runAddingBwxover_iir(LADSPA_Handle instance, unsigned long sample_count) { Bwxover_iir *plugin_data = (Bwxover_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Cutoff Frequency (Hz) (float value) */ const LADSPA_Data cutoff = *(plugin_data->cutoff); @@ -238,9 +248,13 @@ static void runAddingBwxover_iir(LADSPA_Handle instance, unsigned long sample_co iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 25 "butterworth_1902.xml" butterworth_stage(gt, 0, cutoff, resonance, sample_rate); iir_process_buffer_1s_5(iirf, gt, input, lpoutput, sample_count,0); buffer_sub(input, lpoutput, hpoutput, sample_count); + + // Unused variable + (void)(run_adding_gain); } static void activateButtlow_iir(LADSPA_Handle instance) { @@ -248,6 +262,7 @@ static void activateButtlow_iir(LADSPA_Handle instance) { iir_stage_t*gt = plugin_data->gt; iirf_t*iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 34 "butterworth_1902.xml" gt = init_iir_stage(IIR_STAGE_LOWPASS,1,3,2); iirf = init_iirf_t(gt); @@ -261,6 +276,7 @@ static void activateButtlow_iir(LADSPA_Handle instance) { } static void cleanupButtlow_iir(LADSPA_Handle instance) { +#line 42 "butterworth_1902.xml" Buttlow_iir *plugin_data = (Buttlow_iir *)instance; free_iirf_t(plugin_data->iirf, plugin_data->gt); free_iir_stage(plugin_data->gt); @@ -293,11 +309,12 @@ static void connectPortButtlow_iir( static LADSPA_Handle instantiateButtlow_iir( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Buttlow_iir *plugin_data = (Buttlow_iir *)malloc(sizeof(Buttlow_iir)); + Buttlow_iir *plugin_data = (Buttlow_iir *)calloc(1, sizeof(Buttlow_iir)); iir_stage_t*gt = NULL; iirf_t*iirf = NULL; long sample_rate; +#line 22 "butterworth_1902.xml" sample_rate = s_rate; plugin_data->gt = gt; @@ -317,6 +334,7 @@ static LADSPA_Handle instantiateButtlow_iir( static void runButtlow_iir(LADSPA_Handle instance, unsigned long sample_count) { Buttlow_iir *plugin_data = (Buttlow_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Cutoff Frequency (Hz) (float value) */ const LADSPA_Data cutoff = *(plugin_data->cutoff); @@ -333,8 +351,12 @@ static void runButtlow_iir(LADSPA_Handle instance, unsigned long sample_count) { iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 25 "butterworth_1902.xml" butterworth_stage(gt, 0, cutoff, resonance, sample_rate); iir_process_buffer_1s_5(iirf, gt, input, output, sample_count,0); + + // Unused variable + (void)(run_adding_gain); } #undef buffer_write #undef RUN_ADDING @@ -350,6 +372,7 @@ static void setRunAddingGainButtlow_iir(LADSPA_Handle instance, LADSPA_Data gain static void runAddingButtlow_iir(LADSPA_Handle instance, unsigned long sample_count) { Buttlow_iir *plugin_data = (Buttlow_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Cutoff Frequency (Hz) (float value) */ const LADSPA_Data cutoff = *(plugin_data->cutoff); @@ -366,8 +389,12 @@ static void runAddingButtlow_iir(LADSPA_Handle instance, unsigned long sample_co iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 25 "butterworth_1902.xml" butterworth_stage(gt, 0, cutoff, resonance, sample_rate); iir_process_buffer_1s_5(iirf, gt, input, output, sample_count,0); + + // Unused variable + (void)(run_adding_gain); } static void activateButthigh_iir(LADSPA_Handle instance) { @@ -375,6 +402,7 @@ static void activateButthigh_iir(LADSPA_Handle instance) { iir_stage_t*gt = plugin_data->gt; iirf_t*iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 34 "butterworth_1902.xml" gt = init_iir_stage(IIR_STAGE_LOWPASS,1,3,2); iirf = init_iirf_t(gt); @@ -388,6 +416,7 @@ static void activateButthigh_iir(LADSPA_Handle instance) { } static void cleanupButthigh_iir(LADSPA_Handle instance) { +#line 42 "butterworth_1902.xml" Butthigh_iir *plugin_data = (Butthigh_iir *)instance; free_iirf_t(plugin_data->iirf, plugin_data->gt); free_iir_stage(plugin_data->gt); @@ -420,11 +449,12 @@ static void connectPortButthigh_iir( static LADSPA_Handle instantiateButthigh_iir( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Butthigh_iir *plugin_data = (Butthigh_iir *)malloc(sizeof(Butthigh_iir)); + Butthigh_iir *plugin_data = (Butthigh_iir *)calloc(1, sizeof(Butthigh_iir)); iir_stage_t*gt = NULL; iirf_t*iirf = NULL; long sample_rate; +#line 22 "butterworth_1902.xml" sample_rate = s_rate; plugin_data->gt = gt; @@ -444,6 +474,7 @@ static LADSPA_Handle instantiateButthigh_iir( static void runButthigh_iir(LADSPA_Handle instance, unsigned long sample_count) { Butthigh_iir *plugin_data = (Butthigh_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Cutoff Frequency (Hz) (float value) */ const LADSPA_Data cutoff = *(plugin_data->cutoff); @@ -460,8 +491,12 @@ static void runButthigh_iir(LADSPA_Handle instance, unsigned long sample_count) iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 25 "butterworth_1902.xml" butterworth_stage(gt, 1, cutoff, resonance, sample_rate); iir_process_buffer_1s_5(iirf, gt, input, output, sample_count,0); + + // Unused variable + (void)(run_adding_gain); } #undef buffer_write #undef RUN_ADDING @@ -477,6 +512,7 @@ static void setRunAddingGainButthigh_iir(LADSPA_Handle instance, LADSPA_Data gai static void runAddingButthigh_iir(LADSPA_Handle instance, unsigned long sample_count) { Butthigh_iir *plugin_data = (Butthigh_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Cutoff Frequency (Hz) (float value) */ const LADSPA_Data cutoff = *(plugin_data->cutoff); @@ -493,8 +529,12 @@ static void runAddingButthigh_iir(LADSPA_Handle instance, unsigned long sample_c iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 25 "butterworth_1902.xml" butterworth_stage(gt, 1, cutoff, resonance, sample_rate); iir_process_buffer_1s_5(iirf, gt, input, output, sample_count,0); + + // Unused variable + (void)(run_adding_gain); } void __attribute__((constructor)) swh_init() { @@ -504,7 +544,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -741,24 +780,27 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (bwxover_iirDescriptor) { free((LADSPA_PortDescriptor *)bwxover_iirDescriptor->PortDescriptors); free((char **)bwxover_iirDescriptor->PortNames); free((LADSPA_PortRangeHint *)bwxover_iirDescriptor->PortRangeHints); free(bwxover_iirDescriptor); } + bwxover_iirDescriptor = NULL; if (buttlow_iirDescriptor) { free((LADSPA_PortDescriptor *)buttlow_iirDescriptor->PortDescriptors); free((char **)buttlow_iirDescriptor->PortNames); free((LADSPA_PortRangeHint *)buttlow_iirDescriptor->PortRangeHints); free(buttlow_iirDescriptor); } + buttlow_iirDescriptor = NULL; if (butthigh_iirDescriptor) { free((LADSPA_PortDescriptor *)butthigh_iirDescriptor->PortDescriptors); free((char **)butthigh_iirDescriptor->PortNames); free((LADSPA_PortRangeHint *)butthigh_iirDescriptor->PortRangeHints); free(butthigh_iirDescriptor); } + butthigh_iirDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/chebstortion_1430.c b/plugins/LadspaEffect/swh/chebstortion_1430.c index d7b71afa7..d2aa833e2 100644 --- a/plugins/LadspaEffect/swh/chebstortion_1430.c +++ b/plugins/LadspaEffect/swh/chebstortion_1430.c @@ -143,7 +143,7 @@ static void connectPortChebstortion( static LADSPA_Handle instantiateChebstortion( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Chebstortion *plugin_data = (Chebstortion *)malloc(sizeof(Chebstortion)); + Chebstortion *plugin_data = (Chebstortion *)calloc(1, sizeof(Chebstortion)); unsigned int count; float env; float itm1; @@ -321,7 +321,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -399,12 +398,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (chebstortionDescriptor) { free((LADSPA_PortDescriptor *)chebstortionDescriptor->PortDescriptors); free((char **)chebstortionDescriptor->PortNames); free((LADSPA_PortRangeHint *)chebstortionDescriptor->PortRangeHints); free(chebstortionDescriptor); } + chebstortionDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/comb_1190.c b/plugins/LadspaEffect/swh/comb_1190.c index 1e01570ae..20ad6fb8f 100644 --- a/plugins/LadspaEffect/swh/comb_1190.c +++ b/plugins/LadspaEffect/swh/comb_1190.c @@ -121,7 +121,7 @@ static void connectPortComb( static LADSPA_Handle instantiateComb( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Comb *plugin_data = (Comb *)malloc(sizeof(Comb)); + Comb *plugin_data = (Comb *)calloc(1, sizeof(Comb)); long comb_pos; LADSPA_Data *comb_tbl = NULL; float last_offset; @@ -258,7 +258,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -340,12 +339,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (combDescriptor) { free((LADSPA_PortDescriptor *)combDescriptor->PortDescriptors); free((char **)combDescriptor->PortNames); free((LADSPA_PortRangeHint *)combDescriptor->PortRangeHints); free(combDescriptor); } + combDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/comb_1887.c b/plugins/LadspaEffect/swh/comb_1887.c index 23dc53400..cb5c4999a 100644 --- a/plugins/LadspaEffect/swh/comb_1887.c +++ b/plugins/LadspaEffect/swh/comb_1887.c @@ -25,6 +25,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 10 "comb_1887.xml" #include "ladspa-util.h" @@ -151,6 +152,7 @@ static void activateComb_n(LADSPA_Handle instance) { LADSPA_Data last_delay_time = plugin_data->last_delay_time; unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 53 "comb_1887.xml" unsigned int minsize, size; if (plugin_data->max_delay && *plugin_data->max_delay > 0) @@ -182,6 +184,7 @@ static void activateComb_n(LADSPA_Handle instance) { } static void cleanupComb_n(LADSPA_Handle instance) { +#line 75 "comb_1887.xml" Comb_n *plugin_data = (Comb_n *)instance; free(plugin_data->buffer); free(instance); @@ -216,18 +219,27 @@ static void connectPortComb_n( static LADSPA_Handle instantiateComb_n( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Comb_n *plugin_data = (Comb_n *)malloc(sizeof(Comb_n)); + Comb_n *plugin_data = (Comb_n *)calloc(1, sizeof(Comb_n)); LADSPA_Data *buffer = NULL; - unsigned int buffer_mask = 0; - LADSPA_Data delay_samples = 0; - LADSPA_Data feedback = 0; - LADSPA_Data last_decay_time = 0; - LADSPA_Data last_delay_time = 0; - unsigned int sample_rate = 0; - long write_phase = 0; + unsigned int buffer_mask; + LADSPA_Data delay_samples; + LADSPA_Data feedback; + LADSPA_Data last_decay_time; + LADSPA_Data last_delay_time; + unsigned int sample_rate; + long write_phase; +#line 41 "comb_1887.xml" sample_rate = s_rate; + // Uninitialized variables + buffer_mask = 0; + delay_samples = 0; + feedback = 0; + last_decay_time = 0; + last_delay_time = 0; + write_phase = 0; + plugin_data->buffer = buffer; plugin_data->buffer_mask = buffer_mask; plugin_data->delay_samples = delay_samples; @@ -274,7 +286,8 @@ static void runComb_n(LADSPA_Handle instance, unsigned long sample_count) { unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 79 "comb_1887.xml" + int i; i = max_delay; /* stop gcc complaining */ @@ -412,7 +425,8 @@ static void runAddingComb_n(LADSPA_Handle instance, unsigned long sample_count) unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 79 "comb_1887.xml" + int i; i = max_delay; /* stop gcc complaining */ @@ -522,6 +536,7 @@ static void activateComb_l(LADSPA_Handle instance) { LADSPA_Data last_delay_time = plugin_data->last_delay_time; unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 53 "comb_1887.xml" unsigned int minsize, size; if (plugin_data->max_delay && *plugin_data->max_delay > 0) @@ -553,6 +568,7 @@ static void activateComb_l(LADSPA_Handle instance) { } static void cleanupComb_l(LADSPA_Handle instance) { +#line 75 "comb_1887.xml" Comb_l *plugin_data = (Comb_l *)instance; free(plugin_data->buffer); free(instance); @@ -587,18 +603,27 @@ static void connectPortComb_l( static LADSPA_Handle instantiateComb_l( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Comb_l *plugin_data = (Comb_l *)malloc(sizeof(Comb_l)); + Comb_l *plugin_data = (Comb_l *)calloc(1, sizeof(Comb_l)); LADSPA_Data *buffer = NULL; - unsigned int buffer_mask = 0; - LADSPA_Data delay_samples = 0; - LADSPA_Data feedback = 0; - LADSPA_Data last_decay_time = 0; - LADSPA_Data last_delay_time = 0; - unsigned int sample_rate = 0; - long write_phase = 0; + unsigned int buffer_mask; + LADSPA_Data delay_samples; + LADSPA_Data feedback; + LADSPA_Data last_decay_time; + LADSPA_Data last_delay_time; + unsigned int sample_rate; + long write_phase; +#line 41 "comb_1887.xml" sample_rate = s_rate; + // Uninitialized variables + buffer_mask = 0; + delay_samples = 0; + feedback = 0; + last_decay_time = 0; + last_delay_time = 0; + write_phase = 0; + plugin_data->buffer = buffer; plugin_data->buffer_mask = buffer_mask; plugin_data->delay_samples = delay_samples; @@ -645,7 +670,8 @@ static void runComb_l(LADSPA_Handle instance, unsigned long sample_count) { unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 79 "comb_1887.xml" + int i; i = max_delay; @@ -741,7 +767,8 @@ static void runAddingComb_l(LADSPA_Handle instance, unsigned long sample_count) unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 79 "comb_1887.xml" + int i; i = max_delay; @@ -809,6 +836,7 @@ static void activateComb_c(LADSPA_Handle instance) { LADSPA_Data last_delay_time = plugin_data->last_delay_time; unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 53 "comb_1887.xml" unsigned int minsize, size; if (plugin_data->max_delay && *plugin_data->max_delay > 0) @@ -840,6 +868,7 @@ static void activateComb_c(LADSPA_Handle instance) { } static void cleanupComb_c(LADSPA_Handle instance) { +#line 75 "comb_1887.xml" Comb_c *plugin_data = (Comb_c *)instance; free(plugin_data->buffer); free(instance); @@ -874,18 +903,27 @@ static void connectPortComb_c( static LADSPA_Handle instantiateComb_c( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Comb_c *plugin_data = (Comb_c *)malloc(sizeof(Comb_c)); + Comb_c *plugin_data = (Comb_c *)calloc(1, sizeof(Comb_c)); LADSPA_Data *buffer = NULL; - unsigned int buffer_mask = 0; - LADSPA_Data delay_samples = 0; - LADSPA_Data feedback = 0; - LADSPA_Data last_decay_time = 0; - LADSPA_Data last_delay_time = 0; - unsigned int sample_rate = 0; - long write_phase = 0; + unsigned int buffer_mask; + LADSPA_Data delay_samples; + LADSPA_Data feedback; + LADSPA_Data last_decay_time; + LADSPA_Data last_delay_time; + unsigned int sample_rate; + long write_phase; +#line 41 "comb_1887.xml" sample_rate = s_rate; + // Uninitialized variables + buffer_mask = 0; + delay_samples = 0; + feedback = 0; + last_decay_time = 0; + last_delay_time = 0; + write_phase = 0; + plugin_data->buffer = buffer; plugin_data->buffer_mask = buffer_mask; plugin_data->delay_samples = delay_samples; @@ -932,7 +970,8 @@ static void runComb_c(LADSPA_Handle instance, unsigned long sample_count) { unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 79 "comb_1887.xml" + int i; i = max_delay; @@ -1032,7 +1071,8 @@ static void runAddingComb_c(LADSPA_Handle instance, unsigned long sample_count) unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 79 "comb_1887.xml" + int i; i = max_delay; @@ -1101,7 +1141,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -1352,24 +1391,27 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (comb_nDescriptor) { free((LADSPA_PortDescriptor *)comb_nDescriptor->PortDescriptors); free((char **)comb_nDescriptor->PortNames); free((LADSPA_PortRangeHint *)comb_nDescriptor->PortRangeHints); free(comb_nDescriptor); } + comb_nDescriptor = NULL; if (comb_lDescriptor) { free((LADSPA_PortDescriptor *)comb_lDescriptor->PortDescriptors); free((char **)comb_lDescriptor->PortNames); free((LADSPA_PortRangeHint *)comb_lDescriptor->PortRangeHints); free(comb_lDescriptor); } + comb_lDescriptor = NULL; if (comb_cDescriptor) { free((LADSPA_PortDescriptor *)comb_cDescriptor->PortDescriptors); free((char **)comb_cDescriptor->PortNames); free((LADSPA_PortRangeHint *)comb_cDescriptor->PortRangeHints); free(comb_cDescriptor); } + comb_cDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/comb_splitter_1411.c b/plugins/LadspaEffect/swh/comb_splitter_1411.c index 70d78e726..1a82e9204 100644 --- a/plugins/LadspaEffect/swh/comb_splitter_1411.c +++ b/plugins/LadspaEffect/swh/comb_splitter_1411.c @@ -121,7 +121,7 @@ static void connectPortCombSplitter( static LADSPA_Handle instantiateCombSplitter( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - CombSplitter *plugin_data = (CombSplitter *)malloc(sizeof(CombSplitter)); + CombSplitter *plugin_data = (CombSplitter *)calloc(1, sizeof(CombSplitter)); long comb_pos; LADSPA_Data *comb_tbl = NULL; float last_offset; @@ -262,7 +262,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -341,12 +340,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (combSplitterDescriptor) { free((LADSPA_PortDescriptor *)combSplitterDescriptor->PortDescriptors); free((char **)combSplitterDescriptor->PortNames); free((LADSPA_PortRangeHint *)combSplitterDescriptor->PortRangeHints); free(combSplitterDescriptor); } + combSplitterDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/const_1909.c b/plugins/LadspaEffect/swh/const_1909.c index 31633b276..1ede65eac 100644 --- a/plugins/LadspaEffect/swh/const_1909.c +++ b/plugins/LadspaEffect/swh/const_1909.c @@ -93,7 +93,7 @@ static void connectPortConst( static LADSPA_Handle instantiateConst( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Const *plugin_data = (Const *)malloc(sizeof(Const)); + Const *plugin_data = (Const *)calloc(1, sizeof(Const)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -178,7 +178,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -250,12 +249,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (constDescriptor) { free((LADSPA_PortDescriptor *)constDescriptor->PortDescriptors); free((char **)constDescriptor->PortNames); free((LADSPA_PortRangeHint *)constDescriptor->PortRangeHints); free(constDescriptor); } + constDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/crossover_dist_1404.c b/plugins/LadspaEffect/swh/crossover_dist_1404.c index 7ad6c4d3b..947a51876 100644 --- a/plugins/LadspaEffect/swh/crossover_dist_1404.c +++ b/plugins/LadspaEffect/swh/crossover_dist_1404.c @@ -91,7 +91,7 @@ static void connectPortCrossoverDist( static LADSPA_Handle instantiateCrossoverDist( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - CrossoverDist *plugin_data = (CrossoverDist *)malloc(sizeof(CrossoverDist)); + CrossoverDist *plugin_data = (CrossoverDist *)calloc(1, sizeof(CrossoverDist)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -194,7 +194,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -276,12 +275,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (crossoverDistDescriptor) { free((LADSPA_PortDescriptor *)crossoverDistDescriptor->PortDescriptors); free((char **)crossoverDistDescriptor->PortNames); free((LADSPA_PortRangeHint *)crossoverDistDescriptor->PortRangeHints); free(crossoverDistDescriptor); } + crossoverDistDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/dc_remove_1207.c b/plugins/LadspaEffect/swh/dc_remove_1207.c index ff795118f..5d62bd4fb 100644 --- a/plugins/LadspaEffect/swh/dc_remove_1207.c +++ b/plugins/LadspaEffect/swh/dc_remove_1207.c @@ -92,7 +92,7 @@ static void connectPortDcRemove( static LADSPA_Handle instantiateDcRemove( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - DcRemove *plugin_data = (DcRemove *)malloc(sizeof(DcRemove)); + DcRemove *plugin_data = (DcRemove *)calloc(1, sizeof(DcRemove)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -173,7 +173,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -235,12 +234,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (dcRemoveDescriptor) { free((LADSPA_PortDescriptor *)dcRemoveDescriptor->PortDescriptors); free((char **)dcRemoveDescriptor->PortNames); free((LADSPA_PortRangeHint *)dcRemoveDescriptor->PortRangeHints); free(dcRemoveDescriptor); } + dcRemoveDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/decay_1886.c b/plugins/LadspaEffect/swh/decay_1886.c index eab8570d3..ce968f754 100644 --- a/plugins/LadspaEffect/swh/decay_1886.c +++ b/plugins/LadspaEffect/swh/decay_1886.c @@ -25,6 +25,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 10 "decay_1886.xml" #include "ladspa-util.h" @@ -72,6 +73,7 @@ static void activateDecay(LADSPA_Handle instance) { LADSPA_Data last_decay_time = plugin_data->last_decay_time; LADSPA_Data sample_rate = plugin_data->sample_rate; LADSPA_Data y = plugin_data->y; +#line 34 "decay_1886.xml" b = 0.f; y = 0.f; last_decay_time = 0.f; @@ -111,15 +113,22 @@ static void connectPortDecay( static LADSPA_Handle instantiateDecay( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Decay *plugin_data = (Decay *)malloc(sizeof(Decay)); - LADSPA_Data b = 0; - char first_time = 0; - LADSPA_Data last_decay_time = 0; - LADSPA_Data sample_rate = 0; - LADSPA_Data y = 0; + Decay *plugin_data = (Decay *)calloc(1, sizeof(Decay)); + LADSPA_Data b; + char first_time; + LADSPA_Data last_decay_time; + LADSPA_Data sample_rate; + LADSPA_Data y; +#line 24 "decay_1886.xml" sample_rate = s_rate; + // Uninitialized variables + b = 0; + first_time = 0; + last_decay_time = 0; + y = 0; + plugin_data->b = b; plugin_data->first_time = first_time; plugin_data->last_decay_time = last_decay_time; @@ -154,7 +163,8 @@ static void runDecay(LADSPA_Handle instance, unsigned long sample_count) { LADSPA_Data sample_rate = plugin_data->sample_rate; LADSPA_Data y = plugin_data->y; - unsigned int i; +#line 41 "decay_1886.xml" + int i; if (first_time) { plugin_data->last_decay_time = decay_time; @@ -215,7 +225,8 @@ static void runAddingDecay(LADSPA_Handle instance, unsigned long sample_count) { LADSPA_Data sample_rate = plugin_data->sample_rate; LADSPA_Data y = plugin_data->y; - unsigned int i; +#line 41 "decay_1886.xml" + int i; if (first_time) { plugin_data->last_decay_time = decay_time; @@ -254,7 +265,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -325,12 +335,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (decayDescriptor) { free((LADSPA_PortDescriptor *)decayDescriptor->PortDescriptors); free((char **)decayDescriptor->PortNames); free((LADSPA_PortRangeHint *)decayDescriptor->PortRangeHints); free(decayDescriptor); } + decayDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/decimator_1202.c b/plugins/LadspaEffect/swh/decimator_1202.c index 6765d350e..204bbe613 100644 --- a/plugins/LadspaEffect/swh/decimator_1202.c +++ b/plugins/LadspaEffect/swh/decimator_1202.c @@ -95,7 +95,7 @@ static void connectPortDecimator( static LADSPA_Handle instantiateDecimator( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Decimator *plugin_data = (Decimator *)malloc(sizeof(Decimator)); + Decimator *plugin_data = (Decimator *)calloc(1, sizeof(Decimator)); float count; LADSPA_Data last_out; long sample_rate; @@ -247,7 +247,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -335,12 +334,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (decimatorDescriptor) { free((LADSPA_PortDescriptor *)decimatorDescriptor->PortDescriptors); free((char **)decimatorDescriptor->PortNames); free((LADSPA_PortRangeHint *)decimatorDescriptor->PortRangeHints); free(decimatorDescriptor); } + decimatorDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/declip_1195.c b/plugins/LadspaEffect/swh/declip_1195.c index bc3db16c2..66bffe158 100644 --- a/plugins/LadspaEffect/swh/declip_1195.c +++ b/plugins/LadspaEffect/swh/declip_1195.c @@ -84,7 +84,7 @@ static void connectPortDeclip( static LADSPA_Handle instantiateDeclip( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Declip *plugin_data = (Declip *)malloc(sizeof(Declip)); + Declip *plugin_data = (Declip *)calloc(1, sizeof(Declip)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -167,7 +167,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -235,12 +234,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (declipDescriptor) { free((LADSPA_PortDescriptor *)declipDescriptor->PortDescriptors); free((char **)declipDescriptor->PortNames); free((LADSPA_PortRangeHint *)declipDescriptor->PortRangeHints); free(declipDescriptor); } + declipDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/delay_1898.c b/plugins/LadspaEffect/swh/delay_1898.c index 57c8f0195..92450db78 100644 --- a/plugins/LadspaEffect/swh/delay_1898.c +++ b/plugins/LadspaEffect/swh/delay_1898.c @@ -25,6 +25,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 10 "delay_1898.xml" #include "ladspa-util.h" @@ -122,6 +123,7 @@ static void activateDelay_n(LADSPA_Handle instance) { LADSPA_Data last_delay_time = plugin_data->last_delay_time; unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 37 "delay_1898.xml" unsigned int minsize, size; if (plugin_data->max_delay && *plugin_data->max_delay > 0) @@ -151,6 +153,7 @@ static void activateDelay_n(LADSPA_Handle instance) { } static void cleanupDelay_n(LADSPA_Handle instance) { +#line 59 "delay_1898.xml" Delay_n *plugin_data = (Delay_n *)instance; free(plugin_data->buffer); free(instance); @@ -182,16 +185,23 @@ static void connectPortDelay_n( static LADSPA_Handle instantiateDelay_n( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Delay_n *plugin_data = (Delay_n *)malloc(sizeof(Delay_n)); + Delay_n *plugin_data = (Delay_n *)calloc(1, sizeof(Delay_n)); LADSPA_Data *buffer = NULL; - unsigned int buffer_mask = 0; - LADSPA_Data delay_samples = 0; - LADSPA_Data last_delay_time = 0; - unsigned int sample_rate = 0; - long write_phase = 0; + unsigned int buffer_mask; + LADSPA_Data delay_samples; + LADSPA_Data last_delay_time; + unsigned int sample_rate; + long write_phase; +#line 27 "delay_1898.xml" sample_rate = s_rate; + // Uninitialized variables + buffer_mask = 0; + delay_samples = 0; + last_delay_time = 0; + write_phase = 0; + plugin_data->buffer = buffer; plugin_data->buffer_mask = buffer_mask; plugin_data->delay_samples = delay_samples; @@ -219,6 +229,9 @@ static void runDelay_n(LADSPA_Handle instance, unsigned long sample_count) { /* Output (array of floats of length sample_count) */ LADSPA_Data * const out = plugin_data->out; + /* Max Delay (s) (float value) */ + const LADSPA_Data max_delay = *(plugin_data->max_delay); + /* Delay Time (s) (float value) */ const LADSPA_Data delay_time = *(plugin_data->delay_time); LADSPA_Data * buffer = plugin_data->buffer; @@ -228,7 +241,8 @@ static void runDelay_n(LADSPA_Handle instance, unsigned long sample_count) { unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 63 "delay_1898.xml" + int i; if (write_phase == 0) { plugin_data->last_delay_time = delay_time; @@ -286,6 +300,9 @@ static void runDelay_n(LADSPA_Handle instance, unsigned long sample_count) { } plugin_data->write_phase = write_phase; + + // Unused variable + (void)(max_delay); } #undef buffer_write #undef RUN_ADDING @@ -309,6 +326,9 @@ static void runAddingDelay_n(LADSPA_Handle instance, unsigned long sample_count) /* Output (array of floats of length sample_count) */ LADSPA_Data * const out = plugin_data->out; + /* Max Delay (s) (float value) */ + const LADSPA_Data max_delay = *(plugin_data->max_delay); + /* Delay Time (s) (float value) */ const LADSPA_Data delay_time = *(plugin_data->delay_time); LADSPA_Data * buffer = plugin_data->buffer; @@ -318,7 +338,8 @@ static void runAddingDelay_n(LADSPA_Handle instance, unsigned long sample_count) unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 63 "delay_1898.xml" + int i; if (write_phase == 0) { plugin_data->last_delay_time = delay_time; @@ -376,6 +397,9 @@ static void runAddingDelay_n(LADSPA_Handle instance, unsigned long sample_count) } plugin_data->write_phase = write_phase; + + // Unused variable + (void)(max_delay); } static void activateDelay_l(LADSPA_Handle instance) { @@ -386,6 +410,7 @@ static void activateDelay_l(LADSPA_Handle instance) { LADSPA_Data last_delay_time = plugin_data->last_delay_time; unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 37 "delay_1898.xml" unsigned int minsize, size; if (plugin_data->max_delay && *plugin_data->max_delay > 0) @@ -415,6 +440,7 @@ static void activateDelay_l(LADSPA_Handle instance) { } static void cleanupDelay_l(LADSPA_Handle instance) { +#line 59 "delay_1898.xml" Delay_l *plugin_data = (Delay_l *)instance; free(plugin_data->buffer); free(instance); @@ -446,16 +472,23 @@ static void connectPortDelay_l( static LADSPA_Handle instantiateDelay_l( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Delay_l *plugin_data = (Delay_l *)malloc(sizeof(Delay_l)); + Delay_l *plugin_data = (Delay_l *)calloc(1, sizeof(Delay_l)); LADSPA_Data *buffer = NULL; - unsigned int buffer_mask = 0; - LADSPA_Data delay_samples = 0; - LADSPA_Data last_delay_time = 0; - unsigned int sample_rate = 0; - long write_phase = 0; + unsigned int buffer_mask; + LADSPA_Data delay_samples; + LADSPA_Data last_delay_time; + unsigned int sample_rate; + long write_phase; +#line 27 "delay_1898.xml" sample_rate = s_rate; + // Uninitialized variables + buffer_mask = 0; + delay_samples = 0; + last_delay_time = 0; + write_phase = 0; + plugin_data->buffer = buffer; plugin_data->buffer_mask = buffer_mask; plugin_data->delay_samples = delay_samples; @@ -483,6 +516,9 @@ static void runDelay_l(LADSPA_Handle instance, unsigned long sample_count) { /* Output (array of floats of length sample_count) */ LADSPA_Data * const out = plugin_data->out; + /* Max Delay (s) (float value) */ + const LADSPA_Data max_delay = *(plugin_data->max_delay); + /* Delay Time (s) (float value) */ const LADSPA_Data delay_time = *(plugin_data->delay_time); LADSPA_Data * buffer = plugin_data->buffer; @@ -492,7 +528,8 @@ static void runDelay_l(LADSPA_Handle instance, unsigned long sample_count) { unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 63 "delay_1898.xml" + int i; if (write_phase == 0) { plugin_data->last_delay_time = delay_time; @@ -538,6 +575,9 @@ static void runDelay_l(LADSPA_Handle instance, unsigned long sample_count) { } plugin_data->write_phase = write_phase; + + // Unused variable + (void)(max_delay); } #undef buffer_write #undef RUN_ADDING @@ -561,6 +601,9 @@ static void runAddingDelay_l(LADSPA_Handle instance, unsigned long sample_count) /* Output (array of floats of length sample_count) */ LADSPA_Data * const out = plugin_data->out; + /* Max Delay (s) (float value) */ + const LADSPA_Data max_delay = *(plugin_data->max_delay); + /* Delay Time (s) (float value) */ const LADSPA_Data delay_time = *(plugin_data->delay_time); LADSPA_Data * buffer = plugin_data->buffer; @@ -570,7 +613,8 @@ static void runAddingDelay_l(LADSPA_Handle instance, unsigned long sample_count) unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 63 "delay_1898.xml" + int i; if (write_phase == 0) { plugin_data->last_delay_time = delay_time; @@ -616,6 +660,9 @@ static void runAddingDelay_l(LADSPA_Handle instance, unsigned long sample_count) } plugin_data->write_phase = write_phase; + + // Unused variable + (void)(max_delay); } static void activateDelay_c(LADSPA_Handle instance) { @@ -626,6 +673,7 @@ static void activateDelay_c(LADSPA_Handle instance) { LADSPA_Data last_delay_time = plugin_data->last_delay_time; unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 37 "delay_1898.xml" unsigned int minsize, size; if (plugin_data->max_delay && *plugin_data->max_delay > 0) @@ -655,6 +703,7 @@ static void activateDelay_c(LADSPA_Handle instance) { } static void cleanupDelay_c(LADSPA_Handle instance) { +#line 59 "delay_1898.xml" Delay_c *plugin_data = (Delay_c *)instance; free(plugin_data->buffer); free(instance); @@ -686,16 +735,23 @@ static void connectPortDelay_c( static LADSPA_Handle instantiateDelay_c( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Delay_c *plugin_data = (Delay_c *)malloc(sizeof(Delay_c)); + Delay_c *plugin_data = (Delay_c *)calloc(1, sizeof(Delay_c)); LADSPA_Data *buffer = NULL; - unsigned int buffer_mask = 0; - LADSPA_Data delay_samples = 0; - LADSPA_Data last_delay_time = 0; - unsigned int sample_rate = 0; - long write_phase = 0; + unsigned int buffer_mask; + LADSPA_Data delay_samples; + LADSPA_Data last_delay_time; + unsigned int sample_rate; + long write_phase; +#line 27 "delay_1898.xml" sample_rate = s_rate; + // Uninitialized variables + buffer_mask = 0; + delay_samples = 0; + last_delay_time = 0; + write_phase = 0; + plugin_data->buffer = buffer; plugin_data->buffer_mask = buffer_mask; plugin_data->delay_samples = delay_samples; @@ -723,6 +779,9 @@ static void runDelay_c(LADSPA_Handle instance, unsigned long sample_count) { /* Output (array of floats of length sample_count) */ LADSPA_Data * const out = plugin_data->out; + /* Max Delay (s) (float value) */ + const LADSPA_Data max_delay = *(plugin_data->max_delay); + /* Delay Time (s) (float value) */ const LADSPA_Data delay_time = *(plugin_data->delay_time); LADSPA_Data * buffer = plugin_data->buffer; @@ -732,7 +791,8 @@ static void runDelay_c(LADSPA_Handle instance, unsigned long sample_count) { unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 63 "delay_1898.xml" + int i; if (write_phase == 0) { plugin_data->last_delay_time = delay_time; @@ -780,6 +840,9 @@ static void runDelay_c(LADSPA_Handle instance, unsigned long sample_count) { } plugin_data->write_phase = write_phase; + + // Unused variable + (void)(max_delay); } #undef buffer_write #undef RUN_ADDING @@ -803,6 +866,9 @@ static void runAddingDelay_c(LADSPA_Handle instance, unsigned long sample_count) /* Output (array of floats of length sample_count) */ LADSPA_Data * const out = plugin_data->out; + /* Max Delay (s) (float value) */ + const LADSPA_Data max_delay = *(plugin_data->max_delay); + /* Delay Time (s) (float value) */ const LADSPA_Data delay_time = *(plugin_data->delay_time); LADSPA_Data * buffer = plugin_data->buffer; @@ -812,7 +878,8 @@ static void runAddingDelay_c(LADSPA_Handle instance, unsigned long sample_count) unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; - unsigned int i; +#line 63 "delay_1898.xml" + int i; if (write_phase == 0) { plugin_data->last_delay_time = delay_time; @@ -860,6 +927,9 @@ static void runAddingDelay_c(LADSPA_Handle instance, unsigned long sample_count) } plugin_data->write_phase = write_phase; + + // Unused variable + (void)(max_delay); } void __attribute__((constructor)) swh_init() { @@ -869,7 +939,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -1093,24 +1162,27 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (delay_nDescriptor) { free((LADSPA_PortDescriptor *)delay_nDescriptor->PortDescriptors); free((char **)delay_nDescriptor->PortNames); free((LADSPA_PortRangeHint *)delay_nDescriptor->PortRangeHints); free(delay_nDescriptor); } + delay_nDescriptor = NULL; if (delay_lDescriptor) { free((LADSPA_PortDescriptor *)delay_lDescriptor->PortDescriptors); free((char **)delay_lDescriptor->PortNames); free((LADSPA_PortRangeHint *)delay_lDescriptor->PortRangeHints); free(delay_lDescriptor); } + delay_lDescriptor = NULL; if (delay_cDescriptor) { free((LADSPA_PortDescriptor *)delay_cDescriptor->PortDescriptors); free((char **)delay_cDescriptor->PortNames); free((LADSPA_PortRangeHint *)delay_cDescriptor->PortRangeHints); free(delay_cDescriptor); } + delay_cDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/delayorama_1402.c b/plugins/LadspaEffect/swh/delayorama_1402.c index a5d1bcce8..122360d27 100644 --- a/plugins/LadspaEffect/swh/delayorama_1402.c +++ b/plugins/LadspaEffect/swh/delayorama_1402.c @@ -214,7 +214,7 @@ static void connectPortDelayorama( static LADSPA_Handle instantiateDelayorama( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Delayorama *plugin_data = (Delayorama *)malloc(sizeof(Delayorama)); + Delayorama *plugin_data = (Delayorama *)calloc(1, sizeof(Delayorama)); unsigned int active_set; LADSPA_Data *buffer = NULL; unsigned long buffer_pos; @@ -675,7 +675,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -847,12 +846,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (delayoramaDescriptor) { free((LADSPA_PortDescriptor *)delayoramaDescriptor->PortDescriptors); free((char **)delayoramaDescriptor->PortNames); free((LADSPA_PortRangeHint *)delayoramaDescriptor->PortRangeHints); free(delayoramaDescriptor); } + delayoramaDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/diode_1185.c b/plugins/LadspaEffect/swh/diode_1185.c index bce602ae4..c5283c983 100644 --- a/plugins/LadspaEffect/swh/diode_1185.c +++ b/plugins/LadspaEffect/swh/diode_1185.c @@ -83,7 +83,7 @@ static void connectPortDiode( static LADSPA_Handle instantiateDiode( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Diode *plugin_data = (Diode *)malloc(sizeof(Diode)); + Diode *plugin_data = (Diode *)calloc(1, sizeof(Diode)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -192,7 +192,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -264,12 +263,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (diodeDescriptor) { free((LADSPA_PortDescriptor *)diodeDescriptor->PortDescriptors); free((char **)diodeDescriptor->PortNames); free((LADSPA_PortRangeHint *)diodeDescriptor->PortRangeHints); free(diodeDescriptor); } + diodeDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/divider_1186.c b/plugins/LadspaEffect/swh/divider_1186.c index 6c7de0170..f3443e7af 100644 --- a/plugins/LadspaEffect/swh/divider_1186.c +++ b/plugins/LadspaEffect/swh/divider_1186.c @@ -89,7 +89,7 @@ static void connectPortDivider( static LADSPA_Handle instantiateDivider( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Divider *plugin_data = (Divider *)malloc(sizeof(Divider)); + Divider *plugin_data = (Divider *)calloc(1, sizeof(Divider)); LADSPA_Data amp; float count; LADSPA_Data lamp; @@ -256,7 +256,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -331,12 +330,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (dividerDescriptor) { free((LADSPA_PortDescriptor *)dividerDescriptor->PortDescriptors); free((char **)dividerDescriptor->PortNames); free((LADSPA_PortRangeHint *)dividerDescriptor->PortRangeHints); free(dividerDescriptor); } + dividerDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/dj_eq_1901.c b/plugins/LadspaEffect/swh/dj_eq_1901.c index 65205c123..f255a2651 100644 --- a/plugins/LadspaEffect/swh/dj_eq_1901.c +++ b/plugins/LadspaEffect/swh/dj_eq_1901.c @@ -116,6 +116,7 @@ static void activateDj_eq_mono(LADSPA_Handle instance) { } static void cleanupDj_eq_mono(LADSPA_Handle instance) { +#line 60 "dj_eq_1901.xml" Dj_eq_mono *plugin_data = (Dj_eq_mono *)instance; free(plugin_data->filters); free(instance); @@ -153,7 +154,7 @@ static void connectPortDj_eq_mono( static LADSPA_Handle instantiateDj_eq_mono( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Dj_eq_mono *plugin_data = (Dj_eq_mono *)malloc(sizeof(Dj_eq_mono)); + Dj_eq_mono *plugin_data = (Dj_eq_mono *)calloc(1, sizeof(Dj_eq_mono)); biquad *filters = NULL; float fs; @@ -285,6 +286,7 @@ static void activateDj_eq(LADSPA_Handle instance) { } static void cleanupDj_eq(LADSPA_Handle instance) { +#line 60 "dj_eq_1901.xml" Dj_eq *plugin_data = (Dj_eq *)instance; free(plugin_data->filters); free(instance); @@ -328,7 +330,7 @@ static void connectPortDj_eq( static LADSPA_Handle instantiateDj_eq( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Dj_eq *plugin_data = (Dj_eq *)malloc(sizeof(Dj_eq)); + Dj_eq *plugin_data = (Dj_eq *)calloc(1, sizeof(Dj_eq)); biquad *filters = NULL; float fs; @@ -474,7 +476,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -678,18 +679,20 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (dj_eq_monoDescriptor) { free((LADSPA_PortDescriptor *)dj_eq_monoDescriptor->PortDescriptors); free((char **)dj_eq_monoDescriptor->PortNames); free((LADSPA_PortRangeHint *)dj_eq_monoDescriptor->PortRangeHints); free(dj_eq_monoDescriptor); } + dj_eq_monoDescriptor = NULL; if (dj_eqDescriptor) { free((LADSPA_PortDescriptor *)dj_eqDescriptor->PortDescriptors); free((char **)dj_eqDescriptor->PortNames); free((LADSPA_PortRangeHint *)dj_eqDescriptor->PortRangeHints); free(dj_eqDescriptor); } + dj_eqDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/dj_flanger_1438.c b/plugins/LadspaEffect/swh/dj_flanger_1438.c index 1c7a9ce2d..fb59507f2 100644 --- a/plugins/LadspaEffect/swh/dj_flanger_1438.c +++ b/plugins/LadspaEffect/swh/dj_flanger_1438.c @@ -136,7 +136,7 @@ static void connectPortDjFlanger( static LADSPA_Handle instantiateDjFlanger( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - DjFlanger *plugin_data = (DjFlanger *)malloc(sizeof(DjFlanger)); + DjFlanger *plugin_data = (DjFlanger *)calloc(1, sizeof(DjFlanger)); LADSPA_Data *buffer = NULL; unsigned int buffer_mask; unsigned int buffer_pos; @@ -373,7 +373,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -472,12 +471,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (djFlangerDescriptor) { free((LADSPA_PortDescriptor *)djFlangerDescriptor->PortDescriptors); free((char **)djFlangerDescriptor->PortNames); free((LADSPA_PortRangeHint *)djFlangerDescriptor->PortRangeHints); free(djFlangerDescriptor); } + djFlangerDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/dyson_compress_1403.c b/plugins/LadspaEffect/swh/dyson_compress_1403.c index 552edb7b0..90fc76919 100644 --- a/plugins/LadspaEffect/swh/dyson_compress_1403.c +++ b/plugins/LadspaEffect/swh/dyson_compress_1403.c @@ -254,7 +254,7 @@ static void connectPortDysonCompress( static LADSPA_Handle instantiateDysonCompress( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - DysonCompress *plugin_data = (DysonCompress *)malloc(sizeof(DysonCompress)); + DysonCompress *plugin_data = (DysonCompress *)calloc(1, sizeof(DysonCompress)); LADSPA_Data *delay = NULL; float extra_maxlevel; float lastrgain; @@ -783,7 +783,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -885,12 +884,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (dysonCompressDescriptor) { free((LADSPA_PortDescriptor *)dysonCompressDescriptor->PortDescriptors); free((char **)dysonCompressDescriptor->PortNames); free((LADSPA_PortRangeHint *)dysonCompressDescriptor->PortRangeHints); free(dysonCompressDescriptor); } + dysonCompressDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/fad_delay_1192.c b/plugins/LadspaEffect/swh/fad_delay_1192.c index 422e769d9..074f90971 100644 --- a/plugins/LadspaEffect/swh/fad_delay_1192.c +++ b/plugins/LadspaEffect/swh/fad_delay_1192.c @@ -25,6 +25,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 8 "fad_delay_1192.xml" #include "ladspa-util.h" @@ -78,7 +79,8 @@ static void activateFadDelay(LADSPA_Handle instance) { int last_phase = plugin_data->last_phase; float phase = plugin_data->phase; long sample_rate = plugin_data->sample_rate; - unsigned int i; +#line 35 "fad_delay_1192.xml" + int i; for (i = 0; i < buffer_size; i++) { buffer[i] = 0; @@ -86,6 +88,7 @@ static void activateFadDelay(LADSPA_Handle instance) { phase = 0; last_phase = 0; last_in = 0.0f; + sample_rate = sample_rate; plugin_data->buffer = buffer; plugin_data->buffer_mask = buffer_mask; plugin_data->buffer_size = buffer_size; @@ -97,6 +100,7 @@ static void activateFadDelay(LADSPA_Handle instance) { } static void cleanupFadDelay(LADSPA_Handle instance) { +#line 47 "fad_delay_1192.xml" FadDelay *plugin_data = (FadDelay *)instance; free(plugin_data->buffer); free(instance); @@ -128,7 +132,7 @@ static void connectPortFadDelay( static LADSPA_Handle instantiateFadDelay( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - FadDelay *plugin_data = (FadDelay *)malloc(sizeof(FadDelay)); + FadDelay *plugin_data = (FadDelay *)calloc(1, sizeof(FadDelay)); LADSPA_Data *buffer = NULL; unsigned long buffer_mask; unsigned long buffer_size; @@ -137,6 +141,7 @@ static LADSPA_Handle instantiateFadDelay( float phase; long sample_rate; +#line 21 "fad_delay_1192.xml" unsigned int min_bs; sample_rate = s_rate; @@ -190,7 +195,8 @@ static void runFadDelay(LADSPA_Handle instance, unsigned long sample_count) { float phase = plugin_data->phase; long sample_rate = plugin_data->sample_rate; - unsigned long int pos; +#line 51 "fad_delay_1192.xml" + long int pos; float increment = (float)buffer_size / ((float)sample_rate * f_max(fabs(delay), 0.01)); float lin_int, lin_inc; @@ -261,7 +267,8 @@ static void runAddingFadDelay(LADSPA_Handle instance, unsigned long sample_count float phase = plugin_data->phase; long sample_rate = plugin_data->sample_rate; - unsigned long int pos; +#line 51 "fad_delay_1192.xml" + long int pos; float increment = (float)buffer_size / ((float)sample_rate * f_max(fabs(delay), 0.01)); float lin_int, lin_inc; @@ -305,7 +312,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -387,12 +393,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (fadDelayDescriptor) { free((LADSPA_PortDescriptor *)fadDelayDescriptor->PortDescriptors); free((char **)fadDelayDescriptor->PortNames); free((LADSPA_PortRangeHint *)fadDelayDescriptor->PortRangeHints); free(fadDelayDescriptor); } + fadDelayDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/fast_lookahead_limiter_1913.c b/plugins/LadspaEffect/swh/fast_lookahead_limiter_1913.c index eecd72e8e..8e81ea47a 100644 --- a/plugins/LadspaEffect/swh/fast_lookahead_limiter_1913.c +++ b/plugins/LadspaEffect/swh/fast_lookahead_limiter_1913.c @@ -182,7 +182,7 @@ static void connectPortFastLookaheadLimiter( static LADSPA_Handle instantiateFastLookaheadLimiter( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - FastLookaheadLimiter *plugin_data = (FastLookaheadLimiter *)malloc(sizeof(FastLookaheadLimiter)); + FastLookaheadLimiter *plugin_data = (FastLookaheadLimiter *)calloc(1, sizeof(FastLookaheadLimiter)); float atten; float atten_lp; LADSPA_Data *buffer = NULL; @@ -581,7 +581,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -704,12 +703,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (fastLookaheadLimiterDescriptor) { free((LADSPA_PortDescriptor *)fastLookaheadLimiterDescriptor->PortDescriptors); free((char **)fastLookaheadLimiterDescriptor->PortNames); free((LADSPA_PortRangeHint *)fastLookaheadLimiterDescriptor->PortRangeHints); free(fastLookaheadLimiterDescriptor); } + fastLookaheadLimiterDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/flanger_1191.c b/plugins/LadspaEffect/swh/flanger_1191.c index e5741f2e5..7ea70e3f4 100644 --- a/plugins/LadspaEffect/swh/flanger_1191.c +++ b/plugins/LadspaEffect/swh/flanger_1191.c @@ -144,7 +144,7 @@ static void connectPortFlanger( static LADSPA_Handle instantiateFlanger( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Flanger *plugin_data = (Flanger *)malloc(sizeof(Flanger)); + Flanger *plugin_data = (Flanger *)calloc(1, sizeof(Flanger)); long count; long delay_pos; long delay_size; @@ -442,7 +442,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -544,12 +543,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (flangerDescriptor) { free((LADSPA_PortDescriptor *)flangerDescriptor->PortDescriptors); free((char **)flangerDescriptor->PortNames); free((LADSPA_PortRangeHint *)flangerDescriptor->PortRangeHints); free(flangerDescriptor); } + flangerDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/fm_osc_1415.c b/plugins/LadspaEffect/swh/fm_osc_1415.c new file mode 100644 index 000000000..06e2566dd --- /dev/null +++ b/plugins/LadspaEffect/swh/fm_osc_1415.c @@ -0,0 +1,272 @@ +#include +#include +#ifndef WIN32 +#include "config.h" +#endif + +#ifdef ENABLE_NLS +#include +#endif + +#define _ISOC9X_SOURCE 1 +#define _ISOC99_SOURCE 1 +#define __USE_ISOC99 1 +#define __USE_ISOC9X 1 + +#include + +#include "ladspa.h" + +#ifdef WIN32 +#define _WINDOWS_DLL_EXPORT_ __declspec(dllexport) +int bIsFirstTime = 1; +void __attribute__((constructor)) swh_init(); // forward declaration +#else +#define _WINDOWS_DLL_EXPORT_ +#endif + +#line 10 "fm_osc_1415.xml" + +#include "ladspa-util.h" +#include "util/blo.h" + +#define FMOSC_WAVE 0 +#define FMOSC_FM 1 +#define FMOSC_OUTPUT 2 + +static LADSPA_Descriptor *fmOscDescriptor = NULL; + +typedef struct { + LADSPA_Data *wave; + LADSPA_Data *fm; + LADSPA_Data *output; + blo_h_osc * osc; + blo_h_tables *tables; + LADSPA_Data run_adding_gain; +} FmOsc; + +_WINDOWS_DLL_EXPORT_ +const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) { + +#ifdef WIN32 + if (bIsFirstTime) { + swh_init(); + bIsFirstTime = 0; + } +#endif + switch (index) { + case 0: + return fmOscDescriptor; + default: + return NULL; + } +} + +static void cleanupFmOsc(LADSPA_Handle instance) { +#line 37 "fm_osc_1415.xml" + FmOsc *plugin_data = (FmOsc *)instance; + blo_h_tables_free(plugin_data->tables); + blo_h_free(plugin_data->osc); + free(instance); +} + +static void connectPortFmOsc( + LADSPA_Handle instance, + unsigned long port, + LADSPA_Data *data) { + FmOsc *plugin; + + plugin = (FmOsc *)instance; + switch (port) { + case FMOSC_WAVE: + plugin->wave = data; + break; + case FMOSC_FM: + plugin->fm = data; + break; + case FMOSC_OUTPUT: + plugin->output = data; + break; + } +} + +static LADSPA_Handle instantiateFmOsc( + const LADSPA_Descriptor *descriptor, + unsigned long s_rate) { + FmOsc *plugin_data = (FmOsc *)calloc(1, sizeof(FmOsc)); + blo_h_osc *osc = NULL; + blo_h_tables *tables = NULL; + +#line 20 "fm_osc_1415.xml" + tables = blo_h_tables_new(1024); + osc = blo_h_new(tables, BLO_SINE, (float)s_rate); + + plugin_data->osc = osc; + plugin_data->tables = tables; + + return (LADSPA_Handle)plugin_data; +} + +#undef buffer_write +#undef RUN_ADDING +#undef RUN_REPLACING + +#define buffer_write(b, v) (b = v) +#define RUN_ADDING 0 +#define RUN_REPLACING 1 + +static void runFmOsc(LADSPA_Handle instance, unsigned long sample_count) { + FmOsc *plugin_data = (FmOsc *)instance; + + /* Waveform (1=sin, 2=tri, 3=squ, 4=saw) (float value) */ + const LADSPA_Data wave = *(plugin_data->wave); + + /* Frequency (Hz) (array of floats of length sample_count) */ + const LADSPA_Data * const fm = plugin_data->fm; + + /* Output (array of floats of length sample_count) */ + LADSPA_Data * const output = plugin_data->output; + blo_h_osc * osc = plugin_data->osc; + blo_h_tables * tables = plugin_data->tables; + +#line 25 "fm_osc_1415.xml" + unsigned long pos; + osc->wave = LIMIT(f_round(wave) - 1, 0, BLO_N_WAVES-1); + + tables = tables; // So gcc doesn't think it's unused + + for (pos = 0; pos < sample_count; pos++) { + blo_hd_set_freq(osc, fm[pos]); + buffer_write(output[pos], blo_hd_run_cub(osc)); + } +} +#undef buffer_write +#undef RUN_ADDING +#undef RUN_REPLACING + +#define buffer_write(b, v) (b += (v) * run_adding_gain) +#define RUN_ADDING 1 +#define RUN_REPLACING 0 + +static void setRunAddingGainFmOsc(LADSPA_Handle instance, LADSPA_Data gain) { + ((FmOsc *)instance)->run_adding_gain = gain; +} + +static void runAddingFmOsc(LADSPA_Handle instance, unsigned long sample_count) { + FmOsc *plugin_data = (FmOsc *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; + + /* Waveform (1=sin, 2=tri, 3=squ, 4=saw) (float value) */ + const LADSPA_Data wave = *(plugin_data->wave); + + /* Frequency (Hz) (array of floats of length sample_count) */ + const LADSPA_Data * const fm = plugin_data->fm; + + /* Output (array of floats of length sample_count) */ + LADSPA_Data * const output = plugin_data->output; + blo_h_osc * osc = plugin_data->osc; + blo_h_tables * tables = plugin_data->tables; + +#line 25 "fm_osc_1415.xml" + unsigned long pos; + osc->wave = LIMIT(f_round(wave) - 1, 0, BLO_N_WAVES-1); + + tables = tables; // So gcc doesn't think it's unused + + for (pos = 0; pos < sample_count; pos++) { + blo_hd_set_freq(osc, fm[pos]); + buffer_write(output[pos], blo_hd_run_cub(osc)); + } +} + +void __attribute__((constructor)) swh_init() { + char **port_names; + LADSPA_PortDescriptor *port_descriptors; + LADSPA_PortRangeHint *port_range_hints; + +#ifdef ENABLE_NLS +#define D_(s) dgettext(PACKAGE, s) + bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); +#else +#define D_(s) (s) +#endif + + + fmOscDescriptor = + (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); + + if (fmOscDescriptor) { + fmOscDescriptor->UniqueID = 1415; + fmOscDescriptor->Label = "fmOsc"; + fmOscDescriptor->Properties = + LADSPA_PROPERTY_HARD_RT_CAPABLE; + fmOscDescriptor->Name = + D_("FM Oscillator"); + fmOscDescriptor->Maker = + "Steve Harris "; + fmOscDescriptor->Copyright = + "GPL"; + fmOscDescriptor->PortCount = 3; + + port_descriptors = (LADSPA_PortDescriptor *)calloc(3, + sizeof(LADSPA_PortDescriptor)); + fmOscDescriptor->PortDescriptors = + (const LADSPA_PortDescriptor *)port_descriptors; + + port_range_hints = (LADSPA_PortRangeHint *)calloc(3, + sizeof(LADSPA_PortRangeHint)); + fmOscDescriptor->PortRangeHints = + (const LADSPA_PortRangeHint *)port_range_hints; + + port_names = (char **)calloc(3, sizeof(char*)); + fmOscDescriptor->PortNames = + (const char **)port_names; + + /* Parameters for Waveform (1=sin, 2=tri, 3=squ, 4=saw) */ + port_descriptors[FMOSC_WAVE] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[FMOSC_WAVE] = + D_("Waveform (1=sin, 2=tri, 3=squ, 4=saw)"); + port_range_hints[FMOSC_WAVE].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_INTEGER | LADSPA_HINT_DEFAULT_1; + port_range_hints[FMOSC_WAVE].LowerBound = 1; + port_range_hints[FMOSC_WAVE].UpperBound = BLO_N_WAVES; + + /* Parameters for Frequency (Hz) */ + port_descriptors[FMOSC_FM] = + LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; + port_names[FMOSC_FM] = + D_("Frequency (Hz)"); + port_range_hints[FMOSC_FM].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_SAMPLE_RATE | LADSPA_HINT_DEFAULT_440; + port_range_hints[FMOSC_FM].LowerBound = -0.25; + port_range_hints[FMOSC_FM].UpperBound = 0.25; + + /* Parameters for Output */ + port_descriptors[FMOSC_OUTPUT] = + LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; + port_names[FMOSC_OUTPUT] = + D_("Output"); + port_range_hints[FMOSC_OUTPUT].HintDescriptor = 0; + + fmOscDescriptor->activate = NULL; + fmOscDescriptor->cleanup = cleanupFmOsc; + fmOscDescriptor->connect_port = connectPortFmOsc; + fmOscDescriptor->deactivate = NULL; + fmOscDescriptor->instantiate = instantiateFmOsc; + fmOscDescriptor->run = runFmOsc; + fmOscDescriptor->run_adding = runAddingFmOsc; + fmOscDescriptor->set_run_adding_gain = setRunAddingGainFmOsc; + } +} + +void __attribute__((destructor)) swh_fini() { + if (fmOscDescriptor) { + free((LADSPA_PortDescriptor *)fmOscDescriptor->PortDescriptors); + free((char **)fmOscDescriptor->PortNames); + free((LADSPA_PortRangeHint *)fmOscDescriptor->PortRangeHints); + free(fmOscDescriptor); + } + fmOscDescriptor = NULL; + +} diff --git a/plugins/LadspaEffect/swh/foldover_1213.c b/plugins/LadspaEffect/swh/foldover_1213.c index 5f4884476..33b38f850 100644 --- a/plugins/LadspaEffect/swh/foldover_1213.c +++ b/plugins/LadspaEffect/swh/foldover_1213.c @@ -88,7 +88,7 @@ static void connectPortFoldover( static LADSPA_Handle instantiateFoldover( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Foldover *plugin_data = (Foldover *)malloc(sizeof(Foldover)); + Foldover *plugin_data = (Foldover *)calloc(1, sizeof(Foldover)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -173,7 +173,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -255,12 +254,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (foldoverDescriptor) { free((LADSPA_PortDescriptor *)foldoverDescriptor->PortDescriptors); free((char **)foldoverDescriptor->PortNames); free((LADSPA_PortRangeHint *)foldoverDescriptor->PortRangeHints); free(foldoverDescriptor); } + foldoverDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/foverdrive_1196.c b/plugins/LadspaEffect/swh/foverdrive_1196.c index f608e3ade..b986da224 100644 --- a/plugins/LadspaEffect/swh/foverdrive_1196.c +++ b/plugins/LadspaEffect/swh/foverdrive_1196.c @@ -83,7 +83,7 @@ static void connectPortFoverdrive( static LADSPA_Handle instantiateFoverdrive( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Foverdrive *plugin_data = (Foverdrive *)malloc(sizeof(Foverdrive)); + Foverdrive *plugin_data = (Foverdrive *)calloc(1, sizeof(Foverdrive)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -162,7 +162,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -234,12 +233,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (foverdriveDescriptor) { free((LADSPA_PortDescriptor *)foverdriveDescriptor->PortDescriptors); free((char **)foverdriveDescriptor->PortNames); free((LADSPA_PortRangeHint *)foverdriveDescriptor->PortRangeHints); free(foverdriveDescriptor); } + foverdriveDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/freq_tracker_1418.c b/plugins/LadspaEffect/swh/freq_tracker_1418.c index 73a7111ea..24c04abc1 100644 --- a/plugins/LadspaEffect/swh/freq_tracker_1418.c +++ b/plugins/LadspaEffect/swh/freq_tracker_1418.c @@ -111,7 +111,7 @@ static void connectPortFreqTracker( static LADSPA_Handle instantiateFreqTracker( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - FreqTracker *plugin_data = (FreqTracker *)malloc(sizeof(FreqTracker)); + FreqTracker *plugin_data = (FreqTracker *)calloc(1, sizeof(FreqTracker)); int cross_time; LADSPA_Data f; LADSPA_Data fo; @@ -247,7 +247,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -319,12 +318,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (freqTrackerDescriptor) { free((LADSPA_PortDescriptor *)freqTrackerDescriptor->PortDescriptors); free((char **)freqTrackerDescriptor->PortNames); free((LADSPA_PortRangeHint *)freqTrackerDescriptor->PortRangeHints); free(freqTrackerDescriptor); } + freqTrackerDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/gate_1410.c b/plugins/LadspaEffect/swh/gate_1410.c index 71527ace2..44737e6c2 100644 --- a/plugins/LadspaEffect/swh/gate_1410.c +++ b/plugins/LadspaEffect/swh/gate_1410.c @@ -165,7 +165,7 @@ static void connectPortGate( static LADSPA_Handle instantiateGate( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Gate *plugin_data = (Gate *)malloc(sizeof(Gate)); + Gate *plugin_data = (Gate *)calloc(1, sizeof(Gate)); float env; float fs; float gate; @@ -440,7 +440,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -582,12 +581,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (gateDescriptor) { free((LADSPA_PortDescriptor *)gateDescriptor->PortDescriptors); free((char **)gateDescriptor->PortNames); free((LADSPA_PortRangeHint *)gateDescriptor->PortRangeHints); free(gateDescriptor); } + gateDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/giant_flange_1437.c b/plugins/LadspaEffect/swh/giant_flange_1437.c index fd022d7b1..a962e57a8 100644 --- a/plugins/LadspaEffect/swh/giant_flange_1437.c +++ b/plugins/LadspaEffect/swh/giant_flange_1437.c @@ -160,7 +160,7 @@ static void connectPortGiantFlange( static LADSPA_Handle instantiateGiantFlange( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - GiantFlange *plugin_data = (GiantFlange *)malloc(sizeof(GiantFlange)); + GiantFlange *plugin_data = (GiantFlange *)calloc(1, sizeof(GiantFlange)); int16_t *buffer = NULL; unsigned int buffer_mask; unsigned int buffer_pos; @@ -508,7 +508,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -637,12 +636,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (giantFlangeDescriptor) { free((LADSPA_PortDescriptor *)giantFlangeDescriptor->PortDescriptors); free((char **)giantFlangeDescriptor->PortNames); free((LADSPA_PortRangeHint *)giantFlangeDescriptor->PortRangeHints); free(giantFlangeDescriptor); } + giantFlangeDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/gong_1424.c b/plugins/LadspaEffect/swh/gong_1424.c index b7e0656b2..e117fc543 100644 --- a/plugins/LadspaEffect/swh/gong_1424.c +++ b/plugins/LadspaEffect/swh/gong_1424.c @@ -250,7 +250,7 @@ static void connectPortGong( static LADSPA_Handle instantiateGong( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Gong *plugin_data = (Gong *)malloc(sizeof(Gong)); + Gong *plugin_data = (Gong *)calloc(1, sizeof(Gong)); int maxsize_i; int maxsize_o; float *out = NULL; @@ -615,7 +615,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -947,12 +946,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (gongDescriptor) { free((LADSPA_PortDescriptor *)gongDescriptor->PortDescriptors); free((char **)gongDescriptor->PortNames); free((LADSPA_PortRangeHint *)gongDescriptor->PortRangeHints); free(gongDescriptor); } + gongDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/gong_beater_1439.c b/plugins/LadspaEffect/swh/gong_beater_1439.c index b80e164d3..535f754dd 100644 --- a/plugins/LadspaEffect/swh/gong_beater_1439.c +++ b/plugins/LadspaEffect/swh/gong_beater_1439.c @@ -128,7 +128,7 @@ static void connectPortGongBeater( static LADSPA_Handle instantiateGongBeater( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - GongBeater *plugin_data = (GongBeater *)malloc(sizeof(GongBeater)); + GongBeater *plugin_data = (GongBeater *)calloc(1, sizeof(GongBeater)); float fs; float imp_level; unsigned int running; @@ -308,7 +308,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -400,12 +399,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (gongBeaterDescriptor) { free((LADSPA_PortDescriptor *)gongBeaterDescriptor->PortDescriptors); free((char **)gongBeaterDescriptor->PortNames); free((LADSPA_PortRangeHint *)gongBeaterDescriptor->PortRangeHints); free(gongBeaterDescriptor); } + gongBeaterDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/gsm_1215.c b/plugins/LadspaEffect/swh/gsm_1215.c index 8cef93ba5..2e9b00077 100644 --- a/plugins/LadspaEffect/swh/gsm_1215.c +++ b/plugins/LadspaEffect/swh/gsm_1215.c @@ -158,7 +158,7 @@ static void connectPortGsm( static LADSPA_Handle instantiateGsm( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Gsm *plugin_data = (Gsm *)malloc(sizeof(Gsm)); + Gsm *plugin_data = (Gsm *)calloc(1, sizeof(Gsm)); biquad *blf = NULL; int count; LADSPA_Data *dry = NULL; @@ -224,6 +224,7 @@ static void runGsm(LADSPA_Handle instance, unsigned long sample_count) { int count = plugin_data->count; LADSPA_Data * dry = plugin_data->dry; gsm_signal * dst = plugin_data->dst; + float fs = plugin_data->fs; gsm handle = plugin_data->handle; int resamp = plugin_data->resamp; float rsf = plugin_data->rsf; @@ -237,6 +238,8 @@ static void runGsm(LADSPA_Handle instance, unsigned long sample_count) { int error_rate = f_round(error); int num_passes = f_round(passes); + fs = fs; // So gcc doesn't think it's unused + for (pos = 0; pos < sample_count; pos++) { // oversample into buffer down to aprox 8kHz, 13bit @@ -319,6 +322,7 @@ static void runAddingGsm(LADSPA_Handle instance, unsigned long sample_count) { int count = plugin_data->count; LADSPA_Data * dry = plugin_data->dry; gsm_signal * dst = plugin_data->dst; + float fs = plugin_data->fs; gsm handle = plugin_data->handle; int resamp = plugin_data->resamp; float rsf = plugin_data->rsf; @@ -332,6 +336,8 @@ static void runAddingGsm(LADSPA_Handle instance, unsigned long sample_count) { int error_rate = f_round(error); int num_passes = f_round(passes); + fs = fs; // So gcc doesn't think it's unused + for (pos = 0; pos < sample_count; pos++) { // oversample into buffer down to aprox 8kHz, 13bit @@ -388,7 +394,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -487,12 +492,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (gsmDescriptor) { free((LADSPA_PortDescriptor *)gsmDescriptor->PortDescriptors); free((char **)gsmDescriptor->PortNames); free((LADSPA_PortRangeHint *)gsmDescriptor->PortRangeHints); free(gsmDescriptor); } + gsmDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/gverb_1216.c b/plugins/LadspaEffect/swh/gverb_1216.c index e9bdac87d..c3b1c3a25 100644 --- a/plugins/LadspaEffect/swh/gverb_1216.c +++ b/plugins/LadspaEffect/swh/gverb_1216.c @@ -146,7 +146,7 @@ static void connectPortGverb( static LADSPA_Handle instantiateGverb( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Gverb *plugin_data = (Gverb *)malloc(sizeof(Gverb)); + Gverb *plugin_data = (Gverb *)calloc(1, sizeof(Gverb)); ty_gverb *verb = NULL; #line 50 "gverb_1216.xml" @@ -290,7 +290,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -429,12 +428,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (gverbDescriptor) { free((LADSPA_PortDescriptor *)gverbDescriptor->PortDescriptors); free((char **)gverbDescriptor->PortNames); free((LADSPA_PortRangeHint *)gverbDescriptor->PortRangeHints); free(gverbDescriptor); } + gverbDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/hard_limiter_1413.c b/plugins/LadspaEffect/swh/hard_limiter_1413.c index bf41e6acd..a6850f5bc 100644 --- a/plugins/LadspaEffect/swh/hard_limiter_1413.c +++ b/plugins/LadspaEffect/swh/hard_limiter_1413.c @@ -97,7 +97,7 @@ static void connectPortHardLimiter( static LADSPA_Handle instantiateHardLimiter( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - HardLimiter *plugin_data = (HardLimiter *)malloc(sizeof(HardLimiter)); + HardLimiter *plugin_data = (HardLimiter *)calloc(1, sizeof(HardLimiter)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -194,7 +194,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -286,12 +285,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (hardLimiterDescriptor) { free((LADSPA_PortDescriptor *)hardLimiterDescriptor->PortDescriptors); free((char **)hardLimiterDescriptor->PortNames); free((LADSPA_PortRangeHint *)hardLimiterDescriptor->PortRangeHints); free(hardLimiterDescriptor); } + hardLimiterDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/harmonic_gen_1220.c b/plugins/LadspaEffect/swh/harmonic_gen_1220.c index bbd2324c7..1250b3728 100644 --- a/plugins/LadspaEffect/swh/harmonic_gen_1220.c +++ b/plugins/LadspaEffect/swh/harmonic_gen_1220.c @@ -175,7 +175,7 @@ static void connectPortHarmonicGen( static LADSPA_Handle instantiateHarmonicGen( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - HarmonicGen *plugin_data = (HarmonicGen *)malloc(sizeof(HarmonicGen)); + HarmonicGen *plugin_data = (HarmonicGen *)calloc(1, sizeof(HarmonicGen)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -374,7 +374,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -542,12 +541,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (harmonicGenDescriptor) { free((LADSPA_PortDescriptor *)harmonicGenDescriptor->PortDescriptors); free((char **)harmonicGenDescriptor->PortNames); free((LADSPA_PortRangeHint *)harmonicGenDescriptor->PortRangeHints); free(harmonicGenDescriptor); } + harmonicGenDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/hermes_filter_1200.c b/plugins/LadspaEffect/swh/hermes_filter_1200.c index a8dd28e98..67c7055bd 100644 --- a/plugins/LadspaEffect/swh/hermes_filter_1200.c +++ b/plugins/LadspaEffect/swh/hermes_filter_1200.c @@ -117,7 +117,7 @@ inline void setup_f_svf(sv_filter *sv, const float fs, const float fc) { /* Run one sample through the SV filter. Filter is by andy@vellocet */ -static inline float run_svf(sv_filter *sv, float in) { +inline float run_svf(sv_filter *sv, float in) { float out; int i; @@ -144,7 +144,7 @@ static inline float run_svf(sv_filter *sv, float in) { return out; } -static inline int wave_tbl(const float wave) { +inline int wave_tbl(const float wave) { switch (f_round(wave)) { case 0: return BLO_SINE; @@ -569,7 +569,7 @@ static void connectPortHermesFilter( static LADSPA_Handle instantiateHermesFilter( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - HermesFilter *plugin_data = (HermesFilter *)malloc(sizeof(HermesFilter)); + HermesFilter *plugin_data = (HermesFilter *)calloc(1, sizeof(HermesFilter)); long count; float **dela_data = NULL; int *dela_pos = NULL; @@ -817,6 +817,7 @@ static void runHermesFilter(LADSPA_Handle instance, unsigned long sample_count) float lfo2_phase = plugin_data->lfo2_phase; blo_h_osc * osc1_d = plugin_data->osc1_d; blo_h_osc * osc2_d = plugin_data->osc2_d; + blo_h_tables * tables = plugin_data->tables; sv_filter * xover_b1_data = plugin_data->xover_b1_data; sv_filter * xover_b2_data = plugin_data->xover_b2_data; @@ -926,6 +927,8 @@ static void runHermesFilter(LADSPA_Handle instance, unsigned long sample_count) dela_fb[1] = dela2_fb; dela_fb[2] = dela3_fb; + tables = tables; // To shut up gcc + for (pos = 0; pos < sample_count; pos++) { count++; // Count of number of samples processed @@ -1201,6 +1204,7 @@ static void runAddingHermesFilter(LADSPA_Handle instance, unsigned long sample_c float lfo2_phase = plugin_data->lfo2_phase; blo_h_osc * osc1_d = plugin_data->osc1_d; blo_h_osc * osc2_d = plugin_data->osc2_d; + blo_h_tables * tables = plugin_data->tables; sv_filter * xover_b1_data = plugin_data->xover_b1_data; sv_filter * xover_b2_data = plugin_data->xover_b2_data; @@ -1310,6 +1314,8 @@ static void runAddingHermesFilter(LADSPA_Handle instance, unsigned long sample_c dela_fb[1] = dela2_fb; dela_fb[2] = dela3_fb; + tables = tables; // To shut up gcc + for (pos = 0; pos < sample_count; pos++) { count++; // Count of number of samples processed @@ -1404,7 +1410,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -1992,12 +1997,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (hermesFilterDescriptor) { free((LADSPA_PortDescriptor *)hermesFilterDescriptor->PortDescriptors); free((char **)hermesFilterDescriptor->PortNames); free((LADSPA_PortRangeHint *)hermesFilterDescriptor->PortRangeHints); free(hermesFilterDescriptor); } + hermesFilterDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/highpass_iir_1890.c b/plugins/LadspaEffect/swh/highpass_iir_1890.c index d00ddd159..a5c60ee3e 100644 --- a/plugins/LadspaEffect/swh/highpass_iir_1890.c +++ b/plugins/LadspaEffect/swh/highpass_iir_1890.c @@ -25,6 +25,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 9 "highpass_iir_1890.xml" #include "config.h" #include "util/iir.h" @@ -69,6 +70,7 @@ static void activateHighpass_iir(LADSPA_Handle instance) { iir_stage_t*gt = plugin_data->gt; iirf_t*iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 35 "highpass_iir_1890.xml" gt = init_iir_stage(IIR_STAGE_HIGHPASS,10,3,2); iirf = init_iirf_t(gt); @@ -80,6 +82,7 @@ static void activateHighpass_iir(LADSPA_Handle instance) { } static void cleanupHighpass_iir(LADSPA_Handle instance) { +#line 41 "highpass_iir_1890.xml" Highpass_iir *plugin_data = (Highpass_iir *)instance; free_iirf_t(plugin_data->iirf, plugin_data->gt); free_iir_stage(plugin_data->gt); @@ -112,11 +115,12 @@ static void connectPortHighpass_iir( static LADSPA_Handle instantiateHighpass_iir( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Highpass_iir *plugin_data = (Highpass_iir *)malloc(sizeof(Highpass_iir)); + Highpass_iir *plugin_data = (Highpass_iir *)calloc(1, sizeof(Highpass_iir)); iir_stage_t*gt = NULL; iirf_t*iirf = NULL; long sample_rate; +#line 24 "highpass_iir_1890.xml" sample_rate = s_rate; plugin_data->gt = gt; @@ -136,6 +140,7 @@ static LADSPA_Handle instantiateHighpass_iir( static void runHighpass_iir(LADSPA_Handle instance, unsigned long sample_count) { Highpass_iir *plugin_data = (Highpass_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Cutoff Frequency (float value) */ const LADSPA_Data cutoff = *(plugin_data->cutoff); @@ -152,8 +157,12 @@ static void runHighpass_iir(LADSPA_Handle instance, unsigned long sample_count) iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 27 "highpass_iir_1890.xml" chebyshev(iirf, gt, 2*CLAMP((int)stages,1,10), IIR_STAGE_HIGHPASS, cutoff/(float)sample_rate, 0.5f); iir_process_buffer_ns_5(iirf, gt, input, output, sample_count,RUN_ADDING); + + // Unused variable + (void)(run_adding_gain); } #undef buffer_write #undef RUN_ADDING @@ -169,6 +178,7 @@ static void setRunAddingGainHighpass_iir(LADSPA_Handle instance, LADSPA_Data gai static void runAddingHighpass_iir(LADSPA_Handle instance, unsigned long sample_count) { Highpass_iir *plugin_data = (Highpass_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Cutoff Frequency (float value) */ const LADSPA_Data cutoff = *(plugin_data->cutoff); @@ -185,8 +195,12 @@ static void runAddingHighpass_iir(LADSPA_Handle instance, unsigned long sample_c iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 27 "highpass_iir_1890.xml" chebyshev(iirf, gt, 2*CLAMP((int)stages,1,10), IIR_STAGE_HIGHPASS, cutoff/(float)sample_rate, 0.5f); iir_process_buffer_ns_5(iirf, gt, input, output, sample_count,RUN_ADDING); + + // Unused variable + (void)(run_adding_gain); } void __attribute__((constructor)) swh_init() { @@ -196,7 +210,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -278,12 +291,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (highpass_iirDescriptor) { free((LADSPA_PortDescriptor *)highpass_iirDescriptor->PortDescriptors); free((char **)highpass_iirDescriptor->PortNames); free((LADSPA_PortRangeHint *)highpass_iirDescriptor->PortRangeHints); free(highpass_iirDescriptor); } + highpass_iirDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/hilbert_1440.c b/plugins/LadspaEffect/swh/hilbert_1440.c index a52b21390..074f0e761 100644 --- a/plugins/LadspaEffect/swh/hilbert_1440.c +++ b/plugins/LadspaEffect/swh/hilbert_1440.c @@ -128,7 +128,7 @@ static void connectPortHilbert( static LADSPA_Handle instantiateHilbert( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Hilbert *plugin_data = (Hilbert *)malloc(sizeof(Hilbert)); + Hilbert *plugin_data = (Hilbert *)calloc(1, sizeof(Hilbert)); LADSPA_Data *delay = NULL; unsigned int dptr; @@ -240,7 +240,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -316,12 +315,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (hilbertDescriptor) { free((LADSPA_PortDescriptor *)hilbertDescriptor->PortDescriptors); free((char **)hilbertDescriptor->PortNames); free((LADSPA_PortRangeHint *)hilbertDescriptor->PortRangeHints); free(hilbertDescriptor); } + hilbertDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/imp_1199.c b/plugins/LadspaEffect/swh/imp_1199.c index 90e8e8c33..afe2d1a57 100644 --- a/plugins/LadspaEffect/swh/imp_1199.c +++ b/plugins/LadspaEffect/swh/imp_1199.c @@ -63,7 +63,7 @@ typedef rfftw_plan fft_plan; #define MK_IMP(i) impulse2freq(c, i, IMP_LENGTH(i), impulse_freq[c]); c++ -static inline void impulse2freq(int id, float *imp, unsigned int length, fftw_real *out); +inline void impulse2freq(int id, float *imp, unsigned int length, fftw_real *out); #include "impulses/all.h" @@ -77,7 +77,7 @@ unsigned int fft_length[IMPULSES]; #ifdef __clang__ void impulse2freq(int id, float *imp, unsigned int length, fftw_real *out) #else -static inline void impulse2freq(int id, float *imp, unsigned int length, fftw_real *out) +inline void impulse2freq(int id, float *imp, unsigned int length, fftw_real *out) #endif { fftw_real impulse_time[MAX_FFT_LENGTH]; @@ -103,7 +103,7 @@ static inline void impulse2freq(int id, float *imp, unsigned int length, fftw_re for (i=0; i=last) impulse_time[i] = 0.0f; @@ -172,7 +172,7 @@ static void activateImp(LADSPA_Handle instance) { LADSPA_Data *opc = plugin_data->opc; unsigned long out_ptr = plugin_data->out_ptr; LADSPA_Data *overlap = plugin_data->overlap; -#line 161 "imp_1199.xml" +#line 167 "imp_1199.xml" memset(block_time, 0, MAX_FFT_LENGTH * sizeof(fftw_real)); memset(block_freq, 0, MAX_FFT_LENGTH * sizeof(fftw_real)); memset(op, 0, MAX_FFT_LENGTH * sizeof(fftw_real)); @@ -195,7 +195,7 @@ static void activateImp(LADSPA_Handle instance) { } static void cleanupImp(LADSPA_Handle instance) { -#line 173 "imp_1199.xml" +#line 179 "imp_1199.xml" Imp *plugin_data = (Imp *)instance; local_free(plugin_data->block_time); local_free(plugin_data->block_freq); @@ -242,7 +242,7 @@ static void connectPortImp( static LADSPA_Handle instantiateImp( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Imp *plugin_data = (Imp *)malloc(sizeof(Imp)); + Imp *plugin_data = (Imp *)calloc(1, sizeof(Imp)); fftw_real *block_freq = NULL; fftw_real *block_time = NULL; unsigned int count; @@ -253,7 +253,7 @@ static LADSPA_Handle instantiateImp( unsigned long out_ptr; LADSPA_Data *overlap = NULL; -#line 135 "imp_1199.xml" +#line 141 "imp_1199.xml" unsigned int i; impulse_freq = local_malloc(IMPULSES * sizeof(fftw_real *)); @@ -326,7 +326,7 @@ static void runImp(LADSPA_Handle instance, unsigned long sample_count) { unsigned long out_ptr = plugin_data->out_ptr; LADSPA_Data * overlap = plugin_data->overlap; -#line 181 "imp_1199.xml" +#line 192 "imp_1199.xml" unsigned long i, pos, ipos, limit; unsigned int im; unsigned int len; @@ -448,7 +448,7 @@ static void runAddingImp(LADSPA_Handle instance, unsigned long sample_count) { unsigned long out_ptr = plugin_data->out_ptr; LADSPA_Data * overlap = plugin_data->overlap; -#line 181 "imp_1199.xml" +#line 192 "imp_1199.xml" unsigned long i, pos, ipos, limit; unsigned int im; unsigned int len; @@ -538,7 +538,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -637,12 +636,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (impDescriptor) { free((LADSPA_PortDescriptor *)impDescriptor->PortDescriptors); free((char **)impDescriptor->PortNames); free((LADSPA_PortRangeHint *)impDescriptor->PortRangeHints); free(impDescriptor); } + impDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/impulse_1885.c b/plugins/LadspaEffect/swh/impulse_1885.c index cc53506b7..9603ad9d4 100644 --- a/plugins/LadspaEffect/swh/impulse_1885.c +++ b/plugins/LadspaEffect/swh/impulse_1885.c @@ -96,7 +96,7 @@ static void connectPortImpulse_fc( static LADSPA_Handle instantiateImpulse_fc( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Impulse_fc *plugin_data = (Impulse_fc *)malloc(sizeof(Impulse_fc)); + Impulse_fc *plugin_data = (Impulse_fc *)calloc(1, sizeof(Impulse_fc)); float phase; LADSPA_Data sample_rate; @@ -193,7 +193,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -257,12 +256,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (impulse_fcDescriptor) { free((LADSPA_PortDescriptor *)impulse_fcDescriptor->PortDescriptors); free((char **)impulse_fcDescriptor->PortNames); free((LADSPA_PortRangeHint *)impulse_fcDescriptor->PortRangeHints); free(impulse_fcDescriptor); } + impulse_fcDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/inv_1429.c b/plugins/LadspaEffect/swh/inv_1429.c index e0a6f7715..9debf1731 100644 --- a/plugins/LadspaEffect/swh/inv_1429.c +++ b/plugins/LadspaEffect/swh/inv_1429.c @@ -78,7 +78,7 @@ static void connectPortInv( static LADSPA_Handle instantiateInv( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Inv *plugin_data = (Inv *)malloc(sizeof(Inv)); + Inv *plugin_data = (Inv *)calloc(1, sizeof(Inv)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -145,7 +145,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -207,12 +206,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (invDescriptor) { free((LADSPA_PortDescriptor *)invDescriptor->PortDescriptors); free((char **)invDescriptor->PortNames); free((LADSPA_PortRangeHint *)invDescriptor->PortRangeHints); free(invDescriptor); } + invDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/karaoke_1409.c b/plugins/LadspaEffect/swh/karaoke_1409.c index 9dd09c336..3fbde840c 100644 --- a/plugins/LadspaEffect/swh/karaoke_1409.c +++ b/plugins/LadspaEffect/swh/karaoke_1409.c @@ -93,7 +93,7 @@ static void connectPortKaraoke( static LADSPA_Handle instantiateKaraoke( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Karaoke *plugin_data = (Karaoke *)malloc(sizeof(Karaoke)); + Karaoke *plugin_data = (Karaoke *)calloc(1, sizeof(Karaoke)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -188,7 +188,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -274,12 +273,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (karaokeDescriptor) { free((LADSPA_PortDescriptor *)karaokeDescriptor->PortDescriptors); free((char **)karaokeDescriptor->PortNames); free((LADSPA_PortRangeHint *)karaokeDescriptor->PortRangeHints); free(karaokeDescriptor); } + karaokeDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/latency_1914.c b/plugins/LadspaEffect/swh/latency_1914.c index 202b65baa..67c12e494 100644 --- a/plugins/LadspaEffect/swh/latency_1914.c +++ b/plugins/LadspaEffect/swh/latency_1914.c @@ -92,7 +92,7 @@ static void connectPortArtificialLatency( static LADSPA_Handle instantiateArtificialLatency( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - ArtificialLatency *plugin_data = (ArtificialLatency *)malloc(sizeof(ArtificialLatency)); + ArtificialLatency *plugin_data = (ArtificialLatency *)calloc(1, sizeof(ArtificialLatency)); float fs; #line 21 "latency_1914.xml" @@ -180,7 +180,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -259,12 +258,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (artificialLatencyDescriptor) { free((LADSPA_PortDescriptor *)artificialLatencyDescriptor->PortDescriptors); free((char **)artificialLatencyDescriptor->PortNames); free((LADSPA_PortRangeHint *)artificialLatencyDescriptor->PortRangeHints); free(artificialLatencyDescriptor); } + artificialLatencyDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/lcr_delay_1436.c b/plugins/LadspaEffect/swh/lcr_delay_1436.c index f9d4df7b6..162492f98 100644 --- a/plugins/LadspaEffect/swh/lcr_delay_1436.c +++ b/plugins/LadspaEffect/swh/lcr_delay_1436.c @@ -199,7 +199,7 @@ static void connectPortLcrDelay( static LADSPA_Handle instantiateLcrDelay( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - LcrDelay *plugin_data = (LcrDelay *)malloc(sizeof(LcrDelay)); + LcrDelay *plugin_data = (LcrDelay *)calloc(1, sizeof(LcrDelay)); LADSPA_Data *buffer = NULL; unsigned int buffer_mask; unsigned int buffer_pos; @@ -547,7 +547,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -733,12 +732,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (lcrDelayDescriptor) { free((LADSPA_PortDescriptor *)lcrDelayDescriptor->PortDescriptors); free((char **)lcrDelayDescriptor->PortNames); free((LADSPA_PortRangeHint *)lcrDelayDescriptor->PortRangeHints); free(lcrDelayDescriptor); } + lcrDelayDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/lowpass_iir_1891.c b/plugins/LadspaEffect/swh/lowpass_iir_1891.c index a8ecb9ad4..61767c249 100644 --- a/plugins/LadspaEffect/swh/lowpass_iir_1891.c +++ b/plugins/LadspaEffect/swh/lowpass_iir_1891.c @@ -25,6 +25,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 9 "lowpass_iir_1891.xml" #include "config.h" #include "util/iir.h" @@ -70,6 +71,7 @@ static void activateLowpass_iir(LADSPA_Handle instance) { iir_stage_t*gt = plugin_data->gt; iirf_t*iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 36 "lowpass_iir_1891.xml" gt = init_iir_stage(IIR_STAGE_LOWPASS,10,3,2); iirf = init_iirf_t(gt); @@ -82,6 +84,7 @@ static void activateLowpass_iir(LADSPA_Handle instance) { } static void cleanupLowpass_iir(LADSPA_Handle instance) { +#line 43 "lowpass_iir_1891.xml" Lowpass_iir *plugin_data = (Lowpass_iir *)instance; free_iirf_t(plugin_data->iirf, plugin_data->gt); free_iir_stage(plugin_data->gt); @@ -114,11 +117,12 @@ static void connectPortLowpass_iir( static LADSPA_Handle instantiateLowpass_iir( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Lowpass_iir *plugin_data = (Lowpass_iir *)malloc(sizeof(Lowpass_iir)); + Lowpass_iir *plugin_data = (Lowpass_iir *)calloc(1, sizeof(Lowpass_iir)); iir_stage_t*gt = NULL; iirf_t*iirf = NULL; long sample_rate; +#line 25 "lowpass_iir_1891.xml" sample_rate = s_rate; plugin_data->gt = gt; @@ -138,6 +142,7 @@ static LADSPA_Handle instantiateLowpass_iir( static void runLowpass_iir(LADSPA_Handle instance, unsigned long sample_count) { Lowpass_iir *plugin_data = (Lowpass_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Cutoff Frequency (float value) */ const LADSPA_Data cutoff = *(plugin_data->cutoff); @@ -154,8 +159,12 @@ static void runLowpass_iir(LADSPA_Handle instance, unsigned long sample_count) { iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 28 "lowpass_iir_1891.xml" chebyshev(iirf, gt, 2*CLAMP((int)stages,1,10), IIR_STAGE_LOWPASS, cutoff/(float)sample_rate, 0.5f); iir_process_buffer_ns_5(iirf, gt, input, output, sample_count,RUN_ADDING); + + // Unused variable + (void)(run_adding_gain); } #undef buffer_write #undef RUN_ADDING @@ -171,6 +180,7 @@ static void setRunAddingGainLowpass_iir(LADSPA_Handle instance, LADSPA_Data gain static void runAddingLowpass_iir(LADSPA_Handle instance, unsigned long sample_count) { Lowpass_iir *plugin_data = (Lowpass_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Cutoff Frequency (float value) */ const LADSPA_Data cutoff = *(plugin_data->cutoff); @@ -187,8 +197,12 @@ static void runAddingLowpass_iir(LADSPA_Handle instance, unsigned long sample_co iirf_t* iirf = plugin_data->iirf; long sample_rate = plugin_data->sample_rate; +#line 28 "lowpass_iir_1891.xml" chebyshev(iirf, gt, 2*CLAMP((int)stages,1,10), IIR_STAGE_LOWPASS, cutoff/(float)sample_rate, 0.5f); iir_process_buffer_ns_5(iirf, gt, input, output, sample_count,RUN_ADDING); + + // Unused variable + (void)(run_adding_gain); } void __attribute__((constructor)) swh_init() { @@ -198,7 +212,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -280,12 +293,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (lowpass_iirDescriptor) { free((LADSPA_PortDescriptor *)lowpass_iirDescriptor->PortDescriptors); free((char **)lowpass_iirDescriptor->PortNames); free((LADSPA_PortRangeHint *)lowpass_iirDescriptor->PortRangeHints); free(lowpass_iirDescriptor); } + lowpass_iirDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/ls_filter_1908.c b/plugins/LadspaEffect/swh/ls_filter_1908.c index e67177bcd..9c9768b10 100644 --- a/plugins/LadspaEffect/swh/ls_filter_1908.c +++ b/plugins/LadspaEffect/swh/ls_filter_1908.c @@ -113,7 +113,7 @@ static void connectPortLsFilter( static LADSPA_Handle instantiateLsFilter( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - LsFilter *plugin_data = (LsFilter *)malloc(sizeof(LsFilter)); + LsFilter *plugin_data = (LsFilter *)calloc(1, sizeof(LsFilter)); ls_filt *filt = NULL; float fs; @@ -216,7 +216,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -308,12 +307,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (lsFilterDescriptor) { free((LADSPA_PortDescriptor *)lsFilterDescriptor->PortDescriptors); free((char **)lsFilterDescriptor->PortNames); free((LADSPA_PortRangeHint *)lsFilterDescriptor->PortRangeHints); free(lsFilterDescriptor); } + lsFilterDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/matrix_ms_st_1421.c b/plugins/LadspaEffect/swh/matrix_ms_st_1421.c index e1c81d8d2..d68d399a4 100644 --- a/plugins/LadspaEffect/swh/matrix_ms_st_1421.c +++ b/plugins/LadspaEffect/swh/matrix_ms_st_1421.c @@ -93,7 +93,7 @@ static void connectPortMatrixMSSt( static LADSPA_Handle instantiateMatrixMSSt( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - MatrixMSSt *plugin_data = (MatrixMSSt *)malloc(sizeof(MatrixMSSt)); + MatrixMSSt *plugin_data = (MatrixMSSt *)calloc(1, sizeof(MatrixMSSt)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -180,7 +180,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -266,12 +265,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (matrixMSStDescriptor) { free((LADSPA_PortDescriptor *)matrixMSStDescriptor->PortDescriptors); free((char **)matrixMSStDescriptor->PortNames); free((LADSPA_PortRangeHint *)matrixMSStDescriptor->PortRangeHints); free(matrixMSStDescriptor); } + matrixMSStDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/matrix_spatialiser_1422.c b/plugins/LadspaEffect/swh/matrix_spatialiser_1422.c index 74b3f1cfd..333be0a9e 100644 --- a/plugins/LadspaEffect/swh/matrix_spatialiser_1422.c +++ b/plugins/LadspaEffect/swh/matrix_spatialiser_1422.c @@ -165,7 +165,7 @@ static void connectPortMatrixSpatialiser( static LADSPA_Handle instantiateMatrixSpatialiser( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - MatrixSpatialiser *plugin_data = (MatrixSpatialiser *)malloc(sizeof(MatrixSpatialiser)); + MatrixSpatialiser *plugin_data = (MatrixSpatialiser *)calloc(1, sizeof(MatrixSpatialiser)); LADSPA_Data current_m_gain; LADSPA_Data current_s_gain; @@ -338,7 +338,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -424,12 +423,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (matrixSpatialiserDescriptor) { free((LADSPA_PortDescriptor *)matrixSpatialiserDescriptor->PortDescriptors); free((char **)matrixSpatialiserDescriptor->PortNames); free((LADSPA_PortRangeHint *)matrixSpatialiserDescriptor->PortRangeHints); free(matrixSpatialiserDescriptor); } + matrixSpatialiserDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/matrix_st_ms_1420.c b/plugins/LadspaEffect/swh/matrix_st_ms_1420.c index 0d18f98b2..2bc64d9fb 100644 --- a/plugins/LadspaEffect/swh/matrix_st_ms_1420.c +++ b/plugins/LadspaEffect/swh/matrix_st_ms_1420.c @@ -88,7 +88,7 @@ static void connectPortMatrixStMS( static LADSPA_Handle instantiateMatrixStMS( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - MatrixStMS *plugin_data = (MatrixStMS *)malloc(sizeof(MatrixStMS)); + MatrixStMS *plugin_data = (MatrixStMS *)calloc(1, sizeof(MatrixStMS)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -169,7 +169,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -245,12 +244,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (matrixStMSDescriptor) { free((LADSPA_PortDescriptor *)matrixStMSDescriptor->PortDescriptors); free((char **)matrixStMSDescriptor->PortNames); free((LADSPA_PortRangeHint *)matrixStMSDescriptor->PortRangeHints); free(matrixStMSDescriptor); } + matrixStMSDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/mbeq_1197.c b/plugins/LadspaEffect/swh/mbeq_1197.c index c10da5919..946c15c70 100644 --- a/plugins/LadspaEffect/swh/mbeq_1197.c +++ b/plugins/LadspaEffect/swh/mbeq_1197.c @@ -246,7 +246,7 @@ static void connectPortMbeq( static LADSPA_Handle instantiateMbeq( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Mbeq *plugin_data = (Mbeq *)malloc(sizeof(Mbeq)); + Mbeq *plugin_data = (Mbeq *)calloc(1, sizeof(Mbeq)); int *bin_base = NULL; float *bin_delta = NULL; fftw_real *comp = NULL; @@ -286,10 +286,11 @@ static LADSPA_Handle instantiateMbeq( // Create raised cosine window table for (i=0; i < FFT_LENGTH; i++) { - window[i] = -0.5f * cos(2.0f*M_PI*(double)i/(double)FFT_LENGTH) + 0.5f; + window[i] = -0.5f*cos(2.0f*M_PI*(double)i/(double)FFT_LENGTH)+0.5f; + window[i] *= 2.0f; } - // Create db->coefficient lookup table + // Create db->coeffiecnt lookup table db_table = malloc(1000 * sizeof(float)); for (i=0; i < 1000; i++) { db = ((float)i/10) - 70; @@ -471,12 +472,8 @@ static void runMbeq(LADSPA_Handle instance, unsigned long sample_count) { // Window into the output accumulator for (i = 0; i < FFT_LENGTH; i++) { - // correction factor for window measured from white noise - // reduce intermediate output by (number of coefficients) * OVER_SAMP - out_accum[i] += real[i] * window[i] * 1.27519f / - ((FFT_LENGTH/2) * OVER_SAMP); + out_accum[i] += 0.9186162f * window[i] * real[i]/(FFT_LENGTH * OVER_SAMP); } - for (i = 0; i < step_size; i++) { out_fifo[i] = out_accum[i]; } @@ -669,7 +666,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -888,12 +884,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (mbeqDescriptor) { free((LADSPA_PortDescriptor *)mbeqDescriptor->PortDescriptors); free((char **)mbeqDescriptor->PortNames); free((LADSPA_PortRangeHint *)mbeqDescriptor->PortRangeHints); free(mbeqDescriptor); } + mbeqDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/mod_delay_1419.c b/plugins/LadspaEffect/swh/mod_delay_1419.c index 30ae3e553..e97344817 100644 --- a/plugins/LadspaEffect/swh/mod_delay_1419.c +++ b/plugins/LadspaEffect/swh/mod_delay_1419.c @@ -114,7 +114,7 @@ static void connectPortModDelay( static LADSPA_Handle instantiateModDelay( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - ModDelay *plugin_data = (ModDelay *)malloc(sizeof(ModDelay)); + ModDelay *plugin_data = (ModDelay *)calloc(1, sizeof(ModDelay)); LADSPA_Data *buffer = NULL; unsigned int buffer_mask; float fs; @@ -236,7 +236,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -318,12 +317,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (modDelayDescriptor) { free((LADSPA_PortDescriptor *)modDelayDescriptor->PortDescriptors); free((char **)modDelayDescriptor->PortNames); free((LADSPA_PortRangeHint *)modDelayDescriptor->PortRangeHints); free(modDelayDescriptor); } + modDelayDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/multivoice_chorus_1201.c b/plugins/LadspaEffect/swh/multivoice_chorus_1201.c index 24c100dd4..453201b3a 100644 --- a/plugins/LadspaEffect/swh/multivoice_chorus_1201.c +++ b/plugins/LadspaEffect/swh/multivoice_chorus_1201.c @@ -182,7 +182,7 @@ static void connectPortMultivoiceChorus( static LADSPA_Handle instantiateMultivoiceChorus( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - MultivoiceChorus *plugin_data = (MultivoiceChorus *)malloc(sizeof(MultivoiceChorus)); + MultivoiceChorus *plugin_data = (MultivoiceChorus *)calloc(1, sizeof(MultivoiceChorus)); long count; unsigned int delay_mask; unsigned int delay_pos; @@ -534,7 +534,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -656,12 +655,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (multivoiceChorusDescriptor) { free((LADSPA_PortDescriptor *)multivoiceChorusDescriptor->PortDescriptors); free((char **)multivoiceChorusDescriptor->PortNames); free((LADSPA_PortRangeHint *)multivoiceChorusDescriptor->PortRangeHints); free(multivoiceChorusDescriptor); } + multivoiceChorusDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/notch_iir_1894.c b/plugins/LadspaEffect/swh/notch_iir_1894.c index 69009967b..40ddaed9b 100644 --- a/plugins/LadspaEffect/swh/notch_iir_1894.c +++ b/plugins/LadspaEffect/swh/notch_iir_1894.c @@ -25,6 +25,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 9 "notch_iir_1894.xml" #include "config.h" #include "util/iir.h" @@ -79,6 +80,7 @@ static void activateNotch_iir(LADSPA_Handle instance) { long sample_rate = plugin_data->sample_rate; iir_stage_t*second = plugin_data->second; float ufc = plugin_data->ufc; +#line 39 "notch_iir_1894.xml" ufc = (*(plugin_data->center) - *(plugin_data->width)*0.5f)/(float)sample_rate; lfc = (*(plugin_data->center) + *(plugin_data->width)*0.5f)/(float)sample_rate; @@ -99,6 +101,7 @@ static void activateNotch_iir(LADSPA_Handle instance) { } static void cleanupNotch_iir(LADSPA_Handle instance) { +#line 50 "notch_iir_1894.xml" Notch_iir *plugin_data = (Notch_iir *)instance; free_iirf_t(plugin_data->iirf1, plugin_data->first); free_iirf_t(plugin_data->iirf2, plugin_data->second); @@ -136,7 +139,7 @@ static void connectPortNotch_iir( static LADSPA_Handle instantiateNotch_iir( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Notch_iir *plugin_data = (Notch_iir *)malloc(sizeof(Notch_iir)); + Notch_iir *plugin_data = (Notch_iir *)calloc(1, sizeof(Notch_iir)); iir_stage_t*first = NULL; iirf_t*iirf1 = NULL; iirf_t*iirf2 = NULL; @@ -145,6 +148,7 @@ static LADSPA_Handle instantiateNotch_iir( iir_stage_t*second = NULL; float ufc; +#line 23 "notch_iir_1894.xml" sample_rate = s_rate; ufc = lfc = 0.0f; @@ -169,6 +173,7 @@ static LADSPA_Handle instantiateNotch_iir( static void runNotch_iir(LADSPA_Handle instance, unsigned long sample_count) { Notch_iir *plugin_data = (Notch_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Center Frequency (Hz) (float value) */ const LADSPA_Data center = *(plugin_data->center); @@ -192,12 +197,16 @@ static void runNotch_iir(LADSPA_Handle instance, unsigned long sample_count) { iir_stage_t* second = plugin_data->second; float ufc = plugin_data->ufc; +#line 27 "notch_iir_1894.xml" ufc = (center - width*0.5f)/(float)sample_rate; lfc = (center + width*0.5f)/(float)sample_rate; chebyshev(iirf1, first, 2*CLAMP((int)stages,1,10), IIR_STAGE_LOWPASS, ufc, 0.5f); chebyshev(iirf2, second, 2*CLAMP((int)stages,1,10), IIR_STAGE_HIGHPASS, lfc, 0.5f); iir_process_buffer_ns_5(iirf1, first, input, output, sample_count, RUN_ADDING); iir_process_buffer_ns_5(iirf2, second, input, output, sample_count, 1); /* add to first buffer */ + + // Unused variable + (void)(run_adding_gain); } #undef buffer_write #undef RUN_ADDING @@ -213,6 +222,7 @@ static void setRunAddingGainNotch_iir(LADSPA_Handle instance, LADSPA_Data gain) static void runAddingNotch_iir(LADSPA_Handle instance, unsigned long sample_count) { Notch_iir *plugin_data = (Notch_iir *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Center Frequency (Hz) (float value) */ const LADSPA_Data center = *(plugin_data->center); @@ -236,12 +246,16 @@ static void runAddingNotch_iir(LADSPA_Handle instance, unsigned long sample_coun iir_stage_t* second = plugin_data->second; float ufc = plugin_data->ufc; +#line 27 "notch_iir_1894.xml" ufc = (center - width*0.5f)/(float)sample_rate; lfc = (center + width*0.5f)/(float)sample_rate; chebyshev(iirf1, first, 2*CLAMP((int)stages,1,10), IIR_STAGE_LOWPASS, ufc, 0.5f); chebyshev(iirf2, second, 2*CLAMP((int)stages,1,10), IIR_STAGE_HIGHPASS, lfc, 0.5f); iir_process_buffer_ns_5(iirf1, first, input, output, sample_count, RUN_ADDING); iir_process_buffer_ns_5(iirf2, second, input, output, sample_count, 1); /* add to first buffer */ + + // Unused variable + (void)(run_adding_gain); } void __attribute__((constructor)) swh_init() { @@ -251,7 +265,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -343,12 +356,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (notch_iirDescriptor) { free((LADSPA_PortDescriptor *)notch_iirDescriptor->PortDescriptors); free((char **)notch_iirDescriptor->PortNames); free((LADSPA_PortRangeHint *)notch_iirDescriptor->PortRangeHints); free(notch_iirDescriptor); } + notch_iirDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/phasers_1217.c b/plugins/LadspaEffect/swh/phasers_1217.c index da50e11e8..d56cd7752 100644 --- a/plugins/LadspaEffect/swh/phasers_1217.c +++ b/plugins/LadspaEffect/swh/phasers_1217.c @@ -255,7 +255,7 @@ static void connectPortLfoPhaser( static LADSPA_Handle instantiateLfoPhaser( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - LfoPhaser *plugin_data = (LfoPhaser *)malloc(sizeof(LfoPhaser)); + LfoPhaser *plugin_data = (LfoPhaser *)calloc(1, sizeof(LfoPhaser)); allpass *ap = NULL; int count; float f_per_lv; @@ -551,7 +551,7 @@ static void connectPortFourByFourPole( static LADSPA_Handle instantiateFourByFourPole( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - FourByFourPole *plugin_data = (FourByFourPole *)malloc(sizeof(FourByFourPole)); + FourByFourPole *plugin_data = (FourByFourPole *)calloc(1, sizeof(FourByFourPole)); allpass *ap = NULL; float sr_r_2; float y0; @@ -838,7 +838,7 @@ static void connectPortAutoPhaser( static LADSPA_Handle instantiateAutoPhaser( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - AutoPhaser *plugin_data = (AutoPhaser *)malloc(sizeof(AutoPhaser)); + AutoPhaser *plugin_data = (AutoPhaser *)calloc(1, sizeof(AutoPhaser)); allpass *ap = NULL; envelope *env = NULL; float sample_rate; @@ -1037,7 +1037,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -1377,24 +1376,27 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (lfoPhaserDescriptor) { free((LADSPA_PortDescriptor *)lfoPhaserDescriptor->PortDescriptors); free((char **)lfoPhaserDescriptor->PortNames); free((LADSPA_PortRangeHint *)lfoPhaserDescriptor->PortRangeHints); free(lfoPhaserDescriptor); } + lfoPhaserDescriptor = NULL; if (fourByFourPoleDescriptor) { free((LADSPA_PortDescriptor *)fourByFourPoleDescriptor->PortDescriptors); free((char **)fourByFourPoleDescriptor->PortNames); free((LADSPA_PortRangeHint *)fourByFourPoleDescriptor->PortRangeHints); free(fourByFourPoleDescriptor); } + fourByFourPoleDescriptor = NULL; if (autoPhaserDescriptor) { free((LADSPA_PortDescriptor *)autoPhaserDescriptor->PortDescriptors); free((char **)autoPhaserDescriptor->PortNames); free((LADSPA_PortRangeHint *)autoPhaserDescriptor->PortRangeHints); free(autoPhaserDescriptor); } + autoPhaserDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/pitch_scale_1193.c b/plugins/LadspaEffect/swh/pitch_scale_1193.c index 88cf24cc8..9795425cc 100644 --- a/plugins/LadspaEffect/swh/pitch_scale_1193.c +++ b/plugins/LadspaEffect/swh/pitch_scale_1193.c @@ -79,6 +79,7 @@ static void activatePitchScale(LADSPA_Handle instance) { memset(buffers->gAnaFreq, 0, FRAME_LENGTH*sizeof(float)); memset(buffers->gAnaMagn, 0, FRAME_LENGTH*sizeof(float)); buffers->gRover = 0; + sample_rate = sample_rate; /* do one run to make sure the plans are set up */ pitch_scale(buffers, 1.0, FRAME_LENGTH, 4, FRAME_LENGTH, sample_rate, buffers->gInFIFO, buffers->gOutFIFO, 0, 0.0f); @@ -130,7 +131,7 @@ static void connectPortPitchScale( static LADSPA_Handle instantiatePitchScale( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - PitchScale *plugin_data = (PitchScale *)malloc(sizeof(PitchScale)); + PitchScale *plugin_data = (PitchScale *)calloc(1, sizeof(PitchScale)); sbuffers *buffers = NULL; long sample_rate; @@ -247,7 +248,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -326,12 +326,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (pitchScaleDescriptor) { free((LADSPA_PortDescriptor *)pitchScaleDescriptor->PortDescriptors); free((char **)pitchScaleDescriptor->PortNames); free((LADSPA_PortRangeHint *)pitchScaleDescriptor->PortRangeHints); free(pitchScaleDescriptor); } + pitchScaleDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/pitch_scale_1194.c b/plugins/LadspaEffect/swh/pitch_scale_1194.c index 62d6be129..8a06543f3 100644 --- a/plugins/LadspaEffect/swh/pitch_scale_1194.c +++ b/plugins/LadspaEffect/swh/pitch_scale_1194.c @@ -128,7 +128,7 @@ static void connectPortPitchScaleHQ( static LADSPA_Handle instantiatePitchScaleHQ( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - PitchScaleHQ *plugin_data = (PitchScaleHQ *)malloc(sizeof(PitchScaleHQ)); + PitchScaleHQ *plugin_data = (PitchScaleHQ *)calloc(1, sizeof(PitchScaleHQ)); sbuffers *buffers = NULL; long sample_rate; @@ -232,7 +232,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -311,12 +310,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (pitchScaleHQDescriptor) { free((LADSPA_PortDescriptor *)pitchScaleHQDescriptor->PortDescriptors); free((char **)pitchScaleHQDescriptor->PortNames); free((LADSPA_PortRangeHint *)pitchScaleHQDescriptor->PortRangeHints); free(pitchScaleHQDescriptor); } + pitchScaleHQDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/plate_1423.c b/plugins/LadspaEffect/swh/plate_1423.c index f73e8f138..af99c9e46 100644 --- a/plugins/LadspaEffect/swh/plate_1423.c +++ b/plugins/LadspaEffect/swh/plate_1423.c @@ -132,7 +132,7 @@ static void connectPortPlate( static LADSPA_Handle instantiatePlate( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Plate *plugin_data = (Plate *)malloc(sizeof(Plate)); + Plate *plugin_data = (Plate *)calloc(1, sizeof(Plate)); float *out = NULL; waveguide_nl **w = NULL; @@ -302,7 +302,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -401,12 +400,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (plateDescriptor) { free((LADSPA_PortDescriptor *)plateDescriptor->PortDescriptors); free((char **)plateDescriptor->PortNames); free((LADSPA_PortRangeHint *)plateDescriptor->PortRangeHints); free(plateDescriptor); } + plateDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/pointer_cast_1910.c b/plugins/LadspaEffect/swh/pointer_cast_1910.c index 7465bd145..cdd410e54 100644 --- a/plugins/LadspaEffect/swh/pointer_cast_1910.c +++ b/plugins/LadspaEffect/swh/pointer_cast_1910.c @@ -115,7 +115,7 @@ static void connectPortPointerCastDistortion( static LADSPA_Handle instantiatePointerCastDistortion( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - PointerCastDistortion *plugin_data = (PointerCastDistortion *)malloc(sizeof(PointerCastDistortion)); + PointerCastDistortion *plugin_data = (PointerCastDistortion *)calloc(1, sizeof(PointerCastDistortion)); biquad *filt = NULL; float fs; @@ -228,7 +228,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -310,12 +309,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (pointerCastDistortionDescriptor) { free((LADSPA_PortDescriptor *)pointerCastDistortionDescriptor->PortDescriptors); free((char **)pointerCastDistortionDescriptor->PortNames); free((LADSPA_PortRangeHint *)pointerCastDistortionDescriptor->PortRangeHints); free(pointerCastDistortionDescriptor); } + pointerCastDistortionDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/rate_shifter_1417.c b/plugins/LadspaEffect/swh/rate_shifter_1417.c index 21e03cbc3..5bb38d64b 100644 --- a/plugins/LadspaEffect/swh/rate_shifter_1417.c +++ b/plugins/LadspaEffect/swh/rate_shifter_1417.c @@ -111,7 +111,7 @@ static void connectPortRateShifter( static LADSPA_Handle instantiateRateShifter( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - RateShifter *plugin_data = (RateShifter *)malloc(sizeof(RateShifter)); + RateShifter *plugin_data = (RateShifter *)calloc(1, sizeof(RateShifter)); LADSPA_Data *buffer = NULL; unsigned int buffer_mask; fixp32 read_ptr; @@ -242,7 +242,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -314,12 +313,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (rateShifterDescriptor) { free((LADSPA_PortDescriptor *)rateShifterDescriptor->PortDescriptors); free((char **)rateShifterDescriptor->PortNames); free((LADSPA_PortRangeHint *)rateShifterDescriptor->PortRangeHints); free(rateShifterDescriptor); } + rateShifterDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/retro_flange_1208.c b/plugins/LadspaEffect/swh/retro_flange_1208.c index 9c7fb4fe4..eaf6b6945 100644 --- a/plugins/LadspaEffect/swh/retro_flange_1208.c +++ b/plugins/LadspaEffect/swh/retro_flange_1208.c @@ -31,7 +31,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define BASE_BUFFER 0.001 // Base buffer length (s) -static inline LADSPA_Data sat(LADSPA_Data x, float q, float dist) { +inline LADSPA_Data sat(LADSPA_Data x, float q, float dist) { if (x == q) { return 1.0f / dist + q / (1.0f - f_exp(dist * q)); } @@ -178,7 +178,7 @@ static void connectPortRetroFlange( static LADSPA_Handle instantiateRetroFlange( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - RetroFlange *plugin_data = (RetroFlange *)malloc(sizeof(RetroFlange)); + RetroFlange *plugin_data = (RetroFlange *)calloc(1, sizeof(RetroFlange)); LADSPA_Data *buffer = NULL; long buffer_size; long count; @@ -499,7 +499,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -581,12 +580,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (retroFlangeDescriptor) { free((LADSPA_PortDescriptor *)retroFlangeDescriptor->PortDescriptors); free((char **)retroFlangeDescriptor->PortNames); free((LADSPA_PortRangeHint *)retroFlangeDescriptor->PortRangeHints); free(retroFlangeDescriptor); } + retroFlangeDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/revdelay_1605.c b/plugins/LadspaEffect/swh/revdelay_1605.c index e714ee5e2..6091497c5 100644 --- a/plugins/LadspaEffect/swh/revdelay_1605.c +++ b/plugins/LadspaEffect/swh/revdelay_1605.c @@ -25,6 +25,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 10 "revdelay_1605.xml" #include "ladspa-util.h" #include @@ -85,6 +86,7 @@ static void activateRevdelay(LADSPA_Handle instance) { LADSPA_Data last_delay_time = plugin_data->last_delay_time; unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 38 "revdelay_1605.xml" unsigned int size; size = sample_rate * 5 * 2; /* 5 second maximum */ @@ -105,6 +107,7 @@ static void activateRevdelay(LADSPA_Handle instance) { } static void cleanupRevdelay(LADSPA_Handle instance) { +#line 51 "revdelay_1605.xml" Revdelay *plugin_data = (Revdelay *)instance; free(plugin_data->buffer); free(instance); @@ -145,7 +148,7 @@ static void connectPortRevdelay( static LADSPA_Handle instantiateRevdelay( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Revdelay *plugin_data = (Revdelay *)malloc(sizeof(Revdelay)); + Revdelay *plugin_data = (Revdelay *)calloc(1, sizeof(Revdelay)); LADSPA_Data *buffer = NULL; unsigned int buffer_size; LADSPA_Data delay_samples; @@ -153,6 +156,7 @@ static LADSPA_Handle instantiateRevdelay( unsigned int sample_rate; long write_phase; +#line 30 "revdelay_1605.xml" sample_rate = s_rate; buffer_size = 0; delay_samples = 0; @@ -207,6 +211,7 @@ static void runRevdelay(LADSPA_Handle instance, unsigned long sample_count) { unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 55 "revdelay_1605.xml" int i; unsigned long delay2; float dry = DB_CO(dry_level); @@ -335,6 +340,7 @@ static void runAddingRevdelay(LADSPA_Handle instance, unsigned long sample_count unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; +#line 55 "revdelay_1605.xml" int i; unsigned long delay2; float dry = DB_CO(dry_level); @@ -428,7 +434,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -540,12 +545,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (revdelayDescriptor) { free((LADSPA_PortDescriptor *)revdelayDescriptor->PortDescriptors); free((char **)revdelayDescriptor->PortNames); free((LADSPA_PortRangeHint *)revdelayDescriptor->PortRangeHints); free(revdelayDescriptor); } + revdelayDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/ringmod_1188.c b/plugins/LadspaEffect/swh/ringmod_1188.c index 591dc966e..4d628cefb 100644 --- a/plugins/LadspaEffect/swh/ringmod_1188.c +++ b/plugins/LadspaEffect/swh/ringmod_1188.c @@ -120,7 +120,7 @@ static void connectPortRingmod_2i1o( static LADSPA_Handle instantiateRingmod_2i1o( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Ringmod_2i1o *plugin_data = (Ringmod_2i1o *)malloc(sizeof(Ringmod_2i1o)); + Ringmod_2i1o *plugin_data = (Ringmod_2i1o *)calloc(1, sizeof(Ringmod_2i1o)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -207,6 +207,8 @@ static void activateRingmod_1i1o1l(LADSPA_Handle instance) { static void cleanupRingmod_1i1o1l(LADSPA_Handle instance) { #line 93 "ringmod_1188.xml" + Ringmod_1i1o1l *plugin_data = (Ringmod_1i1o1l *)instance; + plugin_data = plugin_data; if (--refcount == 0) { free(sin_tbl); free(tri_tbl); @@ -254,7 +256,7 @@ static void connectPortRingmod_1i1o1l( static LADSPA_Handle instantiateRingmod_1i1o1l( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Ringmod_1i1o1l *plugin_data = (Ringmod_1i1o1l *)malloc(sizeof(Ringmod_1i1o1l)); + Ringmod_1i1o1l *plugin_data = (Ringmod_1i1o1l *)calloc(1, sizeof(Ringmod_1i1o1l)); LADSPA_Data offset; #line 59 "ringmod_1188.xml" @@ -434,7 +436,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -630,18 +631,20 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (ringmod_2i1oDescriptor) { free((LADSPA_PortDescriptor *)ringmod_2i1oDescriptor->PortDescriptors); free((char **)ringmod_2i1oDescriptor->PortNames); free((LADSPA_PortRangeHint *)ringmod_2i1oDescriptor->PortRangeHints); free(ringmod_2i1oDescriptor); } + ringmod_2i1oDescriptor = NULL; if (ringmod_1i1o1lDescriptor) { free((LADSPA_PortDescriptor *)ringmod_1i1o1lDescriptor->PortDescriptors); free((char **)ringmod_1i1o1lDescriptor->PortNames); free((LADSPA_PortRangeHint *)ringmod_1i1o1lDescriptor->PortRangeHints); free(ringmod_1i1o1lDescriptor); } + ringmod_1i1o1lDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/satan_maximiser_1408.c b/plugins/LadspaEffect/swh/satan_maximiser_1408.c index acf99ac3c..112f27ac0 100644 --- a/plugins/LadspaEffect/swh/satan_maximiser_1408.c +++ b/plugins/LadspaEffect/swh/satan_maximiser_1408.c @@ -116,7 +116,7 @@ static void connectPortSatanMaximiser( static LADSPA_Handle instantiateSatanMaximiser( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - SatanMaximiser *plugin_data = (SatanMaximiser *)malloc(sizeof(SatanMaximiser)); + SatanMaximiser *plugin_data = (SatanMaximiser *)calloc(1, sizeof(SatanMaximiser)); LADSPA_Data *buffer = NULL; unsigned int buffer_pos; float env; @@ -262,7 +262,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -344,12 +343,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (satanMaximiserDescriptor) { free((LADSPA_PortDescriptor *)satanMaximiserDescriptor->PortDescriptors); free((char **)satanMaximiserDescriptor->PortNames); free((LADSPA_PortRangeHint *)satanMaximiserDescriptor->PortRangeHints); free(satanMaximiserDescriptor); } + satanMaximiserDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/sc1_1425.c b/plugins/LadspaEffect/swh/sc1_1425.c index 4b2ce94f1..270b9181c 100644 --- a/plugins/LadspaEffect/swh/sc1_1425.c +++ b/plugins/LadspaEffect/swh/sc1_1425.c @@ -126,7 +126,7 @@ static void connectPortSc1( static LADSPA_Handle instantiateSc1( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Sc1 *plugin_data = (Sc1 *)malloc(sizeof(Sc1)); + Sc1 *plugin_data = (Sc1 *)calloc(1, sizeof(Sc1)); float amp; float *as = NULL; unsigned int count; @@ -351,7 +351,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -473,12 +472,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (sc1Descriptor) { free((LADSPA_PortDescriptor *)sc1Descriptor->PortDescriptors); free((char **)sc1Descriptor->PortNames); free((LADSPA_PortRangeHint *)sc1Descriptor->PortRangeHints); free(sc1Descriptor); } + sc1Descriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/sc2_1426.c b/plugins/LadspaEffect/swh/sc2_1426.c index dcad834bc..224834409 100644 --- a/plugins/LadspaEffect/swh/sc2_1426.c +++ b/plugins/LadspaEffect/swh/sc2_1426.c @@ -131,7 +131,7 @@ static void connectPortSc2( static LADSPA_Handle instantiateSc2( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Sc2 *plugin_data = (Sc2 *)malloc(sizeof(Sc2)); + Sc2 *plugin_data = (Sc2 *)calloc(1, sizeof(Sc2)); float amp; float *as = NULL; unsigned int count; @@ -362,7 +362,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -491,12 +490,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (sc2Descriptor) { free((LADSPA_PortDescriptor *)sc2Descriptor->PortDescriptors); free((char **)sc2Descriptor->PortNames); free((LADSPA_PortRangeHint *)sc2Descriptor->PortRangeHints); free(sc2Descriptor); } + sc2Descriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/sc3_1427.c b/plugins/LadspaEffect/swh/sc3_1427.c index 27edde705..7364fd3a9 100644 --- a/plugins/LadspaEffect/swh/sc3_1427.c +++ b/plugins/LadspaEffect/swh/sc3_1427.c @@ -146,7 +146,7 @@ static void connectPortSc3( static LADSPA_Handle instantiateSc3( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Sc3 *plugin_data = (Sc3 *)malloc(sizeof(Sc3)); + Sc3 *plugin_data = (Sc3 *)calloc(1, sizeof(Sc3)); float amp; float *as = NULL; unsigned int count; @@ -409,7 +409,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -562,12 +561,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (sc3Descriptor) { free((LADSPA_PortDescriptor *)sc3Descriptor->PortDescriptors); free((char **)sc3Descriptor->PortNames); free((LADSPA_PortRangeHint *)sc3Descriptor->PortRangeHints); free(sc3Descriptor); } + sc3Descriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/sc4_1882.c b/plugins/LadspaEffect/swh/sc4_1882.c index 3ff1fd002..9d1fce001 100644 --- a/plugins/LadspaEffect/swh/sc4_1882.c +++ b/plugins/LadspaEffect/swh/sc4_1882.c @@ -153,7 +153,7 @@ static void connectPortSc4( static LADSPA_Handle instantiateSc4( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Sc4 *plugin_data = (Sc4 *)malloc(sizeof(Sc4)); + Sc4 *plugin_data = (Sc4 *)calloc(1, sizeof(Sc4)); float amp; float *as = NULL; unsigned int count; @@ -452,7 +452,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -618,12 +617,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (sc4Descriptor) { free((LADSPA_PortDescriptor *)sc4Descriptor->PortDescriptors); free((char **)sc4Descriptor->PortNames); free((LADSPA_PortRangeHint *)sc4Descriptor->PortRangeHints); free(sc4Descriptor); } + sc4Descriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/sc4m_1916.c b/plugins/LadspaEffect/swh/sc4m_1916.c index 4d92a213e..e7fe656f7 100644 --- a/plugins/LadspaEffect/swh/sc4m_1916.c +++ b/plugins/LadspaEffect/swh/sc4m_1916.c @@ -143,7 +143,7 @@ static void connectPortSc4m( static LADSPA_Handle instantiateSc4m( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Sc4m *plugin_data = (Sc4m *)malloc(sizeof(Sc4m)); + Sc4m *plugin_data = (Sc4m *)calloc(1, sizeof(Sc4m)); float amp; float *as = NULL; unsigned int count; @@ -416,7 +416,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -568,12 +567,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (sc4mDescriptor) { free((LADSPA_PortDescriptor *)sc4mDescriptor->PortDescriptors); free((char **)sc4mDescriptor->PortNames); free((LADSPA_PortRangeHint *)sc4mDescriptor->PortRangeHints); free(sc4mDescriptor); } + sc4mDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/se4_1883.c b/plugins/LadspaEffect/swh/se4_1883.c index 2c1ddce6e..5e6c825de 100644 --- a/plugins/LadspaEffect/swh/se4_1883.c +++ b/plugins/LadspaEffect/swh/se4_1883.c @@ -153,7 +153,7 @@ static void connectPortSe4( static LADSPA_Handle instantiateSe4( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Se4 *plugin_data = (Se4 *)malloc(sizeof(Se4)); + Se4 *plugin_data = (Se4 *)calloc(1, sizeof(Se4)); float amp; float *as = NULL; unsigned int count; @@ -448,7 +448,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -614,12 +613,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (se4Descriptor) { free((LADSPA_PortDescriptor *)se4Descriptor->PortDescriptors); free((char **)se4Descriptor->PortNames); free((LADSPA_PortRangeHint *)se4Descriptor->PortRangeHints); free(se4Descriptor); } + se4Descriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/shaper_1187.c b/plugins/LadspaEffect/swh/shaper_1187.c index 89fc699b4..448aa0d20 100644 --- a/plugins/LadspaEffect/swh/shaper_1187.c +++ b/plugins/LadspaEffect/swh/shaper_1187.c @@ -83,7 +83,7 @@ static void connectPortShaper( static LADSPA_Handle instantiateShaper( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Shaper *plugin_data = (Shaper *)malloc(sizeof(Shaper)); + Shaper *plugin_data = (Shaper *)calloc(1, sizeof(Shaper)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -182,7 +182,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -260,12 +259,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (shaperDescriptor) { free((LADSPA_PortDescriptor *)shaperDescriptor->PortDescriptors); free((char **)shaperDescriptor->PortNames); free((LADSPA_PortRangeHint *)shaperDescriptor->PortRangeHints); free(shaperDescriptor); } + shaperDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/sifter_1210.c b/plugins/LadspaEffect/swh/sifter_1210.c index 1c05217b8..f44cab342 100644 --- a/plugins/LadspaEffect/swh/sifter_1210.c +++ b/plugins/LadspaEffect/swh/sifter_1210.c @@ -33,11 +33,7 @@ void __attribute__((constructor)) swh_init(); // forward declaration inline int partition(LADSPA_Data array[], int left, int right); -#ifdef __clang__ void q_sort(LADSPA_Data array[], int left, int right) { -#else -inline void q_sort(LADSPA_Data array[], int left, int right) { -#endif float pivot = partition(array, left, right); if (left < pivot) { @@ -164,7 +160,7 @@ static void connectPortSifter( static LADSPA_Handle instantiateSifter( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Sifter *plugin_data = (Sifter *)malloc(sizeof(Sifter)); + Sifter *plugin_data = (Sifter *)calloc(1, sizeof(Sifter)); LADSPA_Data *b1 = NULL; long b1ptr; LADSPA_Data *b2 = NULL; @@ -366,7 +362,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -438,12 +433,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (sifterDescriptor) { free((LADSPA_PortDescriptor *)sifterDescriptor->PortDescriptors); free((char **)sifterDescriptor->PortNames); free((LADSPA_PortRangeHint *)sifterDescriptor->PortRangeHints); free(sifterDescriptor); } + sifterDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/sin_cos_1881.c b/plugins/LadspaEffect/swh/sin_cos_1881.c index d12977141..239df03af 100644 --- a/plugins/LadspaEffect/swh/sin_cos_1881.c +++ b/plugins/LadspaEffect/swh/sin_cos_1881.c @@ -94,7 +94,7 @@ static void connectPortSinCos( static LADSPA_Handle instantiateSinCos( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - SinCos *plugin_data = (SinCos *)malloc(sizeof(SinCos)); + SinCos *plugin_data = (SinCos *)calloc(1, sizeof(SinCos)); float fs; double last_om; double phi; @@ -214,7 +214,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -296,12 +295,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (sinCosDescriptor) { free((LADSPA_PortDescriptor *)sinCosDescriptor->PortDescriptors); free((char **)sinCosDescriptor->PortNames); free((LADSPA_PortRangeHint *)sinCosDescriptor->PortRangeHints); free(sinCosDescriptor); } + sinCosDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/single_para_1203.c b/plugins/LadspaEffect/swh/single_para_1203.c index ef322fe36..088d33ff8 100644 --- a/plugins/LadspaEffect/swh/single_para_1203.c +++ b/plugins/LadspaEffect/swh/single_para_1203.c @@ -112,7 +112,7 @@ static void connectPortSinglePara( static LADSPA_Handle instantiateSinglePara( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - SinglePara *plugin_data = (SinglePara *)malloc(sizeof(SinglePara)); + SinglePara *plugin_data = (SinglePara *)calloc(1, sizeof(SinglePara)); biquad *filter = NULL; float fs; @@ -214,7 +214,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -312,12 +311,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (singleParaDescriptor) { free((LADSPA_PortDescriptor *)singleParaDescriptor->PortDescriptors); free((char **)singleParaDescriptor->PortNames); free((LADSPA_PortRangeHint *)singleParaDescriptor->PortRangeHints); free(singleParaDescriptor); } + singleParaDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/sinus_wavewrapper_1198.c b/plugins/LadspaEffect/swh/sinus_wavewrapper_1198.c index d8dc7b2cc..05e1d7a14 100644 --- a/plugins/LadspaEffect/swh/sinus_wavewrapper_1198.c +++ b/plugins/LadspaEffect/swh/sinus_wavewrapper_1198.c @@ -83,7 +83,7 @@ static void connectPortSinusWavewrapper( static LADSPA_Handle instantiateSinusWavewrapper( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - SinusWavewrapper *plugin_data = (SinusWavewrapper *)malloc(sizeof(SinusWavewrapper)); + SinusWavewrapper *plugin_data = (SinusWavewrapper *)calloc(1, sizeof(SinusWavewrapper)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -166,7 +166,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -244,12 +243,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (sinusWavewrapperDescriptor) { free((LADSPA_PortDescriptor *)sinusWavewrapperDescriptor->PortDescriptors); free((char **)sinusWavewrapperDescriptor->PortNames); free((LADSPA_PortRangeHint *)sinusWavewrapperDescriptor->PortRangeHints); free(sinusWavewrapperDescriptor); } + sinusWavewrapperDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/smooth_decimate_1414.c b/plugins/LadspaEffect/swh/smooth_decimate_1414.c index c63e6ce6f..e53676646 100644 --- a/plugins/LadspaEffect/swh/smooth_decimate_1414.c +++ b/plugins/LadspaEffect/swh/smooth_decimate_1414.c @@ -114,7 +114,7 @@ static void connectPortSmoothDecimate( static LADSPA_Handle instantiateSmoothDecimate( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - SmoothDecimate *plugin_data = (SmoothDecimate *)malloc(sizeof(SmoothDecimate)); + SmoothDecimate *plugin_data = (SmoothDecimate *)calloc(1, sizeof(SmoothDecimate)); float accum; float *buffer = NULL; int buffer_pos; @@ -247,7 +247,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -329,12 +328,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (smoothDecimateDescriptor) { free((LADSPA_PortDescriptor *)smoothDecimateDescriptor->PortDescriptors); free((char **)smoothDecimateDescriptor->PortNames); free((LADSPA_PortRangeHint *)smoothDecimateDescriptor->PortRangeHints); free(smoothDecimateDescriptor); } + smoothDecimateDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/split_1406.c b/plugins/LadspaEffect/swh/split_1406.c index 2fa1bee7b..84ee4f963 100644 --- a/plugins/LadspaEffect/swh/split_1406.c +++ b/plugins/LadspaEffect/swh/split_1406.c @@ -83,7 +83,7 @@ static void connectPortSplit( static LADSPA_Handle instantiateSplit( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Split *plugin_data = (Split *)malloc(sizeof(Split)); + Split *plugin_data = (Split *)calloc(1, sizeof(Split)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -162,7 +162,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -240,12 +239,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (splitDescriptor) { free((LADSPA_PortDescriptor *)splitDescriptor->PortDescriptors); free((char **)splitDescriptor->PortNames); free((LADSPA_PortRangeHint *)splitDescriptor->PortRangeHints); free(splitDescriptor); } + splitDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/step_muxer_1212.c b/plugins/LadspaEffect/swh/step_muxer_1212.c index 99c4ecf15..8debbb864 100644 --- a/plugins/LadspaEffect/swh/step_muxer_1212.c +++ b/plugins/LadspaEffect/swh/step_muxer_1212.c @@ -100,6 +100,7 @@ static void activateStepMuxer(LADSPA_Handle instance) { } current_ch = 0; last_clock = 0.0f; + sample_rate = sample_rate; plugin_data->ch_gain = ch_gain; plugin_data->ch_state = ch_state; plugin_data->current_ch = current_ch; @@ -163,7 +164,7 @@ static void connectPortStepMuxer( static LADSPA_Handle instantiateStepMuxer( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - StepMuxer *plugin_data = (StepMuxer *)malloc(sizeof(StepMuxer)); + StepMuxer *plugin_data = (StepMuxer *)calloc(1, sizeof(StepMuxer)); float *ch_gain = NULL; int *ch_state = NULL; int current_ch; @@ -403,7 +404,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -531,12 +531,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (stepMuxerDescriptor) { free((LADSPA_PortDescriptor *)stepMuxerDescriptor->PortDescriptors); free((char **)stepMuxerDescriptor->PortNames); free((LADSPA_PortRangeHint *)stepMuxerDescriptor->PortRangeHints); free(stepMuxerDescriptor); } + stepMuxerDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/surround_encoder_1401.c b/plugins/LadspaEffect/swh/surround_encoder_1401.c index 100a03e5a..ca5e74f64 100644 --- a/plugins/LadspaEffect/swh/surround_encoder_1401.c +++ b/plugins/LadspaEffect/swh/surround_encoder_1401.c @@ -160,7 +160,7 @@ static void connectPortSurroundEncoder( static LADSPA_Handle instantiateSurroundEncoder( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - SurroundEncoder *plugin_data = (SurroundEncoder *)malloc(sizeof(SurroundEncoder)); + SurroundEncoder *plugin_data = (SurroundEncoder *)calloc(1, sizeof(SurroundEncoder)); LADSPA_Data *buffer = NULL; unsigned int buffer_pos; unsigned int buffer_size; @@ -324,7 +324,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -414,12 +413,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (surroundEncoderDescriptor) { free((LADSPA_PortDescriptor *)surroundEncoderDescriptor->PortDescriptors); free((char **)surroundEncoderDescriptor->PortNames); free((LADSPA_PortRangeHint *)surroundEncoderDescriptor->PortRangeHints); free(surroundEncoderDescriptor); } + surroundEncoderDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/svf_1214.c b/plugins/LadspaEffect/swh/svf_1214.c index c1a74aa0b..1b4e325fa 100644 --- a/plugins/LadspaEffect/swh/svf_1214.c +++ b/plugins/LadspaEffect/swh/svf_1214.c @@ -192,7 +192,7 @@ static void connectPortSvf( static LADSPA_Handle instantiateSvf( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Svf *plugin_data = (Svf *)malloc(sizeof(Svf)); + Svf *plugin_data = (Svf *)calloc(1, sizeof(Svf)); int sample_rate; sv_filter *svf = NULL; @@ -300,7 +300,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -408,12 +407,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (svfDescriptor) { free((LADSPA_PortDescriptor *)svfDescriptor->PortDescriptors); free((char **)svfDescriptor->PortNames); free((LADSPA_PortRangeHint *)svfDescriptor->PortRangeHints); free(svfDescriptor); } + svfDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/tape_delay_1211.c b/plugins/LadspaEffect/swh/tape_delay_1211.c index 6d78239e3..df44cf860 100644 --- a/plugins/LadspaEffect/swh/tape_delay_1211.c +++ b/plugins/LadspaEffect/swh/tape_delay_1211.c @@ -116,6 +116,7 @@ static void activateTapeDelay(LADSPA_Handle instance) { last_in = 0.0f; last2_in = 0.0f; last3_in = 0.0f; + sample_rate = sample_rate; z0 = 0.0f; z1 = 0.0f; z2 = 0.0f; @@ -191,7 +192,7 @@ static void connectPortTapeDelay( static LADSPA_Handle instantiateTapeDelay( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - TapeDelay *plugin_data = (TapeDelay *)malloc(sizeof(TapeDelay)); + TapeDelay *plugin_data = (TapeDelay *)calloc(1, sizeof(TapeDelay)); LADSPA_Data *buffer = NULL; unsigned int buffer_mask; unsigned int buffer_size; @@ -482,7 +483,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -644,12 +644,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (tapeDelayDescriptor) { free((LADSPA_PortDescriptor *)tapeDelayDescriptor->PortDescriptors); free((char **)tapeDelayDescriptor->PortNames); free((LADSPA_PortRangeHint *)tapeDelayDescriptor->PortRangeHints); free(tapeDelayDescriptor); } + tapeDelayDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/transient_1206.c b/plugins/LadspaEffect/swh/transient_1206.c index 3c591535f..853efd36a 100644 --- a/plugins/LadspaEffect/swh/transient_1206.c +++ b/plugins/LadspaEffect/swh/transient_1206.c @@ -97,6 +97,7 @@ static void activateTransient(LADSPA_Handle instance) { medi_track = 0.1; slow_track = 0.1; count = 0; + sample_rate = sample_rate; plugin_data->buffer = buffer; plugin_data->buffer_pos = buffer_pos; plugin_data->count = count; @@ -143,7 +144,7 @@ static void connectPortTransient( static LADSPA_Handle instantiateTransient( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Transient *plugin_data = (Transient *)malloc(sizeof(Transient)); + Transient *plugin_data = (Transient *)calloc(1, sizeof(Transient)); float *buffer = NULL; int buffer_pos; long count; @@ -376,7 +377,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -464,12 +464,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (transientDescriptor) { free((LADSPA_PortDescriptor *)transientDescriptor->PortDescriptors); free((char **)transientDescriptor->PortNames); free((LADSPA_PortRangeHint *)transientDescriptor->PortRangeHints); free(transientDescriptor); } + transientDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/triple_para_1204.c b/plugins/LadspaEffect/swh/triple_para_1204.c index ef7a26b7c..306395eb0 100644 --- a/plugins/LadspaEffect/swh/triple_para_1204.c +++ b/plugins/LadspaEffect/swh/triple_para_1204.c @@ -176,7 +176,7 @@ static void connectPortTriplePara( static LADSPA_Handle instantiateTriplePara( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - TriplePara *plugin_data = (TriplePara *)malloc(sizeof(TriplePara)); + TriplePara *plugin_data = (TriplePara *)calloc(1, sizeof(TriplePara)); biquad *filters = NULL; float fs; @@ -375,7 +375,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -593,12 +592,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (tripleParaDescriptor) { free((LADSPA_PortDescriptor *)tripleParaDescriptor->PortDescriptors); free((char **)tripleParaDescriptor->PortNames); free((LADSPA_PortRangeHint *)tripleParaDescriptor->PortRangeHints); free(tripleParaDescriptor); } + tripleParaDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/valve_1209.c b/plugins/LadspaEffect/swh/valve_1209.c index 8f10428a0..c61744aa1 100644 --- a/plugins/LadspaEffect/swh/valve_1209.c +++ b/plugins/LadspaEffect/swh/valve_1209.c @@ -105,7 +105,7 @@ static void connectPortValve( static LADSPA_Handle instantiateValve( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Valve *plugin_data = (Valve *)malloc(sizeof(Valve)); + Valve *plugin_data = (Valve *)calloc(1, sizeof(Valve)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -250,7 +250,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -332,12 +331,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (valveDescriptor) { free((LADSPA_PortDescriptor *)valveDescriptor->PortDescriptors); free((char **)valveDescriptor->PortNames); free((LADSPA_PortRangeHint *)valveDescriptor->PortRangeHints); free(valveDescriptor); } + valveDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/valve_rect_1405.c b/plugins/LadspaEffect/swh/valve_rect_1405.c index a4191a4fd..bc2acb0fc 100644 --- a/plugins/LadspaEffect/swh/valve_rect_1405.c +++ b/plugins/LadspaEffect/swh/valve_rect_1405.c @@ -126,7 +126,7 @@ static void connectPortValveRect( static LADSPA_Handle instantiateValveRect( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - ValveRect *plugin_data = (ValveRect *)malloc(sizeof(ValveRect)); + ValveRect *plugin_data = (ValveRect *)calloc(1, sizeof(ValveRect)); unsigned int apos; float *avg = NULL; int avg_size; @@ -319,7 +319,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -401,12 +400,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (valveRectDescriptor) { free((LADSPA_PortDescriptor *)valveRectDescriptor->PortDescriptors); free((char **)valveRectDescriptor->PortNames); free((LADSPA_PortRangeHint *)valveRectDescriptor->PortRangeHints); free(valveRectDescriptor); } + valveRectDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/vocoder_1337.c b/plugins/LadspaEffect/swh/vocoder_1337.c index 599d22ebe..0d70d5046 100644 --- a/plugins/LadspaEffect/swh/vocoder_1337.c +++ b/plugins/LadspaEffect/swh/vocoder_1337.c @@ -1,44 +1,21 @@ -/* vocoder.c - Version 0.3 +#include +#include +#ifndef WIN32 +#include "config.h" +#endif - LADSPA Unique ID: 1337 +#ifdef ENABLE_NLS +#include +#endif - Version 0.31 - Added stereo output, renamed input/output ports, added, - added a control for stereo balance +#define _ISOC9X_SOURCE 1 +#define _ISOC99_SOURCE 1 +#define __USE_ISOC99 1 +#define __USE_ISOC9X 1 - Version 0.3 - Added support for changing bands in real time 2003-12-09 +#include - Version 0.2 - Adapted to LADSPA by Josh Green - 15.6.2001 (for the LinuxTag 2001!) - - Original program can be found at: - http://www.sirlab.de/linux/ - Author: Achim Settelmeier - - Adapted to LMMS by Hexasoft (hexasoft.corp@free.fr) - - - Licence: GPL - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ - - -/* not familiar with WINDOWS stuff. Saw this in other sources, it should be needed */ +#include "ladspa.h" #ifdef WIN32 #define _WINDOWS_DLL_EXPORT_ __declspec(dllexport) @@ -48,25 +25,16 @@ void __attribute__((constructor)) swh_init(); // forward declaration #define _WINDOWS_DLL_EXPORT_ #endif +#line 10 "vocoder_1337.xml" -/*****************************************************************************/ -/* general includes */ -#include -#include -#include -#include +#include "util/iir.h" -/*****************************************************************************/ -/* LADSPA headers */ -#include +#define MAX_BANDS 16 +#define AMPLIFIER 16.0 -/*****************************************************************************/ - - -#define LADSPA_UNIQUE_ID 1337 - -#define MAX_BANDS 16 /* max 16 bands should be increased */ -#define AMPLIFIER 16.0 +// 0 = formant, 1 = carrier, 2 = output, 3 = output2, 4 = bandcount, 5 = pan +#define START_BANDS 6 /* start of bands level */ +#define PORT_COUNT START_BANDS + MAX_BANDS /* bands level */ struct bandpasses { @@ -79,10 +47,12 @@ struct bandpasses LADSPA_Data y[MAX_BANDS]; }; +void inline doBandpasses(struct bandpasses *bands, LADSPA_Data sample, int num_bands); + struct bands_out{ LADSPA_Data decay[MAX_BANDS]; LADSPA_Data oldval[MAX_BANDS]; - LADSPA_Data level[MAX_BANDS]; /* 0.0 - 1.0 level of this output band */ + LADSPA_Data level[MAX_BANDS]; /* 0.0 - 1.0 level of this output band */ }; const LADSPA_Data decay_table[] = @@ -95,367 +65,914 @@ const LADSPA_Data decay_table[] = 1/250.0, 1/250.0, 1/250.0 }; -/* The port numbers for the plugin: */ +void inline doBandpasses(struct bandpasses *bands, LADSPA_Data sample, int num_bands) +{ + int i; + for (i=0; i < num_bands; i++) + { + bands->high1[i] = sample - bands->f[i] * bands->mid1[i] - bands->low1[i]; + bands->mid1[i] += bands->high1[i] * bands->c[i]; + bands->low1[i] += bands->mid1[i]; -#define PORT_FORMANT 0 /* the track to "vocodify */ -#define PORT_CARRIER 1 /* the track to control 1st track */ -#define PORT_OUTPUT 2 /* left output */ -#define PORT_OUTPUT2 3 /* right output */ -#define CTRL_BANDCOUNT 4 /* selected # of bands to use */ -#define CTRL_PAN 5 /* stereo balance for outputs */ -#define CTRL_BAND1LVL 6 /* start of bands level */ + bands->high2[i] = bands->low1[i] - bands->f[i] * bands->mid2[i] - bands->low2[i]; + bands->mid2[i] += bands->high2[i] * bands->c[i]; + bands->low2[i] += bands->mid2[i]; + bands->y[i] = bands->high2[i] * bands->att[i]; + } +} -#define PORT_COUNT 6 + MAX_BANDS /* bands level */ +#define VOCODER_PORT_FORMANT 0 +#define VOCODER_PORT_CARRIER 1 +#define VOCODER_PORT_OUTPUT 2 +#define VOCODER_PORT_OUTPUT2 3 +#define VOCODER_CTRL_BAND_COUNT 4 +#define VOCODER_CTRL_PAN 5 +#define VOCODER_BAND1 6 +#define VOCODER_BAND2 7 +#define VOCODER_BAND3 8 +#define VOCODER_BAND4 9 +#define VOCODER_BAND5 10 +#define VOCODER_BAND6 11 +#define VOCODER_BAND7 12 +#define VOCODER_BAND8 13 +#define VOCODER_BAND9 14 +#define VOCODER_BAND10 15 +#define VOCODER_BAND11 16 +#define VOCODER_BAND12 17 +#define VOCODER_BAND13 18 +#define VOCODER_BAND14 19 +#define VOCODER_BAND15 20 +#define VOCODER_BAND16 21 +static LADSPA_Descriptor *vocoderDescriptor = NULL; -/* useful macros */ -#undef CLAMP -#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) - -/* Instance data for the vocoder plugin */ typedef struct { - LADSPA_Data SampleRate; + LADSPA_Data *port_formant; + LADSPA_Data *port_carrier; + LADSPA_Data *port_output; + LADSPA_Data *port_output2; + LADSPA_Data *ctrl_band_count; + LADSPA_Data *ctrl_pan; + LADSPA_Data *band1; + LADSPA_Data *band2; + LADSPA_Data *band3; + LADSPA_Data *band4; + LADSPA_Data *band5; + LADSPA_Data *band6; + LADSPA_Data *band7; + LADSPA_Data *band8; + LADSPA_Data *band9; + LADSPA_Data *band10; + LADSPA_Data *band11; + LADSPA_Data *band12; + LADSPA_Data *band13; + LADSPA_Data *band14; + LADSPA_Data *band15; + LADSPA_Data *band16; + struct bandpasses bands_carrier; + struct bandpasses bands_formant; + struct bands_out bands_out; + LADSPA_Data *ctrl_band_levels; + float main_vol; + int num_bands; + LADSPA_Data sample_rate; + LADSPA_Data run_adding_gain; +} Vocoder; - int num_bands; /* current number of bands */ - float mainvol; /* main volume */ - - struct bandpasses bands_formant; /* all bands in one struct now */ - struct bandpasses bands_carrier; /* ...same here */ - struct bands_out bands_out; /* ...and here. */ - - /* Ports */ - - LADSPA_Data * portFormant; /* Formant signal port data location */ - LADSPA_Data * portCarrier; /* Carrier signal port data location */ - LADSPA_Data * portOutput; /* Output audio port data location */ - LADSPA_Data * portOutput2; /* Output audio port data location (copy of previous one) */ - LADSPA_Data * ctrlPan; /* PAN for output */ - LADSPA_Data * ctrlBandCount; /* Band count control */ - LADSPA_Data * ctrlBandLevels[MAX_BANDS]; /* level controls for each band */ - -} VocoderInstance; - -/*****************************************************************************/ - -/* Construct a new plugin instance. */ -LADSPA_Handle -instantiateVocoder(const LADSPA_Descriptor * Descriptor, - unsigned long SampleRate) { - VocoderInstance * vocoder; - - vocoder = (VocoderInstance *)malloc(sizeof(VocoderInstance)); - - if (vocoder == NULL) - return NULL; - - vocoder->SampleRate = (LADSPA_Data)SampleRate; - vocoder->num_bands = -1; - - return vocoder; -} - -/*****************************************************************************/ - -/* Initialise and activate a plugin instance. */ -void -activateVocoder(LADSPA_Handle Instance) { - VocoderInstance *vocoder = (VocoderInstance *)Instance; - int i; - - vocoder->mainvol = 1.0 * AMPLIFIER; - - for (i = 0; i < MAX_BANDS; i++) - vocoder->bands_out.oldval[i] = 0.0f; -} - -/*****************************************************************************/ - -/* Connect a port to a data location. */ -void -connectPortToVocoder(LADSPA_Handle Instance, - unsigned long Port, - LADSPA_Data * DataLocation) { - - VocoderInstance * vocoder; - - vocoder = (VocoderInstance *)Instance; - switch (Port) { - case PORT_FORMANT: /* formant port? */ - vocoder->portFormant = DataLocation; - break; - case PORT_CARRIER: /* carrier port? */ - vocoder->portCarrier = DataLocation; - break; - case PORT_OUTPUT: /* output port? */ - vocoder->portOutput = DataLocation; - break; - case PORT_OUTPUT2: /* output port? */ - vocoder->portOutput2 = DataLocation; - break; - case CTRL_BANDCOUNT: /* band count control? */ - vocoder->ctrlBandCount = DataLocation; - break; - case CTRL_PAN: /* Pan control? */ - vocoder->ctrlPan = DataLocation; - break; - default: /* a band level control? */ - if (Port >= CTRL_BAND1LVL && Port < CTRL_BAND1LVL + MAX_BANDS) - vocoder->ctrlBandLevels[Port - CTRL_BAND1LVL] = DataLocation; - break; - } -} - -/*****************************************************************************/ - -// vocoder_do_bandpasses /*fold00*/ -void inline vocoder_do_bandpasses(struct bandpasses *bands, LADSPA_Data sample, - VocoderInstance *vocoder) -{ - int i; - for (i=0; i < vocoder->num_bands; i++) - { - bands->high1[i] = sample - bands->f[i] * bands->mid1[i] - bands->low1[i]; - bands->mid1[i] += bands->high1[i] * bands->c[i]; - bands->low1[i] += bands->mid1[i]; - - bands->high2[i] = bands->low1[i] - bands->f[i] * bands->mid2[i] - - bands->low2[i]; - bands->mid2[i] += bands->high2[i] * bands->c[i]; - bands->low2[i] += bands->mid2[i]; - bands->y[i] = bands->high2[i] * bands->att[i]; - } -} - -/* Run a vocoder instance for a block of SampleCount samples. */ -void -runVocoder(LADSPA_Handle Instance, - unsigned long SampleCount) -{ - VocoderInstance *vocoder = (VocoderInstance *)Instance; - int i, j, numbands, pan; - float a; - LADSPA_Data x, c; - float fl, fr; - - numbands = (int)(*vocoder->ctrlBandCount); - if (numbands < 1 || numbands > MAX_BANDS) numbands = MAX_BANDS; - - /* initialize bandpass information if num_bands control has changed, - or on first run */ - if (vocoder->num_bands != numbands) - { - vocoder->num_bands = numbands; - - memset(&vocoder->bands_formant, 0, sizeof(struct bandpasses)); - for(i=0; i < numbands; i++) - { - a = 16.0 * i/(double)numbands; // stretch existing bands - - if (a < 4.0) - vocoder->bands_formant.freq[i] = 150 + 420 * a / 4.0; - else - vocoder->bands_formant.freq[i] = 600 * pow (1.23, a - 4.0); - - c = vocoder->bands_formant.freq[i] * 2 * M_PI / vocoder->SampleRate; - vocoder->bands_formant.c[i] = c * c; - - vocoder->bands_formant.f[i] = 0.4/c; - vocoder->bands_formant.att[i] = - 1/(6.0 + ((exp (vocoder->bands_formant.freq[i] - / vocoder->SampleRate) - 1) * 10)); - - vocoder->bands_out.decay[i] = decay_table[(int)a]; - vocoder->bands_out.level[i] = - CLAMP (*vocoder->ctrlBandLevels[i], 0.0, 1.0); - } - memcpy(&vocoder->bands_carrier, - &vocoder->bands_formant, sizeof(struct bandpasses)); - - } - else /* get current values of band level controls */ - { - for (i = 0; i < numbands; i++) - vocoder->bands_out.level[i] = CLAMP (*vocoder->ctrlBandLevels[i], - 0.0, 1.0); - } - - for (i=0; i < SampleCount; i++) - { - vocoder_do_bandpasses (&(vocoder->bands_carrier), - vocoder->portCarrier[i], vocoder); - vocoder_do_bandpasses (&(vocoder->bands_formant), - vocoder->portFormant[i], vocoder); - - - LADSPA_Data sample = 0.0; - for (j=0; j < numbands; j++) - { - vocoder->bands_out.oldval[j] = vocoder->bands_out.oldval[j] - + (fabs (vocoder->bands_formant.y[j]) - - vocoder->bands_out.oldval[j]) - * vocoder->bands_out.decay[j]; - x = vocoder->bands_carrier.y[j] * vocoder->bands_out.oldval[j]; - - sample += x * vocoder->bands_out.level[j]; - } - /* treat paning + main volume */ - pan = (int)(*vocoder->ctrlPan); - fl = fr = 1.0f; - if (pan != 0) { /* no paning, don't compute useless values */ - if (pan > 0) { /* reduce left */ - fl = (100.-pan)/100.; - } else { - fr = (100.+pan)/100.; - } - } - /* apply volume and paning */ - vocoder->portOutput[i] = sample * vocoder->mainvol * fl; - vocoder->portOutput2[i] = sample * vocoder->mainvol * fr; - } -} - - -/*****************************************************************************/ - -/* Throw away a vocoder instance. */ -void -cleanupVocoder(LADSPA_Handle Instance) -{ - VocoderInstance * Vocoder; - Vocoder = (VocoderInstance *)Instance; - free(Vocoder); -} - -/*****************************************************************************/ - -LADSPA_Descriptor * g_psDescriptor = NULL; - -/*****************************************************************************/ - -/* __attribute__((constructor)) swh_init() is called automatically when the plugin library is first - loaded. */ -void __attribute__((constructor)) swh_init() { - char ** pcPortNames; - LADSPA_PortDescriptor * piPortDescriptors; - LADSPA_PortRangeHint * psPortRangeHints; - int i; - - g_psDescriptor = (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); - - if (g_psDescriptor) { - g_psDescriptor->UniqueID = LADSPA_UNIQUE_ID; - g_psDescriptor->Label = strdup("vocoder-lmms"); - g_psDescriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; - g_psDescriptor->Name = strdup("Vocoder for LMMS"); - g_psDescriptor->Maker = strdup("Achim Settelmeier (adapted to LADSPA by Josh Green, adapted to LMMS by Hexasoft)"); - g_psDescriptor->Copyright = strdup("GPL"); - g_psDescriptor->PortCount = PORT_COUNT; - piPortDescriptors = (LADSPA_PortDescriptor *)calloc(PORT_COUNT, - sizeof(LADSPA_PortDescriptor)); - g_psDescriptor->PortDescriptors - = (const LADSPA_PortDescriptor *)piPortDescriptors; - piPortDescriptors[PORT_FORMANT] - = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - piPortDescriptors[PORT_CARRIER] - = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; - piPortDescriptors[PORT_OUTPUT] - = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - piPortDescriptors[PORT_OUTPUT2] - = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - piPortDescriptors[CTRL_BANDCOUNT] - = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - piPortDescriptors[CTRL_PAN] - = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - - pcPortNames = (char **)calloc(PORT_COUNT, sizeof(char *)); - g_psDescriptor->PortNames = (const char **)pcPortNames; - pcPortNames[PORT_FORMANT] = strdup("Formant-in"); - pcPortNames[PORT_CARRIER] = strdup("Carrier-in"); - pcPortNames[PORT_OUTPUT] = strdup("Output-out"); - pcPortNames[PORT_OUTPUT2] = strdup("Output2-out"); - pcPortNames[CTRL_BANDCOUNT] = strdup("Number of bands"); - pcPortNames[CTRL_PAN] = strdup("Left/Right"); - - psPortRangeHints = ((LADSPA_PortRangeHint *) - calloc(PORT_COUNT, sizeof(LADSPA_PortRangeHint))); - g_psDescriptor->PortRangeHints - = (const LADSPA_PortRangeHint *)psPortRangeHints; - psPortRangeHints[PORT_FORMANT].HintDescriptor = 0; - psPortRangeHints[PORT_CARRIER].HintDescriptor = 0; - psPortRangeHints[PORT_OUTPUT].HintDescriptor = 0; - psPortRangeHints[PORT_OUTPUT2].HintDescriptor = 0; - psPortRangeHints[CTRL_BANDCOUNT].HintDescriptor - = LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE - | LADSPA_HINT_INTEGER; - psPortRangeHints[CTRL_BANDCOUNT].LowerBound = 1; - psPortRangeHints[CTRL_BANDCOUNT].UpperBound = MAX_BANDS; - psPortRangeHints[CTRL_PAN].HintDescriptor - = LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE - | LADSPA_HINT_INTEGER; - psPortRangeHints[CTRL_PAN].LowerBound = -100; - psPortRangeHints[CTRL_PAN].UpperBound = +100; - - for (i=CTRL_BAND1LVL; i < CTRL_BAND1LVL + MAX_BANDS; i++) - { - piPortDescriptors[i] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; - pcPortNames[i] = malloc (sizeof ("Band 99 Level")); - sprintf(pcPortNames[i], "Band %d Level", i - CTRL_BAND1LVL + 1); - psPortRangeHints[i].HintDescriptor - = LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; - psPortRangeHints[i].LowerBound = 0; - psPortRangeHints[i].UpperBound = 1; - } - - g_psDescriptor->instantiate = instantiateVocoder; - g_psDescriptor->connect_port = connectPortToVocoder; - g_psDescriptor->activate = activateVocoder; - g_psDescriptor->run = runVocoder; - g_psDescriptor->run_adding = NULL; - g_psDescriptor->set_run_adding_gain = NULL; - g_psDescriptor->deactivate = NULL; - g_psDescriptor->cleanup = cleanupVocoder; - } -} - -/*****************************************************************************/ - -/* __attribute__((destructor)) swh_fini() is called automatically when the library is unloaded. */ -void - __attribute__((destructor)) swh_fini() { - long lIndex; - if (g_psDescriptor) { - free((char *)g_psDescriptor->Label); - free((char *)g_psDescriptor->Name); - free((char *)g_psDescriptor->Maker); - free((char *)g_psDescriptor->Copyright); - free((LADSPA_PortDescriptor *)g_psDescriptor->PortDescriptors); - for (lIndex = 0; lIndex < g_psDescriptor->PortCount; lIndex++) - free((char *)(g_psDescriptor->PortNames[lIndex])); - free((char **)g_psDescriptor->PortNames); - free((LADSPA_PortRangeHint *)g_psDescriptor->PortRangeHints); - free(g_psDescriptor); - } -} - -/*****************************************************************************/ - -/* Return a descriptor of the requested plugin type. Only one plugin - type is available in this library. */ _WINDOWS_DLL_EXPORT_ -const LADSPA_Descriptor * -ladspa_descriptor(unsigned long Index) { +const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) { + #ifdef WIN32 if (bIsFirstTime) { swh_init(); bIsFirstTime = 0; } #endif - if (Index == 0) - return g_psDescriptor; - else - return NULL; + switch (index) { + case 0: + return vocoderDescriptor; + default: + return NULL; + } } -/*****************************************************************************/ +static void activateVocoder(LADSPA_Handle instance) { + Vocoder *plugin_data = (Vocoder *)instance; + struct bandpasses bands_carrier = plugin_data->bands_carrier; + struct bandpasses bands_formant = plugin_data->bands_formant; + struct bands_out bands_out = plugin_data->bands_out; + LADSPA_Data *ctrl_band_levels = plugin_data->ctrl_band_levels; + float main_vol = plugin_data->main_vol; + int num_bands = plugin_data->num_bands; + LADSPA_Data sample_rate = plugin_data->sample_rate; +#line 83 "vocoder_1337.xml" + int i; + for (i = 0; i < MAX_BANDS; i++) + { + bands_out.oldval[i] = 0.0f; + } + plugin_data->bands_carrier = bands_carrier; + plugin_data->bands_formant = bands_formant; + plugin_data->bands_out = bands_out; + plugin_data->ctrl_band_levels = ctrl_band_levels; + plugin_data->main_vol = main_vol; + plugin_data->num_bands = num_bands; + plugin_data->sample_rate = sample_rate; -/* EOF */ +} + +static void cleanupVocoder(LADSPA_Handle instance) { +#line 92 "vocoder_1337.xml" + Vocoder *plugin_data = (Vocoder *)instance; + free(plugin_data->ctrl_band_levels); + free(instance); +} + +static void connectPortVocoder( + LADSPA_Handle instance, + unsigned long port, + LADSPA_Data *data) { + Vocoder *plugin; + + plugin = (Vocoder *)instance; + switch (port) { + case VOCODER_PORT_FORMANT: + plugin->port_formant = data; + break; + case VOCODER_PORT_CARRIER: + plugin->port_carrier = data; + break; + case VOCODER_PORT_OUTPUT: + plugin->port_output = data; + break; + case VOCODER_PORT_OUTPUT2: + plugin->port_output2 = data; + break; + case VOCODER_CTRL_BAND_COUNT: + plugin->ctrl_band_count = data; + break; + case VOCODER_CTRL_PAN: + plugin->ctrl_pan = data; + break; + case VOCODER_BAND1: + plugin->band1 = data; + break; + case VOCODER_BAND2: + plugin->band2 = data; + break; + case VOCODER_BAND3: + plugin->band3 = data; + break; + case VOCODER_BAND4: + plugin->band4 = data; + break; + case VOCODER_BAND5: + plugin->band5 = data; + break; + case VOCODER_BAND6: + plugin->band6 = data; + break; + case VOCODER_BAND7: + plugin->band7 = data; + break; + case VOCODER_BAND8: + plugin->band8 = data; + break; + case VOCODER_BAND9: + plugin->band9 = data; + break; + case VOCODER_BAND10: + plugin->band10 = data; + break; + case VOCODER_BAND11: + plugin->band11 = data; + break; + case VOCODER_BAND12: + plugin->band12 = data; + break; + case VOCODER_BAND13: + plugin->band13 = data; + break; + case VOCODER_BAND14: + plugin->band14 = data; + break; + case VOCODER_BAND15: + plugin->band15 = data; + break; + case VOCODER_BAND16: + plugin->band16 = data; + break; + } +} + +static LADSPA_Handle instantiateVocoder( + const LADSPA_Descriptor *descriptor, + unsigned long s_rate) { + Vocoder *plugin_data = (Vocoder *)calloc(1, sizeof(Vocoder)); + struct bandpasses bands_carrier; + struct bandpasses bands_formant; + struct bands_out bands_out; + LADSPA_Data *ctrl_band_levels = NULL; + float main_vol; + int num_bands; + LADSPA_Data sample_rate; + +#line 75 "vocoder_1337.xml" + sample_rate = s_rate; + main_vol = 1.0 * AMPLIFIER; + + ctrl_band_levels = malloc(MAX_BANDS * sizeof(LADSPA_Data)); + num_bands = -1; + + plugin_data->bands_carrier = bands_carrier; + plugin_data->bands_formant = bands_formant; + plugin_data->bands_out = bands_out; + plugin_data->ctrl_band_levels = ctrl_band_levels; + plugin_data->main_vol = main_vol; + plugin_data->num_bands = num_bands; + plugin_data->sample_rate = sample_rate; + + return (LADSPA_Handle)plugin_data; +} + +#undef buffer_write +#undef RUN_ADDING +#undef RUN_REPLACING + +#define buffer_write(b, v) (b = v) +#define RUN_ADDING 0 +#define RUN_REPLACING 1 + +static void runVocoder(LADSPA_Handle instance, unsigned long sample_count) { + Vocoder *plugin_data = (Vocoder *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; + + /* Formant-in (array of floats of length sample_count) */ + const LADSPA_Data * const port_formant = plugin_data->port_formant; + + /* Carrier-in (array of floats of length sample_count) */ + const LADSPA_Data * const port_carrier = plugin_data->port_carrier; + + /* Output-out (array of floats of length sample_count) */ + LADSPA_Data * const port_output = plugin_data->port_output; + + /* Output2-out (array of floats of length sample_count) */ + LADSPA_Data * const port_output2 = plugin_data->port_output2; + + /* Number of bands (float value) */ + const LADSPA_Data ctrl_band_count = *(plugin_data->ctrl_band_count); + + /* Left/Right (float value) */ + const LADSPA_Data ctrl_pan = *(plugin_data->ctrl_pan); + + /* Band 1 Level (float value) */ + const LADSPA_Data band1 = *(plugin_data->band1); + + /* Band 2 Level (float value) */ + const LADSPA_Data band2 = *(plugin_data->band2); + + /* Band 3 Level (float value) */ + const LADSPA_Data band3 = *(plugin_data->band3); + + /* Band 4 Level (float value) */ + const LADSPA_Data band4 = *(plugin_data->band4); + + /* Band 5 Level (float value) */ + const LADSPA_Data band5 = *(plugin_data->band5); + + /* Band 6 Level (float value) */ + const LADSPA_Data band6 = *(plugin_data->band6); + + /* Band 7 Level (float value) */ + const LADSPA_Data band7 = *(plugin_data->band7); + + /* Band 8 Level (float value) */ + const LADSPA_Data band8 = *(plugin_data->band8); + + /* Band 9 Level (float value) */ + const LADSPA_Data band9 = *(plugin_data->band9); + + /* Band 10 Level (float value) */ + const LADSPA_Data band10 = *(plugin_data->band10); + + /* Band 11 Level (float value) */ + const LADSPA_Data band11 = *(plugin_data->band11); + + /* Band 12 Level (float value) */ + const LADSPA_Data band12 = *(plugin_data->band12); + + /* Band 13 Level (float value) */ + const LADSPA_Data band13 = *(plugin_data->band13); + + /* Band 14 Level (float value) */ + const LADSPA_Data band14 = *(plugin_data->band14); + + /* Band 15 Level (float value) */ + const LADSPA_Data band15 = *(plugin_data->band15); + + /* Band 16 Level (float value) */ + const LADSPA_Data band16 = *(plugin_data->band16); + struct bandpasses bands_carrier = plugin_data->bands_carrier; + struct bandpasses bands_formant = plugin_data->bands_formant; + struct bands_out bands_out = plugin_data->bands_out; + LADSPA_Data * ctrl_band_levels = plugin_data->ctrl_band_levels; + float main_vol = plugin_data->main_vol; + int num_bands = plugin_data->num_bands; + LADSPA_Data sample_rate = plugin_data->sample_rate; + +#line 96 "vocoder_1337.xml" + int i, j, numbands, pan; + float a; + LADSPA_Data x, c; + float fl, fr; + + // Bind band level controls + plugin_data->ctrl_band_levels[0] = band1; + plugin_data->ctrl_band_levels[1] = band2; + plugin_data->ctrl_band_levels[2] = band3; + plugin_data->ctrl_band_levels[3] = band4; + plugin_data->ctrl_band_levels[4] = band5; + plugin_data->ctrl_band_levels[5] = band6; + plugin_data->ctrl_band_levels[6] = band7; + plugin_data->ctrl_band_levels[7] = band8; + plugin_data->ctrl_band_levels[8] = band9; + plugin_data->ctrl_band_levels[9] = band10; + plugin_data->ctrl_band_levels[10] = band11; + plugin_data->ctrl_band_levels[11] = band12; + plugin_data->ctrl_band_levels[12] = band13; + plugin_data->ctrl_band_levels[13] = band14; + plugin_data->ctrl_band_levels[14] = band15; + plugin_data->ctrl_band_levels[15] = band16; + + numbands = (int)(*plugin_data->ctrl_band_count); + if (numbands < 1 || numbands > MAX_BANDS) numbands = MAX_BANDS; + + /* initialize bandpass information if num_bands control has changed, + or on first run */ + if (plugin_data->num_bands != numbands) + { + plugin_data->num_bands = numbands; + + memset(&plugin_data->bands_formant, 0, sizeof(struct bandpasses)); + for(i=0; i < numbands; i++) + { + a = 16.0 * i/(double)numbands; // stretch existing bands + + if (a < 4.0) + plugin_data->bands_formant.freq[i] = 150 + 420 * a / 4.0; + else + plugin_data->bands_formant.freq[i] = 600 * pow (1.23, a - 4.0); + + c = plugin_data->bands_formant.freq[i] * 2 * M_PI / plugin_data->sample_rate; + plugin_data->bands_formant.c[i] = c * c; + + plugin_data->bands_formant.f[i] = 0.4/c; + plugin_data->bands_formant.att[i] = + 1/(6.0 + ((exp (plugin_data->bands_formant.freq[i] + / plugin_data->sample_rate) - 1) * 10)); + + plugin_data->bands_out.decay[i] = decay_table[(int)a]; + plugin_data->bands_out.level[i] = + CLAMP (plugin_data->ctrl_band_levels[i], 0.0, 1.0); + } + memcpy(&plugin_data->bands_carrier, + &plugin_data->bands_formant, sizeof(struct bandpasses)); + + } + else /* get current values of band level controls */ + { + for (i = 0; i < numbands; i++) + plugin_data->bands_out.level[i] = CLAMP (plugin_data->ctrl_band_levels[i], + 0.0, 1.0); + } + + for (i=0; i < sample_count; i++) + { + doBandpasses (&(plugin_data->bands_carrier), + plugin_data->port_carrier[i], + plugin_data->num_bands); + doBandpasses (&(plugin_data->bands_formant), + plugin_data->port_formant[i], + plugin_data->num_bands); + + LADSPA_Data sample = 0.0; + for (j=0; j < numbands; j++) + { + plugin_data->bands_out.oldval[j] = plugin_data->bands_out.oldval[j] + + (fabs (plugin_data->bands_formant.y[j]) + - plugin_data->bands_out.oldval[j]) + * plugin_data->bands_out.decay[j]; + x = plugin_data->bands_carrier.y[j] * plugin_data->bands_out.oldval[j]; + + sample += x * plugin_data->bands_out.level[j]; + } + /* treat paning + main volume */ + pan = (int)(*plugin_data->ctrl_pan); + fl = fr = 1.0f; + if (pan != 0) { /* no paning, don't compute useless values */ + if (pan > 0) { /* reduce left */ + fl = (100.-pan)/100.; + } else { + fr = (100.+pan)/100.; + } + } + /* apply volume and paning */ + plugin_data->port_output[i] = sample * plugin_data->main_vol * fl; + plugin_data->port_output2[i] = sample * plugin_data->main_vol * fr; + } + + // Suppress unused warnings + (void)(sample_rate); + (void)(num_bands); + (void)(main_vol); + (void)(bands_formant); + (void)(bands_carrier); + (void)(bands_out); + (void)(ctrl_band_levels); + (void)(port_formant); + (void)(port_carrier); + (void)(port_output); + (void)(port_output2); + (void)(ctrl_band_count); + (void)(ctrl_pan); + (void)(run_adding_gain); +} +#undef buffer_write +#undef RUN_ADDING +#undef RUN_REPLACING + +#define buffer_write(b, v) (b += (v) * run_adding_gain) +#define RUN_ADDING 1 +#define RUN_REPLACING 0 + +static void setRunAddingGainVocoder(LADSPA_Handle instance, LADSPA_Data gain) { + ((Vocoder *)instance)->run_adding_gain = gain; +} + +static void runAddingVocoder(LADSPA_Handle instance, unsigned long sample_count) { + Vocoder *plugin_data = (Vocoder *)instance; + LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; + + /* Formant-in (array of floats of length sample_count) */ + const LADSPA_Data * const port_formant = plugin_data->port_formant; + + /* Carrier-in (array of floats of length sample_count) */ + const LADSPA_Data * const port_carrier = plugin_data->port_carrier; + + /* Output-out (array of floats of length sample_count) */ + LADSPA_Data * const port_output = plugin_data->port_output; + + /* Output2-out (array of floats of length sample_count) */ + LADSPA_Data * const port_output2 = plugin_data->port_output2; + + /* Number of bands (float value) */ + const LADSPA_Data ctrl_band_count = *(plugin_data->ctrl_band_count); + + /* Left/Right (float value) */ + const LADSPA_Data ctrl_pan = *(plugin_data->ctrl_pan); + + /* Band 1 Level (float value) */ + const LADSPA_Data band1 = *(plugin_data->band1); + + /* Band 2 Level (float value) */ + const LADSPA_Data band2 = *(plugin_data->band2); + + /* Band 3 Level (float value) */ + const LADSPA_Data band3 = *(plugin_data->band3); + + /* Band 4 Level (float value) */ + const LADSPA_Data band4 = *(plugin_data->band4); + + /* Band 5 Level (float value) */ + const LADSPA_Data band5 = *(plugin_data->band5); + + /* Band 6 Level (float value) */ + const LADSPA_Data band6 = *(plugin_data->band6); + + /* Band 7 Level (float value) */ + const LADSPA_Data band7 = *(plugin_data->band7); + + /* Band 8 Level (float value) */ + const LADSPA_Data band8 = *(plugin_data->band8); + + /* Band 9 Level (float value) */ + const LADSPA_Data band9 = *(plugin_data->band9); + + /* Band 10 Level (float value) */ + const LADSPA_Data band10 = *(plugin_data->band10); + + /* Band 11 Level (float value) */ + const LADSPA_Data band11 = *(plugin_data->band11); + + /* Band 12 Level (float value) */ + const LADSPA_Data band12 = *(plugin_data->band12); + + /* Band 13 Level (float value) */ + const LADSPA_Data band13 = *(plugin_data->band13); + + /* Band 14 Level (float value) */ + const LADSPA_Data band14 = *(plugin_data->band14); + + /* Band 15 Level (float value) */ + const LADSPA_Data band15 = *(plugin_data->band15); + + /* Band 16 Level (float value) */ + const LADSPA_Data band16 = *(plugin_data->band16); + struct bandpasses bands_carrier = plugin_data->bands_carrier; + struct bandpasses bands_formant = plugin_data->bands_formant; + struct bands_out bands_out = plugin_data->bands_out; + LADSPA_Data * ctrl_band_levels = plugin_data->ctrl_band_levels; + float main_vol = plugin_data->main_vol; + int num_bands = plugin_data->num_bands; + LADSPA_Data sample_rate = plugin_data->sample_rate; + +#line 96 "vocoder_1337.xml" + int i, j, numbands, pan; + float a; + LADSPA_Data x, c; + float fl, fr; + + // Bind band level controls + plugin_data->ctrl_band_levels[0] = band1; + plugin_data->ctrl_band_levels[1] = band2; + plugin_data->ctrl_band_levels[2] = band3; + plugin_data->ctrl_band_levels[3] = band4; + plugin_data->ctrl_band_levels[4] = band5; + plugin_data->ctrl_band_levels[5] = band6; + plugin_data->ctrl_band_levels[6] = band7; + plugin_data->ctrl_band_levels[7] = band8; + plugin_data->ctrl_band_levels[8] = band9; + plugin_data->ctrl_band_levels[9] = band10; + plugin_data->ctrl_band_levels[10] = band11; + plugin_data->ctrl_band_levels[11] = band12; + plugin_data->ctrl_band_levels[12] = band13; + plugin_data->ctrl_band_levels[13] = band14; + plugin_data->ctrl_band_levels[14] = band15; + plugin_data->ctrl_band_levels[15] = band16; + + numbands = (int)(*plugin_data->ctrl_band_count); + if (numbands < 1 || numbands > MAX_BANDS) numbands = MAX_BANDS; + + /* initialize bandpass information if num_bands control has changed, + or on first run */ + if (plugin_data->num_bands != numbands) + { + plugin_data->num_bands = numbands; + + memset(&plugin_data->bands_formant, 0, sizeof(struct bandpasses)); + for(i=0; i < numbands; i++) + { + a = 16.0 * i/(double)numbands; // stretch existing bands + + if (a < 4.0) + plugin_data->bands_formant.freq[i] = 150 + 420 * a / 4.0; + else + plugin_data->bands_formant.freq[i] = 600 * pow (1.23, a - 4.0); + + c = plugin_data->bands_formant.freq[i] * 2 * M_PI / plugin_data->sample_rate; + plugin_data->bands_formant.c[i] = c * c; + + plugin_data->bands_formant.f[i] = 0.4/c; + plugin_data->bands_formant.att[i] = + 1/(6.0 + ((exp (plugin_data->bands_formant.freq[i] + / plugin_data->sample_rate) - 1) * 10)); + + plugin_data->bands_out.decay[i] = decay_table[(int)a]; + plugin_data->bands_out.level[i] = + CLAMP (plugin_data->ctrl_band_levels[i], 0.0, 1.0); + } + memcpy(&plugin_data->bands_carrier, + &plugin_data->bands_formant, sizeof(struct bandpasses)); + + } + else /* get current values of band level controls */ + { + for (i = 0; i < numbands; i++) + plugin_data->bands_out.level[i] = CLAMP (plugin_data->ctrl_band_levels[i], + 0.0, 1.0); + } + + for (i=0; i < sample_count; i++) + { + doBandpasses (&(plugin_data->bands_carrier), + plugin_data->port_carrier[i], + plugin_data->num_bands); + doBandpasses (&(plugin_data->bands_formant), + plugin_data->port_formant[i], + plugin_data->num_bands); + + LADSPA_Data sample = 0.0; + for (j=0; j < numbands; j++) + { + plugin_data->bands_out.oldval[j] = plugin_data->bands_out.oldval[j] + + (fabs (plugin_data->bands_formant.y[j]) + - plugin_data->bands_out.oldval[j]) + * plugin_data->bands_out.decay[j]; + x = plugin_data->bands_carrier.y[j] * plugin_data->bands_out.oldval[j]; + + sample += x * plugin_data->bands_out.level[j]; + } + /* treat paning + main volume */ + pan = (int)(*plugin_data->ctrl_pan); + fl = fr = 1.0f; + if (pan != 0) { /* no paning, don't compute useless values */ + if (pan > 0) { /* reduce left */ + fl = (100.-pan)/100.; + } else { + fr = (100.+pan)/100.; + } + } + /* apply volume and paning */ + plugin_data->port_output[i] = sample * plugin_data->main_vol * fl; + plugin_data->port_output2[i] = sample * plugin_data->main_vol * fr; + } + + // Suppress unused warnings + (void)(sample_rate); + (void)(num_bands); + (void)(main_vol); + (void)(bands_formant); + (void)(bands_carrier); + (void)(bands_out); + (void)(ctrl_band_levels); + (void)(port_formant); + (void)(port_carrier); + (void)(port_output); + (void)(port_output2); + (void)(ctrl_band_count); + (void)(ctrl_pan); + (void)(run_adding_gain); +} + +void __attribute__((constructor)) swh_init() { + char **port_names; + LADSPA_PortDescriptor *port_descriptors; + LADSPA_PortRangeHint *port_range_hints; + +#ifdef ENABLE_NLS +#define D_(s) dgettext(PACKAGE, s) + bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); +#else +#define D_(s) (s) +#endif + + + vocoderDescriptor = + (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor)); + + if (vocoderDescriptor) { + vocoderDescriptor->UniqueID = 1337; + vocoderDescriptor->Label = "vocoder"; + vocoderDescriptor->Properties = + LADSPA_PROPERTY_HARD_RT_CAPABLE; + vocoderDescriptor->Name = + D_("Vocoder"); + vocoderDescriptor->Maker = + "Achim Settelmeier (adapted by Josh Green and Hexasoft)"; + vocoderDescriptor->Copyright = + "GPL"; + vocoderDescriptor->PortCount = 22; + + port_descriptors = (LADSPA_PortDescriptor *)calloc(22, + sizeof(LADSPA_PortDescriptor)); + vocoderDescriptor->PortDescriptors = + (const LADSPA_PortDescriptor *)port_descriptors; + + port_range_hints = (LADSPA_PortRangeHint *)calloc(22, + sizeof(LADSPA_PortRangeHint)); + vocoderDescriptor->PortRangeHints = + (const LADSPA_PortRangeHint *)port_range_hints; + + port_names = (char **)calloc(22, sizeof(char*)); + vocoderDescriptor->PortNames = + (const char **)port_names; + + /* Parameters for Formant-in */ + port_descriptors[VOCODER_PORT_FORMANT] = + LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; + port_names[VOCODER_PORT_FORMANT] = + D_("Formant-in"); + port_range_hints[VOCODER_PORT_FORMANT].HintDescriptor = 0; + + /* Parameters for Carrier-in */ + port_descriptors[VOCODER_PORT_CARRIER] = + LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; + port_names[VOCODER_PORT_CARRIER] = + D_("Carrier-in"); + port_range_hints[VOCODER_PORT_CARRIER].HintDescriptor = 0; + + /* Parameters for Output-out */ + port_descriptors[VOCODER_PORT_OUTPUT] = + LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; + port_names[VOCODER_PORT_OUTPUT] = + D_("Output-out"); + port_range_hints[VOCODER_PORT_OUTPUT].HintDescriptor = 0; + + /* Parameters for Output2-out */ + port_descriptors[VOCODER_PORT_OUTPUT2] = + LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; + port_names[VOCODER_PORT_OUTPUT2] = + D_("Output2-out"); + port_range_hints[VOCODER_PORT_OUTPUT2].HintDescriptor = 0; + + /* Parameters for Number of bands */ + port_descriptors[VOCODER_CTRL_BAND_COUNT] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_CTRL_BAND_COUNT] = + D_("Number of bands"); + port_range_hints[VOCODER_CTRL_BAND_COUNT].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_INTEGER; + port_range_hints[VOCODER_CTRL_BAND_COUNT].LowerBound = 1; + port_range_hints[VOCODER_CTRL_BAND_COUNT].UpperBound = MAX_BANDS; + + /* Parameters for Left/Right */ + port_descriptors[VOCODER_CTRL_PAN] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_CTRL_PAN] = + D_("Left/Right"); + port_range_hints[VOCODER_CTRL_PAN].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_INTEGER; + port_range_hints[VOCODER_CTRL_PAN].LowerBound = -100; + port_range_hints[VOCODER_CTRL_PAN].UpperBound = +100; + + /* Parameters for Band 1 Level */ + port_descriptors[VOCODER_BAND1] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND1] = + D_("Band 1 Level"); + port_range_hints[VOCODER_BAND1].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND1].LowerBound = 0; + port_range_hints[VOCODER_BAND1].UpperBound = 1; + + /* Parameters for Band 2 Level */ + port_descriptors[VOCODER_BAND2] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND2] = + D_("Band 2 Level"); + port_range_hints[VOCODER_BAND2].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND2].LowerBound = 0; + port_range_hints[VOCODER_BAND2].UpperBound = 1; + + /* Parameters for Band 3 Level */ + port_descriptors[VOCODER_BAND3] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND3] = + D_("Band 3 Level"); + port_range_hints[VOCODER_BAND3].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND3].LowerBound = 0; + port_range_hints[VOCODER_BAND3].UpperBound = 1; + + /* Parameters for Band 4 Level */ + port_descriptors[VOCODER_BAND4] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND4] = + D_("Band 4 Level"); + port_range_hints[VOCODER_BAND4].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND4].LowerBound = 0; + port_range_hints[VOCODER_BAND4].UpperBound = 1; + + /* Parameters for Band 5 Level */ + port_descriptors[VOCODER_BAND5] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND5] = + D_("Band 5 Level"); + port_range_hints[VOCODER_BAND5].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND5].LowerBound = 0; + port_range_hints[VOCODER_BAND5].UpperBound = 1; + + /* Parameters for Band 6 Level */ + port_descriptors[VOCODER_BAND6] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND6] = + D_("Band 6 Level"); + port_range_hints[VOCODER_BAND6].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND6].LowerBound = 0; + port_range_hints[VOCODER_BAND6].UpperBound = 1; + + /* Parameters for Band 7 Level */ + port_descriptors[VOCODER_BAND7] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND7] = + D_("Band 7 Level"); + port_range_hints[VOCODER_BAND7].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND7].LowerBound = 0; + port_range_hints[VOCODER_BAND7].UpperBound = 1; + + /* Parameters for Band 8 Level */ + port_descriptors[VOCODER_BAND8] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND8] = + D_("Band 8 Level"); + port_range_hints[VOCODER_BAND8].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND8].LowerBound = 0; + port_range_hints[VOCODER_BAND8].UpperBound = 1; + + /* Parameters for Band 9 Level */ + port_descriptors[VOCODER_BAND9] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND9] = + D_("Band 9 Level"); + port_range_hints[VOCODER_BAND9].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND9].LowerBound = 0; + port_range_hints[VOCODER_BAND9].UpperBound = 1; + + /* Parameters for Band 10 Level */ + port_descriptors[VOCODER_BAND10] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND10] = + D_("Band 10 Level"); + port_range_hints[VOCODER_BAND10].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND10].LowerBound = 0; + port_range_hints[VOCODER_BAND10].UpperBound = 1; + + /* Parameters for Band 11 Level */ + port_descriptors[VOCODER_BAND11] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND11] = + D_("Band 11 Level"); + port_range_hints[VOCODER_BAND11].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND11].LowerBound = 0; + port_range_hints[VOCODER_BAND11].UpperBound = 1; + + /* Parameters for Band 12 Level */ + port_descriptors[VOCODER_BAND12] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND12] = + D_("Band 12 Level"); + port_range_hints[VOCODER_BAND12].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND12].LowerBound = 0; + port_range_hints[VOCODER_BAND12].UpperBound = 1; + + /* Parameters for Band 13 Level */ + port_descriptors[VOCODER_BAND13] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND13] = + D_("Band 13 Level"); + port_range_hints[VOCODER_BAND13].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND13].LowerBound = 0; + port_range_hints[VOCODER_BAND13].UpperBound = 1; + + /* Parameters for Band 14 Level */ + port_descriptors[VOCODER_BAND14] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND14] = + D_("Band 14 Level"); + port_range_hints[VOCODER_BAND14].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND14].LowerBound = 0; + port_range_hints[VOCODER_BAND14].UpperBound = 1; + + /* Parameters for Band 15 Level */ + port_descriptors[VOCODER_BAND15] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND15] = + D_("Band 15 Level"); + port_range_hints[VOCODER_BAND15].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND15].LowerBound = 0; + port_range_hints[VOCODER_BAND15].UpperBound = 1; + + /* Parameters for Band 16 Level */ + port_descriptors[VOCODER_BAND16] = + LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; + port_names[VOCODER_BAND16] = + D_("Band 16 Level"); + port_range_hints[VOCODER_BAND16].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + port_range_hints[VOCODER_BAND16].LowerBound = 0; + port_range_hints[VOCODER_BAND16].UpperBound = 1; + + vocoderDescriptor->activate = activateVocoder; + vocoderDescriptor->cleanup = cleanupVocoder; + vocoderDescriptor->connect_port = connectPortVocoder; + vocoderDescriptor->deactivate = NULL; + vocoderDescriptor->instantiate = instantiateVocoder; + vocoderDescriptor->run = runVocoder; + vocoderDescriptor->run_adding = runAddingVocoder; + vocoderDescriptor->set_run_adding_gain = setRunAddingGainVocoder; + } +} + +void __attribute__((destructor)) swh_fini() { + if (vocoderDescriptor) { + free((LADSPA_PortDescriptor *)vocoderDescriptor->PortDescriptors); + free((char **)vocoderDescriptor->PortNames); + free((LADSPA_PortRangeHint *)vocoderDescriptor->PortRangeHints); + free(vocoderDescriptor); + } + vocoderDescriptor = NULL; + +} diff --git a/plugins/LadspaEffect/swh/vynil_1905.c b/plugins/LadspaEffect/swh/vynil_1905.c index c6aa448b0..a24805841 100644 --- a/plugins/LadspaEffect/swh/vynil_1905.c +++ b/plugins/LadspaEffect/swh/vynil_1905.c @@ -211,7 +211,7 @@ static void connectPortVynil( static LADSPA_Handle instantiateVynil( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Vynil *plugin_data = (Vynil *)malloc(sizeof(Vynil)); + Vynil *plugin_data = (Vynil *)calloc(1, sizeof(Vynil)); LADSPA_Data *buffer_m = NULL; unsigned int buffer_mask; unsigned int buffer_pos; @@ -587,7 +587,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -713,12 +712,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (vynilDescriptor) { free((LADSPA_PortDescriptor *)vynilDescriptor->PortDescriptors); free((char **)vynilDescriptor->PortNames); free((LADSPA_PortRangeHint *)vynilDescriptor->PortRangeHints); free(vynilDescriptor); } + vynilDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/wave_terrain_1412.c b/plugins/LadspaEffect/swh/wave_terrain_1412.c index bb77bd825..3cd04f999 100644 --- a/plugins/LadspaEffect/swh/wave_terrain_1412.c +++ b/plugins/LadspaEffect/swh/wave_terrain_1412.c @@ -83,7 +83,7 @@ static void connectPortWaveTerrain( static LADSPA_Handle instantiateWaveTerrain( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - WaveTerrain *plugin_data = (WaveTerrain *)malloc(sizeof(WaveTerrain)); + WaveTerrain *plugin_data = (WaveTerrain *)calloc(1, sizeof(WaveTerrain)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -162,7 +162,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -231,12 +230,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (waveTerrainDescriptor) { free((LADSPA_PortDescriptor *)waveTerrainDescriptor->PortDescriptors); free((char **)waveTerrainDescriptor->PortNames); free((LADSPA_PortRangeHint *)waveTerrainDescriptor->PortRangeHints); free(waveTerrainDescriptor); } + waveTerrainDescriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/xfade_1915.c b/plugins/LadspaEffect/swh/xfade_1915.c index 3a4ca2345..d82b499d7 100644 --- a/plugins/LadspaEffect/swh/xfade_1915.c +++ b/plugins/LadspaEffect/swh/xfade_1915.c @@ -132,7 +132,7 @@ static void connectPortXfade( static LADSPA_Handle instantiateXfade( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Xfade *plugin_data = (Xfade *)malloc(sizeof(Xfade)); + Xfade *plugin_data = (Xfade *)calloc(1, sizeof(Xfade)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -273,7 +273,7 @@ static void connectPortXfade4( static LADSPA_Handle instantiateXfade4( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Xfade4 *plugin_data = (Xfade4 *)malloc(sizeof(Xfade4)); + Xfade4 *plugin_data = (Xfade4 *)calloc(1, sizeof(Xfade4)); plugin_data->run_adding_gain = 1.0f; return (LADSPA_Handle)plugin_data; @@ -392,7 +392,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -598,18 +597,20 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (xfadeDescriptor) { free((LADSPA_PortDescriptor *)xfadeDescriptor->PortDescriptors); free((char **)xfadeDescriptor->PortNames); free((LADSPA_PortRangeHint *)xfadeDescriptor->PortRangeHints); free(xfadeDescriptor); } + xfadeDescriptor = NULL; if (xfade4Descriptor) { free((LADSPA_PortDescriptor *)xfade4Descriptor->PortDescriptors); free((char **)xfade4Descriptor->PortNames); free((LADSPA_PortRangeHint *)xfade4Descriptor->PortRangeHints); free(xfade4Descriptor); } + xfade4Descriptor = NULL; } diff --git a/plugins/LadspaEffect/swh/zm1_1428.c b/plugins/LadspaEffect/swh/zm1_1428.c index baf063bfc..906ab8532 100644 --- a/plugins/LadspaEffect/swh/zm1_1428.c +++ b/plugins/LadspaEffect/swh/zm1_1428.c @@ -88,7 +88,7 @@ static void connectPortZm1( static LADSPA_Handle instantiateZm1( const LADSPA_Descriptor *descriptor, unsigned long s_rate) { - Zm1 *plugin_data = (Zm1 *)malloc(sizeof(Zm1)); + Zm1 *plugin_data = (Zm1 *)calloc(1, sizeof(Zm1)); LADSPA_Data xm1; #line 17 "zm1_1428.xml" @@ -170,7 +170,6 @@ void __attribute__((constructor)) swh_init() { #ifdef ENABLE_NLS #define D_(s) dgettext(PACKAGE, s) - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); #else #define D_(s) (s) @@ -232,12 +231,13 @@ void __attribute__((constructor)) swh_init() { } } -void __attribute__((destructor)) swh_fini() { +void __attribute__((destructor)) swh_fini() { if (zm1Descriptor) { free((LADSPA_PortDescriptor *)zm1Descriptor->PortDescriptors); free((char **)zm1Descriptor->PortNames); free((LADSPA_PortRangeHint *)zm1Descriptor->PortRangeHints); free(zm1Descriptor); } + zm1Descriptor = NULL; }