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 3a7a71d1aa7d2141b279aef2d9be8a49e761b56a
parent 80655145039cd38b3f48fa327ff681884fa02d1a
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Fri, 31 May 2024 15:25:58 +0200

soft knobs now use new event system too

Diffstat:
Msource/jucePluginLib/event.h | 7++++++-
Msource/jucePluginLib/softknob.cpp | 25++++++++++++-------------
Msource/jucePluginLib/softknob.h | 13+++++++++----
Msource/virusJucePlugin/ArpUserPattern.cpp | 2+-
4 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/source/jucePluginLib/event.h b/source/jucePluginLib/event.h @@ -192,6 +192,12 @@ namespace pluginLib return *this; } + void reset() + { + removeListener(); + } + + private: void removeListener() { if(m_listenerId == InvalidListenerId) @@ -201,7 +207,6 @@ namespace pluginLib m_listenerId = InvalidListenerId; } - private: MyEvent* m_event = nullptr; MyListenerId m_listenerId = InvalidListenerId; }; diff --git a/source/jucePluginLib/softknob.cpp b/source/jucePluginLib/softknob.cpp @@ -16,10 +16,10 @@ namespace pluginLib , m_part(_part) , m_uniqueId(g_softKnobListenerId++) { - m_param = _controller.getParameter(_parameterIndex, _part); - assert(m_param); + m_sourceParam = _controller.getParameter(_parameterIndex, _part); + assert(m_sourceParam); - const auto& desc = m_param->getDescription(); + const auto& desc = m_sourceParam->getDescription(); const auto idxTargetSelect = _controller.getParameterIndexByName(desc.softKnobTargetSelect); assert(idxTargetSelect != Controller::InvalidParameterIndex); @@ -27,12 +27,12 @@ namespace pluginLib m_targetSelect = _controller.getParameter(idxTargetSelect, _part); assert(m_targetSelect); - m_targetSelect->onValueChanged.emplace_back(m_uniqueId, [this]() + m_targetSelectListener.set(m_targetSelect->evValueChanged, [this](auto*) { onTargetChanged(); }); - m_param->onValueChanged.emplace_back(m_uniqueId, [this]() + m_sourceParamListener.set(m_sourceParam->evValueChanged,[this](auto*) { onSourceValueChanged(); }); @@ -43,8 +43,8 @@ namespace pluginLib SoftKnob::~SoftKnob() { unbind(); - m_param->removeListener(m_uniqueId); - m_targetSelect->removeListener(m_uniqueId); + m_sourceParamListener.reset(); + m_targetSelectListener.reset(); } void SoftKnob::onTargetChanged() @@ -57,7 +57,7 @@ namespace pluginLib if(!m_targetParam) return; - const auto v = m_param->getValue(); + const auto v = m_sourceParam->getValue(); m_targetParam->setValue(v, Parameter::ChangedBy::Derived); } @@ -65,14 +65,14 @@ namespace pluginLib { assert(m_targetParam); const auto v = m_targetParam->getValue(); - m_param->setValue(v, Parameter::ChangedBy::Derived); + m_sourceParam->setValue(v, Parameter::ChangedBy::Derived); } void SoftKnob::bind() { unbind(); - const auto* valueList = m_controller.getParameterDescriptions().getValueList(m_param->getDescription().softKnobTargetList); + const auto* valueList = m_controller.getParameterDescriptions().getValueList(m_sourceParam->getDescription().softKnobTargetList); if(!valueList) return; @@ -95,7 +95,7 @@ namespace pluginLib if(!m_targetParam) return; - m_targetParam->onValueChanged.emplace_back(m_uniqueId, [this]() + m_targetParamListener.set(m_targetParam->evValueChanged, [this](pluginLib::Parameter*) { onTargetValueChanged(); }); @@ -105,8 +105,7 @@ namespace pluginLib void SoftKnob::unbind() { - if(m_targetParam) - m_targetParam->removeListener(m_uniqueId); + m_targetParamListener.reset(); m_targetParam = nullptr; } } diff --git a/source/jucePluginLib/softknob.h b/source/jucePluginLib/softknob.h @@ -2,9 +2,10 @@ #include <cstdint> +#include "parameter.h" + namespace pluginLib { - class Parameter; class Controller; class SoftKnob @@ -18,10 +19,10 @@ namespace pluginLib SoftKnob& operator = (const SoftKnob&) = delete; SoftKnob& operator = (SoftKnob&&) = delete; - bool isValid() const { return m_param != nullptr && m_targetSelect != nullptr; } + bool isValid() const { return m_sourceParam != nullptr && m_targetSelect != nullptr; } bool isBound() const { return m_targetParam != nullptr; } - Parameter* getParameter() const { return m_param; } + Parameter* getParameter() const { return m_sourceParam; } Parameter* getTargetParameter() const { return m_targetParam; } private: @@ -36,8 +37,12 @@ namespace pluginLib const uint8_t m_part; const uint32_t m_uniqueId; - Parameter* m_param = nullptr; + Parameter* m_sourceParam = nullptr; Parameter* m_targetSelect = nullptr; Parameter* m_targetParam = nullptr; + + ParameterValueChangeListener m_sourceParamListener; + ParameterValueChangeListener m_targetSelectListener; + ParameterValueChangeListener m_targetParamListener; }; } diff --git a/source/virusJucePlugin/ArpUserPattern.cpp b/source/virusJucePlugin/ArpUserPattern.cpp @@ -81,7 +81,7 @@ namespace genericVirusUI void ArpUserPattern::unbindParameter(BoundParam& _parameter) { assert(_parameter.first); - _parameter.second.removeListener(); + _parameter.second.reset(); _parameter.first = nullptr; }