diff --git a/c++/carla-backend/carla_engine.cpp b/c++/carla-backend/carla_engine.cpp index c60e756..8dbdd46 100644 --- a/c++/carla-backend/carla_engine.cpp +++ b/c++/carla-backend/carla_engine.cpp @@ -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() diff --git a/c++/carla-backend/dssi.cpp b/c++/carla-backend/dssi.cpp index bf68a30..68898a3 100644 --- a/c++/carla-backend/dssi.cpp +++ b/c++/carla-backend/dssi.cpp @@ -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(); diff --git a/c++/carla-backend/ladspa.cpp b/c++/carla-backend/ladspa.cpp index 30a3538..2d4868d 100644 --- a/c++/carla-backend/ladspa.cpp +++ b/c++/carla-backend/ladspa.cpp @@ -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"); diff --git a/c++/carla-backend/lv2.cpp b/c++/carla-backend/lv2.cpp index 68ef65f..9388f8e 100644 --- a/c++/carla-backend/lv2.cpp +++ b/c++/carla-backend/lv2.cpp @@ -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(); diff --git a/c++/carla-backend/vst.cpp b/c++/carla-backend/vst.cpp index 2b71a1e..5d42f3f 100644 --- a/c++/carla-backend/vst.cpp +++ b/c++/carla-backend/vst.cpp @@ -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();