From 4fa1b9c4fd67c3ab50d643b873e028fff1dcc813 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 1 Jan 2014 08:59:34 +0000 Subject: [PATCH] Fix nekofilter build --- .../modules/carla_native/nekofilter/filter.c | 54 +++++++++---------- .../carla_native/nekofilter/nekofilter.c | 47 ++++++++-------- source/modules/carla_native/nekofilter/ui.c | 14 ++--- 3 files changed, 55 insertions(+), 60 deletions(-) diff --git a/source/modules/carla_native/nekofilter/filter.c b/source/modules/carla_native/nekofilter/filter.c index 38ac7be09..dc27e6c68 100644 --- a/source/modules/carla_native/nekofilter/filter.c +++ b/source/modules/carla_native/nekofilter/filter.c @@ -34,9 +34,9 @@ static float exp2ap(float x) int i; i = (int)(floor(x)); - x -= i; + x -= (float)i; // return ldexp(1 + x * (0.66 + 0.34 * x), i); - return ldexp(1 + x * (0.6930 + x * (0.2416 + x * (0.0517 + x * 0.0137))), i); + return ldexpf(1.0f + x * (0.6930f + x * (0.2416f + x * (0.0517f + x * 0.0137f))), i); } struct param_sect @@ -70,9 +70,9 @@ param_sect_proc( s1 = sect_ptr->s1; s2 = sect_ptr->s2; a = sect_ptr->a; - d1 = 0; - d2 = 0; - da = 0; + d1 = 0.0f; + d2 = 0.0f; + da = 0.0f; if (f != sect_ptr->f) { @@ -80,7 +80,7 @@ param_sect_proc( else if (f > 2.0f * sect_ptr->f) f = 2.0f * sect_ptr->f; sect_ptr->f = f; sect_ptr->s1 = -cosf(6.283185f * f); - d1 = (sect_ptr->s1 - s1) / k; + d1 = (sect_ptr->s1 - s1) / (float)k; u2 = true; } @@ -90,7 +90,7 @@ param_sect_proc( else if (g > 2.0f * sect_ptr->g) g = 2.0f * sect_ptr->g; sect_ptr->g = g; sect_ptr->a = 0.5f * (g - 1.0f); - da = (sect_ptr->a - a) / k; + da = (sect_ptr->a - a) / (float)k; u2 = true; } @@ -106,7 +106,7 @@ param_sect_proc( { b *= 7 * f / sqrtf(g); sect_ptr->s2 = (1 - b) / (1 + b); - d2 = (sect_ptr->s2 - s2) / k; + d2 = (sect_ptr->s2 - s2) / (float)k; } while (k--) @@ -240,22 +240,22 @@ filter_run( float sfreq[filter_ptr->bands_count]; float sband[filter_ptr->bands_count]; float sgain[filter_ptr->bands_count]; - float bands_count; + int bands_count; - bands_count = filter_ptr->bands_count; + bands_count = (int)filter_ptr->bands_count; - fgain = exp2ap(0.1661 * *filter_ptr->global_parameters[GLOBAL_PARAMETER_GAIN]); + fgain = exp2ap(0.1661f * *filter_ptr->global_parameters[GLOBAL_PARAMETER_GAIN]); for (j = 0; j < bands_count; ++j) { t = *filter_ptr->band_parameters[BAND_PARAMETERS_COUNT * j + BAND_PARAMETER_FREQUENCY] / filter_ptr->sample_rate; - if (t < 0.0002) + if (t < 0.0002f) { - t = 0.0002; + t = 0.0002f; } - else if (t > 0.4998) + else if (t > 0.4998f) { - t = 0.4998; + t = 0.4998f; } sfreq[j] = t; @@ -263,32 +263,32 @@ filter_run( if (*filter_ptr->band_parameters[BAND_PARAMETERS_COUNT * j + BAND_PARAMETER_ACTIVE] > 0.0) { - sgain[j] = exp2ap(0.1661 * *filter_ptr->band_parameters[BAND_PARAMETERS_COUNT * j + BAND_PARAMETER_GAIN]); + sgain[j] = exp2ap(0.1661f * *filter_ptr->band_parameters[BAND_PARAMETERS_COUNT * j + BAND_PARAMETER_GAIN]); } else { - sgain[j] = 1.0; + sgain[j] = 1.0f; } } while (samples_count) { - k = (samples_count > 48) ? 32 : samples_count; + k = (samples_count > 48) ? 32 : (int)samples_count; t = fgain; g = filter_ptr->gain; - if (t > 1.25 * g) + if (t > 1.25f * g) { - t = 1.25 * g; + t = 1.25f * g; } - else if (t < 0.80 * g) + else if (t < 0.80f * g) { - t = 0.80 * g; + t = 0.80f * g; } filter_ptr->gain = t; - d = (t - g) / k; + d = (t - g) / (float)k; for (i = 0; i < k; ++i) { g += d; @@ -301,7 +301,7 @@ filter_run( } j = filter_ptr->fade; - g = j / 16.0; + g = (float)(j / 16.0); p = 0; if (*filter_ptr->global_parameters[GLOBAL_PARAMETER_ACTIVE] > 0.0) @@ -331,11 +331,11 @@ filter_run( if (p) { - memcpy(output_buffer, p, k * sizeof(float)); + memcpy(output_buffer, p, (size_t)k * sizeof(float)); } else { - d = (j / 16.0 - g) / k; + d = (float)((j / 16.0 - g) / k); for (i = 0; i < k; ++i) { g += d; @@ -345,6 +345,6 @@ filter_run( input_buffer += k; output_buffer += k; - samples_count -= k; + samples_count -= (unsigned long)k; } } diff --git a/source/modules/carla_native/nekofilter/nekofilter.c b/source/modules/carla_native/nekofilter/nekofilter.c index 304cb3124..19c069ac2 100644 --- a/source/modules/carla_native/nekofilter/nekofilter.c +++ b/source/modules/carla_native/nekofilter/nekofilter.c @@ -73,7 +73,7 @@ nekofilter_instantiate( nekofilter_ptr->ui = NULL; #endif - if (! filter_create(host->get_sample_rate(host->handle), BANDS_COUNT, &nekofilter_ptr->filter)) + if (! filter_create((float)host->get_sample_rate(host->handle), BANDS_COUNT, &nekofilter_ptr->filter)) { free(nekofilter_ptr); return NULL; @@ -155,28 +155,20 @@ nekofilter_get_parameter_info( uint32_t index) { static NativeParameter param; - static bool first_init = true; + static char* name = NULL; + static char* unit = NULL; uint32_t band; char strBuf[32]; - if (first_init) + if (name != NULL) { - first_init = false; - param.name = NULL; - param.unit = NULL; + free(name); + name = NULL; } - else + if (unit != NULL) { - if (param.name != NULL) - { - free((void*)param.name); - param.name = NULL; - } - if (param.unit != NULL) - { - free((void*)param.unit); - param.unit = NULL; - } + free(unit); + unit = NULL; } if (handle == NULL && index == 0xf00baa) @@ -193,15 +185,15 @@ nekofilter_get_parameter_info( switch (index) { case GLOBAL_PARAMETER_ACTIVE: + name = strdup("Active"); param.hints |= PARAMETER_IS_BOOLEAN; - param.name = strdup("Active"); param.ranges.max = 1.0f; goto ready; break; case GLOBAL_PARAMETER_GAIN: - param.name = strdup("Gain"); - param.unit = strdup("dB"); + name = strdup("Gain"); + unit = strdup("dB"); param.ranges.min = -20.0f; param.ranges.max = 20.0f; goto ready; @@ -219,16 +211,16 @@ nekofilter_get_parameter_info( { case BAND_PARAMETER_ACTIVE: strcat(strBuf, "Active"); + name = strdup(strBuf); param.hints |= PARAMETER_IS_BOOLEAN; - param.name = strdup(strBuf); param.ranges.max = 1.0f; break; case BAND_PARAMETER_FREQUENCY: strcat(strBuf, "Frequency"); + name = strdup(strBuf); + unit = strdup("Hz"); param.hints |= PARAMETER_IS_LOGARITHMIC; - param.name = strdup(strBuf); - param.unit = strdup("Hz"); switch (band) { @@ -253,16 +245,16 @@ nekofilter_get_parameter_info( case BAND_PARAMETER_BANDWIDTH: strcat(strBuf, "Bandwidth"); + name = strdup(strBuf); param.hints |= PARAMETER_IS_LOGARITHMIC; - param.name = strdup(strBuf); param.ranges.min = 0.125f; param.ranges.max = 8.0f; break; case BAND_PARAMETER_GAIN: strcat(strBuf, "Gain"); - param.name = strdup(strBuf); - param.unit = strdup("dB"); + name = strdup(strBuf); + unit = strdup("dB"); param.ranges.min = -20.0f; param.ranges.max = 20.0f; break; @@ -283,6 +275,9 @@ ready: param.ranges.stepLarge = range/10.0f; } + param.name = name; + param.unit = unit; + return ¶m; } diff --git a/source/modules/carla_native/nekofilter/ui.c b/source/modules/carla_native/nekofilter/ui.c index 648f5c5e7..0d397b88e 100644 --- a/source/modules/carla_native/nekofilter/ui.c +++ b/source/modules/carla_native/nekofilter/ui.c @@ -190,7 +190,7 @@ nekoui_run( if (sscanf(port_value_str, "%f", &value) == 1) { //printf("port %d = %f\n", port, value); - control_ptr->host->ui_parameter_changed(control_ptr->host->handle, index, value); + control_ptr->host->ui_parameter_changed(control_ptr->host->handle, (uint32_t)index, value); } else { @@ -337,7 +337,7 @@ static int clone_fn(void * context) #endif -static bool do_fork(const char * argv[6], int* ret) +static bool do_fork(char * argv[6], int* ret) { int ret2 = *ret = FORK(); @@ -351,7 +351,7 @@ static bool do_fork(const char * argv[6], int* ret) close(pipe2[0]); #endif - execvp(argv[0], (char **)argv); + execvp(argv[0], /*(char **)*/argv); fprintf(stderr, "exec of UI failed: %s\n", strerror(errno)); return false; case -1: @@ -375,7 +375,7 @@ nekoui_instantiate( char ui_send_pipe[100]; int oldflags; FORK_TIME_MEASURE_VAR; - const char * argv[6]; + char * argv[6]; int ret; int i; char ch; @@ -475,7 +475,7 @@ nekoui_instantiate( //printf("waiting UI start\n"); i = 0; loop: - ret = read(control_ptr->recv_pipe, &ch, 1); + ret = (int)read(control_ptr->recv_pipe, &ch, 1); switch (ret) { case -1: @@ -556,9 +556,9 @@ void nekoui_set_parameter_value( ign = write(control_ptr->send_pipe, "port_value\n", 11); len = sprintf(buf, "%u\n", (unsigned int)index); - ign = write(control_ptr->send_pipe, buf, len); + ign = write(control_ptr->send_pipe, buf, (size_t)len); len = sprintf(buf, "%.10f\n", value); - ign = write(control_ptr->send_pipe, buf, len); + ign = write(control_ptr->send_pipe, buf, (size_t)len); fsync(control_ptr->send_pipe); setlocale(LC_NUMERIC, locale);