diff --git a/distrho/DistrhoDetails.hpp b/distrho/DistrhoDetails.hpp index 60d0847db..7178bb12d 100644 --- a/distrho/DistrhoDetails.hpp +++ b/distrho/DistrhoDetails.hpp @@ -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. @@ -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; @@ -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 diff --git a/distrho/src/DistrhoPluginLV2export.cpp b/distrho/src/DistrhoPluginLV2export.cpp index 00f8dc331..9f01328a8 100644 --- a/distrho/src/DistrhoPluginLV2export.cpp +++ b/distrho/src/DistrhoPluginLV2export.cpp @@ -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, @@ -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 @@ -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 @@ -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, @@ -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", @@ -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", @@ -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 @@ -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 }; @@ -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"; @@ -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; } diff --git a/distrho/src/DistrhoUILV2.cpp b/distrho/src/DistrhoUILV2.cpp index 990db39a5..390412e38 100644 --- a/distrho/src/DistrhoUILV2.cpp +++ b/distrho/src/DistrhoUILV2.cpp @@ -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,