Browse Source

Add Parameter short name support, used in LV2 and VST

Closes #163

Signed-off-by: falkTX <falktx@falktx.com>
pull/165/head
falkTX 5 years ago
parent
commit
f4f44ab0cd
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 33 additions and 6 deletions
  1. +15
    -5
      distrho/DistrhoPlugin.hpp
  2. +7
    -0
      distrho/src/DistrhoPluginInternal.hpp
  3. +6
    -0
      distrho/src/DistrhoPluginLV2export.cpp
  4. +5
    -1
      distrho/src/DistrhoPluginVST.cpp

+ 15
- 5
distrho/DistrhoPlugin.hpp View File

@@ -384,6 +384,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
@@ -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;


+ 7
- 0
distrho/src/DistrhoPluginInternal.hpp View File

@@ -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);


+ 6
- 0
distrho/src/DistrhoPluginLV2export.cpp View File

@@ -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));



+ 5
- 1
distrho/src/DistrhoPluginVST.cpp View File

@@ -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;


Loading…
Cancel
Save