From b288b50011c7aed33a217b2890ff26a5b01c9871 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 26 Feb 2014 23:07:27 +0000 Subject: [PATCH] param-text is working again (used in VSTs) --- source/backend/CarlaHost.h | 3 +-- source/backend/CarlaPlugin.hpp | 2 +- source/backend/engine/CarlaEngineNative.cpp | 8 ++++---- source/backend/plugin/CarlaPlugin.cpp | 2 +- source/backend/plugin/JucePlugin.cpp | 12 ++++++++++-- source/backend/plugin/NativePlugin.cpp | 6 +++--- source/backend/plugin/VstPlugin.cpp | 6 ++---- source/backend/standalone/CarlaStandalone.cpp | 4 ++-- source/carla_backend.py | 7 +++---- source/modules/CarlaNative.h | 2 +- source/modules/CarlaNative.hpp | 9 +++------ 11 files changed, 31 insertions(+), 30 deletions(-) diff --git a/source/backend/CarlaHost.h b/source/backend/CarlaHost.h index 9e9983fe1..a00b4eecb 100644 --- a/source/backend/CarlaHost.h +++ b/source/backend/CarlaHost.h @@ -717,10 +717,9 @@ CARLA_EXPORT uint32_t carla_get_custom_data_count(uint pluginId); * Get a plugin's parameter text (custom display of internal values). * @param pluginId Plugin * @param parameterId Parameter index - * @param value Parameter value * @see PARAMETER_USES_CUSTOM_TEXT */ -CARLA_EXPORT const char* carla_get_parameter_text(uint pluginId, uint32_t parameterId, float value); +CARLA_EXPORT const char* carla_get_parameter_text(uint pluginId, uint32_t parameterId); /*! * Get a plugin's program name. diff --git a/source/backend/CarlaPlugin.hpp b/source/backend/CarlaPlugin.hpp index 419b07d80..2084d1dca 100644 --- a/source/backend/CarlaPlugin.hpp +++ b/source/backend/CarlaPlugin.hpp @@ -326,7 +326,7 @@ public: /*! * Get the custom text of the parameter \a parameterId. */ - virtual void getParameterText(const uint32_t parameterId, const float value, char* const strBuf) const noexcept; + virtual void getParameterText(const uint32_t parameterId, char* const strBuf) const noexcept; /*! * Get the unit of the parameter \a parameterId. diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 18a15c58c..549d759f2 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -904,7 +904,7 @@ protected: return 0.0f; } - const char* getParameterText(const uint32_t index, const float value) const + const char* getParameterText(const uint32_t index /*, const float value*/) const { if (CarlaPlugin* const plugin = _getFirstPlugin()) { @@ -913,7 +913,7 @@ protected: static char strBuf[STR_MAX+1]; carla_zeroChar(strBuf, STR_MAX+1); - plugin->getParameterText(index, value, strBuf); + plugin->getParameterText(index, /*value,*/ strBuf); return strBuf; } @@ -1361,9 +1361,9 @@ public: return handlePtr->getParameterValue(index); } - static const char* _get_parameter_text(NativePluginHandle handle, uint32_t index, float value) + static const char* _get_parameter_text(NativePluginHandle handle, uint32_t index /*, float value*/) { - return handlePtr->getParameterText(index, value); + return handlePtr->getParameterText(index /*, value*/); } static uint32_t _get_midi_program_count(NativePluginHandle handle) diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index 4ef0dd078..1f06717e0 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -367,7 +367,7 @@ void CarlaPlugin::getParameterSymbol(const uint32_t parameterId, char* const str strBuf[0] = '\0'; } -void CarlaPlugin::getParameterText(const uint32_t parameterId, const float, char* const strBuf) const noexcept +void CarlaPlugin::getParameterText(const uint32_t parameterId, char* const strBuf) const noexcept { CARLA_SAFE_ASSERT_RETURN(parameterId < getParameterCount(),); CARLA_SAFE_ASSERT(false); // this should never happen diff --git a/source/backend/plugin/JucePlugin.cpp b/source/backend/plugin/JucePlugin.cpp index 6eac4c3f2..f0bff22e2 100644 --- a/source/backend/plugin/JucePlugin.cpp +++ b/source/backend/plugin/JucePlugin.cpp @@ -174,7 +174,15 @@ public: CARLA_SAFE_ASSERT_RETURN(parameterId < pData->param.count,); CARLA_SAFE_ASSERT_RETURN(fInstance != nullptr,); - std::strncpy(strBuf, fInstance->getParameterName(static_cast(parameterId)).toRawUTF8(), STR_MAX); + std::strncpy(strBuf, fInstance->getParameterName(static_cast(parameterId), STR_MAX).toRawUTF8(), STR_MAX); + } + + void getParameterText(const uint32_t parameterId, char* const strBuf) const noexcept override + { + CARLA_SAFE_ASSERT_RETURN(parameterId < pData->param.count,); + CARLA_SAFE_ASSERT_RETURN(fInstance != nullptr,); + + std::strncpy(strBuf, fInstance->getParameterText(static_cast(parameterId), STR_MAX).toRawUTF8(), STR_MAX); } void getParameterUnit(const uint32_t parameterId, char* const strBuf) const noexcept override @@ -406,7 +414,7 @@ public: pData->param.data[j].hints |= PARAMETER_IS_ENABLED; #ifndef BUILD_BRIDGE - //pData->param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT; + pData->param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT; #endif if (fInstance->isParameterAutomatable(static_cast(j))) diff --git a/source/backend/plugin/NativePlugin.cpp b/source/backend/plugin/NativePlugin.cpp index 7cafdbdce..19fe4c948 100644 --- a/source/backend/plugin/NativePlugin.cpp +++ b/source/backend/plugin/NativePlugin.cpp @@ -407,7 +407,7 @@ public: CarlaPlugin::getParameterName(parameterId, strBuf); } - void getParameterText(const uint32_t parameterId, const float value, char* const strBuf) const noexcept override + void getParameterText(const uint32_t parameterId, char* const strBuf) const noexcept override { CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,); CARLA_SAFE_ASSERT_RETURN(fDescriptor->get_parameter_text != nullptr,); @@ -416,14 +416,14 @@ public: CARLA_SAFE_ASSERT_RETURN(parameterId < pData->param.count,); // FIXME - try - if (const char* const text = fDescriptor->get_parameter_text(fHandle, parameterId, value)) + if (const char* const text = fDescriptor->get_parameter_text(fHandle, parameterId /*, fDescriptor->get_parameter_value(fHandle, parameterId)*/)) { std::strncpy(strBuf, text, STR_MAX); return; } carla_safe_assert("const char* const text = fDescriptor->get_parameter_text(fHandle, parameterId, value)", __FILE__, __LINE__); - CarlaPlugin::getParameterText(parameterId, value, strBuf); + CarlaPlugin::getParameterText(parameterId, strBuf); } void getParameterUnit(const uint32_t parameterId, char* const strBuf) const noexcept override diff --git a/source/backend/plugin/VstPlugin.cpp b/source/backend/plugin/VstPlugin.cpp index 209e075f5..00f5f6c12 100644 --- a/source/backend/plugin/VstPlugin.cpp +++ b/source/backend/plugin/VstPlugin.cpp @@ -276,19 +276,17 @@ public: dispatcher(effGetParamName, static_cast(parameterId), 0, strBuf, 0.0f); } -#if 0 void getParameterText(const uint32_t parameterId, char* const strBuf) const noexcept override { CARLA_SAFE_ASSERT_RETURN(fEffect != nullptr,); CARLA_SAFE_ASSERT_RETURN(parameterId < pData->param.count,); strBuf[0] = '\0'; - dispatcher(effGetParamDisplay, parameterId, 0, strBuf, 0.0f); + dispatcher(effGetParamDisplay, static_cast(parameterId), 0, strBuf, 0.0f); if (strBuf[0] == '\0') std::snprintf(strBuf, STR_MAX, "%f", getParameterValue(parameterId)); } -#endif void getParameterUnit(const uint32_t parameterId, char* const strBuf) const noexcept override { @@ -742,7 +740,7 @@ public: pData->param.data[j].hints |= PARAMETER_IS_ENABLED; #ifndef BUILD_BRIDGE - //pData->param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT; + pData->param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT; #endif if ((pData->hints & PLUGIN_USES_OLD_VSTSDK) != 0 || dispatcher(effCanBeAutomated, static_cast(j), 0, nullptr, 0.0f) == 1) diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index 796885447..94cd1c020 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -1615,7 +1615,7 @@ uint32_t carla_get_custom_data_count(uint pluginId) // ------------------------------------------------------------------------------------------------------------------- -const char* carla_get_parameter_text(uint pluginId, uint32_t parameterId, float value) +const char* carla_get_parameter_text(uint pluginId, uint32_t parameterId) { CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, nullptr); carla_debug("carla_get_parameter_text(%i, %i)", pluginId, parameterId); @@ -1627,7 +1627,7 @@ const char* carla_get_parameter_text(uint pluginId, uint32_t parameterId, float if (parameterId < plugin->getParameterCount()) { carla_zeroChar(textBuf, STR_MAX+1); - plugin->getParameterText(parameterId, value, textBuf); + plugin->getParameterText(parameterId, textBuf); return textBuf; } diff --git a/source/carla_backend.py b/source/carla_backend.py index 1f30c2a75..efe7a7e0d 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -1540,10 +1540,9 @@ class Host(object): # Get a plugin's parameter text (custom display of internal values). # @param pluginId Plugin # @param parameterId Parameter index - # @param value Parameter value # @see PARAMETER_USES_CUSTOM_TEXT - def get_parameter_text(self, pluginId, parameterId, value): - return charPtrToString(self.lib.carla_get_parameter_text(pluginId, parameterId, value)) + def get_parameter_text(self, pluginId, parameterId): + return charPtrToString(self.lib.carla_get_parameter_text(pluginId, parameterId)) # Get a plugin's program name. # @param pluginId Plugin @@ -1895,7 +1894,7 @@ class Host(object): self.lib.carla_get_custom_data_count.argtypes = [c_uint] self.lib.carla_get_custom_data_count.restype = c_uint32 - self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32, c_float] + self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32] self.lib.carla_get_parameter_text.restype = c_char_p self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32] diff --git a/source/modules/CarlaNative.h b/source/modules/CarlaNative.h index c8a95c762..0c92f902a 100644 --- a/source/modules/CarlaNative.h +++ b/source/modules/CarlaNative.h @@ -231,7 +231,7 @@ typedef struct _NativePluginDescriptor { uint32_t (*get_parameter_count)(NativePluginHandle handle); const NativeParameter* (*get_parameter_info)(NativePluginHandle handle, uint32_t index); float (*get_parameter_value)(NativePluginHandle handle, uint32_t index); - const char* (*get_parameter_text)(NativePluginHandle handle, uint32_t index, float value); + const char* (*get_parameter_text)(NativePluginHandle handle, uint32_t index /*, float value*/); uint32_t (*get_midi_program_count)(NativePluginHandle handle); const NativeMidiProgram* (*get_midi_program_info)(NativePluginHandle handle, uint32_t index); diff --git a/source/modules/CarlaNative.hpp b/source/modules/CarlaNative.hpp index 12e1ce121..725516a7f 100644 --- a/source/modules/CarlaNative.hpp +++ b/source/modules/CarlaNative.hpp @@ -278,13 +278,10 @@ protected: return 0.0f; } - virtual const char* getParameterText(const uint32_t index, const float value) const + virtual const char* getParameterText(const uint32_t index /*, const float value*/) const { CARLA_SAFE_ASSERT_RETURN(index < getParameterCount(), nullptr); return nullptr; - - // unused - (void)value; } // ------------------------------------------------------------------- @@ -456,9 +453,9 @@ public: return handlePtr->getParameterValue(index); } - static const char* _get_parameter_text(NativePluginHandle handle, uint32_t index, float value) + static const char* _get_parameter_text(NativePluginHandle handle, uint32_t index /*, float value*/) { - return handlePtr->getParameterText(index, value); + return handlePtr->getParameterText(index /*, value*/); } static uint32_t _get_midi_program_count(NativePluginHandle handle)