summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfalkTX <falktx@falktx.com>2019-08-02 19:19:17 +0100
committerfalkTX <falktx@falktx.com>2019-08-02 19:19:17 +0100
commitf4f44ab0cdef7e258ebb82a69875999f5e6cf31c (patch)
tree3b9e7d7b24102aff55699f679e7ebccc4c22fde5
parenta80da9156e120d13e7ec0cb6d8a7d11108ca8640 (diff)
Add Parameter short name support, used in LV2 and VST
Closes #163 Signed-off-by: falkTX <falktx@falktx.com>
-rw-r--r--distrho/DistrhoPlugin.hpp20
-rw-r--r--distrho/src/DistrhoPluginInternal.hpp7
-rw-r--r--distrho/src/DistrhoPluginLV2export.cpp6
-rw-r--r--distrho/src/DistrhoPluginVST.cpp6
4 files changed, 33 insertions, 6 deletions
diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp
index ebc54077..cf4237da 100644
--- 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
index 604f4d98..3dd2c27f 100644
--- 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
index a43ec4b7..70b01738 100644
--- 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
index d8e7640f..c77b7af4 100644
--- 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;