diff --git a/include/PluginIssue.h b/include/PluginIssue.h index 30affde83..7f42a9409 100644 --- a/include/PluginIssue.h +++ b/include/PluginIssue.h @@ -42,6 +42,7 @@ enum PluginIssueType portHasNoDef, portHasNoMin, portHasNoMax, + defaultValueNotInRange, featureNotSupported, //!< plugin requires functionality LMMS can't offer badPortType, //!< port type not supported blacklisted, diff --git a/src/core/PluginIssue.cpp b/src/core/PluginIssue.cpp index 9e7492dca..6214eba02 100644 --- a/src/core/PluginIssue.cpp +++ b/src/core/PluginIssue.cpp @@ -50,6 +50,8 @@ const char *PluginIssue::msgFor(const PluginIssueType &it) return "port is missing min value"; case portHasNoMax: return "port is missing max value"; + case defaultValueNotInRange: + return "default value is not in range [min, max]"; case featureNotSupported: return "required feature not supported"; case badPortType: diff --git a/src/core/lv2/Lv2Ports.cpp b/src/core/lv2/Lv2Ports.cpp index 7415fa911..3bca0c89f 100644 --- a/src/core/lv2/Lv2Ports.cpp +++ b/src/core/lv2/Lv2Ports.cpp @@ -151,12 +151,35 @@ std::vector Meta::get(const LilvPlugin *plugin, }; takeRangeValue(def.get(), m_def, portHasNoDef); - if (!isToggle) + if (isToggle) + { + m_min = .0f; + m_max = 1.f; + if(def.get() && m_def != m_min && m_def != m_max) + { + issue(defaultValueNotInRange, portName); + } + } + else { takeRangeValue(min.get(), m_min, portHasNoMin); takeRangeValue(max.get(), m_max, portHasNoMax); if (hasProperty(LV2_CORE__sampleRate)) { m_sampleRate = true; } + if (def.get()) + { + if (m_def < m_min) { issue(defaultValueNotInRange, portName); } + else if (m_def > m_max) + { + if(m_sampleRate) + { + // multiplying with sample rate will hopefully lead us + // to a good default value + } + else { issue(defaultValueNotInRange, portName); } + } + } + if (m_max - m_min > 15.0f) { // range too large for spinbox visualisation, use knobs