MayaFlux 1.0.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 157 of file NodeGraphManager.cpp.

158{
159 if (!preprocess_networks(token)) {
160 return {};
161 }
162
163 std::vector<std::vector<double>> all_network_outputs;
164
165 auto audio_it = m_audio_networks.find(token);
166 if (audio_it != m_audio_networks.end()) {
167 for (auto& network : audio_it->second) {
168 if (!network || !network->is_enabled()) {
169 continue;
170 }
171
172 if (!network->is_registered_on_channel(channel)) {
173 continue;
174 }
175
176 if (!network->is_processed_this_cycle()) {
177 network->mark_processing(true);
178 network->process_batch(num_samples);
179 network->mark_processing(false);
180 network->mark_processed(true);
181 }
182
183 const auto& net_buffer = network->get_audio_buffer();
184 if (net_buffer && network->get_output_mode() == Network::OutputMode::AUDIO_SINK) {
185 if (network->needs_channel_routing()) {
186 double scale = network->get_routing_state().amount[channel];
187 if (scale == 0.0)
188 continue;
189
190 if (scale == 1.0) {
191 all_network_outputs.push_back(*net_buffer);
192 } else {
193 std::vector<double> scaled_buffer = *net_buffer;
194 for (auto& sample : scaled_buffer)
195 sample *= scale;
196
197 all_network_outputs.push_back(std::move(scaled_buffer));
198 }
199 } else {
200 all_network_outputs.push_back(*net_buffer);
201 }
202 }
203 }
204 }
205
206 postprocess_networks(token, channel);
207 return all_network_outputs;
208}
Core::GlobalNetworkConfig network
Definition Config.cpp:43
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.
Tendency< D, float > scale(const Tendency< D, float > &t, float factor)
Uniform scaling of a scalar-output tendency.
Definition Tendency.hpp:98
@ AUDIO_SINK
Aggregated audio samples sent to output.

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

+ Here is the call graph for this function: