diff --git a/source/backend/plugin/CarlaPluginLADSPADSSI.cpp b/source/backend/plugin/CarlaPluginLADSPADSSI.cpp index e8f0395b4..3ea795f4f 100644 --- a/source/backend/plugin/CarlaPluginLADSPADSSI.cpp +++ b/source/backend/plugin/CarlaPluginLADSPADSSI.cpp @@ -1222,7 +1222,7 @@ public: pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true, 0); - for (uint32_t i=0; i < params; ++i) + for (uint32_t i=0; i < params && i < 32; ++i) { const int32_t rindex = pData->param.data[i].rindex; CARLA_SAFE_ASSERT_CONTINUE(rindex >= 0); @@ -1580,13 +1580,12 @@ public: // ---------------------------------------------------------------------------------------------------- // CV Control Input - for (uint32_t i=0, j=0; i < pData->param.count; ++i) + for (uint32_t i=0, j=0; i < pData->param.count && i < 32; ++i) { if (pData->param.data[i].type != PARAMETER_INPUT) continue; const uint32_t cvIndex = j++; - pData->event.portIn->mixWithCvBuffer(cvIn[cvIndex], frames, i); } diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp index c64ef52ff..e8ac532d4 100644 --- a/source/backend/plugin/CarlaPluginLV2.cpp +++ b/source/backend/plugin/CarlaPluginLV2.cpp @@ -2799,7 +2799,7 @@ public: pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true, 0); - for (uint32_t i=0; i < params; ++i) + for (uint32_t i=0; i < params && i < 32; ++i) { const int32_t rindex = pData->param.data[i].rindex; CARLA_SAFE_ASSERT_CONTINUE(rindex >= 0 && rindex < static_cast(fRdfDescriptor->PortCount)); @@ -2815,11 +2815,7 @@ public: // Parameter as CV CarlaEngineCVPort* const cvPort = (CarlaEngineCVPort*)pData->client->addPort(kEnginePortTypeCV, portName, true, i); - - if (true) - cvPort->setRange(0.0f, 3.0f + (float)i); - else - cvPort->setRange(pData->param.ranges[i].min, pData->param.ranges[i].max); + cvPort->setRange(pData->param.ranges[i].min, pData->param.ranges[i].max); pData->event.portIn->addCVSource(cvPort, i); } } @@ -3524,13 +3520,12 @@ public: // ---------------------------------------------------------------------------------------------------- // CV Control Input - for (uint32_t i=0, j=0; i < pData->param.count; ++i) + for (uint32_t i=0, j=0; i < pData->param.count && i < 32; ++i) { if (pData->param.data[i].type != PARAMETER_INPUT) continue; const uint32_t cvIndex = j++; - pData->event.portIn->mixWithCvBuffer(cvIn[pData->cvIn.count + cvIndex], frames, i); } diff --git a/source/backend/plugin/CarlaPluginVST2.cpp b/source/backend/plugin/CarlaPluginVST2.cpp index 828a16180..b5226c689 100644 --- a/source/backend/plugin/CarlaPluginVST2.cpp +++ b/source/backend/plugin/CarlaPluginVST2.cpp @@ -873,6 +873,26 @@ public: portName.truncate(portNameSize); pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true, 0); + + char strBuf[STR_MAX]; + + for (uint32_t i=0; i < params && i < 32; ++i) + { + if (pData->param.data[i].type != PARAMETER_INPUT) + continue; + + carla_zeroChars(strBuf, STR_MAX); + dispatcher(effGetParamName, static_cast(i), 0, strBuf); + + if (strBuf[0] == '\0') + std::snprintf(strBuf, STR_MAX-1, "Parameter %u", i+1U); + + // Parameter as CV + CarlaEngineCVPort* const cvPort = + (CarlaEngineCVPort*)pData->client->addPort(kEnginePortTypeCV, strBuf, true, i); + cvPort->setRange(pData->param.ranges[i].min, pData->param.ranges[i].max); + pData->event.portIn->addCVSource(cvPort, i); + } } if (needsCtrlOut) @@ -1090,7 +1110,11 @@ public: } catch(...) {} } - void process(const float** const audioIn, float** const audioOut, const float** const, float** const, const uint32_t frames) override + void process(const float** const audioIn, + float** const audioOut, + const float** const cvIn, + float** const, + const uint32_t frames) override { const CarlaScopedValueSetter svs(fProcThread, pthread_self(), kNullThread); @@ -1245,6 +1269,18 @@ public: } // End of MIDI Input (External) + // ---------------------------------------------------------------------------------------------------- + // CV Control Input + + for (uint32_t i=0, j=0; i < pData->param.count && i < 32; ++i) + { + if (pData->param.data[i].type != PARAMETER_INPUT) + continue; + + const uint32_t cvIndex = j++; + pData->event.portIn->mixWithCvBuffer(cvIn[cvIndex], frames, i); + } + // ---------------------------------------------------------------------------------------------------- // Event Input (System) @@ -1301,12 +1337,37 @@ public: break; case kEngineControlEventTypeParameter: { + float value; + #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH + // via CV + if (event.channel == 0xFF) + { + const uint32_t k = ctrlEvent.param; + CARLA_SAFE_ASSERT_CONTINUE(k < pData->param.count); + + if (pData->param.data[k].hints & PARAMETER_IS_BOOLEAN) + { + value = (ctrlEvent.value < 0.5f) ? pData->param.ranges[k].min : pData->param.ranges[k].max; + } + else + { + if (pData->param.data[k].hints & PARAMETER_IS_LOGARITHMIC) + value = pData->param.ranges[k].getUnnormalizedLogValue(ctrlEvent.value); + else + value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); + + if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) + value = std::rint(value); + } + + setParameterValueRT(k, value, true); + continue; + } + // Control backend stuff if (event.channel == pData->ctrlChannel) { - float value; - if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) != 0) { value = ctrlEvent.value; @@ -1358,8 +1419,6 @@ public: if ((pData->param.data[k].hints & PARAMETER_IS_AUTOMABLE) == 0) continue; - float value; - if (pData->param.data[k].hints & PARAMETER_IS_BOOLEAN) { value = (ctrlEvent.value < 0.5f) ? pData->param.ranges[k].min : pData->param.ranges[k].max;