MayaFlux 0.3.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 161 of file NodeUtils.cpp.

162{
163 state.cycles_elapsed++;
164
165 double progress = 0.;
166 if (state.fade_cycles > 0) {
167 progress = std::min<double>(1.0, static_cast<double>(state.cycles_elapsed) / state.fade_cycles);
168 } else {
169 for (uint32_t ch = 0; ch < 32; ++ch) {
170 bool will_be_in = state.to_channels & (1 << ch);
171 state.amount[ch] = will_be_in ? 1.0 : 0.0;
172 }
173 state.phase = RoutingState::NONE;
174 return;
175 }
176
177 for (uint32_t ch = 0; ch < 32; ch++) {
178 bool was_in = state.from_channels & (1 << ch);
179 bool will_be_in = state.to_channels & (1 << ch);
180
181 if (was_in && will_be_in) {
182 state.amount[ch] = 1.0;
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;
187 } else {
188 state.amount[ch] = 0.0;
189 }
190 }
191
192 if (state.cycles_elapsed >= state.fade_cycles) {
193 state.phase = RoutingState::COMPLETED;
194 }
195}

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: