Browse Source

Fixup carla-patchbay and implement dynamic parameters

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-rc1
falkTX 5 years ago
parent
commit
7a9ddac0dd
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 286 additions and 271 deletions
  1. +181
    -181
      source/backend/engine/CarlaEngineNative.cpp
  2. +104
    -89
      source/backend/plugin/CarlaPluginNative.cpp
  3. +1
    -1
      source/utils/CarlaScopeUtils.hpp

+ 181
- 181
source/backend/engine/CarlaEngineNative.cpp View File

@@ -323,10 +323,27 @@ public:
{
CarlaEngine::callback(sendHost, sendOsc, action, pluginId, value1, value2, value3, valuef, valueStr);

if (action == ENGINE_CALLBACK_IDLE && ! pData->aboutToClose) {
pHost->dispatcher(pHost->handle,
NATIVE_HOST_OPCODE_HOST_IDLE,
0, 0, nullptr, 0.0f);
switch (action)
{
case ENGINE_CALLBACK_IDLE:
if (! pData->aboutToClose)
pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_HOST_IDLE, 0, 0, nullptr, 0.0f);
break;

case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
if (sendHost && value1 >= 0)
{
uint32_t rindex = static_cast<uint32_t>(value1);
if (_getRealIndexForPluginParameter(pluginId, rindex))
{
fParameters[rindex] = valuef;
pHost->ui_parameter_changed(pHost->handle, rindex, valuef);
}
}
break;

default:
break;
}
}

@@ -341,29 +358,31 @@ public:

void setParameterValueFromUI(const uint32_t pluginId, const uint32_t index, const float value)
{
if (pluginId != 0)
return;

fParameters[index] = value;
pHost->ui_parameter_changed(pHost->handle, index, value);
uint32_t rindex = index;
if (_getRealIndexForPluginParameter(pluginId, rindex))
{
fParameters[rindex] = value;
pHost->ui_parameter_changed(pHost->handle, rindex, value);
}
}

void setParameterTouchFromUI(const uint32_t pluginId, const uint32_t index, const bool touch)
void setParameterTouchFromUI(const uint32_t pluginId, uint32_t index, const bool touch)
{
if (pluginId != 0)
return;

pHost->dispatcher(pHost->handle,
NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER,
static_cast<int32_t>(index),
touch ? 1 : 0,
nullptr, 0.0f);
uint32_t rindex = index;
if (_getRealIndexForPluginParameter(pluginId, rindex))
{
pHost->dispatcher(pHost->handle,
NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER,
static_cast<int32_t>(rindex),
touch ? 1 : 0,
nullptr, 0.0f);
}
}

void reloadFromUI()
{
carla_zeroFloats(fParameters, kNumInParams+kNumOutParams);
pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_RELOAD_ALL, 0, 0, nullptr, 0.0f);
pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_RELOAD_PARAMETERS, 0, 0, nullptr, 0.0f);
}

protected:
@@ -515,7 +534,7 @@ protected:

for (int32_t i=PARAMETER_ACTIVE; i>PARAMETER_MAX; --i)
{
std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%i:%i\n", pluginId, i);
std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%u:%i\n", pluginId, i);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);

std::snprintf(tmpBuf, STR_MAX, "%f\n", static_cast<double>(plugin->getInternalParameterValue(i)));
@@ -579,7 +598,7 @@ protected:
static_cast<double>(paramRanges.stepLarge));
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);

std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%i:%i\n", pluginId, i);
std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%u:%u\n", pluginId, i);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);

std::snprintf(tmpBuf, STR_MAX, "%f\n", static_cast<double>(plugin->getParameterValue(i)));
@@ -923,55 +942,53 @@ protected:
carla_zeroChars(strBufName, STR_MAX+1);
carla_zeroChars(strBufUnit, STR_MAX+1);

if (CarlaPlugin* const plugin = _getFirstPlugin())
uint32_t rindex = index;
if (CarlaPlugin* const plugin = _getPluginForParameterIndex(rindex))
{
if (index < plugin->getParameterCount())
const ParameterData& paramData(plugin->getParameterData(rindex));
const ParameterRanges& paramRanges(plugin->getParameterRanges(rindex));

if (! plugin->getParameterName(rindex, strBufName))
strBufName[0] = '\0';
if (! plugin->getParameterUnit(rindex, strBufUnit))
strBufUnit[0] = '\0';

uint hints = 0x0;

if (paramData.hints & PARAMETER_IS_BOOLEAN)
hints |= NATIVE_PARAMETER_IS_BOOLEAN;
if (paramData.hints & PARAMETER_IS_INTEGER)
hints |= NATIVE_PARAMETER_IS_INTEGER;
if (paramData.hints & PARAMETER_IS_LOGARITHMIC)
hints |= NATIVE_PARAMETER_IS_LOGARITHMIC;
if (paramData.hints & PARAMETER_IS_AUTOMABLE)
hints |= NATIVE_PARAMETER_IS_AUTOMABLE;
if (paramData.hints & PARAMETER_USES_SAMPLERATE)
hints |= NATIVE_PARAMETER_USES_SAMPLE_RATE;
if (paramData.hints & PARAMETER_USES_SCALEPOINTS)
hints |= NATIVE_PARAMETER_USES_SCALEPOINTS;

if (paramData.type == PARAMETER_INPUT || paramData.type == PARAMETER_OUTPUT)
{
const ParameterData& paramData(plugin->getParameterData(index));
const ParameterRanges& paramRanges(plugin->getParameterRanges(index));

if (! plugin->getParameterName(index, strBufName))
strBufName[0] = '\0';
if (! plugin->getParameterUnit(index, strBufUnit))
strBufUnit[0] = '\0';

uint hints = 0x0;

if (paramData.hints & PARAMETER_IS_BOOLEAN)
hints |= NATIVE_PARAMETER_IS_BOOLEAN;
if (paramData.hints & PARAMETER_IS_INTEGER)
hints |= NATIVE_PARAMETER_IS_INTEGER;
if (paramData.hints & PARAMETER_IS_LOGARITHMIC)
hints |= NATIVE_PARAMETER_IS_LOGARITHMIC;
if (paramData.hints & PARAMETER_IS_AUTOMABLE)
hints |= NATIVE_PARAMETER_IS_AUTOMABLE;
if (paramData.hints & PARAMETER_USES_SAMPLERATE)
hints |= NATIVE_PARAMETER_USES_SAMPLE_RATE;
if (paramData.hints & PARAMETER_USES_SCALEPOINTS)
hints |= NATIVE_PARAMETER_USES_SCALEPOINTS;

if (paramData.type == PARAMETER_INPUT || paramData.type == PARAMETER_OUTPUT)
{
if (paramData.hints & PARAMETER_IS_ENABLED)
hints |= NATIVE_PARAMETER_IS_ENABLED;
if (paramData.type == PARAMETER_OUTPUT)
hints |= NATIVE_PARAMETER_IS_OUTPUT;
}

param.hints = static_cast<NativeParameterHints>(hints);
param.name = strBufName;
param.unit = strBufUnit;
param.ranges.def = paramRanges.def;
param.ranges.min = paramRanges.min;
param.ranges.max = paramRanges.max;
param.ranges.step = paramRanges.step;
param.ranges.stepSmall = paramRanges.stepSmall;
param.ranges.stepLarge = paramRanges.stepLarge;
param.scalePointCount = 0; // TODO
param.scalePoints = nullptr;

return &param;
if (paramData.hints & PARAMETER_IS_ENABLED)
hints |= NATIVE_PARAMETER_IS_ENABLED;
if (paramData.type == PARAMETER_OUTPUT)
hints |= NATIVE_PARAMETER_IS_OUTPUT;
}

param.hints = static_cast<NativeParameterHints>(hints);
param.name = strBufName;
param.unit = strBufUnit;
param.ranges.def = paramRanges.def;
param.ranges.min = paramRanges.min;
param.ranges.max = paramRanges.max;
param.ranges.step = paramRanges.step;
param.ranges.stepSmall = paramRanges.stepSmall;
param.ranges.stepLarge = paramRanges.stepLarge;
param.scalePointCount = 0; // TODO
param.scalePoints = nullptr;

return &param;
}

param.hints = index < kNumInParams ? static_cast<NativeParameterHints>(0x0) : NATIVE_PARAMETER_IS_OUTPUT;
@@ -991,72 +1008,25 @@ protected:

float getParameterValue(const uint32_t index) const
{
if (CarlaPlugin* const plugin = _getFirstPlugin())
{
if (index < plugin->getParameterCount())
return plugin->getParameterValue(index);
}
uint32_t rindex = index;
if (CarlaPlugin* const plugin = _getPluginForParameterIndex(rindex))
return plugin->getParameterValue(rindex);

return fParameters[index];
}

// -------------------------------------------------------------------
// Plugin midi-program calls

uint32_t getMidiProgramCount() const
{
if (CarlaPlugin* const plugin = _getFirstPlugin())
return plugin->getMidiProgramCount();

return 0;
}

const NativeMidiProgram* getMidiProgramInfo(const uint32_t index) const
{
if (CarlaPlugin* const plugin = _getFirstPlugin())
{
if (index < plugin->getMidiProgramCount())
{
static NativeMidiProgram midiProg;

{
const MidiProgramData& midiProgData(plugin->getMidiProgramData(index));

midiProg.bank = midiProgData.bank;
midiProg.program = midiProgData.program;
midiProg.name = midiProgData.name;
}

return &midiProg;
}
}

return nullptr;
}

// -------------------------------------------------------------------
// Plugin state calls

void setParameterValue(const uint32_t index, const float value)
{
if (CarlaPlugin* const plugin = _getFirstPlugin())
{
if (index < plugin->getParameterCount())
{
const float rvalue = plugin->getParameterRanges(index).getUnnormalizedValue(value);
plugin->setParameterValueRT(index, rvalue, false);
}
}
uint32_t rindex = index;
if (CarlaPlugin* const plugin = _getPluginForParameterIndex(rindex))
plugin->setParameterValue(rindex, value, false, false, false);

fParameters[index] = value;
}

void setMidiProgram(const uint8_t, const uint32_t bank, const uint32_t program)
{
if (CarlaPlugin* const plugin = _getFirstPlugin())
plugin->setMidiProgramById(bank, program, false, false, false);
}

// -------------------------------------------------------------------
// Plugin process calls

@@ -1364,10 +1334,20 @@ protected:

void uiSetParameterValue(const uint32_t index, const float value)
{
if (CarlaPlugin* const plugin = _getFirstPlugin())
uint32_t rindex = index;
if (CarlaPlugin* const plugin = _getPluginForParameterIndex(rindex))
{
if (index < plugin->getParameterCount())
plugin->uiParameterChange(index, value);
plugin->uiParameterChange(rindex, value);

if (index >= kNumInParams || ! fUiServer.isPipeRunning())
return;

uiServerCallback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED,
plugin->getId(),
static_cast<int>(rindex),
0, 0,
value,
nullptr);
}
}

@@ -1443,7 +1423,7 @@ protected:
if (! plugin->isParameterOutput(j))
continue;

std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%i:%i\n", i, j);
std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%u:%u\n", i, j);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
std::snprintf(tmpBuf, STR_MAX, "%f\n", static_cast<double>(plugin->getParameterValue(j)));
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
@@ -1482,6 +1462,8 @@ protected:
const String state(data);
XmlDocument xml(state);
loadProjectInternal(xml);

reloadFromUI();
}

// -------------------------------------------------------------------
@@ -1549,26 +1531,11 @@ public:
return handlePtr->getParameterValue(index);
}

static uint32_t _get_midi_program_count(NativePluginHandle handle)
{
return handlePtr->getMidiProgramCount();
}

static const NativeMidiProgram* _get_midi_program_info(NativePluginHandle handle, uint32_t index)
{
return handlePtr->getMidiProgramInfo(index);
}

static void _set_parameter_value(NativePluginHandle handle, uint32_t index, float value)
{
handlePtr->setParameterValue(index, value);
}

static void _set_midi_program(NativePluginHandle handle, uint8_t channel, uint32_t bank, uint32_t program)
{
handlePtr->setMidiProgram(channel, bank, program);
}

static void _ui_show(NativePluginHandle handle, bool show)
{
handlePtr->uiShow(show);
@@ -1684,17 +1651,53 @@ private:

bool fOptionsForced;

CarlaPlugin* _getFirstPlugin() const noexcept
CarlaPlugin* _getPluginForParameterIndex(uint32_t& index) const noexcept
{
if (pData->curPluginCount == 0 || pData->plugins == nullptr)
return nullptr;

CarlaPlugin* const plugin(pData->plugins[0].plugin);
CarlaPlugin* plugin;

if (plugin == nullptr || ! plugin->isEnabled())
return nullptr;
for (uint32_t i=0; i<pData->curPluginCount; ++i)
{
plugin = pData->plugins[i].plugin;

if (plugin == nullptr || ! plugin->isEnabled())
break;

if (const uint32_t paramCount = plugin->getParameterCount())
{
if (index >= paramCount)
{
index -= paramCount;
continue;
}

return plugin;
}
}

return pData->plugins[0].plugin;
return nullptr;
}

bool _getRealIndexForPluginParameter(const uint32_t pluginId, uint32_t& rindex) const noexcept
{
if (pData->curPluginCount == 0 || pluginId >= pData->curPluginCount || pData->plugins == nullptr)
return false;

CarlaPlugin* plugin;

for (uint32_t i=0; i<pluginId; ++i)
{
plugin = pData->plugins[i].plugin;

if (plugin == nullptr || ! plugin->isEnabled())
return false;

rindex += plugin->getParameterCount();
}

return true;
}

CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineNative)
@@ -1881,9 +1884,7 @@ bool CarlaEngineNativeUI::msgReceived(const char*const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);

ok = fEngine->removePlugin(pluginId);

if (pluginId == 0)
fEngine->reloadFromUI();
fEngine->reloadFromUI();
}
else if (std::strcmp(msg, "remove_all_plugins") == 0)
{
@@ -1926,9 +1927,7 @@ bool CarlaEngineNativeUI::msgReceived(const char*const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginIdB), true);

ok = fEngine->switchPlugins(pluginIdA, pluginIdB);

if (pluginIdA == 0 || pluginIdB == 0)
fEngine->reloadFromUI();
fEngine->reloadFromUI();
}
else if (std::strcmp(msg, "load_plugin_state") == 0)
{
@@ -2264,6 +2263,7 @@ void CarlaEngineNativeUI::_updateParamValues(CarlaPlugin* const plugin, const ui
}

if (sendPluginHost) {
carla_stdout("_updateParamValues");
fEngine->setParameterValueFromUI(pluginId, i, value);
}
}
@@ -2294,10 +2294,10 @@ static const NativePluginDescriptor carlaRackDesc = {
CarlaEngineNative::_get_parameter_count,
CarlaEngineNative::_get_parameter_info,
CarlaEngineNative::_get_parameter_value,
CarlaEngineNative::_get_midi_program_count,
CarlaEngineNative::_get_midi_program_info,
/* _get_midi_program_count */ nullptr,
/* _get_midi_program_info */ nullptr,
CarlaEngineNative::_set_parameter_value,
CarlaEngineNative::_set_midi_program,
/* _set_midi_program */ nullptr,
/* _set_custom_data */ nullptr,
CarlaEngineNative::_ui_show,
CarlaEngineNative::_ui_idle,
@@ -2339,14 +2339,14 @@ static const NativePluginDescriptor carlaRackNoMidiOutDesc = {
CarlaEngineNative::_get_parameter_count,
CarlaEngineNative::_get_parameter_info,
CarlaEngineNative::_get_parameter_value,
CarlaEngineNative::_get_midi_program_count,
CarlaEngineNative::_get_midi_program_info,
/* _get_midi_program_count */ nullptr,
/* _get_midi_program_info */ nullptr,
CarlaEngineNative::_set_parameter_value,
CarlaEngineNative::_set_midi_program,
/* _set_midi_program */ nullptr,
/* _set_custom_data */ nullptr,
CarlaEngineNative::_ui_show,
CarlaEngineNative::_ui_idle,
/* _ui_set_parameter_value */ nullptr,
CarlaEngineNative::_ui_set_parameter_value,
/* _ui_set_midi_program */ nullptr,
/* _ui_set_custom_data */ nullptr,
CarlaEngineNative::_activate,
@@ -2384,14 +2384,14 @@ static const NativePluginDescriptor carlaPatchbayDesc = {
CarlaEngineNative::_get_parameter_count,
CarlaEngineNative::_get_parameter_info,
CarlaEngineNative::_get_parameter_value,
CarlaEngineNative::_get_midi_program_count,
CarlaEngineNative::_get_midi_program_info,
/* _get_midi_program_count */ nullptr,
/* _get_midi_program_info */ nullptr,
CarlaEngineNative::_set_parameter_value,
CarlaEngineNative::_set_midi_program,
/* _set_midi_program */ nullptr,
/* _set_custom_data */ nullptr,
CarlaEngineNative::_ui_show,
CarlaEngineNative::_ui_idle,
/* _ui_set_parameter_value */ nullptr,
CarlaEngineNative::_ui_set_parameter_value,
/* _ui_set_midi_program */ nullptr,
/* _ui_set_custom_data */ nullptr,
CarlaEngineNative::_activate,
@@ -2429,14 +2429,14 @@ static const NativePluginDescriptor carlaPatchbay3sDesc = {
CarlaEngineNative::_get_parameter_count,
CarlaEngineNative::_get_parameter_info,
CarlaEngineNative::_get_parameter_value,
CarlaEngineNative::_get_midi_program_count,
CarlaEngineNative::_get_midi_program_info,
/* _get_midi_program_count */ nullptr,
/* _get_midi_program_info */ nullptr,
CarlaEngineNative::_set_parameter_value,
CarlaEngineNative::_set_midi_program,
/* _set_midi_program */ nullptr,
/* _set_custom_data */ nullptr,
CarlaEngineNative::_ui_show,
CarlaEngineNative::_ui_idle,
/* _ui_set_parameter_value */ nullptr,
CarlaEngineNative::_ui_set_parameter_value,
/* _ui_set_midi_program */ nullptr,
/* _ui_set_custom_data */ nullptr,
CarlaEngineNative::_activate,
@@ -2474,14 +2474,14 @@ static const NativePluginDescriptor carlaPatchbay16Desc = {
CarlaEngineNative::_get_parameter_count,
CarlaEngineNative::_get_parameter_info,
CarlaEngineNative::_get_parameter_value,
CarlaEngineNative::_get_midi_program_count,
CarlaEngineNative::_get_midi_program_info,
/* _get_midi_program_count */ nullptr,
/* _get_midi_program_info */ nullptr,
CarlaEngineNative::_set_parameter_value,
CarlaEngineNative::_set_midi_program,
/* _set_midi_program */ nullptr,
/* _set_custom_data */ nullptr,
CarlaEngineNative::_ui_show,
CarlaEngineNative::_ui_idle,
/* _ui_set_parameter_value */ nullptr,
CarlaEngineNative::_ui_set_parameter_value,
/* _ui_set_midi_program */ nullptr,
/* _ui_set_custom_data */ nullptr,
CarlaEngineNative::_activate,
@@ -2519,14 +2519,14 @@ static const NativePluginDescriptor carlaPatchbay32Desc = {
CarlaEngineNative::_get_parameter_count,
CarlaEngineNative::_get_parameter_info,
CarlaEngineNative::_get_parameter_value,
CarlaEngineNative::_get_midi_program_count,
CarlaEngineNative::_get_midi_program_info,
/* _get_midi_program_count */ nullptr,
/* _get_midi_program_info */ nullptr,
CarlaEngineNative::_set_parameter_value,
CarlaEngineNative::_set_midi_program,
/* _set_midi_program */ nullptr,
/* _set_custom_data */ nullptr,
CarlaEngineNative::_ui_show,
CarlaEngineNative::_ui_idle,
/* _ui_set_parameter_value */ nullptr,
CarlaEngineNative::_ui_set_parameter_value,
/* _ui_set_midi_program */ nullptr,
/* _ui_set_custom_data */ nullptr,
CarlaEngineNative::_activate,
@@ -2564,14 +2564,14 @@ static const NativePluginDescriptor carlaPatchbay64Desc = {
CarlaEngineNative::_get_parameter_count,
CarlaEngineNative::_get_parameter_info,
CarlaEngineNative::_get_parameter_value,
CarlaEngineNative::_get_midi_program_count,
CarlaEngineNative::_get_midi_program_info,
/* _get_midi_program_count */ nullptr,
/* _get_midi_program_info */ nullptr,
CarlaEngineNative::_set_parameter_value,
CarlaEngineNative::_set_midi_program,
/* _set_midi_program */ nullptr,
/* _set_custom_data */ nullptr,
CarlaEngineNative::_ui_show,
CarlaEngineNative::_ui_idle,
/* _ui_set_parameter_value */ nullptr,
CarlaEngineNative::_ui_set_parameter_value,
/* _ui_set_midi_program */ nullptr,
/* _ui_set_custom_data */ nullptr,
CarlaEngineNative::_activate,
@@ -2610,14 +2610,14 @@ static const NativePluginDescriptor carlaPatchbayCVDesc = {
CarlaEngineNative::_get_parameter_count,
CarlaEngineNative::_get_parameter_info,
CarlaEngineNative::_get_parameter_value,
CarlaEngineNative::_get_midi_program_count,
CarlaEngineNative::_get_midi_program_info,
/* _get_midi_program_count */ nullptr,
/* _get_midi_program_info */ nullptr,
CarlaEngineNative::_set_parameter_value,
CarlaEngineNative::_set_midi_program,
/* _set_midi_program */ nullptr,
/* _set_custom_data */ nullptr,
CarlaEngineNative::_ui_show,
CarlaEngineNative::_ui_idle,
/* _ui_set_parameter_value */ nullptr,
CarlaEngineNative::_ui_set_parameter_value,
/* _ui_set_midi_program */ nullptr,
/* _ui_set_custom_data */ nullptr,
CarlaEngineNative::_activate,


+ 104
- 89
source/backend/plugin/CarlaPluginNative.cpp View File

@@ -983,9 +983,7 @@ public:

clearBuffers();

const float sampleRate((float)pData->engine->getSampleRate());

uint32_t aIns, aOuts, cvIns, cvOuts, mIns, mOuts, params, j;
uint32_t aIns, aOuts, cvIns, cvOuts, mIns, mOuts, j;

bool forcedStereoIn, forcedStereoOut;
forcedStereoIn = forcedStereoOut = false;
@@ -999,7 +997,6 @@ public:
cvOuts = fDescriptor->cvOuts;
mIns = fDescriptor->midiIns;
mOuts = fDescriptor->midiOuts;
params = (fDescriptor->get_parameter_count != nullptr && fDescriptor->get_parameter_info != nullptr) ? fDescriptor->get_parameter_count(fHandle) : 0;

if ((pData->options & PLUGIN_OPTION_FORCE_STEREO) != 0 && (aIns == 1 || aOuts == 1) && mIns <= 1 && mOuts <= 1)
{
@@ -1067,11 +1064,6 @@ public:
needsCtrlOut = (mOuts == 1);
}

if (params > 0)
{
pData->param.createNew(params, true);
}

const uint portNameSize(pData->engine->getMaxPortNameSize());
CarlaString portName;

@@ -1255,7 +1247,102 @@ public:
pData->event.portOut = fMidiOut.ports[0];
}

for (j=0; j < params; ++j)
reloadParameters(&needsCtrlIn, &needsCtrlOut);

if (needsCtrlIn || mIns == 1)
{
portName.clear();

if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{
portName = pData->name;
portName += ":";
}

portName += "events-in";
portName.truncate(portNameSize);

pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true, 0);
}

if (needsCtrlOut || mOuts == 1)
{
portName.clear();

if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{
portName = pData->name;
portName += ":";
}

portName += "events-out";
portName.truncate(portNameSize);

pData->event.portOut = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, false, 0);
}

if (forcedStereoIn || forcedStereoOut)
pData->options |= PLUGIN_OPTION_FORCE_STEREO;
else
pData->options &= ~PLUGIN_OPTION_FORCE_STEREO;

// plugin hints
pData->hints = 0x0;

if (aOuts > 0 && (aIns == aOuts || aIns == 1))
pData->hints |= PLUGIN_CAN_DRYWET;

if (aOuts > 0)
pData->hints |= PLUGIN_CAN_VOLUME;

if (aOuts >= 2 && aOuts % 2 == 0)
pData->hints |= PLUGIN_CAN_BALANCE;

// native plugin hints
if (fDescriptor->hints & NATIVE_PLUGIN_IS_RTSAFE)
pData->hints |= PLUGIN_IS_RTSAFE;
if (fDescriptor->hints & NATIVE_PLUGIN_IS_SYNTH)
pData->hints |= PLUGIN_IS_SYNTH;
if (fDescriptor->hints & NATIVE_PLUGIN_HAS_UI)
pData->hints |= PLUGIN_HAS_CUSTOM_UI;
if (fDescriptor->hints & NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS)
pData->hints |= PLUGIN_NEEDS_FIXED_BUFFERS;
if (fDescriptor->hints & NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD)
pData->hints |= PLUGIN_NEEDS_UI_MAIN_THREAD;
if (fDescriptor->hints & NATIVE_PLUGIN_USES_MULTI_PROGS)
pData->hints |= PLUGIN_USES_MULTI_PROGS;
if (fDescriptor->hints & NATIVE_PLUGIN_HAS_INLINE_DISPLAY)
pData->hints |= PLUGIN_HAS_INLINE_DISPLAY;

// extra plugin hints
pData->extraHints = 0x0;

bufferSizeChanged(pData->engine->getBufferSize());
reloadPrograms(true);

if (pData->active)
activate();

carla_debug("CarlaPluginNative::reload() - end");
}

void reloadParameters(bool* const needsCtrlIn, bool* const needsCtrlOut)
{
carla_debug("CarlaPluginNative::reloadParameters() - start");

const float sampleRate = static_cast<float>(pData->engine->getSampleRate());
const uint32_t params = (fDescriptor->get_parameter_count != nullptr && fDescriptor->get_parameter_info != nullptr)
? fDescriptor->get_parameter_count(fHandle)
: 0;

pData->param.clear();

if (params > 0)
{
pData->param.createNew(params, true);
}

for (uint32_t j=0; j < params; ++j)
{
const NativeParameter* const paramInfo(fDescriptor->get_parameter_info(fHandle, j));

@@ -1323,12 +1410,14 @@ public:
if (paramInfo->hints & NATIVE_PARAMETER_IS_OUTPUT)
{
pData->param.data[j].type = PARAMETER_OUTPUT;
needsCtrlOut = true;
if (needsCtrlOut != nullptr)
*needsCtrlOut = true;
}
else
{
pData->param.data[j].type = PARAMETER_INPUT;
needsCtrlIn = true;
if (needsCtrlIn != nullptr)
*needsCtrlIn = true;
}

// extra parameter hints
@@ -1352,81 +1441,7 @@ public:
pData->param.ranges[j].stepLarge = stepLarge;
}

if (needsCtrlIn || mIns == 1)
{
portName.clear();

if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{
portName = pData->name;
portName += ":";
}

portName += "events-in";
portName.truncate(portNameSize);

pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true, 0);
}

if (needsCtrlOut || mOuts == 1)
{
portName.clear();

if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{
portName = pData->name;
portName += ":";
}

portName += "events-out";
portName.truncate(portNameSize);

pData->event.portOut = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, false, 0);
}

if (forcedStereoIn || forcedStereoOut)
pData->options |= PLUGIN_OPTION_FORCE_STEREO;
else
pData->options &= ~PLUGIN_OPTION_FORCE_STEREO;

// plugin hints
pData->hints = 0x0;

if (aOuts > 0 && (aIns == aOuts || aIns == 1))
pData->hints |= PLUGIN_CAN_DRYWET;

if (aOuts > 0)
pData->hints |= PLUGIN_CAN_VOLUME;

if (aOuts >= 2 && aOuts % 2 == 0)
pData->hints |= PLUGIN_CAN_BALANCE;

// native plugin hints
if (fDescriptor->hints & NATIVE_PLUGIN_IS_RTSAFE)
pData->hints |= PLUGIN_IS_RTSAFE;
if (fDescriptor->hints & NATIVE_PLUGIN_IS_SYNTH)
pData->hints |= PLUGIN_IS_SYNTH;
if (fDescriptor->hints & NATIVE_PLUGIN_HAS_UI)
pData->hints |= PLUGIN_HAS_CUSTOM_UI;
if (fDescriptor->hints & NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS)
pData->hints |= PLUGIN_NEEDS_FIXED_BUFFERS;
if (fDescriptor->hints & NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD)
pData->hints |= PLUGIN_NEEDS_UI_MAIN_THREAD;
if (fDescriptor->hints & NATIVE_PLUGIN_USES_MULTI_PROGS)
pData->hints |= PLUGIN_USES_MULTI_PROGS;
if (fDescriptor->hints & NATIVE_PLUGIN_HAS_INLINE_DISPLAY)
pData->hints |= PLUGIN_HAS_INLINE_DISPLAY;

// extra plugin hints
pData->extraHints = 0x0;

bufferSizeChanged(pData->engine->getBufferSize());
reloadPrograms(true);

if (pData->active)
activate();

carla_debug("CarlaPluginNative::reload() - end");
carla_debug("CarlaPluginNative::reloadParameters() - end");
}

void reloadPrograms(const bool doInit) override
@@ -2599,8 +2614,8 @@ protected:
pData->engine->callback(true, true, ENGINE_CALLBACK_UPDATE, pData->id, -1, 0, 0, 0.0f, nullptr);
break;
case NATIVE_HOST_OPCODE_RELOAD_PARAMETERS:
reload(); // FIXME
pData->engine->callback(true, true, ENGINE_CALLBACK_RELOAD_PARAMETERS, pData->id, -1, 0, 0, 0.0f, nullptr);
reloadParameters(nullptr, nullptr);
pData->engine->callback(true, true, ENGINE_CALLBACK_RELOAD_ALL, pData->id, -1, 0, 0, 0.0f, nullptr);
break;
case NATIVE_HOST_OPCODE_RELOAD_MIDI_PROGRAMS:
reloadPrograms(false);


+ 1
- 1
source/utils/CarlaScopeUtils.hpp View File

@@ -34,7 +34,7 @@ public:
: key(nullptr),
origValue(nullptr)
{
CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(envVar != nullptr && envVar[0] != '\0',);

key = carla_strdup_safe(envVar);
CARLA_SAFE_ASSERT_RETURN(key != nullptr,);


Loading…
Cancel
Save