Browse Source

Do not save/restore lv2 parameter-patch values, intercept restore

tags/v2.3.0-RC1
falkTX 4 years ago
parent
commit
b5193900b5
5 changed files with 85 additions and 3 deletions
  1. +6
    -0
      source/backend/CarlaBackend.h
  2. +5
    -0
      source/backend/plugin/CarlaPlugin.cpp
  3. +3
    -3
      source/backend/plugin/CarlaPluginInternal.hpp
  4. +67
    -0
      source/backend/plugin/CarlaPluginLV2.cpp
  5. +4
    -0
      source/frontend/carla_backend.py

+ 6
- 0
source/backend/CarlaBackend.h View File

@@ -341,6 +341,12 @@ static const uint PARAMETER_USES_CUSTOM_TEXT = 0x400;
*/
static const uint PARAMETER_CAN_BE_CV_CONTROLLED = 0x800;

/*!
* Parameter should not be saved as part of the project/session.
* @note only valid for parameter inputs.
*/
static const uint PARAMETER_IS_NOT_SAVED = 0x1000;

/** @} */

/* ------------------------------------------------------------------------------------------------------------


+ 5
- 0
source/backend/plugin/CarlaPlugin.cpp View File

@@ -604,6 +604,8 @@ const CarlaStateSave& CarlaPlugin::getStateSave(const bool callPrepareForSave)

if ((paramData.hints & PARAMETER_IS_ENABLED) == 0)
continue;
if (paramData.hints & PARAMETER_IS_NOT_SAVED)
continue;

const bool dummy = paramData.type != PARAMETER_INPUT || usingChunk;

@@ -750,6 +752,9 @@ void CarlaPlugin::loadStateSave(const CarlaStateSave& stateSave)
{
for (uint32_t i=0; i < pData->param.count; ++i)
{
if (pData->param.data[i].hints & PARAMETER_IS_NOT_SAVED)
continue;

if (getParameterSymbol(i, strBuf))
{
ParamSymbol* const paramSymbol(new ParamSymbol(i, strBuf));


+ 3
- 3
source/backend/plugin/CarlaPluginInternal.hpp View File

@@ -48,9 +48,9 @@ const ushort kPluginMaxMidiEvents = 512;
// -----------------------------------------------------------------------
// Extra parameter hints, hidden from backend

const uint PARAMETER_MAPPED_RANGES_SET = 0x1000;
const uint PARAMETER_IS_STRICT_BOUNDS = 0x2000;
const uint PARAMETER_IS_TRIGGER = 0x4000;
const uint PARAMETER_MAPPED_RANGES_SET = 0x10000;
const uint PARAMETER_IS_STRICT_BOUNDS = 0x20000;
const uint PARAMETER_IS_TRIGGER = 0x40000;

// -----------------------------------------------------------------------
// Extra plugin hints, hidden from backend


+ 67
- 0
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -1512,6 +1512,72 @@ public:
if (std::strcmp(type, CUSTOM_DATA_TYPE_PROPERTY) == 0)
return CarlaPlugin::setCustomData(type, key, value, sendGui);

// See if this key is from a parameter exposed by carla, apply value if yes
for (uint32_t i=0; i < fRdfDescriptor->ParameterCount; ++i)
{
const LV2_RDF_Parameter& rdfParam(fRdfDescriptor->Parameters[i]);

if (std::strcmp(rdfParam.URI, key) == 0)
{
uint32_t parameterId = UINT32_MAX;
const int32_t rindex = static_cast<int32_t>(fRdfDescriptor->PortCount + i);

switch (rdfParam.Type)
{
case LV2_PARAMETER_BOOL:
case LV2_PARAMETER_INT:
// case LV2_PARAMETER_LONG:
case LV2_PARAMETER_FLOAT:
case LV2_PARAMETER_DOUBLE:
for (uint32_t j=0; j < pData->param.count; ++j)
{
if (pData->param.data[j].rindex == rindex)
{
parameterId = j;
break;
}
}
break;
}

if (parameterId == UINT32_MAX)
break;

std::vector<uint8_t> chunk(carla_getChunkFromBase64String(value));
CARLA_SAFE_ASSERT_RETURN(chunk.size() > 0,);

#ifdef CARLA_PROPER_CPP11_SUPPORT
const uint8_t* const valueptr = chunk.data();
#else
const uint8_t* const valueptr = &chunk.front();
#endif
float rvalue;

switch (rdfParam.Type)
{
case LV2_PARAMETER_BOOL:
rvalue = *(const int32_t*)valueptr != 0 ? 1.0f : 0.0f;
break;
case LV2_PARAMETER_INT:
rvalue = static_cast<float>(*(const int32_t*)valueptr);
break;
case LV2_PARAMETER_FLOAT:
rvalue = *(const float*)valueptr;
break;
case LV2_PARAMETER_DOUBLE:
rvalue = static_cast<float>(*(const double*)valueptr);
break;
default:
// making compilers happy
rvalue = pData->param.ranges[parameterId].def;
break;
}

fParamBuffers[parameterId] = pData->param.getFixedValue(parameterId, rvalue);
break;
}
}

CarlaPlugin::setCustomData(type, key, value, sendGui);
}

@@ -2965,6 +3031,7 @@ public:
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints |= PARAMETER_IS_ENABLED;
pData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE;
pData->param.data[j].hints |= PARAMETER_IS_NOT_SAVED;
needsCtrlIn = true;
}
else


+ 4
- 0
source/frontend/carla_backend.py View File

@@ -321,6 +321,10 @@ PARAMETER_USES_CUSTOM_TEXT = 0x400
# Parameter can be turned into a CV control.
PARAMETER_CAN_BE_CV_CONTROLLED = 0x800

# Parameter should not be saved as part of the project/session.
# @note only valid for parameter inputs.
PARAMETER_IS_NOT_SAVED = 0x1000

# ---------------------------------------------------------------------------------------------------------------------
# Mapped Parameter Flags
# Various flags for parameter mappings.


Loading…
Cancel
Save