commit e95844fb6e152bf2ee1ae979977e43db9e6400b2 parent 87396ebf3445a9602aea4f0a9c5bef65a6247c21 Author: dsp56300 <dsp56300@users.noreply.github.com> Date: Sat, 3 Dec 2022 03:01:14 +0100 fix UI sending wrong parameters back to synth if multiple parameters / UI objects reference the same parameter page/index Diffstat:
M | source/jucePluginLib/parameter.cpp | | | 10 | ++++++---- |
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/source/jucePluginLib/parameter.cpp b/source/jucePluginLib/parameter.cpp @@ -76,20 +76,22 @@ namespace pluginLib void Parameter::setValueFromSynth(int newValue, const bool notifyHost) { - if (newValue == m_lastValue) + const auto clampedValue = juce::roundToInt(m_range.getRange().clipValue(static_cast<float>(newValue))); + + if (clampedValue == m_lastValue) return; - m_lastValue = newValue; + m_lastValue = clampedValue; if (notifyHost && getDescription().isPublic) { beginChangeGesture(); - setValueNotifyingHost(convertTo0to1(static_cast<float>(newValue))); + setValueNotifyingHost(convertTo0to1(static_cast<float>(clampedValue))); endChangeGesture(); } else { - m_value.setValue(newValue); + m_value.setValue(clampedValue); } if (m_changingLinkedValues)