From 39f2d4e5464b56d5342fde77c5d6567d4b519373 Mon Sep 17 00:00:00 2001 From: Christoph Hart Date: Mon, 27 Jan 2025 21:47:38 +0100 Subject: [PATCH] - added polyphonic support to input_toggle node - fixed missing [poly] suffix to show up at control nodes in polyphonic networks --- currentGitHash.txt | 2 +- hi_backend/backend/currentGit.h | 2 +- hi_dsp_library/dsp_nodes/CableNodes.h | 82 +++++++++++++------ .../scriptnode/api/StaticNodeWrappers.h | 2 + .../node_library/HiseNodeFactory.cpp | 12 ++- 5 files changed, 68 insertions(+), 32 deletions(-) diff --git a/currentGitHash.txt b/currentGitHash.txt index bb1dfb3f4..e332ae0d5 100644 --- a/currentGitHash.txt +++ b/currentGitHash.txt @@ -1 +1 @@ -d141f8ca68142cc287297ceaffe615748f4fac02 +ea13649c90872a62dbb1326d9f44727c125914d1 diff --git a/hi_backend/backend/currentGit.h b/hi_backend/backend/currentGit.h index 76b5df073..b14ea31a1 100644 --- a/hi_backend/backend/currentGit.h +++ b/hi_backend/backend/currentGit.h @@ -1 +1 @@ -#define PREVIOUS_HISE_COMMIT "d141f8ca68142cc287297ceaffe615748f4fac02" +#define PREVIOUS_HISE_COMMIT "ea13649c90872a62dbb1326d9f44727c125914d1" diff --git a/hi_dsp_library/dsp_nodes/CableNodes.h b/hi_dsp_library/dsp_nodes/CableNodes.h index f02c9dfaf..37e63e326 100644 --- a/hi_dsp_library/dsp_nodes/CableNodes.h +++ b/hi_dsp_library/dsp_nodes/CableNodes.h @@ -245,16 +245,39 @@ namespace control AnalyserType analyser; }; - template struct input_toggle : public pimpl::parameter_node_base, - public pimpl::no_mod_normalisation, - public pimpl::no_processing + struct input_toggle_base: public mothernode { - SN_NODE_ID("input_toggle"); + virtual ~input_toggle_base() {}; + + struct Data + { + bool useValue1 = false; + double v1 = 0.0; + double v2 = 0.0; + }; + + virtual const Data& getUIData() const = 0; + + private: + + JUCE_DECLARE_WEAK_REFERENCEABLE(input_toggle_base); + }; + + template struct input_toggle : public input_toggle_base, + public pimpl::parameter_node_base, + public pimpl::no_mod_normalisation, + public polyphonic_base, + public pimpl::no_processing + { + static constexpr int NumVoices = NV; + + SN_POLY_NODE_ID("input_toggle"); SN_GET_SELF_AS_OBJECT(input_toggle); input_toggle() : pimpl::parameter_node_base(getStaticId()), - pimpl::no_mod_normalisation(getStaticId(), {"Value1", "Value2" }) + pimpl::no_mod_normalisation(getStaticId(), {"Value1", "Value2" }), + polyphonic_base(getStaticId(), false) {}; SN_DESCRIPTION("Switch between two input values as modulation signal"); @@ -274,38 +297,51 @@ namespace control }; SN_PARAMETER_MEMBER_FUNCTION; - - void setInput(double input) { - useValue1 = input < 0.5; + for(auto& d: data) + { + d.useValue1 = input < 0.5; - if (this->getParameter().isConnected()) - this->getParameter().call(useValue1 ? v1 : v2); + if (this->getParameter().isConnected()) + this->getParameter().call(d.useValue1 ? d.v1 : d.v2); + } + } void setValue1(double input) { - v1 = input; - - if (useValue1) + for(auto& d: data) { - if (this->getParameter().isConnected()) - this->getParameter().call(v1); + d.v1 = input; + + if (d.useValue1) + { + if (this->getParameter().isConnected()) + this->getParameter().call(d.v1); + } } } void setValue2(double input) { - v2 = input; - - if (!useValue1) + for(auto& d: data) { - if (this->getParameter().isConnected()) - this->getParameter().call(v2); + d.v2 = input; + + if (!d.useValue1) + { + if (this->getParameter().isConnected()) + this->getParameter().call(d.v2); + } } } + void prepare(PrepareSpecs ps) override + { + data.prepare(ps); + } + void createParameters(ParameterDataList& data) { { @@ -328,9 +364,9 @@ namespace control } } - bool useValue1 = false; - double v1 = 0.0; - double v2 = 0.0; + const Data& getUIData() const override { return data.getFirst(); } + + PolyData data; JUCE_DECLARE_WEAK_REFERENCEABLE(input_toggle); }; diff --git a/hi_scripting/scripting/scriptnode/api/StaticNodeWrappers.h b/hi_scripting/scripting/scriptnode/api/StaticNodeWrappers.h index f876a15fa..6b5271669 100644 --- a/hi_scripting/scripting/scriptnode/api/StaticNodeWrappers.h +++ b/hi_scripting/scripting/scriptnode/api/StaticNodeWrappers.h @@ -617,6 +617,8 @@ struct InterpretedCableNode : public ModulationSourceNode, this->obj.handleHiseEvent(e); } + bool isPolyphonic() const override { return this->obj.isPolyphonic(); } + private: typedef parameter::dynamic_base_holder*(*getParamFunc)(void*); diff --git a/hi_scripting/scripting/scriptnode/node_library/HiseNodeFactory.cpp b/hi_scripting/scripting/scriptnode/node_library/HiseNodeFactory.cpp index 311ecbb2b..32eaec32d 100644 --- a/hi_scripting/scripting/scriptnode/node_library/HiseNodeFactory.cpp +++ b/hi_scripting/scripting/scriptnode/node_library/HiseNodeFactory.cpp @@ -49,9 +49,9 @@ namespace scriptnode namespace control { -struct input_toggle_editor : public ScriptnodeExtraComponent> +struct input_toggle_editor : public ScriptnodeExtraComponent { - using ObjType = input_toggle; + using ObjType = input_toggle_base; input_toggle_editor(ObjType* t, PooledUIUpdater* u) : ScriptnodeExtraComponent(t, u), @@ -93,12 +93,10 @@ struct input_toggle_editor : public ScriptnodeExtraComponentuseValue1 ? 1.0f : 0.2f)); + g.setColour(c.withAlpha(getObject()->getUIData().useValue1 ? 1.0f : 0.2f)); g.fillRoundedRectangle(l, l.getHeight() / 2.0f); - g.setColour(c.withAlpha(!getObject()->useValue1 ? 1.0f : 0.2f)); + g.setColour(c.withAlpha(!getObject()->getUIData().useValue1 ? 1.0f : 0.2f)); g.fillRoundedRectangle(r, r.getHeight() / 2.0f); - - } ModulationSourceBaseComponent dragger; @@ -1319,7 +1317,7 @@ namespace control registerNoProcessNode, ModulationSourceBaseComponent>(); - registerNoProcessNode, input_toggle_editor>(); + registerPolyNoProcessNode, control::input_toggle, input_toggle_editor>(); registerNoProcessNode();