MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ process_sample()

double MayaFlux::Nodes::RootNode::process_sample ( )

Processes a single sample from all registered nodes.

Returns
Combined output sample from all nodes

This method processes each registered node and combines their outputs into a single sample. It is typically called in a loop to process multiple samples, but can also be used for single-sample processing.

Definition at line 73 of file RootNode.cpp.

74{
75 if (!preprocess())
76 return 0.;
77
78 auto sample = 0.;
79
80 for (auto& node : m_Nodes) {
81 if (!node)
82 continue;
83
84 uint32_t state = node->m_state.load();
85 double node_output = 0.0;
86
87 if (!(state & NodeState::PROCESSED)) {
88 node_output = node->process_sample();
90 } else {
91 node_output = node->get_last_output();
92 }
93
94 if (node->is_output_excluded_from_graph()) {
95 continue;
96 }
97
98 if (node->needs_channel_routing()) {
99 node_output *= node->get_routing_state().amount[m_channel];
100 }
101
102 sample += node_output;
103 }
104
105 postprocess();
106
107 return sample;
108}
std::vector< std::shared_ptr< Node > > m_Nodes
Collection of nodes registered with this root node.
Definition RootNode.hpp:166
uint32_t m_channel
The processing channel index for this root node.
Definition RootNode.hpp:236
bool preprocess()
Checks if the root node can process pending operations.
Definition RootNode.cpp:51
void postprocess()
Performs post-processing after all nodes have been processed.
Definition RootNode.cpp:126
@ PROCESSED
Node has been processed this cycle.
Definition NodeSpec.hpp:49
void atomic_add_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically adds a flag to a node state.

References MayaFlux::Nodes::atomic_add_flag(), m_channel, m_Nodes, postprocess(), preprocess(), and MayaFlux::Nodes::PROCESSED.

Referenced by process_batch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: