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

◆ process_sample()

template<size_t N = 0>
double MayaFlux::Nodes::CompositeOpNode< N >::process_sample ( double  input = 0.)
inlineoverridevirtual

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 419 of file NodeCombine.hpp.

420 {
421 if (!is_initialized())
422 initialize();
423
424 for (auto& node : m_inputs) {
425 atomic_inc_modulator_count(node->m_modulator_count, 1);
426 }
427
428 for (size_t i = 0; i < m_inputs.size(); ++i) {
429 uint32_t state = m_inputs[i]->m_state.load();
430 if (state & NodeState::PROCESSED) {
431 m_input_values[i] = input + m_inputs[i]->get_last_output();
432 } else {
433 m_input_values[i] = m_inputs[i]->process_sample(input);
435 }
436 }
437
438 m_last_output = m_func(std::span<const double>(m_input_values));
439
442
443 for (auto& node : m_inputs) {
444 atomic_dec_modulator_count(node->m_modulator_count, 1);
445 }
446
447 for (auto& node : m_inputs) {
449 }
450
451 return m_last_output;
452 }
std::vector< double > m_input_values
void notify_tick(double value) override
Notifies all registered callbacks with the current context.
std::vector< std::shared_ptr< Node > > m_inputs
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:377
std::atomic< NodeState > m_state
Atomic state flag tracking the node's processing status.
Definition Node.hpp:468
bool m_fire_events_during_snapshot
Internal flag controlling whether notify_tick fires during state snapshots Default: false (events don...
Definition Node.hpp:453
@ 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(), MayaFlux::is_initialized(), and MayaFlux::Nodes::try_reset_processed_state().

+ Here is the call graph for this function: