gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit 362e12a8abb3e35b31356596934339e9a841d8a2
parent 2c0dda8b46a0ff81fd803039f5b867d7173f8bdd
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Sat,  8 Jun 2024 02:20:46 +0200

do not apply link source to target when establishing links as part of a DAW state reload

Diffstat:
Msource/jucePluginEditorLib/pluginEditor.cpp | 2+-
Msource/jucePluginLib/parameterlink.cpp | 10+++++-----
Msource/jucePluginLib/parameterlink.h | 4++--
Msource/jucePluginLib/parameterlinks.cpp | 18+++++++++---------
Msource/jucePluginLib/parameterlinks.h | 6+++---
5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/source/jucePluginEditorLib/pluginEditor.cpp b/source/jucePluginEditorLib/pluginEditor.cpp @@ -390,7 +390,7 @@ namespace jucePluginEditorLib if(isLinked) links.unlinkRegion(regionId, currentPart, p); else - links.linkRegion(regionId, currentPart, p); + links.linkRegion(regionId, currentPart, p, true); }); } diff --git a/source/jucePluginLib/parameterlink.cpp b/source/jucePluginLib/parameterlink.cpp @@ -5,7 +5,7 @@ namespace pluginLib { - ParameterLink::ParameterLink(Parameter* _source, Parameter* _dest) : m_source(_source), m_sourceListener(_source) + ParameterLink::ParameterLink(Parameter* _source, Parameter* _dest, bool _applyCurrentSourceToTarget) : m_source(_source), m_sourceListener(_source) { m_sourceValue = _source->getUnnormalizedValue(); @@ -15,7 +15,7 @@ namespace pluginLib }; _source->setLinkState(Source); - add(_dest); + add(_dest, _applyCurrentSourceToTarget); } ParameterLink::~ParameterLink() @@ -23,8 +23,7 @@ namespace pluginLib m_source->clearLinkState(Source); } - // ReSharper disable once CppParameterMayBeConstPtrOrRef - bool ParameterLink::add(Parameter* _target) + bool ParameterLink::add(Parameter* _target, bool _applyCurrentSourceToTarget) { if(!_target) return false; @@ -32,7 +31,8 @@ namespace pluginLib if(!m_targets.insert(_target).second) return false; - _target->setUnnormalizedValue(m_sourceValue, Parameter::Origin::Ui); + if(_applyCurrentSourceToTarget) + _target->setUnnormalizedValue(m_sourceValue, Parameter::Origin::Ui); return true; } diff --git a/source/jucePluginLib/parameterlink.h b/source/jucePluginLib/parameterlink.h @@ -11,10 +11,10 @@ namespace pluginLib class ParameterLink { public: - ParameterLink(Parameter* _source, Parameter* _dest); + ParameterLink(Parameter* _source, Parameter* _dest, bool _applyCurrentSourceToTarget); ~ParameterLink(); - bool add(Parameter* _target); + bool add(Parameter* _target, bool _applyCurrentSourceToTarget); bool remove(Parameter* _target); bool empty() const { return m_targets.empty(); } diff --git a/source/jucePluginLib/parameterlinks.cpp b/source/jucePluginLib/parameterlinks.cpp @@ -8,7 +8,7 @@ namespace pluginLib { } - bool ParameterLinks::add(Parameter* _source, Parameter* _dest) + bool ParameterLinks::add(Parameter* _source, Parameter* _dest, bool _applyCurrentSourceToTarget) { if(!_source || !_dest) return false; @@ -19,9 +19,9 @@ namespace pluginLib const auto it = m_parameterLinks.find(_source); if(it != m_parameterLinks.end()) - return it->second->add(_dest); + return it->second->add(_dest, _applyCurrentSourceToTarget); - m_parameterLinks.insert({_source, std::make_unique<ParameterLink>(_source, _dest)}); + m_parameterLinks.insert({_source, std::make_unique<ParameterLink>(_source, _dest, _applyCurrentSourceToTarget)}); m_destToSource[_dest].insert(_source); _dest->setLinkState(Target); @@ -90,7 +90,7 @@ namespace pluginLib return result; } - bool ParameterLinks::linkRegion(const std::string& _regionId, const uint8_t _partSource, const uint8_t _partDest) + bool ParameterLinks::linkRegion(const std::string& _regionId, const uint8_t _partSource, const uint8_t _partDest, bool _applyCurrentSourceToTarget) { const auto& regions = m_controller.getParameterDescriptions().getRegions(); @@ -104,7 +104,7 @@ namespace pluginLib if(!m_linkedRegions.insert(link).second) return false; - return updateRegionLinks(itRegion->second, _partSource, _partDest, true); + return updateRegionLinks(itRegion->second, _partSource, _partDest, true, _applyCurrentSourceToTarget); } bool ParameterLinks::unlinkRegion(const std::string& _regionId, const uint8_t _partSource, const uint8_t _partDest) @@ -121,7 +121,7 @@ namespace pluginLib if(itRegion == regions.end()) return false; - return updateRegionLinks(itRegion->second, _partSource, _partDest, false); + return updateRegionLinks(itRegion->second, _partSource, _partDest, false, false); } bool ParameterLinks::isRegionLinked(const std::string& _regionId, const uint8_t _partSource, const uint8_t _partDest) const @@ -159,12 +159,12 @@ namespace pluginLib const auto sourcePart = _binaryStream.read<uint8_t>(); const auto destPart = _binaryStream.read<uint8_t>(); - linkRegion(regionId, sourcePart, destPart); + linkRegion(regionId, sourcePart, destPart, false); } }); } - bool ParameterLinks::updateRegionLinks(const ParameterRegion& _region, const uint8_t _partSource, const uint8_t _partDest, const bool _enableLink) + bool ParameterLinks::updateRegionLinks(const ParameterRegion& _region, const uint8_t _partSource, const uint8_t _partDest, const bool _enableLink, const bool _applyCurrentSourceToTarget) { bool res = false; @@ -174,7 +174,7 @@ namespace pluginLib auto* paramDest = m_controller.getParameter(name, _partDest); if(_enableLink) - res |= add(paramSource, paramDest); + res |= add(paramSource, paramDest, _applyCurrentSourceToTarget); else res |= remove(paramSource, paramDest); } diff --git a/source/jucePluginLib/parameterlinks.h b/source/jucePluginLib/parameterlinks.h @@ -17,12 +17,12 @@ namespace pluginLib public: ParameterLinks(Controller& _controller); - bool add(Parameter* _source, Parameter* _dest); + bool add(Parameter* _source, Parameter* _dest, bool _applyCurrentSourceToTarget); bool remove(const Parameter* _source, Parameter* _dest); ParameterLinkType getRegionLinkType(const std::string& _regionId, uint8_t _part) const; - bool linkRegion(const std::string& _regionId, uint8_t _partSource, uint8_t _partDest); + bool linkRegion(const std::string& _regionId, uint8_t _partSource, uint8_t _partDest, bool _applyCurrentSourceToTarget); bool unlinkRegion(const std::string& _regionId, uint8_t _partSource, uint8_t _partDest); bool isRegionLinked(const std::string& _regionId, uint8_t _partSource, uint8_t _partDest) const; @@ -52,7 +52,7 @@ namespace pluginLib } }; - bool updateRegionLinks(const ParameterRegion& _region, uint8_t _partSource, uint8_t _partDest, bool _enableLink); + bool updateRegionLinks(const ParameterRegion& _region, uint8_t _partSource, uint8_t _partDest, bool _enableLink, bool _applyCurrentSourceToTarget); Controller& m_controller; std::map<const Parameter*, std::unique_ptr<ParameterLink>> m_parameterLinks;