DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit f4f44ab0cdef7e258ebb82a69875999f5e6cf31c
parent a80da9156e120d13e7ec0cb6d8a7d11108ca8640
Author: falkTX <falktx@falktx.com>
Date:   Fri,  2 Aug 2019 19:18:50 +0100

Add Parameter short name support, used in LV2 and VST
Closes #163

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdistrho/DistrhoPlugin.hpp | 20+++++++++++++++-----
Mdistrho/src/DistrhoPluginInternal.hpp | 7+++++++
Mdistrho/src/DistrhoPluginLV2export.cpp | 6++++++
Mdistrho/src/DistrhoPluginVST.cpp | 6+++++-
4 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp @@ -385,6 +385,13 @@ struct Parameter { String name; /** + The short name of this parameter.@n + Used when displaying the parameter name in a very limited space. + @note This value is optional, the full name is used when the short one is missing. + */ + String shortName; + + /** The symbol of this parameter.@n A parameter symbol is a short restricted name used as a machine and human readable identifier.@n The first character must be one of _, a-z or A-Z and subsequent characters can be from _, a-z, A-Z and 0-9. @@ -430,6 +437,7 @@ struct Parameter { Parameter() noexcept : hints(0x0), name(), + shortName(), symbol(), unit(), ranges(), @@ -443,6 +451,7 @@ struct Parameter { Parameter(uint32_t h, const char* n, const char* s, const char* u, float def, float min, float max) noexcept : hints(h), name(n), + shortName(), symbol(s), unit(u), ranges(def, min, max), @@ -462,11 +471,12 @@ struct Parameter { case kParameterDesignationNull: break; case kParameterDesignationBypass: - hints = kParameterIsAutomable|kParameterIsBoolean|kParameterIsInteger; - name = "Bypass"; - symbol = "dpf_bypass"; - unit = ""; - midiCC = 0; + hints = kParameterIsAutomable|kParameterIsBoolean|kParameterIsInteger; + name = "Bypass"; + shortName = "Bypass"; + symbol = "dpf_bypass"; + unit = ""; + midiCC = 0; ranges.def = 0.0f; ranges.min = 0.0f; ranges.max = 1.0f; diff --git a/distrho/src/DistrhoPluginInternal.hpp b/distrho/src/DistrhoPluginInternal.hpp @@ -375,6 +375,13 @@ public: return fData->parameters[index].name; } + const String& getParameterShortName(const uint32_t index) const noexcept + { + DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr && index < fData->parameterCount, sFallbackString); + + return fData->parameters[index].shortName; + } + const String& getParameterSymbol(const uint32_t index) const noexcept { DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr && index < fData->parameterCount, sFallbackString); diff --git a/distrho/src/DistrhoPluginLV2export.cpp b/distrho/src/DistrhoPluginLV2export.cpp @@ -440,6 +440,12 @@ void lv2_generate_ttl(const char* const basename) pluginString += " lv2:symbol \"" + symbol + "\" ;\n"; + // short name + const String& shortName(plugin.getParameterShortName(i)); + + if (shortName.isNotEmpty()) + pluginString += " lv2:shortName \"" + shortName + "\" ;\n"; + // ranges const ParameterRanges& ranges(plugin.getParameterRanges(i)); diff --git a/distrho/src/DistrhoPluginVST.cpp b/distrho/src/DistrhoPluginVST.cpp @@ -1294,7 +1294,11 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t case effGetParamName: if (ptr != nullptr && index < static_cast<int32_t>(plugin.getParameterCount())) { - DISTRHO_NAMESPACE::strncpy((char*)ptr, plugin.getParameterName(index), 16); + const String& shortName(plugin.getParameterShortName(index)); + if (shortName.isNotEmpty()) + DISTRHO_NAMESPACE::strncpy((char*)ptr, shortName, 16); + else + DISTRHO_NAMESPACE::strncpy((char*)ptr, plugin.getParameterName(index), 16); return 1; } return 0;