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

◆ play_for() [2/3]

void MayaFlux::Kriya::NodeTimer::play_for ( std::shared_ptr< Nodes::Node node,
double  duration_seconds,
std::vector< uint32_t >  channels 
)

Activates a processing node for a specific duration.

Parameters
nodeThe processing node to activate
duration_secondsHow long to keep the node active (in seconds)
channelsThe output channels to connect the node to
channelThe output channel to connect the node to (single-channel overload)

This method connects the specified node to the output channel, activates it for the specified duration, then automatically disconnects it. The timing is sample-accurate, ensuring that the node remains active for exactly the right duration.

If a node is already active, it is deactivated before starting the new one.

Definition at line 96 of file Timers.cpp.

97{
98 cancel();
99
100 m_current_node = node;
101 m_channels = channels;
102
103 for (auto& channel : channels) {
104 m_node_graph_manager.add_to_root(node, token, channel);
105 }
106
107 m_timer.schedule(duration_seconds, [this]() {
109 });
110}
static MayaFlux::Nodes::ProcessingToken token
Definition Timers.cpp:8
std::shared_ptr< Nodes::Node > m_current_node
The currently active node being played.
Definition Timers.hpp:366
Nodes::NodeGraphManager & m_node_graph_manager
Reference to the graph manager that manages processing nodes.
Definition Timers.hpp:349
void cleanup_current_operation()
Cleans up the current operation, disconnecting the node and resetting state.
Definition Timers.cpp:171
void cancel()
Cancels any currently active node.
Definition Timers.cpp:184
std::vector< uint32_t > m_channels
The output channels the current node is connected to.
Definition Timers.hpp:375
Timer m_timer
The timer used to schedule node disconnection.
Definition Timers.hpp:357
void schedule(double delay_seconds, std::function< void()> callback)
Schedules a callback to execute after a delay.
Definition Timers.cpp:18
void add_to_root(const std::shared_ptr< Node > &node, ProcessingToken token, unsigned int channel=0)
Add node to specific processing token and channel.

References MayaFlux::Nodes::NodeGraphManager::add_to_root(), cancel(), cleanup_current_operation(), m_channels, m_current_node, m_node_graph_manager, m_timer, MayaFlux::Kriya::Timer::schedule(), and token.

Referenced by play_for(), and play_for().

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