Browse Source

Fix audio-file and nekofilter for strict build

tags/1.9.4
falkTX 10 years ago
parent
commit
9d826096a1
4 changed files with 85 additions and 53 deletions
  1. +21
    -12
      source/modules/native-plugins/audio-file.cpp
  2. +31
    -28
      source/modules/native-plugins/nekofilter/filter.c
  3. +16
    -3
      source/modules/native-plugins/nekofilter/nekofilter.c
  4. +17
    -10
      source/modules/native-plugins/nekofilter/ui.c

+ 21
- 12
source/modules/native-plugins/audio-file.cpp View File

@@ -52,10 +52,15 @@ public:
: NativePluginClass(host),
fLoopMode(false),
fDoProcess(false),
fLength(0)
//fThread("AudioFilePluginThread")
fLength(0),
//fThread("AudioFilePluginThread"),
fReaderBuffer(),
fReaderMutex(),
fReader(),
fReaderSource(),
leakDetector_AudioFilePlugin()
{
fReaderBuffer.setSize(2, getBufferSize());
fReaderBuffer.setSize(2, static_cast<int>(getBufferSize()));
}

~AudioFilePlugin() override
@@ -142,6 +147,7 @@ protected:
void process(float**, float** const outBuffer, const uint32_t frames, const NativeMidiEvent* const, const uint32_t) override
{
const NativeTimeInfo* const timePos(getTimeInfo());
const int iframes(static_cast<int>(frames));

float* const out1(outBuffer[0]);
float* const out2(outBuffer[1]);
@@ -149,19 +155,19 @@ protected:
if (fLength == 0 || ! fDoProcess)
{
//carla_stderr("P: no process");
FloatVectorOperations::clear(out1, frames);
FloatVectorOperations::clear(out2, frames);
FloatVectorOperations::clear(out1, iframes);
FloatVectorOperations::clear(out2, iframes);
return;
}

const int64_t nextReadPos(fLoopMode ? (timePos->frame % fLength) : timePos->frame);
const int64_t nextReadPos(fLoopMode ? (static_cast<int64_t>(timePos->frame) % fLength) : static_cast<int64_t>(timePos->frame));

// not playing
if (! timePos->playing)
{
//carla_stderr("P: not playing");
FloatVectorOperations::clear(out1, frames);
FloatVectorOperations::clear(out2, frames);
FloatVectorOperations::clear(out1, iframes);
FloatVectorOperations::clear(out2, iframes);

const CarlaMutexLocker cml(fReaderMutex);

@@ -179,10 +185,10 @@ protected:
if (fReader == nullptr)
return;

fReader->read(&fReaderBuffer, 0, frames, nextReadPos, true, true);
fReader->read(&fReaderBuffer, 0, iframes, nextReadPos, true, true);

FloatVectorOperations::copy(out1, fReaderBuffer.getReadPointer(0), frames);
FloatVectorOperations::copy(out2, fReaderBuffer.getReadPointer(1), frames);
FloatVectorOperations::copy(out1, fReaderBuffer.getReadPointer(0), iframes);
FloatVectorOperations::copy(out2, fReaderBuffer.getReadPointer(1), iframes);
}

// -------------------------------------------------------------------
@@ -204,7 +210,7 @@ protected:

void bufferSizeChanged(const uint32_t bufferSize) override
{
fReaderBuffer.setSize(2, bufferSize);
fReaderBuffer.setSize(2, static_cast<int>(bufferSize));
}

private:
@@ -304,6 +310,9 @@ static const NativePluginDescriptor audiofileDesc = {

// -----------------------------------------------------------------------

CARLA_EXPORT
void carla_register_native_plugin_audiofile();

CARLA_EXPORT
void carla_register_native_plugin_audiofile()
{


+ 31
- 28
source/modules/native-plugins/nekofilter/filter.c View File

@@ -29,14 +29,15 @@

#include "filter.h"

static float exp2ap(float x)
static
float
exp2ap(float x)
{
int i;

i = (int)(floor(x));
x -= 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);
i = (int)(floorf(x));
x -= (float)i;
return ldexpf(1.0f + x * (0.6930f + x * (0.2416f + x * (0.0517f + x * 0.0137f))), i);
}

struct param_sect
@@ -46,6 +47,7 @@ struct param_sect
float z1, z2;
};

static
void
param_sect_init(
struct param_sect * sect_ptr)
@@ -55,10 +57,11 @@ param_sect_init(
sect_ptr->a = sect_ptr->s1 = sect_ptr->s2 = sect_ptr->z1 = sect_ptr->z2 = 0.0f;
}

static
void
param_sect_proc(
struct param_sect * sect_ptr,
int k,
unsigned long k,
float * sig,
float f,
float b,
@@ -80,7 +83,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 +93,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 +109,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--)
@@ -133,7 +136,7 @@ struct filter
const float ** band_parameters; /* [band_index * BAND_PARAMETERS_COUNT + parameter_index] */

float gain;
int fade;
unsigned long fade;
struct param_sect * sect; /* [band_index] */
};

@@ -232,7 +235,8 @@ filter_run(
float * output_buffer,
unsigned long samples_count)
{
int i, j, k;
unsigned long i, j, k;
unsigned long bands_count;
const float * p;
float sig[48];
float t, g, d;
@@ -240,22 +244,21 @@ filter_run(
float sfreq[filter_ptr->bands_count];
float sband[filter_ptr->bands_count];
float sgain[filter_ptr->bands_count];
float bands_count;

bands_count = 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,11 +266,11 @@ 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;
}
}

@@ -278,17 +281,17 @@ filter_run(
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,10 +304,10 @@ filter_run(
}

j = filter_ptr->fade;
g = j / 16.0;
g = (float)j / 16.0f;
p = 0;

if (*filter_ptr->global_parameters[GLOBAL_PARAMETER_ACTIVE] > 0.0)
if (*filter_ptr->global_parameters[GLOBAL_PARAMETER_ACTIVE] > 0.0f)
{
if (j == 16)
{
@@ -335,11 +338,11 @@ filter_run(
}
else
{
d = (j / 16.0 - g) / k;
d = ((float)j / 16.0f - g) / (float)k;
for (i = 0; i < k; ++i)
{
g += d;
output_buffer[i] = g * sig[i] + (1 - g) * input_buffer[i];
output_buffer[i] = g * sig[i] + (1.0f - g) * input_buffer[i];
}
}



+ 16
- 3
source/modules/native-plugins/nekofilter/nekofilter.c View File

@@ -53,6 +53,7 @@ struct nekofilter
#endif
};

static
NativePluginHandle
nekofilter_instantiate(
const NativeHostDescriptor* host)
@@ -139,6 +140,7 @@ nekofilter_instantiate(

#define nekofilter_ptr ((struct nekofilter *)handle)

static
uint32_t
nekofilter_get_parameter_count(
NativePluginHandle handle)
@@ -149,6 +151,7 @@ nekofilter_get_parameter_count(
(void)handle;
}

static
const NativeParameter*
nekofilter_get_parameter_info(
NativePluginHandle handle,
@@ -281,6 +284,7 @@ ready:
return &param;
}

static
float
nekofilter_get_parameter_value(
NativePluginHandle handle,
@@ -299,6 +303,7 @@ nekofilter_get_parameter_value(
}
}

static
void
nekofilter_set_parameter_value(
NativePluginHandle handle,
@@ -318,6 +323,7 @@ nekofilter_set_parameter_value(
}
}

static
void
nekofilter_process(
NativePluginHandle handle,
@@ -342,7 +348,9 @@ nekofilter_process(
}

#ifdef WANT_UI
void nekofilter_ui_show(
static
void
nekofilter_ui_show(
NativePluginHandle handle,
bool show)
{
@@ -359,14 +367,18 @@ void nekofilter_ui_show(
nekoui_hide(nekofilter_ptr->ui);
}

void nekofilter_ui_idle(
static
void
nekofilter_ui_idle(
NativePluginHandle handle)
{
if (nekofilter_ptr->ui != NULL)
nekoui_run(nekofilter_ptr->ui);
}

void nekofilter_ui_set_parameter_value(
static
void
nekofilter_ui_set_parameter_value(
NativePluginHandle handle,
uint32_t index,
float value)
@@ -376,6 +388,7 @@ void nekofilter_ui_set_parameter_value(
}
#endif

static
void
nekofilter_cleanup(
NativePluginHandle handle)


+ 17
- 10
source/modules/native-plugins/nekofilter/ui.c View File

@@ -341,7 +341,7 @@ static int clone_fn(void * context)

#endif

static bool do_fork(char * argv[6], int* ret /*, int pipe1[2], int pipe2[2]*/)
static bool do_fork(char* const argv[6], int* ret /*, int pipe1[2], int pipe2[2]*/)
{
int ret2 = *ret = FORK();

@@ -355,7 +355,7 @@ static bool do_fork(char * argv[6], int* ret /*, int pipe1[2], int pipe2[2]*/)
close(pipe2[0]);
#endif

execvp(argv[0], /*(char **)*/argv);
execvp(argv[0], argv);
fprintf(stderr, "exec of UI failed: %s\n", strerror(errno));
_exit(0);
return false;
@@ -385,13 +385,17 @@ nekoui_instantiate(
int ret;
int i;
char ch;

if (access("/usr/bin/python2", F_OK) != -1)
argv[0] = "/usr/bin/python2";
else if (access("/usr/bin/python2.7", F_OK) != -1)
argv[0] = "/usr/bin/python2.7";
else if (access("/usr/bin/python2.6", F_OK) != -1)
argv[0] = "/usr/bin/python2.6";
char ap2[18], ap26[18], ap27[18];
strcpy(ap2, "/usr/bin/python2");
strcpy(ap26, "/usr/bin/python2.6");
strcpy(ap27, "/usr/bin/python2,7");

if (access(ap2, F_OK) != -1)
argv[0] = ap2;
else if (access(ap27, F_OK) != -1)
argv[0] = ap27;
else if (access(ap26, F_OK) != -1)
argv[0] = ap26;
else
goto fail;

@@ -537,6 +541,7 @@ fail:
return NULL;
}

static
void
nekoui_cleanup(
struct control * control_ptr)
@@ -545,7 +550,9 @@ nekoui_cleanup(
free(control_ptr);
}

void nekoui_set_parameter_value(
static
void
nekoui_set_parameter_value(
struct control * control_ptr,
uint32_t index,
float value)


Loading…
Cancel
Save