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

◆ update_routing_state()

MAYAFLUX_API 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 338 of file NodeUtils.cpp.

339{
340 state.cycles_elapsed++;
341
342 double progress = 0.;
343 if (state.fade_cycles > 0) {
344 progress = std::min<double>(1.0, static_cast<double>(state.cycles_elapsed) / state.fade_cycles);
345 } else {
346 for (uint32_t ch = 0; ch < 32; ++ch) {
347 bool will_be_in = state.to_channels & (1 << ch);
348 state.amount[ch] = will_be_in ? 1.0 : 0.0;
349 }
350 state.phase = RoutingState::NONE;
351 return;
352 }
353
354 for (uint32_t ch = 0; ch < 32; ch++) {
355 bool was_in = state.from_channels & (1 << ch);
356 bool will_be_in = state.to_channels & (1 << ch);
357
358 if (was_in && will_be_in) {
359 state.amount[ch] = 1.0;
360 } else if (was_in && !will_be_in) {
361 state.amount[ch] = 1.0 - progress;
362 } else if (!was_in && will_be_in) {
363 state.amount[ch] = progress;
364 } else {
365 state.amount[ch] = 0.0;
366 }
367 }
368
369 if (state.cycles_elapsed >= state.fade_cycles) {
370 state.phase = RoutingState::COMPLETED;
371 }
372}

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: