Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Lv2Ports: Smash plugins with out-of-bounds defaults
  • Loading branch information
JohannesLorenz committed Nov 13, 2020
commit 6a0460f99113169ae2b1b6ce4d9949dec4e89c0b
1 change: 1 addition & 0 deletions include/PluginIssue.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum PluginIssueType
portHasNoDef,
portHasNoMin,
portHasNoMax,
defaultValueNotInRange,
featureNotSupported, //!< plugin requires functionality LMMS can't offer
badPortType, //!< port type not supported
noIssue
Expand Down
2 changes: 2 additions & 0 deletions src/core/PluginIssue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
25 changes: 24 additions & 1 deletion src/core/lv2/Lv2Ports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,35 @@ std::vector<PluginIssue> 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
Expand Down