MayaFlux 0.3.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 723 of file NodeGraphManager.cpp.

728{
729 if (network->get_output_mode() != Network::OutputMode::AUDIO_SINK) {
732 "Attempted to route network that is not an audio sink. Operation ignored.");
733 return;
734 }
735
737 network->set_enabled(true);
738
739 auto& networks = m_audio_networks[token];
740 if (std::ranges::find(networks, network) == networks.end()) {
741 networks.push_back(network);
742 }
743
744 uint32_t current_channels = network->get_channel_mask();
745
746 uint32_t target_bitmask = 0;
747 for (auto ch : target_channels) {
748 target_bitmask |= (1 << ch);
749 }
750
751 uint32_t combined_mask = current_channels | target_bitmask;
752 network->set_channel_mask(combined_mask);
753 for (auto ch : target_channels) {
754 network->add_channel_usage(ch);
755 ensure_root_exists(token, ch);
756 }
757
758 uint32_t fade_blocks = (fade_cycles + m_registered_block_size - 1) / m_registered_block_size;
759 fade_blocks = std::max(1u, fade_blocks);
760
761 RoutingState state;
762 state.from_channels = current_channels;
763 state.to_channels = target_bitmask;
764 state.fade_cycles = fade_blocks;
765 state.phase = RoutingState::ACTIVE;
766
767 for (uint32_t ch = 0; ch < 32; ch++) {
768 state.amount[ch] = (current_channels & (1 << ch)) ? 1.0 : 0.0;
769 }
770
771 network->get_routing_state() = state;
772}
#define MF_WARN(comp, ctx,...)
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, MayaFlux::Journal::NodeProcessing, MayaFlux::Journal::Nodes, register_network_global(), and MayaFlux::Nodes::RoutingState::to_channels.

+ Here is the call graph for this function: