MayaFlux 0.4.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 104 of file NodeCombine.cpp.

105{
106 if (!m_lhs || !m_rhs) {
107 return input;
108 }
109
110 if (!is_initialized())
111 initialize();
112
113 atomic_inc_modulator_count(m_lhs->m_modulator_count, 1);
114 atomic_inc_modulator_count(m_rhs->m_modulator_count, 1);
115
116 uint32_t lstate = m_lhs->m_state.load();
117 if (lstate & NodeState::PROCESSED) {
118 m_last_lhs_value = input + m_lhs->get_last_output();
119 } else {
120 m_last_lhs_value = m_lhs->process_sample(input);
122 }
123
124 uint32_t rstate = m_rhs->m_state.load();
125 if (rstate & NodeState::PROCESSED) {
126 m_last_rhs_value = input + m_rhs->get_last_output();
127 } else {
128 m_last_rhs_value = m_rhs->process_sample(input);
130 }
131
133
136
137 atomic_dec_modulator_count(m_lhs->m_modulator_count, 1);
138 atomic_dec_modulator_count(m_rhs->m_modulator_count, 1);
139
142
143 return m_last_output;
144}
Core::GlobalInputConfig input
Definition Config.cpp:36
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:405
bool m_fire_events_during_snapshot
Internal flag controlling whether notify_tick fires during state snapshots Default: false (events don...
Definition Node.hpp:487
@ 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:60
void try_reset_processed_state(std::shared_ptr< Node > node)
Attempts to reset the processed state of a node.
Definition NodeUtils.cpp:97
void atomic_inc_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically increments the modulator count by a specified amount.
Definition NodeUtils.cpp:87
void atomic_dec_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically decrements the modulator count by a specified amount.
Definition NodeUtils.cpp:92

References MayaFlux::Nodes::atomic_add_flag(), MayaFlux::Nodes::atomic_dec_modulator_count(), MayaFlux::Nodes::atomic_inc_modulator_count(), initialize(), input, 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: