10 : m_nodes(
std::move(nodes))
13 error<std::invalid_argument>(
15 std::source_location::current(),
16 "ChainNode requires at least 2 nodes, got {}",
m_nodes.size());
19 for (
size_t i = 0; i <
m_nodes.size(); ++i) {
21 error<std::invalid_argument>(
23 std::source_location::current(),
24 "ChainNode node at index {} is null", i);
30 std::vector<std::shared_ptr<Node>> nodes,
40 const std::shared_ptr<Node>& source,
41 const std::shared_ptr<Node>& target)
47 const std::shared_ptr<Node>& source,
48 const std::shared_ptr<Node>& target,
60 error<std::invalid_argument>(
62 std::source_location::current(),
63 "Cannot append null node to ChainNode");
71 std::make_move_iterator(other->m_nodes.begin()),
72 std::make_move_iterator(other->m_nodes.end()));
134 uint32_t state = node->m_state.load();
156 std::vector<double> output(num_samples);
157 for (
size_t i = 0; i < num_samples; i++) {
168 node->reset_processed_state();
185 node->restore_state();
193 auto state = node->m_state.load();
204 error<std::runtime_error>(
206 std::source_location::current(),
207 "ChainNode has no nodes when retrieving last context");
209 return m_nodes.back()->get_last_context();
NodeContext & get_last_context() override
Retrieves the last created context object.
std::vector< std::shared_ptr< Node > > m_nodes
void initialize()
Initializes the chain node.
void append_chain(const std::shared_ptr< ChainNode > &other)
Appends all nodes from another chain.
std::vector< double > process_batch(unsigned int num_samples) override
Processes multiple samples at once.
double process_sample(double input=0.) override
Processes a single data sample.
void restore_state() override
Restores the node's state from the last save Recursively cascades through all connected modulator nod...
ChainNode(std::vector< std::shared_ptr< Node > > nodes)
Creates a chain from an ordered sequence of nodes.
void save_state() override
Saves the node's current state for later restoration Recursively cascades through all connected modul...
void reset_processed_state() override
Resets the processed state of the node and any attached input nodes.
NodeGraphManager * m_manager
void append(const std::shared_ptr< Node > &node)
Appends a node to the end of the chain.
bool is_initialized() const
Connects an ordered sequence of nodes in series.
Base context class for node callbacks.
void add_to_root(const std::shared_ptr< Node > &node, ProcessingToken token, unsigned int channel=0)
Add node to specific processing token and channel.
void remove_from_root(const std::shared_ptr< Node > &node, ProcessingToken token, unsigned int channel=0)
Remove node from a specific processing token and channel.
NodeConfig & get_node_config()
Gets the current node configuration.
Central manager for the computational processing node graph.
double m_last_output
The most recent sample value generated by this oscillator.
std::atomic< NodeState > m_state
Atomic state flag tracking the node's processing status.
Base interface for all computational processing nodes.
@ Init
Engine/subsystem initialization.
@ Runtime
General runtime operations (default fallback)
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.
@ PROCESSED
Node has been processed this cycle.
@ ACTIVE
Engine is processing this node.
ProcessingToken
Enumerates the different processing domains for nodes.
void atomic_add_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically adds a flag to a node state.
std::vector< uint32_t > get_active_channels(const std::shared_ptr< Nodes::Node > &node, uint32_t fallback_channel)
Extracts active channel list from a node's channel mask.
@ PRESERVE_BOTH
Preserve both nodes in the chain, add new chain node to root, i.e doubling the target signal.
@ ONLY_CHAIN
Only keep the new chain node, unregistering the source and target.
@ REPLACE_TARGET
Unregister the target and register with the new chain node.
void try_reset_processed_state(std::shared_ptr< Node > node)
Attempts to reset the processed state of a node.
void atomic_inc_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically increments the modulator count by a specified amount.
void atomic_remove_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically removes a flag from a node state.
void atomic_dec_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically decrements the modulator count by a specified amount.
Contains the node-based computational processing system components.
NodeChainSemantics chain_semantics