MayaFlux 0.2.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 218 of file NodeGraphManager.cpp.

219{
220 if (m_terminate_requested.load())
221 return 0.0;
222
223 auto& root = get_root_node(token, channel);
224
225 if (auto it = m_token_sample_processors.find(token); it != m_token_sample_processors.end()) {
226 return it->second(&root, channel);
227 }
228
229 double sample = root.process_sample();
230 normalize_sample(sample, root.get_node_size());
231 return sample;
232}
static MayaFlux::Nodes::ProcessingToken token
Definition Timers.cpp:8
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 get_root_node(), m_terminate_requested, m_token_sample_processors, normalize_sample(), and token.

+ Here is the call graph for this function: