From da214bad8f3c7e57dd31e2b834ec5e10eedb3727 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 1 Nov 2012 01:15:52 +0000 Subject: [PATCH] Carla: More fixing on VST and bridges --- c++/carla-backend/carla_engine.cpp | 5 +++ c++/carla-backend/carla_engine.h | 1 + c++/carla-backend/carla_osc.cpp | 15 ++++++++ c++/carla-backend/carla_osc.h | 1 + c++/carla-backend/carla_threads.cpp | 4 +++ c++/carla-backend/vst.cpp | 22 +++++++++++- c++/carla-bridge/carla_bridge_plugin.cpp | 44 +++++++++++++----------- 7 files changed, 71 insertions(+), 21 deletions(-) diff --git a/c++/carla-backend/carla_engine.cpp b/c++/carla-backend/carla_engine.cpp index 70a2a61..6a62ee7 100644 --- a/c++/carla-backend/carla_engine.cpp +++ b/c++/carla-backend/carla_engine.cpp @@ -799,6 +799,11 @@ bool CarlaEngine::isOscControlRegisted() const } #ifndef BUILD_BRIDGE +void CarlaEngine::oscWaitEvents() +{ + m_osc.waitForEvents(); +} + const char* CarlaEngine::getOscServerPathTCP() const { return m_osc.getServerPathTCP(); diff --git a/c++/carla-backend/carla_engine.h b/c++/carla-backend/carla_engine.h index 4249848..99b8f37 100644 --- a/c++/carla-backend/carla_engine.h +++ b/c++/carla-backend/carla_engine.h @@ -269,6 +269,7 @@ public: bool isOscControlRegisted() const; #ifndef BUILD_BRIDGE + void oscWaitEvents(); const char* getOscServerPathTCP() const; const char* getOscServerPathUDP() const; #else diff --git a/c++/carla-backend/carla_osc.cpp b/c++/carla-backend/carla_osc.cpp index 9a5eccf..c4e1eb3 100644 --- a/c++/carla-backend/carla_osc.cpp +++ b/c++/carla-backend/carla_osc.cpp @@ -123,6 +123,21 @@ void CarlaOsc::close() m_nameSize = 0; } +void CarlaOsc::waitForEvents() +{ + if (m_serverThreadTCP) + { + while (lo_server_thread_events_pending(m_serverThreadTCP)) + carla_msleep(10); + } + + if (m_serverThreadUDP) + { + while (lo_server_thread_events_pending(m_serverThreadUDP)) + carla_msleep(10); + } +} + // ----------------------------------------------------------------------- int CarlaOsc::handleMessage(const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg) diff --git a/c++/carla-backend/carla_osc.h b/c++/carla-backend/carla_osc.h index 37d236f..0638a0a 100644 --- a/c++/carla-backend/carla_osc.h +++ b/c++/carla-backend/carla_osc.h @@ -57,6 +57,7 @@ public: void init(const char* const name); void close(); + void waitForEvents(); // ------------------------------------------------------------------- diff --git a/c++/carla-backend/carla_threads.cpp b/c++/carla-backend/carla_threads.cpp index b3c0e15..1bd562f 100644 --- a/c++/carla-backend/carla_threads.cpp +++ b/c++/carla-backend/carla_threads.cpp @@ -79,6 +79,10 @@ void CarlaCheckThread::run() const ScopedLocker m(this); oscControlRegisted = engine->isOscControlRegisted(); +#ifndef BUILD_BRIDGE + engine->oscWaitEvents(); +#endif + for (unsigned short i=0; i < maxPluginNumber; i++) { CarlaPlugin* const plugin = engine->getPluginUnchecked(i); diff --git a/c++/carla-backend/vst.cpp b/c++/carla-backend/vst.cpp index 828208f..f3de1b7 100644 --- a/c++/carla-backend/vst.cpp +++ b/c++/carla-backend/vst.cpp @@ -1056,6 +1056,8 @@ public: sendMidiAllNotesOff(); effect->dispatcher(effect, effStopProcess, 0, 0, nullptr, 0.0f); + effect->dispatcher(effect, effMainsChanged, 0, 0, nullptr, 0.0f); + effect->dispatcher(effect, effMainsChanged, 0, 1, nullptr, 0.0f); effect->dispatcher(effect, effStartProcess, 0, 0, nullptr, 0.0f); postponeEvent(PluginPostEventParameterChange, PARAMETER_ACTIVE, 0, 0.0); @@ -1237,6 +1239,7 @@ public: memset(m_latencyBuffers[i], 0, sizeof(float)*m_latency); } + effect->dispatcher(effect, effMainsChanged, 0, 1, nullptr, 0.0f); effect->dispatcher(effect, effStartProcess, 0, 0, nullptr, 0.0f); } @@ -1273,7 +1276,10 @@ public: else { if (m_activeBefore) + { effect->dispatcher(effect, effStopProcess, 0, 0, nullptr, 0.0f); + effect->dispatcher(effect, effMainsChanged, 0, 0, nullptr, 0.0f); + } } CARLA_PROCESS_CONTINUE_CHECK; @@ -1409,7 +1415,10 @@ public: void bufferSizeChanged(uint32_t newBufferSize) { if (m_active) + { effect->dispatcher(effect, effStopProcess, 0, 0, nullptr, 0.0f); + effect->dispatcher(effect, effMainsChanged, 0, 0, nullptr, 0.0f); + } #if ! VST_FORCE_DEPRECATED effect->dispatcher(effect, effSetBlockSizeAndSampleRate, 0, newBufferSize, nullptr, x_engine->getSampleRate()); @@ -1417,7 +1426,10 @@ public: effect->dispatcher(effect, effSetBlockSize, 0, newBufferSize, nullptr, 0.0f); if (m_active) + { + effect->dispatcher(effect, effMainsChanged, 0, 1, nullptr, 0.0f); effect->dispatcher(effect, effStartProcess, 0, 0, nullptr, 0.0f); + } } // ------------------------------------------------------------------- @@ -1603,12 +1615,18 @@ public: engineProcessUnlock(); if (m_active) + { effect->dispatcher(effect, effStopProcess, 0, 0, nullptr, 0.0f); + effect->dispatcher(effect, effMainsChanged, 0, 0, nullptr, 0.0f); + } reload(); if (m_active) + { + effect->dispatcher(effect, effMainsChanged, 0, 1, nullptr, 0.0f); effect->dispatcher(effect, effStartProcess, 0, 0, nullptr, 0.0f); + } x_engine->callback(CALLBACK_RELOAD_ALL, m_id, 0, 0, 0.0); @@ -2222,7 +2240,7 @@ public: #endif effect->dispatcher(effect, effOpen, 0, 0, nullptr, 0.0f); - effect->dispatcher(effect, effMainsChanged, 0, 1, nullptr, 0.0f); + effect->dispatcher(effect, effMainsChanged, 0, 0, nullptr, 0.0f); // --------------------------------------------------------------- // get info @@ -2267,8 +2285,10 @@ public: #if ! VST_FORCE_DEPRECATED // dummy pre-start to catch possible wantEvents() call on old plugins + effect->dispatcher(effect, effMainsChanged, 0, 1, nullptr, 0.0f); effect->dispatcher(effect, effStartProcess, 0, 0, nullptr, 0.0f); effect->dispatcher(effect, effStopProcess, 0, 0, nullptr, 0.0f); + effect->dispatcher(effect, effMainsChanged, 0, 0, nullptr, 0.0f); #endif // special checks diff --git a/c++/carla-bridge/carla_bridge_plugin.cpp b/c++/carla-bridge/carla_bridge_plugin.cpp index d412ebc..789d5e6 100644 --- a/c++/carla-bridge/carla_bridge_plugin.cpp +++ b/c++/carla-bridge/carla_bridge_plugin.cpp @@ -20,6 +20,7 @@ #include "carla_bridge_client.h" #include "carla_plugin.h" +#include #include #include #include @@ -225,9 +226,6 @@ public: msgTimerGUI = 0; msgTimerOSC = 0; - nextWidth = 0; - nextHeight = 0; - engine = nullptr; plugin = nullptr; pluginGui = nullptr; @@ -555,6 +553,9 @@ public: switch (action) { case CarlaBackend::CALLBACK_PARAMETER_VALUE_CHANGED: +#if 0 + parametersToUpdate.insert(value1); +#endif engine->osc_send_bridge_set_parameter_value(value1, value3); break; @@ -587,17 +588,11 @@ public: case CarlaBackend::CALLBACK_RESIZE_GUI: CARLA_ASSERT(value1 > 0 && value2 > 0); - if (value3 == 1.0) - { - nextWidth = 0; - nextHeight = 0; - pluginGui->setFixedSize(value1, value2); - } - else if (nextWidth != value1 && nextHeight != value2) - { - nextWidth = value1; - nextHeight = value2; - } + CARLA_ASSERT(pluginGui); + + if (value1 > 0 && value2 > 0 && pluginGui) + pluginGui->setNewSize(value1, value2); + break; case CarlaBackend::CALLBACK_RELOAD_PARAMETERS: @@ -617,7 +612,6 @@ public: default: break; } - Q_UNUSED(value3); } // --------------------------------------------------------------------- @@ -636,6 +630,8 @@ public: protected: void guiClosedCallback() { + if (engine) + engine->osc_send_bridge_configure(CarlaBackend::CARLA_BRIDGE_MSG_HIDE_GUI, ""); } void timerEvent(QTimerEvent* const event) @@ -645,12 +641,18 @@ protected: if (event->timerId() == msgTimerGUI) { - if (nextWidth > 0 && nextHeight > 0 && pluginGui) +#if 0 + if (parametersToUpdate.size() > 0) { - pluginGui->setNewSize(nextWidth, nextHeight); - nextWidth = 0; - nextHeight = 0; + for (auto it = parametersToUpdate.begin(); it != parametersToUpdate.end(); it++) + { + const int32_t paramId(*it); + engine->osc_send_bridge_set_parameter_value(paramId, plugin->getParameterValue(paramId)); + } + + parametersToUpdate.clear(); } +#endif if (plugin) plugin->idleGui(); @@ -673,7 +675,9 @@ protected: private: bool hasUI; int msgTimerGUI, msgTimerOSC; - int nextWidth, nextHeight; +#if 0 + std::set parametersToUpdate; +#endif CarlaBackend::CarlaEngine* engine; CarlaBackend::CarlaPlugin* plugin;