9 return std::ranges::any_of(callbacks,
11 return hook.target_type() == callback.target_type();
17 return std::ranges::any_of(callbacks,
18 [&callback](
const std::pair<NodeHook, NodeCondition>& pair) {
19 return pair.second.target_type() == callback.target_type();
25 return std::ranges::any_of(callbacks,
26 [&callback, &condition](
const std::pair<NodeHook, NodeCondition>& pair) {
27 return pair.first.target_type() == callback.target_type() && pair.second.target_type() == condition.target_type();
34 callbacks.push_back(callback);
43 callbacks.emplace_back(callback, condition);
52 auto it = callbacks.begin();
54 while (it != callbacks.end()) {
55 if (it->target_type() == callback.target_type()) {
56 it = callbacks.erase(it);
69 auto it = callbacks.begin();
71 while (it != callbacks.end()) {
72 if (it->second.target_type() == callback.target_type()) {
73 it = callbacks.erase(it);
85 flag.compare_exchange_strong(expected, desired);
90 auto expected = flag.load();
91 flag.compare_exchange_strong(expected, desired);
96 auto current = state.load();
99 desired =
static_cast<NodeState>(current | flag);
100 }
while (!state.compare_exchange_weak(current, desired,
101 std::memory_order_acq_rel,
102 std::memory_order_acquire));
107 auto current = state.load();
110 desired =
static_cast<NodeState>(current & ~flag);
111 }
while (!state.compare_exchange_weak(current, desired,
112 std::memory_order_acq_rel,
113 std::memory_order_acquire));
118 flag.compare_exchange_weak(expected, desired);
123 count.fetch_add(amount, std::memory_order_relaxed);
128 count.fetch_sub(amount, std::memory_order_relaxed);
133 if (node && node->m_modulator_count.load(std::memory_order_relaxed) == 0) {
134 node->reset_processed_state();
138std::vector<uint32_t>
get_active_channels(
const std::shared_ptr<Nodes::Node>& node, uint32_t fallback_channel)
140 uint32_t channel_mask = node ? node->get_channel_mask().load() : 0;
146 std::vector<uint32_t> channels;
148 if (channel_mask == 0) {
149 channels.push_back(fallback_channel);
152 if (channel_mask & (1ULL << channel)) {
153 channels.push_back(channel);
165 double progress = 0.;
169 for (uint32_t ch = 0; ch < 32; ++ch) {
171 state.
amount[ch] = will_be_in ? 1.0 : 0.0;
177 for (uint32_t ch = 0; ch < 32; ch++) {
181 if (was_in && will_be_in) {
183 }
else if (was_in && !will_be_in) {
184 state.
amount[ch] = 1.0 - progress;
185 }
else if (!was_in && will_be_in) {
186 state.
amount[ch] = progress;
std::function< void(NodeContext &)> NodeHook
Callback function type for node processing events.
NodeState
Represents the processing state of a node in the audio graph.
bool callback_pair_exists(const std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeHook &callback, const NodeCondition &condition)
Checks if a specific callback and condition pair already exists.
void atomic_add_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically adds a flag to a node state.
bool callback_exists(const std::vector< NodeHook > &callbacks, const NodeHook &callback)
Checks if a callback function already exists in a collection.
bool safe_remove_conditional_callback(std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeCondition &callback)
Safely removes all conditional callbacks with a specific condition.
constexpr uint32_t MAX_CHANNEL_COUNT
Hard limit imposed by uint32_t channel mask width.
bool safe_add_callback(std::vector< NodeHook > &callbacks, const NodeHook &callback)
Safely adds a callback to a collection if it doesn't already exist.
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 atomic_set_strong(std::atomic< NodeState > &flag, NodeState &expected, const NodeState &desired)
Atomically sets a node state flag with strong memory ordering.
bool conditional_callback_exists(const std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeCondition &callback)
Checks if a condition function already exists in a collection of conditional callbacks.
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_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.
std::function< bool(NodeContext &)> NodeCondition
Predicate function type for conditional callbacks.
void atomic_dec_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically decrements the modulator count by a specified amount.
bool safe_add_conditional_callback(std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeHook &callback, const NodeCondition &condition)
Safely adds a conditional callback if it doesn't already exist.
void atomic_set_flag_weak(std::atomic< NodeState > &flag, NodeState &expected, const NodeState &desired)
Atomically sets a node state flag with weak memory ordering.
void update_routing_state(RoutingState &state)
Updates the routing state for a node based on its current channel usage.
bool safe_remove_callback(std::vector< NodeHook > &callbacks, const NodeHook &callback)
Safely removes a callback from a collection.
Contains the node-based computational processing system components.
enum MayaFlux::Nodes::RoutingState::Phase NONE
@ COMPLETED
Routing transition has completed.
Represents the state of routing transitions for a node.