MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kriya::NodeTimer Class Reference

Specialized timer for controlling computational nodes with precise timing. More...

#include <Timers.hpp>

+ Collaboration diagram for MayaFlux::Kriya::NodeTimer:

Public Member Functions

 NodeTimer (Vruta::TaskScheduler &scheduler)
 Constructs a NodeTimer with the specified scheduler.
 
 NodeTimer (Vruta::TaskScheduler &scheduler, Nodes::NodeGraphManager &graph_manager)
 Constructs a NodeTimer with the specified scheduler and graph manager.
 
 ~NodeTimer ()=default
 
void play_for (std::shared_ptr< Nodes::Node > node, double duration_seconds, std::vector< uint32_t > channels)
 Activates a processing node for a specific duration.
 
void play_for (std::shared_ptr< Nodes::Node > node, double duration_seconds, uint32_t channel)
 
void play_for (std::shared_ptr< Nodes::Node > node, double duration_seconds)
 
void play_with_processing (std::shared_ptr< Nodes::Node > node, std::function< void(std::shared_ptr< Nodes::Node >)> setup_func, std::function< void(std::shared_ptr< Nodes::Node >)> cleanup_func, double duration_seconds, std::vector< uint32_t > channels)
 Activates a processing node with custom setup and cleanup functions.
 
void play_with_processing (std::shared_ptr< Nodes::Node > node, std::function< void(std::shared_ptr< Nodes::Node >)> setup_func, std::function< void(std::shared_ptr< Nodes::Node >)> cleanup_func, double duration_seconds, uint32_t channel)
 
void play_with_processing (std::shared_ptr< Nodes::Node > node, std::function< void(std::shared_ptr< Nodes::Node >)> setup_func, std::function< void(std::shared_ptr< Nodes::Node >)> cleanup_func, double duration_seconds)
 
void cancel ()
 Cancels any currently active node.
 
bool is_active () const
 Checks if a node is currently active.
 

Private Member Functions

void cleanup_current_operation ()
 Cleans up the current operation, disconnecting the node and resetting state.
 

Private Attributes

Vruta::TaskSchedulerm_scheduler
 Reference to the scheduler that manages this timer.
 
Nodes::NodeGraphManagerm_node_graph_manager
 Reference to the graph manager that manages processing nodes.
 
Timer m_timer
 The timer used to schedule node disconnection.
 
std::shared_ptr< Nodes::Nodem_current_node
 The currently active node being played.
 
std::vector< uint32_t > m_channels
 The output channels the current node is connected to.
 

Detailed Description

Specialized timer for controlling computational nodes with precise timing.

The NodeTimer class provides a convenient way to activate processing nodes for specific durations with sample-accurate timing. It handles the details of connecting and disconnecting nodes from the processing graph at precisely the right moments.

This is particularly useful for activating temporary processes, applying time-limited transformations, or creating precisely timed events in any computational domain.

NOTE: As this class is centered around audio playback, it enforces use of AUDIO_RATE processing token that cant be overridden.

Example usage:

// Create a node timer
NodeTimer timer(*scheduler, *graph_manager);
// Activate a processing node for exactly 2 seconds
timer.play_for(process_node, 2.0);
Specialized timer for controlling computational nodes with precise timing.
Definition Timers.hpp:232

Only one node can be active at a time; activating a new node cancels any previously active node.

Definition at line 232 of file Timers.hpp.


The documentation for this class was generated from the following files: