Skip to content

Commit

Permalink
Declare the hardcoded dpf param symbols in the public API
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Oct 11, 2023
1 parent 9659a2f commit 92dcde4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
20 changes: 18 additions & 2 deletions distrho/DistrhoDetails.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,22 @@ enum ParameterDesignation {
kParameterDesignationBypass = 1
};

/**
Parameter designation symbols.@n
These are static, hard-coded definitions to ensure consistency across DPF and plugins.
*/
struct ParameterDesignationSymbols {
/**
Bypass designation symbol.
*/
static constexpr const char* const bypass = "dpf_bypass";

/**
Bypass designation symbol, inverted for LV2 so it becomes "enabled".
*/
static constexpr const char* const bypass_lv2 = "lv2_enabled";
};

/**
Predefined Port Groups Ids.
Expand Down Expand Up @@ -731,7 +747,7 @@ struct Parameter {
hints = kParameterIsAutomatable|kParameterIsBoolean|kParameterIsInteger;
name = "Bypass";
shortName = "Bypass";
symbol = "dpf_bypass";
symbol = ParameterDesignationSymbols::bypass;
unit = "";
midiCC = 0;
groupId = kPortGroupNone;
Expand All @@ -749,7 +765,7 @@ struct Parameter {
*/
static constexpr const Parameter kParameterBypass = {
kParameterIsAutomatable|kParameterIsBoolean|kParameterIsInteger,
"Bypass", "Bypass", "dpf_bypass", "", "", {}, {}, 0, kPortGroupNone,
"Bypass", "Bypass", ParameterDesignationSymbols::bypass, "", "", {}, {}, 0, kPortGroupNone,
};
#endif

Expand Down
22 changes: 10 additions & 12 deletions distrho/src/DistrhoPluginLV2export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@
#define DISTRHO_LV2_USE_EVENTS_IN (DISTRHO_PLUGIN_WANT_MIDI_INPUT || DISTRHO_PLUGIN_WANT_TIMEPOS || DISTRHO_PLUGIN_WANT_STATE)
#define DISTRHO_LV2_USE_EVENTS_OUT (DISTRHO_PLUGIN_WANT_MIDI_OUTPUT || DISTRHO_PLUGIN_WANT_STATE)

#define DISTRHO_BYPASS_PARAMETER_NAME "lv2_enabled"

// --------------------------------------------------------------------------------------------------------------------

static const char* const lv2ManifestPluginExtensionData[] = {
static constexpr const char* const lv2ManifestPluginExtensionData[] = {
"opts:interface",
#if DISTRHO_PLUGIN_WANT_STATE
LV2_STATE__interface,
Expand All @@ -110,7 +108,7 @@ static const char* const lv2ManifestPluginExtensionData[] = {
nullptr
};

static const char* const lv2ManifestPluginOptionalFeatures[] = {
static constexpr const char* const lv2ManifestPluginOptionalFeatures[] = {
#if DISTRHO_PLUGIN_IS_RT_SAFE
LV2_CORE__hardRTCapable,
#endif
Expand All @@ -125,7 +123,7 @@ static const char* const lv2ManifestPluginOptionalFeatures[] = {
nullptr
};

static const char* const lv2ManifestPluginRequiredFeatures[] = {
static constexpr const char* const lv2ManifestPluginRequiredFeatures[] = {
"opts:options",
LV2_URID__map,
#if DISTRHO_PLUGIN_WANT_STATE
Expand All @@ -137,7 +135,7 @@ static const char* const lv2ManifestPluginRequiredFeatures[] = {
nullptr
};

static const char* const lv2ManifestPluginSupportedOptions[] =
static constexpr const char* const lv2ManifestPluginSupportedOptions[] =
{
LV2_BUF_SIZE__nominalBlockLength,
LV2_BUF_SIZE__maxBlockLength,
Expand All @@ -146,7 +144,7 @@ static const char* const lv2ManifestPluginSupportedOptions[] =
};

#if DISTRHO_PLUGIN_HAS_UI
static const char* const lv2ManifestUiExtensionData[] = {
static constexpr const char* const lv2ManifestUiExtensionData[] = {
"opts:interface",
"ui:idleInterface",
"ui:showInterface",
Expand All @@ -156,7 +154,7 @@ static const char* const lv2ManifestUiExtensionData[] = {
nullptr
};

static const char* const lv2ManifestUiOptionalFeatures[] = {
static constexpr const char* const lv2ManifestUiOptionalFeatures[] = {
#if DISTRHO_PLUGIN_HAS_EMBED_UI
#if !DISTRHO_UI_USER_RESIZABLE
"ui:noUserResize",
Expand All @@ -168,7 +166,7 @@ static const char* const lv2ManifestUiOptionalFeatures[] = {
nullptr
};

static const char* const lv2ManifestUiRequiredFeatures[] = {
static constexpr const char* const lv2ManifestUiRequiredFeatures[] = {
"opts:options",
"ui:idleInterface",
#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
Expand All @@ -179,7 +177,7 @@ static const char* const lv2ManifestUiRequiredFeatures[] = {
nullptr
};

static const char* const lv2ManifestUiSupportedOptions[] = {
static constexpr const char* const lv2ManifestUiSupportedOptions[] = {
LV2_PARAMETERS__sampleRate,
nullptr
};
Expand Down Expand Up @@ -746,7 +744,7 @@ void lv2_generate_ttl(const char* const basename)
case kParameterDesignationBypass:
designated = true;
pluginString += " lv2:name \"Enabled\" ;\n";
pluginString += " lv2:symbol \"" DISTRHO_BYPASS_PARAMETER_NAME "\" ;\n";
pluginString += " lv2:symbol \"" + String(ParameterDesignationSymbols::bypass_lv2) + "\" ;\n";
pluginString += " lv2:default 1 ;\n";
pluginString += " lv2:minimum 0 ;\n";
pluginString += " lv2:maximum 1 ;\n";
Expand Down Expand Up @@ -1682,7 +1680,7 @@ void lv2_generate_ttl(const char* const basename)

if (plugin.getParameterDesignation(j) == kParameterDesignationBypass)
{
parameterSymbol = DISTRHO_BYPASS_PARAMETER_NAME;
parameterSymbol = ParameterDesignationSymbols::bypass_lv2;
parameterValue = 1.0f - parameterValue;
}

Expand Down
2 changes: 1 addition & 1 deletion distrho/src/DistrhoUILV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class UiLv2
fController(controller),
fWriteFunction(writeFunc),
fURIDs(uridMap),
fBypassParameterIndex(fUiPortMap != nullptr ? fUiPortMap->port_index(fUiPortMap->handle, "lv2_enabled")
fBypassParameterIndex(fUiPortMap != nullptr ? fUiPortMap->port_index(fUiPortMap->handle, ParameterDesignationSymbols::bypass_lv2)
: LV2UI_INVALID_PORT_INDEX),
fWinIdWasNull(winId == 0),
fUI(this, winId, sampleRate,
Expand Down

0 comments on commit 92dcde4

Please sign in to comment.