Skip to content

Commit

Permalink
Refactor and tidy up granulation nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Jan 22, 2024
1 parent 35b83e5 commit c0dca0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion source/include/signalflow/node/buffer/segment-player.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class SegmentPlayer : public Node
SegmentPlayer(BufferRef buffer = nullptr,
std::vector<float> onsets = {},
NodeRef index = nullptr,
NodeRef rate = 1.0);
NodeRef rate = 1.0,
NodeRef clock = nullptr);

virtual void process(Buffer &out, int num_frames) override;
virtual void trigger(std::string name = SIGNALFLOW_DEFAULT_TRIGGER, float value = 1.0) override;
Expand All @@ -32,6 +33,7 @@ class SegmentPlayer : public Node
NodeRef index;
NodeRef rate;
float rate_scale_factor;
NodeRef clock;
};

REGISTER(SegmentPlayer, "segment-player")
Expand Down
10 changes: 8 additions & 2 deletions source/src/node/buffer/segment-player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
namespace signalflow
{

SegmentPlayer::SegmentPlayer(BufferRef buffer, std::vector<float> onsets, NodeRef index, NodeRef rate)
: buffer(buffer), index(index), rate(rate)
SegmentPlayer::SegmentPlayer(BufferRef buffer, std::vector<float> onsets, NodeRef index, NodeRef rate, NodeRef clock)
: buffer(buffer), index(index), rate(rate), clock(clock)
{
this->name = "segment-player";

Expand All @@ -18,6 +18,7 @@ SegmentPlayer::SegmentPlayer(BufferRef buffer, std::vector<float> onsets, NodeRe
this->set_property("onsets", onsets);
this->create_input("index", this->index);
this->create_input("rate", this->rate);
this->create_input("clock", this->clock);

this->rate_scale_factor = 1.0;
this->phase = 0.0;
Expand Down Expand Up @@ -66,6 +67,11 @@ void SegmentPlayer::process(Buffer &out, int num_frames)

void SegmentPlayer::trigger(std::string name, float value)
{
/*--------------------------------------------------------------------------------
* TODO: How to honour `value` here, if specified?
* Perhaps the default should be a null value, that gets ignored in favour
* of `index` if not specified.
*--------------------------------------------------------------------------------*/
if (name == SIGNALFLOW_DEFAULT_TRIGGER)
{
PropertyRef onsetsref = this->get_property("onsets");
Expand Down

0 comments on commit c0dca0b

Please sign in to comment.