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

◆ notify_tick()

void MayaFlux::Nodes::Generator::Phasor::notify_tick ( double  value)
overrideprotectedvirtual

Notifies all registered callbacks about a new sample.

Parameters
valueThe newly generated sample

This method is called internally whenever a new sample is generated, creating the appropriate context and invoking all registered callbacks that should receive notification about this sample.

Implements MayaFlux::Nodes::Node.

Definition at line 204 of file Phasor.cpp.

205{
207
208 for (auto& callback : m_callbacks) {
209 callback(*m_last_context);
210 }
211
212 if (m_phase_wrapped) {
213 for (auto& callback : m_phase_wrap_callbacks) {
214 callback(*m_last_context);
215 }
216 }
217
218 for (auto& [callback, condition] : m_conditional_callbacks) {
219 if (condition(*m_last_context)) {
220 callback(*m_last_context);
221 }
222 }
223
224 for (auto& [callback, threshold] : m_threshold_callbacks) {
225 if (value >= threshold && !m_threshold_crossed) {
226 callback(*m_last_context);
227 m_threshold_crossed = true;
228 } else if (value < threshold) {
229 m_threshold_crossed = false;
230 }
231 }
232}
virtual std::unique_ptr< NodeContext > create_context(double value) override
Creates a context object for callbacks.
Definition Generator.cpp:19
bool m_threshold_crossed
Flag indicating whether the threshold has been crossed in the current sample.
Definition Phasor.hpp:338
bool m_phase_wrapped
Flag indicating whether the phase has wrapped in the current sample.
Definition Phasor.hpp:333
std::vector< NodeHook > m_phase_wrap_callbacks
Collection of phase wrap-specific callback functions.
Definition Phasor.hpp:323
std::vector< std::pair< NodeHook, double > > m_threshold_callbacks
Collection of threshold-specific callback functions with their thresholds.
Definition Phasor.hpp:328
std::vector< NodeHook > m_callbacks
Collection of standard callback functions.
Definition Node.hpp:416
std::vector< std::pair< NodeHook, NodeCondition > > m_conditional_callbacks
Collection of conditional callback functions with their predicates.
Definition Node.hpp:426
std::unique_ptr< NodeContext > m_last_context
The last context object created for callbacks.
Definition Node.hpp:396

References MayaFlux::Nodes::Generator::Generator::create_context(), MayaFlux::Nodes::Node::m_callbacks, MayaFlux::Nodes::Node::m_conditional_callbacks, MayaFlux::Nodes::Node::m_last_context, m_phase_wrap_callbacks, m_phase_wrapped, m_threshold_callbacks, and m_threshold_crossed.

Referenced by process_sample().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: