-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TriggerRoundRobin node; because this requires an ordered sequence…
…, store Node outputs as a vector, not a set
- Loading branch information
Showing
11 changed files
with
112 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
source/include/signalflow/node/sequencing/trigger-round-robin.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "signalflow/core/constants.h" | ||
#include "signalflow/node/node.h" | ||
|
||
namespace signalflow | ||
{ | ||
|
||
/**--------------------------------------------------------------------------------* | ||
* Relay trigger() events to a single node from the list of connected outputs, | ||
* with `direction` determining the direction: 1 (or above) = move forwards by N, | ||
* -1 = move backwards by N, 0 = stationary. | ||
*---------------------------------------------------------------------------------*/ | ||
class TriggerRoundRobin : public Node | ||
{ | ||
|
||
public: | ||
TriggerRoundRobin(NodeRef direction = 1); | ||
|
||
virtual void process(Buffer &out, int num_frames) override; | ||
virtual void trigger(std::string = SIGNALFLOW_DEFAULT_TRIGGER, | ||
float value = SIGNALFLOW_NULL_FLOAT) override; | ||
|
||
private: | ||
unsigned int current_output_index = 0; | ||
NodeRef direction; | ||
}; | ||
|
||
REGISTER(TriggerRoundRobin, "trigger-round-robin") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "signalflow/node/sequencing/trigger-round-robin.h" | ||
#include <math.h> | ||
|
||
namespace signalflow | ||
{ | ||
|
||
TriggerRoundRobin::TriggerRoundRobin(NodeRef direction) | ||
: Node(), direction(direction) | ||
{ | ||
this->name = "trigger-round-robin"; | ||
this->create_input("direction", this->direction); | ||
} | ||
|
||
void TriggerRoundRobin::process(Buffer &out, int num_frames) | ||
{ | ||
for (int channel = 0; channel < this->num_output_channels; channel++) | ||
{ | ||
for (int frame = 0; frame < num_frames; frame++) | ||
{ | ||
out[channel][frame] = 0.0; | ||
} | ||
} | ||
} | ||
|
||
void TriggerRoundRobin::trigger(std::string name, float value) | ||
{ | ||
for (size_t index = 0; index < this->outputs.size(); index++) | ||
{ | ||
if (index == current_output_index) | ||
{ | ||
int direction = this->direction->out[0][0]; | ||
auto output_node = this->outputs[index].first; | ||
output_node->trigger(name, value); | ||
this->current_output_index = (this->current_output_index + direction) % outputs.size(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters