From cac2d6292553184c2aac57115795273be1a03e6d Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 4 Oct 2021 18:08:18 +0100 Subject: [PATCH] Fetch/set some extra info for VST3 plugin parameters Signed-off-by: falkTX --- source/backend/plugin/CarlaPluginJuce.cpp | 85 ++++++++++++++++++----- source/backend/plugin/CarlaPluginVST2.cpp | 2 +- source/discovery/carla-discovery.cpp | 2 +- source/plugin/carla-vst.cpp | 4 +- source/utils/JucePluginWindow.hpp | 2 +- 5 files changed, 72 insertions(+), 23 deletions(-) diff --git a/source/backend/plugin/CarlaPluginJuce.cpp b/source/backend/plugin/CarlaPluginJuce.cpp index 718ee3b73..1af03a5a5 100644 --- a/source/backend/plugin/CarlaPluginJuce.cpp +++ b/source/backend/plugin/CarlaPluginJuce.cpp @@ -24,7 +24,8 @@ #include "CarlaMathUtils.hpp" #include "CarlaProcessUtils.hpp" #include "CarlaScopeUtils.hpp" -#include "CarlaVstUtils.hpp" +#include "CarlaVst2Utils.hpp" +#include "CarlaVst3Utils.hpp" #if defined(__clang__) # pragma clang diagnostic push @@ -561,6 +562,7 @@ public: const bool isAU = fDesc.pluginFormatName == "AU" || fDesc.pluginFormatName == "AudioUnit"; const bool isVST2 = fDesc.pluginFormatName == "VST" || fDesc.pluginFormatName == "VST2"; + const bool isVST3 = fDesc.pluginFormatName == "VST3"; findMaxTotalChannels(fInstance.get(), isAU, aIns, aOuts); fInstance->refreshParameterList(); @@ -668,6 +670,7 @@ public: const float min = 0.0f; const float max = 1.0f; float def, step, stepSmall, stepLarge; + bool hasDetails = false; if (isVST2) { @@ -678,6 +681,8 @@ public: if (effect != nullptr && effect->dispatcher(effect, effGetParameterProperties, ij, 0, &prop, 0.0f) == 1) { + hasDetails = true; + /**/ if (prop.flags & kVstParameterIsSwitch) { step = max - min; @@ -710,30 +715,74 @@ public: if (prop.flags & kVstParameterCanRamp) pData->param.data[j].hints |= PARAMETER_IS_LOGARITHMIC; } + } + else if (isVST3) + { + v3_component** const component = (v3_component**)fInstance->getPlatformSpecificData(); + + v3_edit_controller** controller = nullptr; + v3_cpp_obj_query_interface(component, v3_edit_controller_iid, &controller); + + if (controller != nullptr) + { + v3_param_info info; + if (v3_cpp_obj(controller)->get_parameter_info(controller, static_cast(j), &info) == V3_OK) + { + hasDetails = true; + + if (info.step_count == 1) + { + step = stepSmall = stepLarge = 1; + pData->param.data[j].hints |= PARAMETER_IS_BOOLEAN; + } + else if (info.step_count != 0) + { + step = 1.0f / static_cast(info.step_count); + stepSmall = step/10.0f; + stepLarge = std::min(1.0f, step*10.0f); + } + else + { + const float range = max - min; + step = range/100.0f; + stepSmall = range/1000.0f; + stepLarge = range/10.0f; + } + + if (info.flags & V3_PARAM_READ_ONLY) + pData->param.data[j].type = PARAMETER_OUTPUT; + // TODO V3_PARAM_IS_LIST + if (info.flags & (V3_PARAM_IS_HIDDEN|V3_PARAM_PROGRAM_CHANGE)) + pData->param.data[j].hints &= ~PARAMETER_IS_ENABLED; + + if ((info.flags & (V3_PARAM_IS_LIST|V3_PARAM_IS_HIDDEN|V3_PARAM_PROGRAM_CHANGE)) == 0x0) + if (info.flags & V3_PARAM_CAN_AUTOMATE) + pData->param.data[j].hints |= PARAMETER_CAN_BE_CV_CONTROLLED; + } + + v3_cpp_obj_unref(controller); + } + } + + if (! hasDetails) + { + if (parameter->isBoolean()) + { + step = max - min; + stepSmall = step; + stepLarge = step; + pData->param.data[j].hints |= PARAMETER_IS_BOOLEAN; + } else { const float range = max - min; step = range/100.0f; stepSmall = range/1000.0f; stepLarge = range/10.0f; - } - } - else if (parameter->isBoolean()) - { - step = max - min; - stepSmall = step; - stepLarge = step; - pData->param.data[j].hints |= PARAMETER_IS_BOOLEAN; - } - else - { - const float range = max - min; - step = range/100.0f; - stepSmall = range/1000.0f; - stepLarge = range/10.0f; - if (! parameter->isMetaParameter()) - pData->param.data[j].hints |= PARAMETER_CAN_BE_CV_CONTROLLED; + if (! parameter->isMetaParameter()) + pData->param.data[j].hints |= PARAMETER_CAN_BE_CV_CONTROLLED; + } } def = parameter->getDefaultValue(); diff --git a/source/backend/plugin/CarlaPluginVST2.cpp b/source/backend/plugin/CarlaPluginVST2.cpp index 77ad98431..2eb03735f 100644 --- a/source/backend/plugin/CarlaPluginVST2.cpp +++ b/source/backend/plugin/CarlaPluginVST2.cpp @@ -27,7 +27,7 @@ #include "CarlaMathUtils.hpp" #include "CarlaProcessUtils.hpp" #include "CarlaScopeUtils.hpp" -#include "CarlaVstUtils.hpp" +#include "CarlaVst2Utils.hpp" #include "CarlaPluginUI.hpp" diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index 92fa6639d..e5a1fec39 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -52,7 +52,7 @@ #include "CarlaLv2Utils.hpp" #ifndef USING_JUCE_FOR_VST2 -# include "CarlaVstUtils.hpp" +# include "CarlaVst2Utils.hpp" #endif #ifdef CARLA_OS_MAC diff --git a/source/plugin/carla-vst.cpp b/source/plugin/carla-vst.cpp index 0b78ed375..07581303f 100644 --- a/source/plugin/carla-vst.cpp +++ b/source/plugin/carla-vst.cpp @@ -1,6 +1,6 @@ /* * Carla Native Plugins - * Copyright (C) 2013-2020 Filipe Coelho + * Copyright (C) 2013-2021 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -40,7 +40,7 @@ #include "water/files/File.h" #include "CarlaMathUtils.hpp" -#include "CarlaVstUtils.hpp" +#include "CarlaVst2Utils.hpp" static uint32_t d_lastBufferSize = 0; static double d_lastSampleRate = 0.0; diff --git a/source/utils/JucePluginWindow.hpp b/source/utils/JucePluginWindow.hpp index 277732ba2..5fad055ea 100644 --- a/source/utils/JucePluginWindow.hpp +++ b/source/utils/JucePluginWindow.hpp @@ -19,7 +19,7 @@ #define JUCE_PLUGIN_WINDOW_HPP_INCLUDED #include "CarlaJuceUtils.hpp" -#include "CarlaVstUtils.hpp" +#include "CarlaVst2Utils.hpp" #include "AppConfig.h" #include "juce_gui_basics/juce_gui_basics.h"