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

◆ process_sample()

double MayaFlux::Nodes::ChainNode::process_sample ( double  input = 0.)
overridevirtual

Processes a single data sample.

Parameters
inputThe input sample value
Returns
The processed output sample value

This is the core processing method that all nodes must implement. It takes a single input value, applies the node's transformation algorithm, and returns the resulting output value.

For generator nodes that don't require input (like oscillators or stochastic generators), the input parameter may be ignored. Note: This method does NOT mark the node as processed. That responsibility belongs to the caller, typically a chained parent node or the root node.

Implements MayaFlux::Nodes::Node.

Definition at line 119 of file NodeChain.cpp.

120{
121 if (m_nodes.empty())
122 return input;
123
124 if (!is_initialized())
125 initialize();
126
127 for (auto& node : m_nodes) {
128 atomic_inc_modulator_count(node->m_modulator_count, 1);
129 }
130
131 m_last_output = input;
132
133 for (auto& node : m_nodes) {
134 uint32_t state = node->m_state.load();
135 if (state & NodeState::PROCESSED) {
136 m_last_output += node->get_last_output();
137 } else {
138 m_last_output = node->process_sample(m_last_output);
140 }
141 }
142
143 for (auto& node : m_nodes) {
144 atomic_dec_modulator_count(node->m_modulator_count, 1);
145 }
146
147 for (auto& node : m_nodes) {
149 }
150
151 return m_last_output;
152}
std::vector< std::shared_ptr< Node > > m_nodes
void initialize()
Initializes the chain node.
Definition NodeChain.cpp:75
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:377
@ 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
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_dec_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically decrements the modulator count by a specified amount.

References MayaFlux::Nodes::atomic_add_flag(), MayaFlux::Nodes::atomic_dec_modulator_count(), MayaFlux::Nodes::atomic_inc_modulator_count(), initialize(), is_initialized(), MayaFlux::Nodes::Node::m_last_output, m_nodes, MayaFlux::Nodes::PROCESSED, and MayaFlux::Nodes::try_reset_processed_state().

Referenced by process_batch().

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