8 : m_is_processing(false)
11 , m_skip_state_management(false)
22 bool expected =
false;
23 if (pending_op.active.compare_exchange_strong(
25 std::memory_order_acquire,
26 std::memory_order_relaxed)) {
27 pending_op.node = node;
28 pending_op.is_addition =
true;
54 bool expected =
false;
55 if (pending_op.active.compare_exchange_strong(
57 std::memory_order_acquire,
58 std::memory_order_relaxed)) {
59 pending_op.node = node;
60 pending_op.is_addition =
false;
71 if ((*it).get() == node.get()) {
78 node->reset_processed_state();
80 uint32_t flag = node->m_state.load();
92 bool expected =
false;
98 std::memory_order_acquire, std::memory_order_relaxed)) {
120 uint32_t state = node->m_state.load();
121 double node_output = 0.0;
124 auto generator = std::dynamic_pointer_cast<Nodes::Generator::Generator>(node);
125 if (generator && generator->should_mock_process()) {
126 generator->process_sample();
128 node_output = node->process_sample();
132 node_output = node->get_last_output();
135 if (node->needs_channel_routing()) {
136 node_output *= node->get_routing_state().amount[
m_channel];
139 sample += node_output;
153 uint32_t state = node->m_state.load();
155 node->process_sample();
169 node->request_reset_from_channel(
m_channel);
186 std::vector<double> output(num_samples);
188 for (
unsigned int i = 0; i < num_samples; i++) {
196 for (uint32_t i = 0; i < num_frames; i++) {
204 if (!pending_op.active.load(std::memory_order_acquire))
207 auto& op = pending_op;
209 if (op.is_addition) {
212 uint32_t state = op.node->m_state.load();
220 if ((*it).get() == op.node.get()) {
226 op.node->reset_processed_state();
227 uint32_t state = op.node->m_state.load();
235 op.active.store(
false, std::memory_order_release);
void process_pending_operations()
Processes any pending node registration/unregistration operations.
std::vector< std::shared_ptr< Node > > m_Nodes
Collection of nodes registered with this root node.
uint32_t m_channel
The processing channel index for this root node.
RootNode(ProcessingToken token=ProcessingToken::AUDIO_RATE, uint32_t channel=0)
Constructs a RootNode for a specific processing token and channel.
void unregister_node(const std::shared_ptr< Node > &node)
Removes a node from this root node.
void process_frame()
Processes a single frame from all registered nodes.
bool preprocess()
Checks if the root node can process pending operations.
void register_node(const std::shared_ptr< Node > &node)
Adds a node to this root node.
std::atomic< bool > m_is_processing
Flag indicating if the root node is currently processing nodes.
double process_sample()
Processes a single sample from all registered nodes.
bool m_skip_state_management
Flag indicating whether to skip preprocessing and post processing.
void process_batch_frame(uint32_t num_frames)
Processes multiple frames from all registered nodes.
struct MayaFlux::Nodes::RootNode::PendingOp m_pending_ops[2048]
std::atomic< uint32_t > m_pending_count
Counter tracking the number of pending operations.
std::atomic< bool > m_request_terminate
Flag to request termination of processing.
void postprocess()
Performs post-processing after all nodes have been processed.
std::vector< double > process_batch(uint32_t num_samples)
Processes all registered nodes and combines their outputs.
void terminate_all_nodes()
Terminates all nodes registered with this root node.
NodeState
Represents the processing state of a node in the audio graph.
@ PROCESSED
Node has been processed this cycle.
@ ACTIVE
Engine is processing this node.
@ INACTIVE
Engine is not processing this node.
@ PENDING_REMOVAL
Node is marked for removal.
ProcessingToken
Enumerates the different processing domains for nodes.
void atomic_add_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically adds a flag to a node state.
void atomic_remove_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically removes a flag from a node state.
void atomic_set_flag_strong(std::atomic< NodeState > &flag, const NodeState &desired)
Atomically sets a node state flag to a specific value.
Contains the node-based computational processing system components.