Browse Source

More work, LADSPA kinda working

tags/1.9.4
falkTX 11 years ago
parent
commit
a246459129
11 changed files with 216 additions and 234 deletions
  1. +5
    -0
      source/backend/carla_backend.hpp
  2. +9
    -1
      source/backend/carla_engine.hpp
  3. +24
    -0
      source/backend/carla_plugin.hpp
  4. +17
    -5
      source/backend/engine/carla_engine.cpp
  5. +1
    -1
      source/backend/engine/carla_engine_thread.cpp
  6. +33
    -63
      source/backend/engine/jack.cpp
  7. +18
    -1
      source/backend/plugin/carla_plugin.cpp
  8. +2
    -0
      source/backend/plugin/carla_plugin_internal.hpp
  9. +102
    -154
      source/backend/plugin/ladspa.cpp
  10. +4
    -5
      source/bridges/carla_bridge_plugin.cpp
  11. +1
    -4
      source/utils/carla_ladspa_utils.hpp

+ 5
- 0
source/backend/carla_backend.hpp View File

@@ -608,6 +608,11 @@ struct ParameterRanges {
return max;
return value;
}

float Value(const float& value) const
{
return (value - min) / (max - min);
}
};

/*!


+ 9
- 1
source/backend/carla_engine.hpp View File

@@ -381,6 +381,14 @@ public:
*/
virtual void initBuffer(CarlaEngine* const engine);

/*!
* Direct access to the port's audio buffer.
*/
float* getBuffer() const
{
return fBuffer;
}

protected:
float* fBuffer;

@@ -655,7 +663,7 @@ public:

/*!
* Get a unique plugin name within the engine.\n
* Returned variable must be free'd when no longer needed.
* Returned variable must NOT be free'd.
*/
const char* getNewUniquePluginName(const char* const name);



+ 24
- 0
source/backend/carla_plugin.hpp View File

@@ -732,6 +732,12 @@ public:
*/
const char* libError(const char* const filename);

// -------------------------------------------------------------------
// Engine helpers

float* getAudioInPortBuffer(uint32_t index);
float* getAudioOutPortBuffer(uint32_t index);

// -------------------------------------------------------------------
// Plugin initializers

@@ -775,6 +781,24 @@ public:
protected:
ScopedPointer<CarlaPluginProtectedData> const fData;

class ScopedDisabler
{
public:
ScopedDisabler(CarlaPlugin* const plugin)
: kPlugin(plugin)
{
plugin->setEnabled(false);
}

~ScopedDisabler()
{
kPlugin->setEnabled(true);
}

private:
CarlaPlugin* const kPlugin;
};

private:
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPlugin)
};


+ 17
- 5
source/backend/engine/carla_engine.cpp View File

@@ -605,11 +605,12 @@ CarlaPlugin* CarlaEngine::getPluginUnchecked(const unsigned int id) const
const char* CarlaEngine::getNewUniquePluginName(const char* const name)
{
qDebug("CarlaEngine::getNewUniquePluginName(\"%s\")", name);
CARLA_ASSERT(fData->curPluginCount > 0);
CARLA_ASSERT(fData->maxPluginNumber > 0);
CARLA_ASSERT(fData->plugins != nullptr);
CARLA_ASSERT(name != nullptr);

CarlaString sname(name);
static CarlaString sname;
sname = name;

if (sname.isEmpty() || fData->plugins == nullptr)
return strdup("(No name)");
@@ -675,7 +676,7 @@ const char* CarlaEngine::getNewUniquePluginName(const char* const name)
sname += " (2)";
}

return strdup(sname);
return (const char*)sname;
}

bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, const void* const extra)
@@ -692,9 +693,11 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons
return false;
}

const unsigned int id = fData->curPluginCount;

CarlaPlugin::Initializer init = {
this,
fData->curPluginCount,
id,
filename,
name,
label
@@ -815,9 +818,16 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons
if (plugin == nullptr)
return false;

fData->plugins[id].plugin = plugin;
fData->plugins[id].insPeak[0] = 0.0f;
fData->plugins[id].insPeak[1] = 0.0f;
fData->plugins[id].outsPeak[0] = 0.0f;
fData->plugins[id].outsPeak[1] = 0.0f;

fData->curPluginCount++;

callback(CALLBACK_PLUGIN_ADDED, init.id, 0, 0, 0.0f, nullptr);
// FIXME
//callback(CALLBACK_PLUGIN_ADDED, id, 0, 0, 0.0f, nullptr);

return true;
}
@@ -1326,6 +1336,8 @@ void CarlaEngine::proccessPendingEvents()
doPluginRemove(fData, true);
break;
}

// TODO - peak values
}

void CarlaEngine::bufferSizeChanged(const uint32_t newBufferSize)


+ 1
- 1
source/backend/engine/carla_engine_thread.cpp View File

@@ -79,7 +79,7 @@ void CarlaEngineThread::run()
CARLA_ASSERT(kEngine->isRunning());

bool oscRegisted, usesSingleThread;
int i, count;
unsigned int i, count;
double value;

while (kEngine->isRunning() && ! fStopNow)


+ 33
- 63
source/backend/engine/jack.cpp View File

@@ -76,11 +76,6 @@ public:
fBuffer = (float*)jackbridge_port_get_buffer(m_port, engine->getBufferSize());
}

float* getBuffer() const
{
return fBuffer;
}

private:
jack_client_t* const m_client;
jack_port_t* const m_port;
@@ -482,6 +477,8 @@ public:

#ifdef BUILD_BRIDGE
m_hasQuit = false;

fOptions.processMode = PROCESS_MODE_MULTIPLE_CLIENTS;
#endif
}

@@ -551,10 +548,9 @@ public:

if (jackbridge_activate(m_client) == 0)
{
fName = jackbridge_get_client_name(m_client);
fName.toBasic();
const char* const clientName = jackbridge_get_client_name(m_client);

CarlaEngine::init(fName);
CarlaEngine::init(clientName);
return true;
}
else
@@ -583,10 +579,7 @@ public:
}
}

fName = clientName;
fName.toBasic();

CarlaEngine::init(fName);
CarlaEngine::init(clientName);
return true;
#endif
}
@@ -671,11 +664,9 @@ public:
}
else if (fOptions.processMode == PROCESS_MODE_MULTIPLE_CLIENTS)
{
#if 0
client = jackbridge_client_open(plugin->name(), JackNullOption, nullptr);
jackbridge_set_process_callback(client, carla_jack_process_callback_plugin, plugin);
jackbridge_set_latency_callback(client, carla_jack_latency_callback_plugin, plugin);
#endif
}
#endif

@@ -693,11 +684,6 @@ protected:
{
fBufferSize = newBufferSize;

#ifndef BUILD_BRIDGE
if (fOptions.processHighPrecision)
return;
#endif

bufferSizeChanged(newBufferSize);
}

@@ -714,7 +700,7 @@ protected:
void handleJackProcessCallback(const uint32_t nframes)
{
#ifndef BUILD_BRIDGE
if (maxPluginNumber() == 0)
if (currentPluginCount() == 0)
return;
#endif

@@ -749,25 +735,26 @@ protected:
fTimeInfo.valid = 0;
}

#if 0
#ifndef BUILD_BRIDGE
#ifdef BUILD_BRIDGE
CarlaPlugin* const plugin = getPluginUnchecked(0);

if (plugin && plugin->enabled())
{
plugin->initBuffers();
processPlugin(plugin, nframes);
}
#else
if (options.processMode == PROCESS_MODE_SINGLE_CLIENT)
{
for (unsigned short i=0, max=maxPluginNumber(); i < max; i++)
{
CarlaPlugin* const plugin = getPluginUnchecked(i);
#else
CarlaPlugin* const plugin = getPluginUnchecked(0);
#endif

if (plugin && plugin->enabled())
{
processLock();
plugin->initBuffers();
processPlugin(plugin, nframes);
processUnlock();
}
#ifndef BUILD_BRIDGE
}
}
else if (options.processMode == PROCESS_MODE_CONTINUOUS_RACK)
@@ -938,7 +925,8 @@ protected:
}
}
#endif
#endif

proccessPendingEvents();
}

void handleJackLatencyCallback(const jack_latency_callback_mode_t mode)
@@ -948,7 +936,6 @@ protected:
return;
#endif

#if 0
for (unsigned short i=0, max=maxPluginNumber(); i < max; i++)
{
CarlaPlugin* const plugin = getPluginUnchecked(i);
@@ -956,7 +943,6 @@ protected:
if (plugin && plugin->enabled())
latencyPlugin(plugin, mode);
}
#endif
}

void handleJackShutdownCallback()
@@ -1003,48 +989,32 @@ private:

static void processPlugin(CarlaPlugin* const p, const uint32_t nframes)
{
#if 0
float* inBuffer[p->aIn.count];
float* outBuffer[p->aOut.count];

for (uint32_t i=0; i < p->aIn.count; i++)
inBuffer[i] = ((CarlaEngineJackAudioPort*)p->aIn.ports[i])->getBuffer();

for (uint32_t i=0; i < p->aOut.count; i++)
outBuffer[i] = ((CarlaEngineJackAudioPort*)p->aOut.ports[i])->getBuffer();
const uint32_t inCount = p->audioInCount();
const uint32_t outCount = p->audioOutCount();

if (p->m_processHighPrecision)
{
float* inBuffer2[p->aIn.count];
float* outBuffer2[p->aOut.count];
float* inBuffer[inCount];
float* outBuffer[outCount];

for (uint32_t i=0, j; i < nframes; i += 8)
{
for (j=0; j < p->aIn.count; j++)
inBuffer2[j] = inBuffer[j] + i;
for (uint32_t i=0; i < inCount; i++)
inBuffer[i] = p->getAudioInPortBuffer(i);

for (j=0; j < p->aOut.count; j++)
outBuffer2[j] = outBuffer[j] + i;
for (uint32_t i=0; i < outCount; i++)
outBuffer[i] = p->getAudioOutPortBuffer(i);

p->process(inBuffer2, outBuffer2, 8, i);
}
}
else
p->process(inBuffer, outBuffer, nframes);
#endif
p->process(inBuffer, outBuffer, nframes);
}

static void latencyPlugin(CarlaPlugin* const p, jack_latency_callback_mode_t mode)
{
#if 0
jack_latency_range_t range;
uint32_t pluginLatency = p->x_client->getLatency();
uint32_t pluginLatency = 0; //p->getLatency();

if (pluginLatency == 0)
return;

if (mode == JackCaptureLatency)
{
#if 0
for (uint32_t i=0; i < p->aIn.count; i++)
{
uint aOutI = (i >= p->aOut.count) ? p->aOut.count : i;
@@ -1056,9 +1026,11 @@ private:
range.max += pluginLatency;
jackbridge_port_set_latency_range(portOut, mode, &range);
}
#endif
}
else
{
#if 0
for (uint32_t i=0; i < p->aOut.count; i++)
{
uint aInI = (i >= p->aIn.count) ? p->aIn.count : i;
@@ -1070,8 +1042,8 @@ private:
range.max += pluginLatency;
jackbridge_port_set_latency_range(portIn, mode, &range);
}
}
#endif
}
}

// -------------------------------------
@@ -1117,11 +1089,11 @@ private:

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

#ifndef BUILD_BRIDGE
static int carla_jack_process_callback_plugin(jack_nframes_t nframes, void* arg)
{
CarlaPlugin* const plugin = (CarlaPlugin*)arg;

#if 0
if (plugin && plugin->enabled())
{
//plugin->engineProcessLock();
@@ -1129,20 +1101,18 @@ private:
processPlugin(plugin, nframes);
//plugin->engineProcessUnlock();
}
#endif

return 0;
}

static void carla_jack_latency_callback_plugin(jack_latency_callback_mode_t mode, void* arg)
{
#if 0
CarlaPlugin* const plugin = (CarlaPlugin*)arg;

if (plugin && plugin->enabled())
latencyPlugin(plugin, mode);
#endif
}
#endif

CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineJack)
};


+ 18
- 1
source/backend/plugin/carla_plugin.cpp View File

@@ -41,7 +41,7 @@ CarlaPlugin::CarlaPlugin(CarlaEngine* const engine, const unsigned int id)
{
CARLA_ASSERT(fData != nullptr);
CARLA_ASSERT(engine != nullptr);
CARLA_ASSERT(id < engine->currentPluginCount());
CARLA_ASSERT(id < engine->maxPluginNumber());
qDebug("CarlaPlugin::CarlaPlugin(%p, %i)", engine, id);

if (engine->getProccessMode() == PROCESS_MODE_CONTINUOUS_RACK)
@@ -1404,6 +1404,23 @@ const char* CarlaPlugin::libError(const char* const filename)
return lib_error(filename);
}

// -------------------------------------------------------------------
// Engine helpers

float* CarlaPlugin::getAudioInPortBuffer(uint32_t index)
{
CARLA_ASSERT(fData->audioIn.ports[index].port);

return fData->audioIn.ports[index].port->getBuffer();
}

float* CarlaPlugin::getAudioOutPortBuffer(uint32_t index)
{
CARLA_ASSERT(fData->audioOut.ports[index].port);

return fData->audioOut.ports[index].port->getBuffer();
}

// -------------------------------------------------------------------
// CarlaPluginGUI



+ 2
- 0
source/backend/plugin/carla_plugin_internal.hpp View File

@@ -78,6 +78,8 @@ struct PluginAudioData {

if (ports == nullptr)
ports = new PluginAudioPort[count];

this->count = count;
}

void freePorts()


+ 102
- 154
source/backend/plugin/ladspa.cpp View File

@@ -332,7 +332,7 @@ public:
const ProcessMode processMode(fData->engine->getOptions().processMode);

// Safely disable plugin for reload
//const ScopedDisabler m(this);
const ScopedDisabler sd(this);

if (fData->client->isActive())
fData->client->deactivate();
@@ -386,21 +386,21 @@ public:

if (aIns > 0)
{
//fData->audioIn.ports = new CarlaEngineAudioPort*[aIns];
//fData->audioIn.rindexes = new uint32_t[aIns];
fData->audioIn.createNew(aIns);
aIns = 0;
}

if (aOuts > 0)
{
//fData->audioOut.ports = new CarlaEngineAudioPort*[aOuts];
//fData->audioOut.rindexes = new uint32_t[aOuts];
fData->audioOut.createNew(aOuts);
aOuts = 0;
}

if (params > 0)
{
fData->param.data = new ParameterData[params];
fData->param.ranges = new ParameterRanges[params];
fParamBuffers = new float[params];
fData->param.createNew(params);
fParamBuffers = new float[params];
params = 0;
}

bool needsCtrlIn = false;
@@ -430,29 +430,29 @@ public:

if (LADSPA_IS_PORT_INPUT(portType))
{
//j = fData->audioIn.count++;
//aIn.ports[j] = (CarlaEngineAudioPort*)fData->client->addPort(kEnginePortTypeAudio, portName, true);
//aIn.rindexes[j] = i;
j = aIns++;
fData->audioIn.ports[j].port = (CarlaEngineAudioPort*)fData->client->addPort(kEnginePortTypeAudio, portName, true);
fData->audioIn.ports[j].rindex = i;

if (forcedStereoIn)
{
portName += "_2";
//aIn.ports[1] = (CarlaEngineAudioPort*)fData->client->addPort(kEnginePortTypeAudio, portName, true);
//aIn.rindexes[1] = i;
fData->audioIn.ports[1].port = (CarlaEngineAudioPort*)fData->client->addPort(kEnginePortTypeAudio, portName, true);
fData->audioIn.ports[1].rindex = i;
}
}
else if (LADSPA_IS_PORT_OUTPUT(portType))
{
//j = aOut.count++;
//aOut.ports[j] = (CarlaEngineAudioPort*)fData->client->addPort(kEnginePortTypeAudio, portName, false);
//aOut.rindexes[j] = i;
j = aOuts++;
fData->audioOut.ports[j].port = (CarlaEngineAudioPort*)fData->client->addPort(kEnginePortTypeAudio, portName, false);
fData->audioOut.ports[j].rindex = i;
needsCtrlIn = true;

if (forcedStereoOut)
{
portName += "_2";
//aOut.ports[1] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, false);
//aOut.rindexes[1] = i;
fData->audioOut.ports[1].port = (CarlaEngineAudioPort*)fData->client->addPort(kEnginePortTypeAudio, portName, false);
fData->audioOut.ports[1].rindex = i;
}
}
else
@@ -460,7 +460,7 @@ public:
}
else if (LADSPA_IS_PORT_CONTROL(portType))
{
j = fData->param.count++;
j = params++;
fData->param.data[j].index = j;
fData->param.data[j].rindex = i;
fData->param.data[j].hints = 0;
@@ -473,23 +473,23 @@ public:
if (LADSPA_IS_HINT_BOUNDED_BELOW(portHints.HintDescriptor))
min = portHints.LowerBound;
else
min = 0.0;
min = 0.0f;

// max value
if (LADSPA_IS_HINT_BOUNDED_ABOVE(portHints.HintDescriptor))
max = portHints.UpperBound;
else
max = 1.0;
max = 1.0f;

if (min > max)
max = min;
else if (max < min)
min = max;

if (max - min == 0.0)
if (max - min == 0.0f)
{
qWarning("Broken plugin parameter: max - min == 0");
max = min + 0.1;
max = min + 0.1f;
}

// default value
@@ -520,17 +520,17 @@ public:
}
else if (LADSPA_IS_HINT_INTEGER(portHints.HintDescriptor))
{
step = 1.0;
stepSmall = 1.0;
stepLarge = 10.0;
step = 1.0f;
stepSmall = 1.0f;
stepLarge = 10.0f;
fData->param.data[j].hints |= PARAMETER_IS_INTEGER;
}
else
{
double range = max - min;
step = range/100.0;
stepSmall = range/1000.0;
stepLarge = range/10.0;
float range = max - min;
step = range/100.0f;
stepSmall = range/1000.0f;
stepLarge = range/10.0f;
}

if (LADSPA_IS_PORT_INPUT(portType))
@@ -544,12 +544,12 @@ public:
{
if (strcmp(fDescriptor->PortNames[i], "latency") == 0 || strcmp(fDescriptor->PortNames[i], "_latency") == 0)
{
min = 0.0;
min = 0.0f;
max = sampleRate;
def = 0.0;
step = 1.0;
stepSmall = 1.0;
stepLarge = 1.0;
def = 0.0f;
step = 1.0f;
stepSmall = 1.0f;
stepLarge = 1.0f;

fData->param.data[j].type = PARAMETER_LATENCY;
fData->param.data[j].hints = 0;
@@ -557,9 +557,9 @@ public:
else if (strcmp(fDescriptor->PortNames[i], "_sample-rate") == 0)
{
def = sampleRate;
step = 1.0;
stepSmall = 1.0;
stepLarge = 1.0;
step = 1.0f;
stepSmall = 1.0f;
stepLarge = 1.0f;

fData->param.data[j].type = PARAMETER_SAMPLE_RATE;
fData->param.data[j].hints = 0;
@@ -623,7 +623,7 @@ public:
portName += "control-in";
portName.truncate(portNameSize);

//param.portCin = (CarlaEngineControlPort*)x_client->addPort(CarlaEnginePortTypeControl, portName, true);
fData->event.portIn = (CarlaEngineEventPort*)fData->client->addPort(kEnginePortTypeEvent, portName, true);
}

if (needsCtrlOut)
@@ -639,13 +639,9 @@ public:
portName += "control-out";
portName.truncate(portNameSize);

//param.portCout = (CarlaEngineControlPort*)x_client->addPort(CarlaEnginePortTypeControl, portName, false);
fData->event.portOut = (CarlaEngineEventPort*)fData->client->addPort(kEnginePortTypeEvent, portName, false);
}

//aIn.count = aIns;
//aOut.count = aOuts;
//param.count = params;

// plugin checks
fData->hints &= ~(PLUGIN_IS_SYNTH | PLUGIN_USES_CHUNKS | PLUGIN_CAN_DRYWET | PLUGIN_CAN_VOLUME | PLUGIN_CAN_BALANCE | PLUGIN_CAN_FORCE_STEREO);

@@ -728,37 +724,6 @@ public:
{
uint32_t i, k;

double aInsPeak[2] = { 0.0 };
double aOutsPeak[2] = { 0.0 };

CARLA_PROCESS_CONTINUE_CHECK;

// --------------------------------------------------------------------------------------------------------
// Input VU

if (fData->audioIn.count > 0 && fData->engine->getOptions().processMode != PROCESS_MODE_CONTINUOUS_RACK)
{
if (fData->audioIn.count == 1)
{
for (k=0; k < frames; k++)
{
if (std::abs(inBuffer[0][k]) > aInsPeak[0])
aInsPeak[0] = std::abs(inBuffer[0][k]);
}
}
else if (fData->audioIn.count > 1)
{
for (k=0; k < frames; k++)
{
if (std::abs(inBuffer[0][k]) > aInsPeak[0])
aInsPeak[0] = std::abs(inBuffer[0][k]);

if (std::abs(inBuffer[1][k]) > aInsPeak[1])
aInsPeak[1] = std::abs(inBuffer[1][k]);
}
}
}

CARLA_PROCESS_CONTINUE_CHECK;

// --------------------------------------------------------------------------------------------------------
@@ -942,23 +907,21 @@ public:
}
}

#if 0
for (i=0; i < aIn.count; i++)
for (i=0; i < fData->audioIn.count; i++)
{
if (i == 0 || ! fHandle2)
fDescriptor->connect_port(fHandle, aIn.rindexes[i], inBuffer[i]);
else if (i == 1)
fDescriptor->connect_port(fHandle2, aIn.rindexes[i], inBuffer[i]);
//if (i == 0 || ! fHandle2)
fDescriptor->connect_port(fHandle, fData->audioIn.ports[i].rindex, inBuffer[i]);
//else if (i == 1)
// fDescriptor->connect_port(fHandle2, fData->audioIn.ports[i].rindex, inBuffer[i]);
}

for (i=0; i < aOut.count; i++)
for (i=0; i < fData->audioOut.count; i++)
{
if (i == 0 || ! fHandle2)
fDescriptor->connect_port(handle, aOut.rindexes[i], outBuffer[i]);
else if (i == 1)
fDescriptor->connect_port(fHandle2, aOut.rindexes[i], outBuffer[i]);
//if (i == 0 || ! fHandle2)
fDescriptor->connect_port(fHandle, fData->audioOut.ports[i].rindex, outBuffer[i]);
//else if (i == 1)
//fDescriptor->connect_port(fHandle2, fData->audioOut.ports[i].rindex, outBuffer[i]);
}
#endif

fDescriptor->run(fHandle, frames);
if (fHandle2) fDescriptor->run(fHandle2, frames);
@@ -980,130 +943,112 @@ public:
// --------------------------------------------------------------------------------------------------------
// Post-processing (dry/wet, volume and balance)

#if 0
if (fData->active)
{
bool do_drywet = (fData->hints & PLUGIN_CAN_DRYWET) > 0 && x_dryWet != 1.0;
bool do_volume = (fData->hints & PLUGIN_CAN_VOLUME) > 0 && x_volume != 1.0;
bool do_balance = (fData->hints & PLUGIN_CAN_BALANCE) > 0 && (x_balanceLeft != -1.0 || x_balanceRight != 1.0);
const bool doDryWet = (fData->hints & PLUGIN_CAN_DRYWET) > 0 && fData->postProc.dryWet != 1.0;
const bool doVolume = (fData->hints & PLUGIN_CAN_VOLUME) > 0 && fData->postProc.volume != 1.0;
const bool doBalance = (fData->hints & PLUGIN_CAN_BALANCE) > 0 && (fData->postProc.balanceLeft != -1.0 || fData->postProc.balanceRight != 1.0);

double bal_rangeL, bal_rangeR;
float bufValue, oldBufLeft[do_balance ? frames : 1];
float balRangeL, balRangeR;
float bufValue, oldBufLeft[doBalance ? frames : 1];

for (i=0; i < aOut.count; i++)
for (i=0; i < fData->audioOut.count; i++)
{
// Dry/Wet
if (do_drywet)
if (doDryWet)
{
for (k=0; k < frames; k++)
{
if (k < m_latency && m_latency < frames)
bufValue = (aIn.count == 1) ? fData->latencyBuffers[0][k] : fData->latencyBuffers[i][k];
else
bufValue = (aIn.count == 1) ? inBuffer[0][k-m_latency] : inBuffer[i][k-m_latency];
//if (k < m_latency && m_latency < frames)
// bufValue = (aIn.count == 1) ? fData->latencyBuffers[0][k] : fData->latencyBuffers[i][k];
//else
// bufValue = (aIn.count == 1) ? inBuffer[0][k-m_latency] : inBuffer[i][k-m_latency];

bufValue = (fData->audioIn.count == 1) ? inBuffer[0][k] : inBuffer[i][k];

outBuffer[i][k] = (outBuffer[i][k]*x_dryWet)+(bufValue*(1.0-x_dryWet));
outBuffer[i][k] = (outBuffer[i][k] * fData->postProc.dryWet) + (bufValue * (1.0f - fData->postProc.dryWet));
}
}

// Balance
if (do_balance)
if (doBalance)
{
if (i%2 == 0)
if (i % 2 == 0)
memcpy(&oldBufLeft, outBuffer[i], sizeof(float)*frames);

bal_rangeL = (x_balanceLeft+1.0)/2;
bal_rangeR = (x_balanceRight+1.0)/2;
balRangeL = (fData->postProc.balanceLeft + 1.0f)/2.0f;
balRangeR = (fData->postProc.balanceRight + 1.0f)/2.0f;

for (k=0; k < frames; k++)
{
if (i%2 == 0)
if (i % 2 == 0)
{
// left output
outBuffer[i][k] = oldBufLeft[k]*(1.0-bal_rangeL);
outBuffer[i][k] += outBuffer[i+1][k]*(1.0-bal_rangeR);
outBuffer[i][k] = oldBufLeft[k] * (1.0f - balRangeL);
outBuffer[i][k] += outBuffer[i+1][k] * (1.0f - balRangeR);
}
else
{
// right
outBuffer[i][k] = outBuffer[i][k]*bal_rangeR;
outBuffer[i][k] += oldBufLeft[k]*bal_rangeL;
outBuffer[i][k] = outBuffer[i][k] * balRangeR;
outBuffer[i][k] += oldBufLeft[k] * balRangeL;
}
}
}

// Volume
if (do_volume)
if (doVolume)
{
for (k=0; k < frames; k++)
outBuffer[i][k] *= x_volume;
}

// Output VU
if (fData->engine->getOptions().processMode != PROCESS_MODE_CONTINUOUS_RACK)
{
for (k=0; i < 2 && k < frames; k++)
{
if (abs(outBuffer[i][k]) > aOutsPeak[i])
aOutsPeak[i] = abs(outBuffer[i][k]);
}
outBuffer[i][k] *= fData->postProc.volume;
}
}

#if 0
// Latency, save values for next callback
if (fData->latency > 0 && fData->latency < frames)
{
for (i=0; i < aIn.count; i++)
memcpy(fData->latencyBuffers[i], inBuffer[i] + (frames - fData->latency), sizeof(float)*fData->latency);
}
#endif
}
else
{
// disable any output sound if not active
for (i=0; i < aOut.count; i++)
carla_zeroF(outBuffer[i], frames);

aOutsPeak[0] = 0.0;
aOutsPeak[1] = 0.0;
for (i=0; i < fData->audioOut.count; i++)
carla_zeroFloat(outBuffer[i], frames);

} // End of Post-processing
#endif


CARLA_PROCESS_CONTINUE_CHECK;

// --------------------------------------------------------------------------------------------------------
// Control Output

#if 0
if (param.portCout && m_active)
if (fData->event.portOut && fData->active)
{
double value;
float value;

for (k=0; k < param.count; k++)
for (k=0; k < fData->param.count; k++)
{
if (param.data[k].type == PARAMETER_OUTPUT)
if (fData->param.data[k].type == PARAMETER_OUTPUT)
{
fixParameterValue(paramBuffers[k], param.ranges[k]);
fData->param.ranges[k].fixValue(fParamBuffers[k]);

if (param.data[k].midiCC > 0)
if (fData->param.data[k].midiCC > 0)
{
value = (paramBuffers[k] - param.ranges[k].min) / (param.ranges[k].max - param.ranges[k].min);
param.portCout->writeEvent(CarlaEngineParameterChangeEvent, framesOffset, param.data[k].midiChannel, param.data[k].midiCC, value);
value = fData->param.ranges[k].Value(fParamBuffers[k]);
fData->event.portOut->writeControlEvent(framesOffset, fData->param.data[k].midiChannel, kEngineControlEventTypeParameter, fData->param.data[k].midiCC, value);
}
}
}
} // End of Control Output
#endif

CARLA_PROCESS_CONTINUE_CHECK;

// --------------------------------------------------------------------------------------------------------
// Peak Values

//fData->engine->setInputPeak(fData->id, 0, aInsPeak[0]);
//fData->engine->setInputPeak(fData->id, 1, aInsPeak[1]);
//fData->engine->setOutputPeak(fData->id, 0, aOutsPeak[0]);
//fData->engine->setOutputPeak(fData->id, 1, aOutsPeak[1]);

fData->activeBefore = fData->active;
}
@@ -1115,10 +1060,11 @@ public:
{
qDebug("LadspaPlugin::deleteBuffers() - start");

if (fData->param.count > 0)
if (fParamBuffers != nullptr)
{
delete[] fParamBuffers;
fParamBuffers = nullptr;
fParamBuffers = nullptr;
}

CarlaPlugin::deleteBuffers();

@@ -1143,7 +1089,7 @@ public:

const LADSPA_Descriptor_Function descFn = (LADSPA_Descriptor_Function)libSymbol("ladspa_descriptor");

if (! descFn)
if (descFn == nullptr)
{
fData->engine->setLastError("Could not find the LASDPA Descriptor in the plugin library");
return false;
@@ -1153,13 +1099,15 @@ public:
// get descriptor that matches label

unsigned long i = 0;
while ((fDescriptor = descFn(i++)))
while ((fDescriptor = descFn(i++)) != nullptr)
{
if (strcmp(fDescriptor->Label, label) == 0)
if (fDescriptor->Label == nullptr)
continue;
if (std::strcmp(fDescriptor->Label, label) == 0)
break;
}

if (! fDescriptor)
if (fDescriptor == nullptr)
{
fData->engine->setLastError("Could not find the requested plugin Label in the plugin library");
return false;
@@ -1168,18 +1116,18 @@ public:
// ---------------------------------------------------------------
// get info

fData->filename = strdup(filename);

if (is_ladspa_rdf_descriptor_valid(rdfDescriptor, fDescriptor))
fRdfDescriptor = ladspa_rdf_dup(rdfDescriptor);

if (name)
if (name != nullptr)
fData->name = fData->engine->getNewUniquePluginName(name);
else if (fRdfDescriptor && fRdfDescriptor->Title)
fData->name = fData->engine->getNewUniquePluginName(fRdfDescriptor->Title);
else
fData->name = fData->engine->getNewUniquePluginName(fDescriptor->Name);

fData->filename = filename;

// ---------------------------------------------------------------
// register client

@@ -1239,7 +1187,7 @@ CarlaPlugin* CarlaPlugin::newLADSPA(const Initializer& init, const LADSPA_RDF_De

if (init.engine->getOptions().processMode == PROCESS_MODE_CONTINUOUS_RACK)
{
if (! (plugin->hints() & PLUGIN_CAN_FORCE_STEREO))
if ((plugin->hints() & PLUGIN_CAN_FORCE_STEREO) == 0)
{
init.engine->setLastError("Carla's rack mode can only work with Mono or Stereo LADSPA plugins, sorry!");
delete plugin;


+ 4
- 5
source/bridges/carla_bridge_plugin.cpp View File

@@ -1100,7 +1100,7 @@ int main(int argc, char* argv[])
engName.toBasic();
engName.truncate(engine->maxClientNameSize());

if (! engine->init(engName))
if (! engine->init((const char*)engName))
{
if (const char* const lastError = engine->getLastError())
{
@@ -1119,13 +1119,12 @@ int main(int argc, char* argv[])
if (itype == CarlaBackend::PLUGIN_DSSI)
extraStuff = findDSSIGUI(filename, name, label);

// Init plugin, FIXME
int id = engine->addPlugin(itype, filename, name, label, extraStuff);
// Init plugin
int ret;

if (id >= 0 && id < CarlaBackend::MAX_DEFAULT_PLUGINS)
if (engine->addPlugin(itype, filename, name, label, extraStuff))
{
CarlaBackend::CarlaPlugin* const plugin = engine->getPlugin(id);
CarlaBackend::CarlaPlugin* const plugin = engine->getPlugin(0);
client.setPlugin(plugin);

if (! useOsc)


+ 1
- 4
source/utils/carla_ladspa_utils.hpp View File

@@ -111,10 +111,7 @@ bool is_ladspa_port_good(const LADSPA_PortDescriptor port1, const LADSPA_PortDes
static inline
bool is_ladspa_rdf_descriptor_valid(const LADSPA_RDF_Descriptor* const rdfDescriptor, const LADSPA_Descriptor* const descriptor)
{
CARLA_ASSERT(rdfDescriptor);
CARLA_ASSERT(descriptor);

if (! (rdfDescriptor && descriptor))
if (rdfDescriptor == nullptr || descriptor == nullptr)
return false;

if (rdfDescriptor->UniqueID != descriptor->UniqueID)


Loading…
Cancel
Save