Browse Source

Carla: initial code for plugin latency support

tags/v0.9.0
falkTX 13 years ago
parent
commit
8292595c24
5 changed files with 131 additions and 2 deletions
  1. +1
    -2
      c++/carla-backend/carla_engine.cpp
  2. +44
    -0
      c++/carla-backend/dssi.cpp
  3. +44
    -0
      c++/carla-backend/ladspa.cpp
  4. +35
    -0
      c++/carla-backend/lv2.cpp
  5. +7
    -0
      c++/carla-backend/vst.cpp

+ 1
- 2
c++/carla-backend/carla_engine.cpp View File

@@ -22,8 +22,7 @@ CARLA_BACKEND_START_NAMESPACE

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

unsigned int CarlaPlugin::m_count = 0;

unsigned int CarlaPlugin::m_count = 0;
unsigned short CarlaEngine::m_maxPluginNumber = 0;

CarlaEngine::CarlaEngine()


+ 44
- 0
c++/carla-backend/dssi.cpp View File

@@ -696,6 +696,50 @@ public:
if (aIns <= 2 && aOuts <= 2 && (aIns == aOuts || aIns == 0 || aOuts == 0))
m_hints |= PLUGIN_CAN_FORCE_STEREO;

// check latency
{
bool hasLatency = false;
uint32_t latency = 0;

for (uint32_t i=0; i < param.count; i++)
{
if (param.data[i].type == PARAMETER_LATENCY)
{
// pre-run so plugin can update latency control-port
float tmpIn[2][aIns];
float tmpOut[2][aOuts];

for (j=0; j < aIn.count; j++)
{
tmpIn[j][0] = 0.0f;
tmpIn[j][1] = 0.0f;

if (j == 0 || ! h2)
ldescriptor->connect_port(handle, aIn.rindexes[j], tmpIn[j]);
}

for (j=0; j < aOut.count; j++)
{
tmpOut[j][0] = 0.0f;
tmpOut[j][1] = 0.0f;

if (j == 0 || ! h2)
ldescriptor->connect_port(handle, aOut.rindexes[j], tmpOut[j]);
}

ldescriptor->activate(handle);
ldescriptor->run(handle, 2);
ldescriptor->deactivate(handle);

latency = rint(paramBuffers[i]);
hasLatency = true;
break;
}
}

// TODO - adjust latency now
}

reloadPrograms(true);

x_client->activate();


+ 44
- 0
c++/carla-backend/ladspa.cpp View File

@@ -665,6 +665,50 @@ public:
if (aIns <= 2 && aOuts <= 2 && (aIns == aOuts || aIns == 0 || aOuts == 0))
m_hints |= PLUGIN_CAN_FORCE_STEREO;

// check latency
{
bool hasLatency = false;
uint32_t latency = 0;

for (uint32_t i=0; i < param.count; i++)
{
if (param.data[i].type == PARAMETER_LATENCY)
{
// pre-run so plugin can update latency control-port
float tmpIn[2][aIns];
float tmpOut[2][aOuts];

for (j=0; j < aIn.count; j++)
{
tmpIn[j][0] = 0.0f;
tmpIn[j][1] = 0.0f;

if (j == 0 || ! h2)
descriptor->connect_port(handle, aIn.rindexes[j], tmpIn[j]);
}

for (j=0; j < aOut.count; j++)
{
tmpOut[j][0] = 0.0f;
tmpOut[j][1] = 0.0f;

if (j == 0 || ! h2)
descriptor->connect_port(handle, aOut.rindexes[j], tmpOut[j]);
}

descriptor->activate(handle);
descriptor->run(handle, 2);
descriptor->deactivate(handle);

latency = rint(paramBuffers[i]);
hasLatency = true;
break;
}
}

// TODO - adjust latency now
}

x_client->activate();

qDebug("LadspaPlugin::reload() - end");


+ 35
- 0
c++/carla-backend/lv2.cpp View File

@@ -1737,6 +1737,41 @@ public:
m_hints |= PLUGIN_CAN_FORCE_STEREO;
}

// check latency
{
bool hasLatency = false;
uint32_t latency = 0;

for (uint32_t i=0; i < param.count; i++)
{
if (param.data[i].type == PARAMETER_LATENCY)
{
// pre-run so plugin can update latency control-port
for (j=0; j < aIn.count; j++)
{
if (j == 0 || ! h2)
descriptor->connect_port(handle, aIn.rindexes[j], nullptr);
}

for (j=0; j < aOut.count; j++)
{
if (j == 0 || ! h2)
descriptor->connect_port(handle, aOut.rindexes[j], nullptr);
}

descriptor->activate(handle);
descriptor->run(handle, 0);
descriptor->deactivate(handle);

latency = rint(paramBuffers[i]);
hasLatency = true;
break;
}
}

// TODO - adjust latency now
}

reloadPrograms(true);

x_client->activate();


+ 7
- 0
c++/carla-backend/vst.cpp View File

@@ -729,6 +729,13 @@ public:
if ((aIns == 0 || aIns == 2) && (aOuts == 0 || aOuts == 2))
m_hints |= PLUGIN_CAN_FORCE_STEREO;

// check latency
{
uint32_t latency = effect->initialDelay;

// TODO - adjust latency now
}

reloadPrograms(true);

x_client->activate();


Loading…
Cancel
Save