Skip to content

Commit

Permalink
- added polyphonic support to input_toggle node
Browse files Browse the repository at this point in the history
- fixed missing [poly] suffix to show up at control nodes in polyphonic networks
  • Loading branch information
christoph-hart committed Jan 27, 2025
1 parent ea13649 commit 39f2d4e
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 32 deletions.
2 changes: 1 addition & 1 deletion currentGitHash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d141f8ca68142cc287297ceaffe615748f4fac02
ea13649c90872a62dbb1326d9f44727c125914d1
2 changes: 1 addition & 1 deletion hi_backend/backend/currentGit.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define PREVIOUS_HISE_COMMIT "d141f8ca68142cc287297ceaffe615748f4fac02"
#define PREVIOUS_HISE_COMMIT "ea13649c90872a62dbb1326d9f44727c125914d1"
82 changes: 59 additions & 23 deletions hi_dsp_library/dsp_nodes/CableNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,39 @@ namespace control
AnalyserType analyser;
};

template <typename ParameterClass> struct input_toggle : public pimpl::parameter_node_base<ParameterClass>,
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 <int NV, typename ParameterClass> struct input_toggle : public input_toggle_base,
public pimpl::parameter_node_base<ParameterClass>,
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<ParameterClass>(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");
Expand All @@ -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)
{
{
Expand All @@ -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, NV> data;

JUCE_DECLARE_WEAK_REFERENCEABLE(input_toggle);
};
Expand Down
2 changes: 2 additions & 0 deletions hi_scripting/scripting/scriptnode/api/StaticNodeWrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ namespace scriptnode
namespace control
{

struct input_toggle_editor : public ScriptnodeExtraComponent<input_toggle<parameter::dynamic_base_holder>>
struct input_toggle_editor : public ScriptnodeExtraComponent<input_toggle_base>
{
using ObjType = input_toggle<parameter::dynamic_base_holder>;
using ObjType = input_toggle_base;

input_toggle_editor(ObjType* t, PooledUIUpdater* u) :
ScriptnodeExtraComponent<ObjType>(t, u),
Expand Down Expand Up @@ -93,12 +93,10 @@ struct input_toggle_editor : public ScriptnodeExtraComponent<input_toggle<parame
if (c == Colours::transparentBlack)
c = Colour(0xFFADADAD);

g.setColour(c.withAlpha(getObject()->useValue1 ? 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;
Expand Down Expand Up @@ -1319,7 +1317,7 @@ namespace control

registerNoProcessNode<control::random<parameter::dynamic_base_holder>, ModulationSourceBaseComponent>();

registerNoProcessNode<control::input_toggle<parameter::dynamic_base_holder>, input_toggle_editor>();
registerPolyNoProcessNode<control::input_toggle<1, parameter::dynamic_base_holder>, control::input_toggle<NUM_POLYPHONIC_VOICES, parameter::dynamic_base_holder>, input_toggle_editor>();

registerNoProcessNode<conversion_logic::dynamic::NodeType, conversion_logic::dynamic::editor>();

Expand Down

0 comments on commit 39f2d4e

Please sign in to comment.