Skip to content

Commit

Permalink
- add random mode to control.midi node
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Hart committed Dec 23, 2023
1 parent a81cdc5 commit b39544e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
19 changes: 19 additions & 0 deletions hi_dsp_library/dsp_basics/logic_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,25 @@ template <int Unused> struct gate
}
};

template <int Unused> struct random
{
SN_EMPTY_PREPARE;
SN_EMPTY_INITIALISE;

bool getMidiValue(HiseEvent& e, double& v)
{
if (e.isNoteOn())
{
v = r.nextDouble();
return true;
}

return false;
}

Random r;
};

template <int Unused> struct velocity
{
SN_EMPTY_PREPARE;
Expand Down
4 changes: 3 additions & 1 deletion hi_scripting/scripting/scriptnode/snex_nodes/SnexMidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ bool dynamic::getMidiValueWrapped(HiseEvent& e, double& v)
return notenumber<0>().getMidiValue(e, v);
case Mode::Frequency:
return frequency<0>().getMidiValue(e, v);

case Mode::Random:
return random<0>().getMidiValue(e, v);

case Mode::Custom:
{
#if HISE_INCLUDE_SNEX
Expand Down
3 changes: 2 additions & 1 deletion hi_scripting/scripting/scriptnode/snex_nodes/SnexMidi.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@ struct dynamic : public OptionalSnexSource
Velocity,
NoteNumber,
Frequency,
Random,
Custom
};

static StringArray getModes()
{
return { "Gate", "Velocity", "NoteNumber", "Frequency", "Custom" };
return { "Gate", "Velocity", "NoteNumber", "Frequency", "Random", "Custom" };
}

String getEmptyText(const Identifier& id) const override;
Expand Down

0 comments on commit b39544e

Please sign in to comment.