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

◆ process_sample()

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

Processes a single sample through both nodes and combines the results.

Parameters
inputThe input sample
Returns
The combined output after processing through both nodes

The input is processed by both the left and right nodes, and their outputs are combined using the specified function.

Implements MayaFlux::Nodes::Node.

Definition at line 106 of file NodeCombine.cpp.

107{
108 if (!m_lhs || !m_rhs) {
109 return input;
110 }
111
112 if (!is_initialized())
113 initialize();
114
115 atomic_inc_modulator_count(m_lhs->m_modulator_count, 1);
116 atomic_inc_modulator_count(m_rhs->m_modulator_count, 1);
117
118 uint32_t lstate = m_lhs->m_state.load();
119 if (lstate & NodeState::PROCESSED) {
120 m_last_lhs_value = input + m_lhs->get_last_output();
121 } else {
122 m_last_lhs_value = m_lhs->process_sample(input);
124 }
125
126 uint32_t rstate = m_rhs->m_state.load();
127 if (rstate & NodeState::PROCESSED) {
128 m_last_rhs_value = input + m_rhs->get_last_output();
129 } else {
130 m_last_rhs_value = m_rhs->process_sample(input);
132 }
133
135
138
139 atomic_dec_modulator_count(m_lhs->m_modulator_count, 1);
140 atomic_dec_modulator_count(m_rhs->m_modulator_count, 1);
141
144
145 return m_last_output;
146}
void initialize()
Initializes the binary operation node.
void notify_tick(double value) override
Notifies all registered callbacks about a new output value.
std::shared_ptr< Node > m_lhs
The left-hand side node.
CombineFunc m_func
The function used to combine the outputs of both nodes.
double m_last_rhs_value
The last output value from the right-hand side node.
double m_last_lhs_value
The last output value from the left-hand side node.
std::shared_ptr< Node > m_rhs
The right-hand side node.
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:377
bool m_fire_events_during_snapshot
Internal flag controlling whether notify_tick fires during state snapshots Default: false (events don...
Definition Node.hpp:455
@ 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_fire_events_during_snapshot, m_func, m_last_lhs_value, MayaFlux::Nodes::Node::m_last_output, m_last_rhs_value, m_lhs, m_rhs, m_state_saved, notify_tick(), 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: