13 : m_Scheduler(scheduler)
28 if (timer_ptr && timer_ptr->is_active()) {
29 timer_ptr->m_callback();
30 timer_ptr->m_active =
false;
34 m_routine = std::make_shared<Vruta::SoundRoutine>(
42 m_routine->initialize_state(current_time);
55 : m_Scheduler(scheduler)
60void TimedAction::execute(
const std::function<
void()>& start_func,
const std::function<
void()>& end_func,
double duration_seconds)
80 : m_scheduler(scheduler)
81 , m_node_graph_manager(node_graph_manager)
82 , m_buffer_manager(buffer_manager)
88 double duration_seconds,
90 const std::vector<uint32_t>& channels)
99 for (
auto channel : channels) {
118 for (
const auto& ch : channels) {
119 network->add_channel_usage(ch);
130 double duration_seconds,
void remove_buffer(const std::shared_ptr< Buffer > &buffer, ProcessingToken token, uint32_t channel=0)
Removes a buffer from a token.
void add_buffer(const std::shared_ptr< Buffer > &buffer, ProcessingToken token, uint32_t channel=0)
Adds a buffer to a token and channel.
Token-based multimodal buffer management system for unified data stream processing.
Buffers::ProcessingToken m_buffer_token
The processing token associated with the currently active buffer.
std::vector< uint32_t > m_channels
The output channels the current node is connected to.
void activate_network(const std::shared_ptr< Nodes::Network::NodeNetwork > &network, double duration_seconds, Nodes::ProcessingToken token=Nodes::ProcessingToken::AUDIO_RATE, const std::vector< uint32_t > &channels={})
Activates a node network for a specified duration.
Nodes::ProcessingToken m_node_token
The processing token associated with the currently active node or buffer.
void cleanup_current_operation()
Cleans up the current operation, disconnecting the entity and resetting state.
std::shared_ptr< Buffers::Buffer > m_current_buffer
The currently active buffer being played.
std::shared_ptr< Nodes::Network::NodeNetwork > m_current_network
The currently active network being played.
Nodes::NodeGraphManager & m_node_graph_manager
Reference to the graph manager that manages processing nodes.
TemporalActivation(Vruta::TaskScheduler &scheduler, Nodes::NodeGraphManager &graph_manager, Buffers::BufferManager &buffer_manager)
Constructs a TemporalActivation with the specified scheduler and manager.
void cancel()
Cancels any currently active node.
void activate_node(const std::shared_ptr< Nodes::Node > &node, double duration_seconds, Nodes::ProcessingToken token=Nodes::ProcessingToken::AUDIO_RATE, const std::vector< uint32_t > &channels={})
Activates a node for a specified duration.
void activate_buffer(const std::shared_ptr< Buffers::Buffer > &buffer, double duration_seconds, Buffers::ProcessingToken token=Buffers::ProcessingToken::AUDIO_BACKEND, uint32_t channel=0)
Activates a buffer for a specified duration.
std::shared_ptr< Nodes::Node > m_current_node
The currently active node being played.
Buffers::BufferManager & m_buffer_manager
Reference to the buffer manager that manages processing buffers.
Timer m_timer
The timer used to schedule processing duration.
void cancel()
Cancels any active action.
bool is_pending() const
Checks if an action is currently in progress.
Timer m_timer
The timer used to schedule the end function.
void execute(const std::function< void()> &start_func, const std::function< void()> &end_func, double duration_seconds)
Executes a pair of functions with a time interval between them.
TimedAction(Vruta::TaskScheduler &scheduler)
Constructs a TimedAction with the specified scheduler.
bool m_active
Flag indicating whether a callback is currently scheduled.
bool is_active() const
Checks if a callback is currently scheduled.
Timer(Vruta::TaskScheduler &scheduler)
Constructs a Timer with the specified scheduler.
std::function< void()> m_callback
The callback function to execute when the timer fires.
Vruta::TaskScheduler & m_Scheduler
Reference to the scheduler that manages this timer.
std::shared_ptr< Vruta::SoundRoutine > m_routine
The underlying computational routine that implements the timer.
void schedule(double delay_seconds, std::function< void()> callback)
Schedules a callback to execute after a delay.
void cancel()
Cancels any scheduled callback.
High-level utility for scheduling one-shot timed callbacks.
void remove_network(const std::shared_ptr< Network::NodeNetwork > &network, ProcessingToken token)
Remove a network from a processing token.
void add_network(const std::shared_ptr< Network::NodeNetwork > &network, ProcessingToken token)
Add a network to a processing token.
void add_to_root(const std::shared_ptr< Node > &node, ProcessingToken token, unsigned int channel=0)
Add node to specific processing token and channel.
RootNode & get_root_node(ProcessingToken token, unsigned int channel)
Gets or creates the root node for a specific token and channel.
Central manager for the computational processing node graph.
void unregister_node(const std::shared_ptr< Node > &node)
Removes a node from this root node.
A C++20 coroutine-based audio processing task with sample-accurate timing.
void add_task(const std::shared_ptr< Routine > &routine, const std::string &name="", bool initialize=false)
Add a routine to the scheduler based on its processing token.
uint64_t seconds_to_samples(double seconds) const
Converts a time in seconds to a number of samples.
uint64_t current_units(ProcessingToken token=ProcessingToken::SAMPLE_ACCURATE) const
Get current processing units for a domain.
bool cancel_task(const std::shared_ptr< Routine > &routine)
Cancels and removes a task from the scheduler.
Token-based multimodal task scheduling system for unified coroutine processing.
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
ProcessingToken
Enumerates the different processing domains for nodes.
Templated awaitable for accessing a coroutine's promise object.
Awaitable object for precise sample-accurate timing delays.