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

◆ play_with_processing() [2/3]

void MayaFlux::Kriya::NodeTimer::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.

Parameters
nodeThe processing node to activate
setup_funcFunction to call before activating the node
cleanup_funcFunction to call after deactivating the node
duration_secondsHow long to keep the node active (in seconds)
channelsThe output channel to connect the node to
channelThe output channel to connect the node to (single-channel overload)

This method provides more control over the node activation process by allowing custom setup and cleanup functions. The setup function is called before connecting the node, and the cleanup function is called after disconnecting it.

This is useful for more complex scenarios where additional setup or cleanup steps are needed, such as configuring node parameters or managing resources.

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

Definition at line 133 of file Timers.cpp.

134{
135 cancel();
136
137 m_current_node = node;
138 m_channels = channels;
139
140 setup_func(node);
141
142 for (auto channel : channels) {
143 m_node_graph_manager.add_to_root(node, token, channel);
144 }
145
146 m_timer.schedule(duration_seconds, [this, node, cleanup_func]() {
147 cleanup_func(node);
149 });
150}
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_with_processing(), and play_with_processing().

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