Browse Source

Update parameter values after plugin setChunk called

tags/1.9.4
falkTX 10 years ago
parent
commit
5139135eb7
7 changed files with 69 additions and 44 deletions
  1. +2
    -0
      source/backend/plugin/BridgePlugin.cpp
  2. +2
    -40
      source/backend/plugin/CarlaPlugin.cpp
  3. +36
    -0
      source/backend/plugin/CarlaPluginInternal.cpp
  4. +2
    -0
      source/backend/plugin/CarlaPluginInternal.hpp
  5. +13
    -4
      source/backend/plugin/DssiPlugin.cpp
  6. +7
    -0
      source/backend/plugin/ReWirePlugin.cpp
  7. +7
    -0
      source/backend/plugin/VstPlugin.cpp

+ 2
- 0
source/backend/plugin/BridgePlugin.cpp View File

@@ -610,6 +610,8 @@ public:
file.close();
osc_send_configure(&osc.data, CARLA_BRIDGE_MSG_SET_CHUNK, filePath.toUtf8().constData());
}

pData->updateParameterValues(this, pData->engine->isOscControlRegistered(), true, false);
}
#endif



+ 2
- 40
source/backend/plugin/CarlaPlugin.cpp View File

@@ -1320,26 +1320,7 @@ void CarlaPlugin::setProgram(const int32_t index, const bool sendGui, const bool
if (getType() == PLUGIN_FILE_CSD || getType() == PLUGIN_FILE_GIG || getType() == PLUGIN_FILE_SF2 || getType() == PLUGIN_FILE_SFZ)
return;

for (uint32_t i=0; i < pData->param.count; ++i)
{
const float value(pData->param.ranges[i].getFixedValue(getParameterValue(i)));

pData->param.ranges[i].def = value;

#ifndef BUILD_BRIDGE
if (reallySendOsc)
{
pData->engine->oscSend_control_set_parameter_value(pData->id, static_cast<int32_t>(i), value);
pData->engine->oscSend_control_set_default_value(pData->id, i, value);
}
#endif

if (sendCallback)
{
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, static_cast<int>(i), 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED, pData->id, static_cast<int>(i), 0, value, nullptr);
}
}
pData->updateParameterValues(this, sendOsc, sendCallback, true);
}

#ifdef BUILD_BRIDGE
@@ -1382,26 +1363,7 @@ void CarlaPlugin::setMidiProgram(const int32_t index, const bool sendGui, const
if (getType() == PLUGIN_FILE_CSD || getType() == PLUGIN_FILE_GIG || getType() == PLUGIN_FILE_SF2 || getType() == PLUGIN_FILE_SFZ)
return;

for (uint32_t i=0; i < pData->param.count; ++i)
{
const float value(pData->param.ranges[i].getFixedValue(getParameterValue(i)));

pData->param.ranges[i].def = value;

#ifndef BUILD_BRIDGE
if (reallySendOsc)
{
pData->engine->oscSend_control_set_parameter_value(pData->id, static_cast<int32_t>(i), value);
pData->engine->oscSend_control_set_default_value(pData->id, i, value);
}
#endif

if (sendCallback)
{
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, static_cast<int>(i), 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED, pData->id, static_cast<int>(i), 0, value, nullptr);
}
}
pData->updateParameterValues(this, sendOsc, sendCallback, true);
}

#ifdef BUILD_BRIDGE


+ 36
- 0
source/backend/plugin/CarlaPluginInternal.cpp View File

@@ -812,6 +812,42 @@ void CarlaPlugin::ProtectedData::tryTransient() noexcept
}
#endif

void CarlaPlugin::ProtectedData::updateParameterValues(CarlaPlugin* const plugin, const bool sendOsc, const bool sendCallback, const bool useDefault) noexcept
{
CARLA_SAFE_ASSERT_RETURN(sendOsc || sendCallback,);

for (uint32_t i=0; i < param.count; ++i)
{
const float value(param.ranges[i].getFixedValue(plugin->getParameterValue(i)));

if (useDefault)
param.ranges[i].def = value;

#ifndef BUILD_BRIDGE
if (sendOsc)
{
if (useDefault)
engine->oscSend_control_set_default_value(id, i, value);

engine->oscSend_control_set_parameter_value(id, static_cast<int32_t>(i), value);
}
#endif

if (sendCallback)
{
if (useDefault)
engine->callback(ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED, id, static_cast<int>(i), 0, value, nullptr);

engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, id, static_cast<int>(i), 0, value, nullptr);
}
}

#ifdef BUILD_BRIDGE
// unused
return; (void)sendOsc;
#endif
}

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

CARLA_BACKEND_END_NAMESPACE

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

@@ -361,6 +361,8 @@ struct CarlaPlugin::ProtectedData {
void tryTransient() noexcept;
#endif

void updateParameterValues(CarlaPlugin* const plugin, const bool sendOsc, const bool sendCallback, const bool useDefault) noexcept;

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

#ifdef CARLA_PROPER_CPP11_SUPPORT


+ 13
- 4
source/backend/plugin/DssiPlugin.cpp View File

@@ -361,11 +361,20 @@ public:

CARLA_SAFE_ASSERT_RETURN(chunk.size() > 0,);

const ScopedSingleProcessLocker spl(this, true);
{
const ScopedSingleProcessLocker spl(this, true);

try {
fDssiDescriptor->set_custom_data(fHandle, chunk.data(), static_cast<ulong>(chunk.size()));
} catch(...) {}
try {
fDssiDescriptor->set_custom_data(fHandle, chunk.data(), static_cast<ulong>(chunk.size()));
} catch(...) {}
}

#ifdef BUILD_BRIDGE
const bool sendOsc(false);
#else
const bool sendOsc(pData->engine->isOscControlRegistered());
#endif
pData->updateParameterValues(this, sendOsc, true, false);
}

void setMidiProgram(const int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) noexcept override


+ 7
- 0
source/backend/plugin/ReWirePlugin.cpp View File

@@ -455,6 +455,13 @@ public:
CARLA_SAFE_ASSERT_RETURN(stringData != nullptr,);

// TODO

#ifdef BUILD_BRIDGE
const bool sendOsc(false);
#else
const bool sendOsc(pData->engine->isOscControlRegistered());
#endif
pData->updateParameterValues(this, sendOsc, true, false);
}

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


+ 7
- 0
source/backend/plugin/VstPlugin.cpp View File

@@ -356,6 +356,13 @@ public:
dispatcher(effSetChunk, 0 /* bank */, chunk.size(), fLastChunk, 0.0f);
}

#ifdef BUILD_BRIDGE
const bool sendOsc(false);
#else
const bool sendOsc(pData->engine->isOscControlRegistered());
#endif
pData->updateParameterValues(this, sendOsc, true, false);

// simulate an updateDisplay callback
handleAudioMasterCallback(audioMasterUpdateDisplay, 0, 0, nullptr, 0.0f);
}


Loading…
Cancel
Save