MayaFlux 0.4.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 425 of file NodeCombine.hpp.

426 {
427 if (!is_initialized())
428 initialize();
429
430 for (auto& node : m_inputs) {
431 atomic_inc_modulator_count(node->m_modulator_count, 1);
432 }
433
434 for (size_t i = 0; i < m_inputs.size(); ++i) {
435 uint32_t state = m_inputs[i]->m_state.load();
436 if (state & NodeState::PROCESSED) {
437 m_input_values[i] = input + m_inputs[i]->get_last_output();
438 } else {
439 m_input_values[i] = m_inputs[i]->process_sample(input);
441 }
442 }
443
444 m_last_output = m_func(std::span<const double>(m_input_values));
445
448
449 for (auto& node : m_inputs) {
450 atomic_dec_modulator_count(node->m_modulator_count, 1);
451 }
452
453 for (auto& node : m_inputs) {
455 }
456
457 return m_last_output;
458 }
Core::GlobalInputConfig input
Definition Config.cpp:36
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:405
std::atomic< NodeState > m_state
Atomic state flag tracking the node's processing status.
Definition Node.hpp:502
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, MayaFlux::is_initialized(), and MayaFlux::Nodes::try_reset_processed_state().

+ Here is the call graph for this function: