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 max;
return value; 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); virtual void initBuffer(CarlaEngine* const engine);


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

protected: protected:
float* fBuffer; float* fBuffer;


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


/*! /*!
* Get a unique plugin name within the engine.\n * 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); 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); const char* libError(const char* const filename);


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

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

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


@@ -775,6 +781,24 @@ public:
protected: protected:
ScopedPointer<CarlaPluginProtectedData> const fData; 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: private:
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPlugin) 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) const char* CarlaEngine::getNewUniquePluginName(const char* const name)
{ {
qDebug("CarlaEngine::getNewUniquePluginName(\"%s\")", name); qDebug("CarlaEngine::getNewUniquePluginName(\"%s\")", name);
CARLA_ASSERT(fData->curPluginCount > 0);
CARLA_ASSERT(fData->maxPluginNumber > 0);
CARLA_ASSERT(fData->plugins != nullptr); CARLA_ASSERT(fData->plugins != nullptr);
CARLA_ASSERT(name != nullptr); CARLA_ASSERT(name != nullptr);


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


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


const unsigned int id = fData->curPluginCount;

CarlaPlugin::Initializer init = { CarlaPlugin::Initializer init = {
this, this,
fData->curPluginCount,
id,
filename, filename,
name, name,
label label
@@ -815,9 +818,16 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons
if (plugin == nullptr) if (plugin == nullptr)
return false; 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++; 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; return true;
} }
@@ -1326,6 +1336,8 @@ void CarlaEngine::proccessPendingEvents()
doPluginRemove(fData, true); doPluginRemove(fData, true);
break; break;
} }

// TODO - peak values
} }


void CarlaEngine::bufferSizeChanged(const uint32_t newBufferSize) 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()); CARLA_ASSERT(kEngine->isRunning());


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


while (kEngine->isRunning() && ! fStopNow) 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()); fBuffer = (float*)jackbridge_port_get_buffer(m_port, engine->getBufferSize());
} }


float* getBuffer() const
{
return fBuffer;
}

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


#ifdef BUILD_BRIDGE #ifdef BUILD_BRIDGE
m_hasQuit = false; m_hasQuit = false;

fOptions.processMode = PROCESS_MODE_MULTIPLE_CLIENTS;
#endif #endif
} }


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


if (jackbridge_activate(m_client) == 0) 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; return true;
} }
else else
@@ -583,10 +579,7 @@ public:
} }
} }


fName = clientName;
fName.toBasic();

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


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


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

bufferSizeChanged(newBufferSize); bufferSizeChanged(newBufferSize);
} }


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


@@ -749,25 +735,26 @@ protected:
fTimeInfo.valid = 0; 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) if (options.processMode == PROCESS_MODE_SINGLE_CLIENT)
{ {
for (unsigned short i=0, max=maxPluginNumber(); i < max; i++) for (unsigned short i=0, max=maxPluginNumber(); i < max; i++)
{ {
CarlaPlugin* const plugin = getPluginUnchecked(i); CarlaPlugin* const plugin = getPluginUnchecked(i);
#else
CarlaPlugin* const plugin = getPluginUnchecked(0);
#endif


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

proccessPendingEvents();
} }


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


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


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


static void processPlugin(CarlaPlugin* const p, const uint32_t nframes) 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) static void latencyPlugin(CarlaPlugin* const p, jack_latency_callback_mode_t mode)
{ {
#if 0
jack_latency_range_t range; jack_latency_range_t range;
uint32_t pluginLatency = p->x_client->getLatency();
uint32_t pluginLatency = 0; //p->getLatency();


if (pluginLatency == 0) if (pluginLatency == 0)
return; return;


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


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


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


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


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


return 0; return 0;
} }


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


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


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineJack) 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(fData != nullptr);
CARLA_ASSERT(engine != nullptr); CARLA_ASSERT(engine != nullptr);
CARLA_ASSERT(id < engine->currentPluginCount());
CARLA_ASSERT(id < engine->maxPluginNumber());
qDebug("CarlaPlugin::CarlaPlugin(%p, %i)", engine, id); qDebug("CarlaPlugin::CarlaPlugin(%p, %i)", engine, id);


if (engine->getProccessMode() == PROCESS_MODE_CONTINUOUS_RACK) if (engine->getProccessMode() == PROCESS_MODE_CONTINUOUS_RACK)
@@ -1404,6 +1404,23 @@ const char* CarlaPlugin::libError(const char* const filename)
return lib_error(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 // CarlaPluginGUI




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

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


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

this->count = count;
} }


void freePorts() void freePorts()


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

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


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


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


if (aIns > 0) 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) 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) 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; bool needsCtrlIn = false;
@@ -430,29 +430,29 @@ public:


if (LADSPA_IS_PORT_INPUT(portType)) 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) if (forcedStereoIn)
{ {
portName += "_2"; 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)) 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; needsCtrlIn = true;


if (forcedStereoOut) if (forcedStereoOut)
{ {
portName += "_2"; 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 else
@@ -460,7 +460,7 @@ public:
} }
else if (LADSPA_IS_PORT_CONTROL(portType)) else if (LADSPA_IS_PORT_CONTROL(portType))
{ {
j = fData->param.count++;
j = params++;
fData->param.data[j].index = j; fData->param.data[j].index = j;
fData->param.data[j].rindex = i; fData->param.data[j].rindex = i;
fData->param.data[j].hints = 0; fData->param.data[j].hints = 0;
@@ -473,23 +473,23 @@ public:
if (LADSPA_IS_HINT_BOUNDED_BELOW(portHints.HintDescriptor)) if (LADSPA_IS_HINT_BOUNDED_BELOW(portHints.HintDescriptor))
min = portHints.LowerBound; min = portHints.LowerBound;
else else
min = 0.0;
min = 0.0f;


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


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


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


// default value // default value
@@ -520,17 +520,17 @@ public:
} }
else if (LADSPA_IS_HINT_INTEGER(portHints.HintDescriptor)) 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; fData->param.data[j].hints |= PARAMETER_IS_INTEGER;
} }
else 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)) if (LADSPA_IS_PORT_INPUT(portType))
@@ -544,12 +544,12 @@ public:
{ {
if (strcmp(fDescriptor->PortNames[i], "latency") == 0 || strcmp(fDescriptor->PortNames[i], "_latency") == 0) if (strcmp(fDescriptor->PortNames[i], "latency") == 0 || strcmp(fDescriptor->PortNames[i], "_latency") == 0)
{ {
min = 0.0;
min = 0.0f;
max = sampleRate; 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].type = PARAMETER_LATENCY;
fData->param.data[j].hints = 0; fData->param.data[j].hints = 0;
@@ -557,9 +557,9 @@ public:
else if (strcmp(fDescriptor->PortNames[i], "_sample-rate") == 0) else if (strcmp(fDescriptor->PortNames[i], "_sample-rate") == 0)
{ {
def = sampleRate; 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].type = PARAMETER_SAMPLE_RATE;
fData->param.data[j].hints = 0; fData->param.data[j].hints = 0;
@@ -623,7 +623,7 @@ public:
portName += "control-in"; portName += "control-in";
portName.truncate(portNameSize); portName.truncate(portNameSize);


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


if (needsCtrlOut) if (needsCtrlOut)
@@ -639,13 +639,9 @@ public:
portName += "control-out"; portName += "control-out";
portName.truncate(portNameSize); 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 // plugin checks
fData->hints &= ~(PLUGIN_IS_SYNTH | PLUGIN_USES_CHUNKS | PLUGIN_CAN_DRYWET | PLUGIN_CAN_VOLUME | PLUGIN_CAN_BALANCE | PLUGIN_CAN_FORCE_STEREO); 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; 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; 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); fDescriptor->run(fHandle, frames);
if (fHandle2) fDescriptor->run(fHandle2, frames); if (fHandle2) fDescriptor->run(fHandle2, frames);
@@ -980,130 +943,112 @@ public:
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// Post-processing (dry/wet, volume and balance) // Post-processing (dry/wet, volume and balance)


#if 0
if (fData->active) 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 // Dry/Wet
if (do_drywet)
if (doDryWet)
{ {
for (k=0; k < frames; k++) 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 // Balance
if (do_balance)
if (doBalance)
{ {
if (i%2 == 0)
if (i % 2 == 0)
memcpy(&oldBufLeft, outBuffer[i], sizeof(float)*frames); 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++) for (k=0; k < frames; k++)
{ {
if (i%2 == 0)
if (i % 2 == 0)
{ {
// left output // 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 else
{ {
// right // 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 // Volume
if (do_volume)
if (doVolume)
{ {
for (k=0; k < frames; k++) 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 // Latency, save values for next callback
if (fData->latency > 0 && fData->latency < frames) if (fData->latency > 0 && fData->latency < frames)
{ {
for (i=0; i < aIn.count; i++) for (i=0; i < aIn.count; i++)
memcpy(fData->latencyBuffers[i], inBuffer[i] + (frames - fData->latency), sizeof(float)*fData->latency); memcpy(fData->latencyBuffers[i], inBuffer[i] + (frames - fData->latency), sizeof(float)*fData->latency);
} }
#endif
} }
else else
{ {
// disable any output sound if not active // 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 } // End of Post-processing
#endif



CARLA_PROCESS_CONTINUE_CHECK; CARLA_PROCESS_CONTINUE_CHECK;


// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// Control Output // 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 } // End of Control Output
#endif


CARLA_PROCESS_CONTINUE_CHECK; 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; fData->activeBefore = fData->active;
} }
@@ -1115,10 +1060,11 @@ public:
{ {
qDebug("LadspaPlugin::deleteBuffers() - start"); qDebug("LadspaPlugin::deleteBuffers() - start");


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


CarlaPlugin::deleteBuffers(); CarlaPlugin::deleteBuffers();


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


const LADSPA_Descriptor_Function descFn = (LADSPA_Descriptor_Function)libSymbol("ladspa_descriptor"); 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"); fData->engine->setLastError("Could not find the LASDPA Descriptor in the plugin library");
return false; return false;
@@ -1153,13 +1099,15 @@ public:
// get descriptor that matches label // get descriptor that matches label


unsigned long i = 0; 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; break;
} }


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


fData->filename = strdup(filename);

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


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


fData->filename = filename;

// --------------------------------------------------------------- // ---------------------------------------------------------------
// register client // 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 (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!"); init.engine->setLastError("Carla's rack mode can only work with Mono or Stereo LADSPA plugins, sorry!");
delete plugin; 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.toBasic();
engName.truncate(engine->maxClientNameSize()); engName.truncate(engine->maxClientNameSize());


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


// Init plugin, FIXME
int id = engine->addPlugin(itype, filename, name, label, extraStuff);
// Init plugin
int ret; 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); client.setPlugin(plugin);


if (! useOsc) 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 static inline
bool is_ladspa_rdf_descriptor_valid(const LADSPA_RDF_Descriptor* const rdfDescriptor, const LADSPA_Descriptor* const descriptor) 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; return false;


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


Loading…
Cancel
Save