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

◆ update_routing_state()

void MayaFlux::Nodes::update_routing_state ( RoutingState state)

Updates the routing state for a node based on its current channel usage.

Parameters
stateThe routing state to update

This function evaluates the current channel usage of a node and updates the routing state accordingly. It manages transitions between different routing phases (such as fade-in and fade-out(Active)) based on changes in channel counts, ensuring smooth audio output during dynamic reconfigurations of the processing graph.

Definition at line 127 of file NodeUtils.cpp.

128{
129 state.cycles_elapsed++;
130
131 double progress = 0.;
132 if (state.fade_cycles > 0) {
133 progress = std::min<double>(1.0, static_cast<double>(state.cycles_elapsed) / state.fade_cycles);
134 } else {
135 for (uint32_t ch = 0; ch < 32; ++ch) {
136 bool will_be_in = state.to_channels & (1 << ch);
137 state.amount[ch] = will_be_in ? 1.0 : 0.0;
138 }
139 state.phase = RoutingState::NONE;
140 return;
141 }
142
143 for (uint32_t ch = 0; ch < 32; ch++) {
144 bool was_in = state.from_channels & (1 << ch);
145 bool will_be_in = state.to_channels & (1 << ch);
146
147 if (was_in && will_be_in) {
148 state.amount[ch] = 1.0;
149 } else if (was_in && !will_be_in) {
150 state.amount[ch] = 1.0 - progress;
151 } else if (!was_in && will_be_in) {
152 state.amount[ch] = progress;
153 } else {
154 state.amount[ch] = 0.0;
155 }
156 }
157
158 if (state.cycles_elapsed >= state.fade_cycles) {
159 state.phase = RoutingState::COMPLETED;
160 }
161}

References MayaFlux::Nodes::RoutingState::amount, MayaFlux::Nodes::RoutingState::COMPLETED, MayaFlux::Nodes::RoutingState::cycles_elapsed, MayaFlux::Nodes::RoutingState::fade_cycles, MayaFlux::Nodes::RoutingState::from_channels, MayaFlux::Nodes::RoutingState::NONE, and MayaFlux::Nodes::RoutingState::to_channels.

Referenced by MayaFlux::Nodes::NodeGraphManager::update_routing_states_for_cycle().

+ Here is the caller graph for this function: