MayaFlux 0.4.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 154 of file NodeGraphManager.cpp.

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