MayaFlux 0.4.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.

Reimplemented from MayaFlux::Nodes::Generator::Generator.

Definition at line 198 of file Phasor.cpp.

199{
200 update_context(value);
201
202 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
203 auto& ctx = static_cast<GeneratorContext&>(get_last_context());
204
205 for (auto& callback : m_callbacks) {
206 callback(ctx);
207 }
208
209 if (m_phase_wrapped) {
210 for (auto& callback : m_phase_wrap_callbacks) {
211 callback(ctx);
212 }
213 }
214
215 for (auto& [callback, condition] : m_conditional_callbacks) {
216 if (condition(ctx)) {
217 callback(ctx);
218 }
219 }
220
221 for (auto& [callback, threshold] : m_threshold_callbacks) {
222 if (value >= threshold && !m_threshold_crossed) {
223 callback(ctx);
224 m_threshold_crossed = true;
225 } else if (value < threshold) {
226 m_threshold_crossed = false;
227 }
228 }
229}
NodeContext & get_last_context() override
Gets the last created context object.
Definition Generator.cpp:51
virtual void update_context(double value) override
Updates the context object for callbacks.
Definition Generator.cpp:21
bool m_threshold_crossed
Flag indicating whether the threshold has been crossed in the current sample.
Definition Phasor.hpp:328
bool m_phase_wrapped
Flag indicating whether the phase has wrapped in the current sample.
Definition Phasor.hpp:323
std::vector< std::pair< TypedHook< GeneratorContext >, double > > m_threshold_callbacks
Collection of threshold-specific callback functions with their thresholds.
Definition Phasor.hpp:318
std::vector< TypedHook< GeneratorContext > > m_phase_wrap_callbacks
Collection of phase wrap-specific callback functions.
Definition Phasor.hpp:313
std::vector< NodeHook > m_callbacks
Collection of standard callback functions.
Definition Node.hpp:434
std::vector< std::pair< NodeHook, NodeCondition > > m_conditional_callbacks
Collection of conditional callback functions with their predicates.
Definition Node.hpp:444

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

Referenced by process_sample().

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