10 , m_is_initialized(false)
17 auto self = shared_from_this();
69 uint32_t sstate =
m_Source->m_state.load();
77 uint32_t tstate =
m_Target->m_state.load();
97 std::vector<double> output(num_samples);
98 for (
size_t i = 0; i < num_samples; i++) {
135 auto sState =
m_Source->m_state.load();
136 auto tState =
m_Target->m_state.load();
145 , lhs_value(lhs_value)
146 , rhs_value(rhs_value)
160 , m_func(
std::move(func))
167 auto self = shared_from_this();
168 uint32_t lhs_mask =
m_lhs ?
m_lhs->get_channel_mask().load() : 0;
169 uint32_t rhs_mask =
m_rhs ?
m_rhs->get_channel_mask().load() : 0;
170 uint32_t combined_mask = lhs_mask | rhs_mask;
172 if (combined_mask != 0) {
214 uint32_t lstate =
m_lhs->m_state.load();
222 uint32_t rstate =
m_rhs->m_state.load();
246 std::vector<double> output(num_samples);
247 for (
unsigned int i = 0; i < num_samples; ++i) {
271 m_lhs->reset_processed_state();
273 m_rhs->reset_processed_state();
295 m_lhs->restore_state();
297 m_rhs->restore_state();
305 return std::make_unique<BinaryOpContextGpu>(
317 auto lstate =
m_lhs->m_state.load();
318 auto rstate =
m_rhs->m_state.load();
321 return !is_lhs_registered && !is_rhs_registered;
BinaryOpContextGpu(double value, double lhs_value, double rhs_value, std::span< const float > gpu_data)
GPU-compatible context for binary operation callbacks.
BinaryOpContext(double value, double lhs_value, double rhs_value)
Constructs a BinaryOpContext with the current operation state.
Specialized context for binary operation callbacks.
bool m_is_initialized
Flag indicating whether the binary operator has been properly initialized.
std::unique_ptr< NodeContext > create_context(double value) override
Creates a context object for callbacks.
void restore_state() override
Restores the node's state from the last save Recursively cascades through all connected modulator nod...
void initialize()
Initializes the binary operation node.
bool is_initialized() const
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.
double m_saved_last_rhs_value
std::function< double(double, double)> CombineFunc
Function type for combining two node outputs.
void reset_processed_state() override
Resets the processed state of the node and any attached input nodes.
CombineFunc m_func
The function used to combine the outputs of both nodes.
double process_sample(double input=0.) override
Processes a single sample through both nodes and combines the results.
void save_state() override
Saves the node's current state for later restoration Recursively cascades through all connected modul...
double m_saved_last_lhs_value
std::vector< double > process_batch(unsigned int num_samples) override
Processes multiple samples through both nodes and combines the results.
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.
BinaryOpNode(const std::shared_ptr< Node > &lhs, const std::shared_ptr< Node > &rhs, CombineFunc func)
Creates a new binary operation node.
std::shared_ptr< Node > m_rhs
The right-hand side node.
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.
std::vector< double > process_batch(unsigned int num_samples) override
Processes multiple samples through the chain.
bool m_is_initialized
Flag indicating whether the chain has been properly initialized.
double process_sample(double input=0.) override
Processes a single sample through the chain.
void restore_state() override
Restores the node's state from the last save Recursively cascades through all connected modulator nod...
void save_state() override
Saves the node's current state for later restoration Recursively cascades through all connected modul...
void reset_processed_state() override
Resets the processed state of the node and any attached input nodes.
ChainNode(const std::shared_ptr< Node > &source, const std::shared_ptr< Node > &target)
Creates a new chain connecting source to target.
bool is_initialized() const
GPU-uploadable 1D array data interface.
std::string type_id
Type identifier for runtime type checking.
Base context class for node callbacks.
std::vector< NodeHook > m_callbacks
Collection of standard callback functions.
double m_last_output
The most recent sample value generated by this oscillator.
bool m_fire_events_during_snapshot
Internal flag controlling whether notify_tick fires during state snapshots Default: false (events don...
std::vector< std::pair< NodeHook, NodeCondition > > m_conditional_callbacks
Collection of conditional callback functions with their predicates.
std::atomic< Utils::NodeState > m_state
Atomic state flag tracking the node's processing status.
bool m_gpu_compatible
Flag indicating if the node supports GPU processing This flag is set by derived classes to indicate w...
std::unique_ptr< NodeContext > m_last_context
The last context object created for callbacks.
std::span< const float > get_gpu_data_buffer() const
Provides access to the GPU data buffer.
GraphConfig & get_graph_config()
void atomic_add_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically adds a flag to a node state.
std::vector< uint32_t > get_active_channels(const std::shared_ptr< Nodes::Node > &node, uint32_t fallback_channel)
Extracts active channel list from a node's channel mask.
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_remove_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically removes a flag from a node state.
Contains the node-based computational processing system components.
@ PRESERVE_BOTH
Preserve both nodes in the chain, add new chain node to root, i.e doubling the target signal.
@ REPLACE_TARGET
Unregister the target and register with the new chain node.
@ ONLY_CHAIN
Only keep the new chain node, unregistering the source and target.
@ KEEP
Preserve both nodes in the binary op, add new binary op node to root, i.e doubling the signal.
@ REPLACE
Unregister both nodes and register with the new binary op node.
@ ACTIVE
Engine is processing this node.
@ PROCESSED
Node has been processed this cycle.
void register_audio_node(const std::shared_ptr< Nodes::Node > &node, uint32_t channel)
Adds a node to the root node of a specific channel.
void unregister_audio_node(const std::shared_ptr< Nodes::Node > &node, uint32_t channel)
Removes a node from the root node of a specific channel.
Utils::NodeBinaryOpSemantics binary_op_semantics
Utils::NodeChainSemantics chain_semantics