MayaFlux 0.3.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 109 of file RootNode.cpp.

110{
111 if (!preprocess())
112 return 0.;
113
114 auto sample = 0.;
115
116 for (auto& node : m_Nodes) {
117 if (!node)
118 continue;
119
120 uint32_t state = node->m_state.load();
121 double node_output = 0.0;
122
123 if (!(state & NodeState::PROCESSED)) {
124 auto generator = std::dynamic_pointer_cast<Nodes::Generator::Generator>(node);
125 if (generator && generator->should_mock_process()) {
126 generator->process_sample();
127 } else {
128 node_output = node->process_sample();
129 }
131 } else {
132 node_output = node->get_last_output();
133 }
134
135 if (node->needs_channel_routing()) {
136 node_output *= node->get_routing_state().amount[m_channel];
137 }
138
139 sample += node_output;
140 }
141
142 postprocess();
143
144 return sample;
145}
std::vector< std::shared_ptr< Node > > m_Nodes
Collection of nodes registered with this root node.
Definition RootNode.hpp:159
uint32_t m_channel
The processing channel index for this root node.
Definition RootNode.hpp:229
bool preprocess()
Checks if the root node can process pending operations.
Definition RootNode.cpp:87
void postprocess()
Performs post-processing after all nodes have been processed.
Definition RootNode.cpp:163
@ 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.
Definition NodeUtils.cpp:94

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: