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 725 of file NodeGraphManager.cpp.

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