MayaFlux 0.2.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 118 of file RootNode.cpp.

119{
120 if (!preprocess())
121 return 0.;
122
123 auto sample = 0.;
124
125 for (auto& node : m_Nodes) {
126 if (!node)
127 continue;
128
129 uint32_t state = node->m_state.load();
130 if (!(state & Utils::NodeState::PROCESSED)) {
131 auto generator = std::dynamic_pointer_cast<Nodes::Generator::Generator>(node);
132 if (generator && generator->should_mock_process()) {
133 generator->process_sample();
134 } else {
135 sample += node->process_sample();
136 }
138 } else {
139 sample += node->get_last_output();
140 }
141 }
142
143 postprocess();
144
145 return sample;
146}
std::vector< std::shared_ptr< Node > > m_Nodes
Collection of nodes registered with this root node.
Definition RootNode.hpp:159
bool preprocess()
Checks if the root node can process pending operations.
Definition RootNode.cpp:96
void postprocess()
Performs post-processing after all nodes have been processed.
Definition RootNode.cpp:164
void atomic_add_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically adds a flag to a node state.
Definition NodeUtils.cpp:96
@ PROCESSED
Node has been processed this cycle.
Definition Utils.hpp:34

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

Referenced by process_batch().

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