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

◆ process_sample()

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

Processes a single sample.

Parameters
inputInput value
Returns
The next sample value from the polynomial function

Computes the next output value based on the polynomial function and current mode.

Implements MayaFlux::Nodes::Node.

Definition at line 54 of file Polynomial.cpp.

55{
56 double result = 0.0;
57
58 if (m_input_node) {
59 atomic_inc_modulator_count(m_input_node->m_modulator_count, 1);
60 uint32_t state = m_input_node->m_state.load();
61 if (state & NodeState::PROCESSED) {
62 input += m_input_node->get_last_output();
63 } else {
64 input = m_input_node->process_sample(input);
66 }
67 }
68
69 switch (m_mode) {
72 break;
73
75 if (m_buffer_size > 0) {
76 std::span<double> view;
77
80 } else {
83 }
84
85 result = m_buffer_function(view);
86
88 }
89 break;
90
92 if (m_buffer_size > 0) {
93 std::span<double> view;
94
97 } else {
100 }
101
102 result = m_buffer_function(view);
103 }
104 break;
105 }
106
107 result *= m_scale_factor;
108
109 m_last_output = result;
110
112 && !m_networked_node) {
113 notify_tick(result);
114 }
115
116 if (m_input_node) {
117 atomic_dec_modulator_count(m_input_node->m_modulator_count, 1);
119 }
120
121 return result;
122}
Core::GlobalInputConfig input
Definition Config.cpp:42
std::span< T > linearized_view()
Get mutable linearized view of entire history.
void overwrite_newest(const T &value)
Overwrite the newest element without advancing position.
void push(const T &value)
Push new value to front of history.
void notify_tick(double value) override
Notifies all registered callbacks with the current context.
Definition Generator.cpp:56
PolynomialMode m_mode
Current processing mode.
static double power_sum(const std::vector< double > &coefficients, double x) noexcept
Evaluates the coefficient list at x, highest power first.
Memory::HistoryBuffer< double > m_history
Ring buffer for input/output history.
double m_scale_factor
Scaling factor for output.
std::span< double > m_external_buffer_context
View into external buffer.
std::span< double > external_context_view(double input)
size_t m_buffer_size
Maximum size of the buffers.
BufferFunction m_buffer_function
Function for recursive/feedforward mode.
bool m_coef_direct
True while DIRECT output is evaluated from m_coefficients.
std::shared_ptr< Node > m_input_node
Input node for processing.
DirectFunction m_direct_function
Function for direct mode.
std::vector< double > m_coefficients
Polynomial coefficients (if using coefficient-based definition)
bool m_state_saved
tracks if the node's state has been saved by a snapshot operation
Definition Node.hpp:498
bool m_networked_node
Flag indicating if the node is part of a NodeNetwork This flag is used to disable event firing when t...
Definition Node.hpp:493
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:441
bool m_fire_events_during_snapshot
Internal flag controlling whether notify_tick fires during state snapshots Default: false (events don...
Definition Node.hpp:528
@ RECURSIVE
Evaluates using current and previous outputs: y[n] = f(y[n-1], y[n-2], ...)
@ DIRECT
Evaluates f(x) where x is the current phase/input.
@ FEEDFORWARD
Evaluates using current and previous inputs: y[n] = f(x[n], x[n-1], ...)
@ PROCESSED
Node has been processed this cycle.
Definition NodeSpec.hpp:49
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.
void atomic_add_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically adds a flag to a node state.

References MayaFlux::Nodes::atomic_add_flag(), MayaFlux::Nodes::atomic_dec_modulator_count(), MayaFlux::Nodes::atomic_inc_modulator_count(), MayaFlux::Nodes::Generator::DIRECT, external_context_view(), MayaFlux::Nodes::Generator::FEEDFORWARD, input, MayaFlux::Memory::HistoryBuffer< T >::linearized_view(), m_buffer_function, m_buffer_size, m_coef_direct, m_coefficients, m_direct_function, m_external_buffer_context, MayaFlux::Nodes::Node::m_fire_events_during_snapshot, m_history, m_input_node, MayaFlux::Nodes::Node::m_last_output, m_mode, MayaFlux::Nodes::Node::m_networked_node, m_scale_factor, MayaFlux::Nodes::Node::m_state_saved, m_use_external_context, MayaFlux::Nodes::Generator::Generator::notify_tick(), MayaFlux::Memory::HistoryBuffer< T >::overwrite_newest(), power_sum(), MayaFlux::Nodes::PROCESSED, MayaFlux::Memory::HistoryBuffer< T >::push(), MayaFlux::Nodes::Generator::RECURSIVE, 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: