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

◆ route_network_to_channels()

void MayaFlux::Nodes::NodeGraphManager::route_network_to_channels ( const std::shared_ptr< Network::NodeNetwork > &  network,
const std::vector< uint32_t > &  target_channels,
uint32_t  fade_cycles,
ProcessingToken  token 
)

Routes a network's output to specific channels within a token domain.

Parameters
networkNetwork to route (must be an audio sink)
target_channelsVector of channel indices to route the network's output to
fade_cyclesNumber of cycles to fade in the routing (optional)
tokenProcessing domain to route within

This method registers the network and adds it to the specified channels' root nodes within the given processing domain. If fade_cycles is greater than 0, the routing will be smoothly faded in over that many processing cycles.

Definition at line 681 of file NodeGraphManager.cpp.

686{
687 if (network->get_output_mode() != Network::OutputMode::AUDIO_SINK) {
690 "Attempted to route network that is not an audio sink. Operation ignored.");
691 return;
692 }
693
695 network->set_enabled(true);
696
697 auto& networks = m_audio_networks[token];
698 if (std::ranges::find(networks, network) == networks.end()) {
699 networks.push_back(network);
700 }
701
702 uint32_t current_channels = network->get_channel_mask();
703
704 uint32_t target_bitmask = 0;
705 for (auto ch : target_channels) {
706 target_bitmask |= (1 << ch);
707 }
708
709 uint32_t combined_mask = current_channels | target_bitmask;
710 network->set_channel_mask(combined_mask);
711 for (auto ch : target_channels) {
712 network->add_channel_usage(ch);
713 ensure_root_exists(token, ch);
714 }
715
716 uint32_t fade_blocks = (fade_cycles + m_registered_block_size - 1) / m_registered_block_size;
717 fade_blocks = std::max(1U, fade_blocks);
718
719 RoutingState state;
720 state.from_channels = current_channels;
721 state.to_channels = target_bitmask;
722 state.fade_cycles = fade_blocks;
723 state.phase = RoutingState::ACTIVE;
724
725 for (uint32_t ch = 0; ch < 32; ch++) {
726 state.amount[ch] = (current_channels & (1 << ch)) ? 1.0 : 0.0;
727 }
728
729 network->get_routing_state() = state;
730}
#define MF_WARN(comp, ctx,...)
Core::GlobalNetworkConfig network
Definition Config.cpp:37
uint32_t m_registered_block_size
Block size for audio processing, used for normalizationbuffer.
void register_network_global(const std::shared_ptr< Network::NodeNetwork > &network)
Register network globally (like nodes)
void ensure_root_exists(ProcessingToken token, unsigned int channel)
Ensures a root node exists for the given token and channel.
std::unordered_map< ProcessingToken, std::vector< std::shared_ptr< Network::NodeNetwork > > > m_audio_networks
Audio-sink networks Only populated for networks with OutputMode::AUDIO_SINK.
@ NodeProcessing
Node graph processing (Nodes::NodeGraphManager)
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.
@ AUDIO_SINK
Aggregated audio samples sent to output.
@ ACTIVE
Currently in the fade-out phase of a routing transition.
Definition NodeSpec.hpp:81

References MayaFlux::Nodes::RoutingState::ACTIVE, MayaFlux::Nodes::RoutingState::amount, MayaFlux::Nodes::Network::AUDIO_SINK, ensure_root_exists(), MayaFlux::Nodes::RoutingState::fade_cycles, MayaFlux::Nodes::RoutingState::from_channels, m_audio_networks, m_registered_block_size, MF_WARN, network, MayaFlux::Journal::NodeProcessing, MayaFlux::Journal::Nodes, register_network_global(), and MayaFlux::Nodes::RoutingState::to_channels.

+ Here is the call graph for this function: