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

◆ process_audio_networks()

std::vector< std::vector< double > > MayaFlux::Nodes::NodeGraphManager::process_audio_networks ( ProcessingToken  token,
uint32_t  num_samples,
uint32_t  channel = 0 
)

Process audio networks for a specific channel.

Parameters
tokenProcessing domain (should be AUDIO_RATE)
num_samplesNumber of samples/frames to process
channelChannel index within that domain
Returns
Vector of processed audio data from all networks for that channel

Processes all audio-sink networks registered to the specified channel and returns their combined output data.

Definition at line 123 of file NodeGraphManager.cpp.

124{
125 if (!preprocess_networks(token)) {
126 return {};
127 }
128
129 std::vector<std::vector<double>> all_network_outputs;
130
131 auto audio_it = m_audio_networks.find(token);
132 if (audio_it != m_audio_networks.end()) {
133 for (auto& network : audio_it->second) {
134 if (!network || !network->is_enabled()) {
135 continue;
136 }
137
138 if (!network->is_registered_on_channel(channel)) {
139 continue;
140 }
141
142 if (!network->is_processed_this_cycle()) {
143 network->mark_processing(true);
144 network->process_batch(num_samples);
145 network->mark_processing(false);
146 network->mark_processed(true);
147 }
148
149 const auto& net_buffer = network->get_audio_buffer();
150 if (net_buffer && network->get_output_mode() == Network::OutputMode::AUDIO_SINK) {
151 if (network->needs_channel_routing()) {
152 double scale = network->get_routing_state().amount[channel];
153 if (scale == 0.0)
154 continue;
155
156 if (scale == 1.0) {
157 all_network_outputs.push_back(*net_buffer);
158 } else {
159 std::vector<double> scaled_buffer = *net_buffer;
160 for (auto& sample : scaled_buffer)
161 sample *= scale;
162
163 all_network_outputs.push_back(std::move(scaled_buffer));
164 }
165 } else {
166 all_network_outputs.push_back(*net_buffer);
167 }
168 }
169 }
170 }
171
172 postprocess_networks(token, channel);
173 return all_network_outputs;
174}
bool preprocess_networks(ProcessingToken token)
Preprocess networks for a specific token.
void postprocess_networks(ProcessingToken token, std::optional< uint32_t > channel)
Postprocess networks for a specific 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.
@ AUDIO_SINK
Aggregated audio samples sent to output.

References MayaFlux::Nodes::Network::AUDIO_SINK, m_audio_networks, postprocess_networks(), and preprocess_networks().

+ Here is the call graph for this function: