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

◆ notify_tick()

void MayaFlux::Nodes::Generator::Logic::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 503 of file Logic.cpp.

504{
505 update_context(value);
506 bool state_changed = (value != m_last_output);
507
508 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
509 auto& ctx = static_cast<LogicContext&>(get_last_context());
510
511 for (const auto& cb : m_all_callbacks) {
512 bool should_call = false;
513
514 switch (cb.event_type) {
516 should_call = true;
517 break;
518
520 should_call = (bool)value;
521 break;
522
524 should_call = !value;
525 break;
526
528 should_call = state_changed;
529 break;
530
532 should_call = state_changed && (bool)value;
533 break;
534
536 should_call = state_changed && !value;
537 break;
538
540 should_call = cb.condition && cb.condition.value()(ctx);
541 break;
542 }
543
544 if (should_call) {
545 cb.callback(ctx);
546 }
547 }
548}
void update_context(double value) override
Updates the context with the latest sample value.
Definition Logic.cpp:474
NodeContext & get_last_context() override
Retrieves the last created context object.
Definition Logic.cpp:550
std::vector< LogicCallback > m_all_callbacks
Collection of all callback functions.
Definition Logic.hpp:643
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:405

References MayaFlux::Nodes::Generator::CHANGE, MayaFlux::Nodes::Generator::CONDITIONAL, MayaFlux::Nodes::Generator::FALSE, get_last_context(), m_all_callbacks, MayaFlux::Nodes::Node::m_last_output, MayaFlux::Nodes::Generator::TICK, MayaFlux::Nodes::Generator::TRUE, update_context(), MayaFlux::Nodes::NodeContext::value, MayaFlux::Nodes::Generator::WHILE_FALSE, and MayaFlux::Nodes::Generator::WHILE_TRUE.

Referenced by process_multi_input(), and process_sample().

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