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

◆ process_sample()

double MayaFlux::Nodes::NodeGraphManager::process_sample ( ProcessingToken  token,
uint32_t  channel 
)

Process a single sample for a specific channel.

Parameters
tokenProcessing domain
channelChannel index within that domain
Returns
Processed sample value from the channel's root node

Processes a single sample for the specified channel and returns the processed value. If a custom per-sample processor is registered, it is used; otherwise, the default root node processing is performed. As node graph manager feeds into hardware audio output, the value returned is normalized

Definition at line 244 of file NodeGraphManager.cpp.

245{
246 if (m_terminate_requested.load())
247 return 0.0;
248
249 auto& root = get_root_node(token, channel);
250
251 if (auto it = m_token_sample_processors.find(token); it != m_token_sample_processors.end()) {
252 return it->second(&root, channel);
253 }
254
255 double sample = root.process_sample();
256 normalize_sample(sample, root.get_node_size());
257 return sample;
258}
uint32_t channel
std::atomic< bool > m_terminate_requested
Global termination flag.
void normalize_sample(double &sample, uint32_t num_nodes)
Normalizes a sample to the range [-1, 1] based on the number of nodes.
std::unordered_map< ProcessingToken, TokenSampleProcessor > m_token_sample_processors
Per-sample processors for each processing token.
RootNode & get_root_node(ProcessingToken token, unsigned int channel)
Gets or creates the root node for a specific token and channel.

References channel, get_root_node(), m_terminate_requested, m_token_sample_processors, and normalize_sample().

+ Here is the call graph for this function: