MayaFlux 0.2.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 229 of file NodeStructure.cpp.

230{
231 if (!m_lhs || !m_rhs) {
232 return input;
233 }
234
235 if (!is_initialized())
236 initialize();
237
238 atomic_inc_modulator_count(m_lhs->m_modulator_count, 1);
239 atomic_inc_modulator_count(m_rhs->m_modulator_count, 1);
240
241 uint32_t lstate = m_lhs->m_state.load();
242 if (lstate & Utils::NodeState::PROCESSED) {
243 m_last_lhs_value = input + m_lhs->get_last_output();
244 } else {
245 m_last_lhs_value = m_lhs->process_sample(input);
247 }
248
249 uint32_t rstate = m_rhs->m_state.load();
250 if (rstate & Utils::NodeState::PROCESSED) {
251 m_last_rhs_value = input + m_rhs->get_last_output();
252 } else {
253 m_last_rhs_value = m_rhs->process_sample(input);
255 }
256
258
261
262 atomic_dec_modulator_count(m_lhs->m_modulator_count, 1);
263 atomic_dec_modulator_count(m_rhs->m_modulator_count, 1);
264
267
268 return m_last_output;
269}
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:374
bool m_fire_events_during_snapshot
Internal flag controlling whether notify_tick fires during state snapshots Default: false (events don...
Definition Node.hpp:448
void atomic_add_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically adds a flag to a node state.
Definition NodeUtils.cpp:96
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.
@ PROCESSED
Node has been processed this cycle.
Definition Utils.hpp:34

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::Utils::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: