commit 97f38aaffc1acebbc2ef0fad9c1139047cf72eae
parent 9d1b7ad881324132b798d5de08c0d3dedd92e840
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Sat, 1 Jun 2024 13:11:21 +0200
remove notifyHost parameter, we can derive it from the origin
Diffstat:
5 files changed, 33 insertions(+), 28 deletions(-)
diff --git a/source/jucePluginLib/parameter.cpp b/source/jucePluginLib/parameter.cpp
@@ -176,29 +176,21 @@ namespace pluginLib
setValue(v, _origin);
}
- void Parameter::forwardToDerived(const int _newValue, Origin _origin, const bool _notifyHost)
- {
- if (m_changingDerivedValues)
- return;
-
- m_changingDerivedValues = true;
-
- for (const auto& p : m_derivedParameters)
- p->setDerivedValue(_newValue, _origin, _notifyHost);
-
- m_changingDerivedValues = false;
- }
-
- void Parameter::setValueFromSynth(const int _newValue, const bool _notifyHost, const Origin _origin)
+ void Parameter::setValueFromSynth(const int _newValue, const Origin _origin)
{
const auto clampedValue = clampValue(_newValue);
+ // we do not want to send an excessive amount of value changes to the host if a preset is
+ // changed, we use updateHostDisplay() (see caller) to inform the host to read all
+ // parameters again instead
+ const auto notifyHost = _origin != Origin::PresetChange;
+
if (clampedValue != m_lastValue)
{
m_lastValue = clampedValue;
m_lastValueOrigin = _origin;
- if (_notifyHost && getDescription().isPublic)
+ if (notifyHost && getDescription().isPublic)
{
beginChangeGesture();
const auto v = convertTo0to1(static_cast<float>(clampedValue));
@@ -211,9 +203,22 @@ namespace pluginLib
}
}
- forwardToDerived(_newValue, _origin, _notifyHost);
+ forwardToDerived(_newValue, _origin, notifyHost);
}
+ void Parameter::forwardToDerived(const int _newValue, Origin _origin, const bool _notifyHost)
+ {
+ if (m_changingDerivedValues)
+ return;
+
+ m_changingDerivedValues = true;
+
+ for (const auto& p : m_derivedParameters)
+ p->setDerivedValue(_newValue, _origin, _notifyHost);
+
+ m_changingDerivedValues = false;
+ }
+
juce::String Parameter::genId(const Description& d, const int part, const int uniqueId)
{
if(uniqueId > 0)
diff --git a/source/jucePluginLib/parameter.h b/source/jucePluginLib/parameter.h
@@ -48,7 +48,7 @@ namespace pluginLib
void setValue(float _newValue) override;
void setValue(float _newValue, Origin _origin);
void setUnnormalizedValue(int _newValue, Origin _origin);
- void setValueFromSynth(int _newValue, bool _notifyHost, Origin _origin);
+ void setValueFromSynth(int _newValue, Origin _origin);
bool isDiscrete() const override { return m_desc.isDiscrete; }
bool isBoolean() const override { return m_desc.isBool; }
diff --git a/source/mqJucePlugin/mqController.cpp b/source/mqJucePlugin/mqController.cpp
@@ -195,10 +195,10 @@ void Controller::applyPatchParameters(const pluginLib::MidiPacket::ParamValues&
for (const auto& it : _params)
{
auto* p = getParameter(it.first.second, _part);
- p->setValueFromSynth(it.second, false, pluginLib::Parameter::Origin::PresetChange);
+ p->setValueFromSynth(it.second, pluginLib::Parameter::Origin::PresetChange);
for (const auto& derivedParam : p->getDerivedParameters())
- derivedParam->setValueFromSynth(it.second, false, pluginLib::Parameter::Origin::PresetChange);
+ derivedParam->setValueFromSynth(it.second, pluginLib::Parameter::Origin::PresetChange);
}
getProcessor().updateHostDisplay(juce::AudioProcessorListener::ChangeDetails().withProgramChanged(true));
@@ -307,7 +307,7 @@ bool Controller::parseSysexMessage(const pluginLib::SysEx& _msg, synthLib::MidiE
auto& params = findSynthParam(part, page, index);
for (auto& param : params)
- param->setValueFromSynth(value, true, pluginLib::Parameter::Origin::Midi);
+ param->setValueFromSynth(value, pluginLib::Parameter::Origin::Midi);
LOG("Single parameter " << static_cast<int>(index) << ", page " << static_cast<int>(page) << " for part " << static_cast<int>(part) << " changed to value " << static_cast<int>(value));
}
diff --git a/source/virusJucePlugin/VirusController.cpp b/source/virusJucePlugin/VirusController.cpp
@@ -166,10 +166,10 @@ namespace Virus
}
}
for (const auto& param : globalParams)
- param->setValueFromSynth(value, true, pluginLib::Parameter::Origin::Midi);
+ param->setValueFromSynth(value, pluginLib::Parameter::Origin::Midi);
}
for (const auto& param : partParams)
- param->setValueFromSynth(value, true, pluginLib::Parameter::Origin::Midi);
+ param->setValueFromSynth(value, pluginLib::Parameter::Origin::Midi);
// TODO:
/**
If a
@@ -454,7 +454,7 @@ namespace Virus
auto* p = getParameter(it->first.second, ch);
if(locked.find(p->getDescription().name) == locked.end())
- p->setValueFromSynth(it->second, false, pluginLib::Parameter::Origin::PresetChange);
+ p->setValueFromSynth(it->second, pluginLib::Parameter::Origin::PresetChange);
}
getProcessor().updateHostDisplay(juce::AudioProcessorListener::ChangeDetails().withProgramChanged(true));
@@ -535,7 +535,7 @@ namespace Virus
if(desc.page != virusLib::PAGE_C)
continue;
- param->setValueFromSynth(value, false, pluginLib::Parameter::Origin::PresetChange);
+ param->setValueFromSynth(value, pluginLib::Parameter::Origin::PresetChange);
}
getProcessor().updateHostDisplay(juce::AudioProcessorListener::ChangeDetails().withProgramChanged(true));
@@ -563,7 +563,7 @@ namespace Virus
const auto& params = findSynthParam(part, page, m.b);
for (const auto & p : params)
- p->setValueFromSynth(m.c, true, pluginLib::Parameter::Origin::Midi);
+ p->setValueFromSynth(m.c, pluginLib::Parameter::Origin::Midi);
return true;
}
diff --git a/source/xtJucePlugin/xtController.cpp b/source/xtJucePlugin/xtController.cpp
@@ -253,10 +253,10 @@ void Controller::applyPatchParameters(const pluginLib::MidiPacket::ParamValues&
for (const auto& it : _params)
{
auto* p = getParameter(it.first.second, _part);
- p->setValueFromSynth(it.second, false, pluginLib::Parameter::Origin::PresetChange);
+ p->setValueFromSynth(it.second, pluginLib::Parameter::Origin::PresetChange);
for (const auto& derivedParam : p->getDerivedParameters())
- derivedParam->setValueFromSynth(it.second, false, pluginLib::Parameter::Origin::PresetChange);
+ derivedParam->setValueFromSynth(it.second, pluginLib::Parameter::Origin::PresetChange);
}
getProcessor().updateHostDisplay(juce::AudioProcessorListener::ChangeDetails().withProgramChanged(true));
@@ -376,7 +376,7 @@ bool Controller::parseSysexMessage(const pluginLib::SysEx& _msg, synthLib::MidiE
auto& params = findSynthParam(part, page, index);
for (auto& param : params)
- param->setValueFromSynth(value, true, pluginLib::Parameter::Origin::Midi);
+ param->setValueFromSynth(value, pluginLib::Parameter::Origin::Midi);
LOG("Single parameter " << static_cast<int>(index) << ", page " << static_cast<int>(page) << " for part " << static_cast<int>(part) << " changed to value " << static_cast<int>(value));
}