13 : m_Scheduler(scheduler)
31 if (timer_ptr && timer_ptr->is_active()) {
32 timer_ptr->m_callback();
33 timer_ptr->m_active =
false;
36 m_routine = std::make_shared<Vruta::GraphicsRoutine>(
44 if (timer_ptr && timer_ptr->is_active()) {
45 timer_ptr->m_callback();
46 timer_ptr->m_active =
false;
49 m_routine = std::make_shared<Vruta::SoundRoutine>(
56 m_routine->initialize_state(current_time);
69 : m_Scheduler(scheduler)
70 , m_timer(scheduler, token)
75void TimedAction::execute(
const std::function<
void()>& start_func,
const std::function<
void()>& end_func,
double duration_seconds)
95 : m_scheduler(scheduler)
96 , m_node_graph_manager(node_graph_manager)
97 , m_buffer_manager(buffer_manager)
98 , m_timer(scheduler, token)
99 , m_execution_token(token)
104 double duration_seconds,
106 const std::vector<uint32_t>& channels)
115 for (
auto channel : channels) {
134 for (
const auto& ch : channels) {
135 network->add_channel_usage(ch);
146 double duration_seconds,
Core::GlobalNetworkConfig network
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.
TemporalActivation(Vruta::TaskScheduler &scheduler, Nodes::NodeGraphManager &graph_manager, Buffers::BufferManager &buffer_manager, Vruta::ProcessingToken token=Vruta::ProcessingToken::SAMPLE_ACCURATE)
Constructs a TemporalActivation with the specified scheduler and manager.
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.
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.
TimedAction(Vruta::TaskScheduler &scheduler, Vruta::ProcessingToken token=Vruta::ProcessingToken::SAMPLE_ACCURATE)
Constructs a TimedAction with the specified scheduler.
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.
bool m_active
Flag indicating whether a callback is currently scheduled.
bool is_active() const
Checks if a callback is currently scheduled.
std::shared_ptr< Vruta::Routine > m_routine
The underlying computational routine that implements the timer.
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.
Vruta::ProcessingToken m_token
The processing token that determines the timing context and thread evaluator for this timer.
void schedule(double delay_seconds, std::function< void()> callback)
Schedules a callback to execute after a delay.
Timer(Vruta::TaskScheduler &scheduler, Vruta::ProcessingToken token=Vruta::ProcessingToken::SAMPLE_ACCURATE)
Constructs a Timer with the specified scheduler.
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 graphics processing task with frame-accurate timing.
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_units(double seconds, ProcessingToken token=ProcessingToken::SAMPLE_ACCURATE) const
Convert seconds to processing units for a specific domain.
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.
@ FRAME_ACCURATE
Coroutine is frame-accurate.
graphics-domain awaiter for frame-accurate timing delays
Templated awaitable for accessing a coroutine's promise object.
Awaitable object for precise sample-accurate timing delays.