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

◆ process_sample()

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

Processes a single sample through the chain.

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

The input is first processed by the source node, and the result is then processed by the target node.

Implements MayaFlux::Nodes::Node.

Definition at line 64 of file NodeStructure.cpp.

65{
66 if (!m_Source || !m_Target) {
67 return input;
68 }
69 if (!is_initialized())
70 initialize();
71
72 atomic_inc_modulator_count(m_Source->m_modulator_count, 1);
73 atomic_inc_modulator_count(m_Target->m_modulator_count, 1);
74
75 m_last_output = input;
76
77 uint32_t sstate = m_Source->m_state.load();
78 if (sstate & Utils::NodeState::PROCESSED) {
79 m_last_output = input + m_Source->get_last_output();
80 } else {
81 m_last_output = m_Source->process_sample(input);
83 }
84
85 uint32_t tstate = m_Target->m_state.load();
86 if (tstate & Utils::NodeState::PROCESSED) {
87 m_last_output += m_Target->get_last_output();
88 } else {
89 m_last_output = m_Target->process_sample(m_last_output);
90 tstate = tstate | Utils::NodeState::PROCESSED;
92 }
93
94 atomic_dec_modulator_count(m_Source->m_modulator_count, 1);
95 atomic_dec_modulator_count(m_Target->m_modulator_count, 1);
96
99
100 return m_last_output;
101}
std::shared_ptr< Node > m_Source
The upstream node that processes input first.
std::shared_ptr< Node > m_Target
The downstream node that processes the source's output.
void initialize()
Initializes the chain node.
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:374
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_last_output, m_Source, m_Target, 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: