MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Operators.cpp
Go to the documentation of this file.
1#include "Operators.hpp"
2
6
7namespace MayaFlux::Kriya {
8
9NodeTimeSpec::NodeTimeSpec(double seconds, std::optional<std::vector<uint32_t>> channels)
10 : m_seconds(seconds)
11 , m_channels(std::move(channels))
12 , m_scheduler(*MayaFlux::get_scheduler())
13 , m_graph_manager(*MayaFlux::get_node_graph_manager())
14{
15}
16
18 : m_seconds(seconds)
19 , m_scheduler(scheduler)
20 , m_graph_manager(graph_manager)
21{
22}
23
24void operator>>(std::shared_ptr<Nodes::Node> node, DAC& dac)
25{
27}
28
29void operator>>(std::shared_ptr<Nodes::Node> node, const NodeTimeSpec& time_op)
30{
31 auto timer = std::make_shared<NodeTimer>(time_op.m_scheduler, time_op.m_graph_manager);
32
33 if (time_op.has_explicit_channels()) {
34 timer->play_for(node, time_op.get_seconds(), time_op.get_channels());
35 } else {
36 timer->play_for(node, time_op.get_seconds());
37 }
38
39 static std::vector<std::shared_ptr<NodeTimer>> active_timers;
40 active_timers.push_back(timer);
41
42 if (active_timers.size() > MayaFlux::Config::get_node_config().callback_cache_size) {
43 active_timers.erase(
44 std::remove_if(active_timers.begin(), active_timers.end(),
45 [](const std::shared_ptr<NodeTimer>& t) {
46 return !t->is_active();
47 }),
48 active_timers.end());
49 }
50}
51
52NodeTimeSpec Time(double seconds)
53{
54 return { seconds };
55}
56
57NodeTimeSpec Time(double seconds, uint32_t channel)
58{
59 return NodeTimeSpec(seconds, std::vector<uint32_t> { channel });
60}
61
62NodeTimeSpec Time(double seconds, std::vector<uint32_t> channels)
63{
64 return { seconds, channels };
65}
66
67}
unsigned int channel
The output channel to connect to.
bool has_explicit_channels() const
Checks if explicit channels were specified.
Definition Operators.hpp:73
NodeTimeSpec(double seconds, std::optional< std::vector< uint32_t > > channels=std::nullopt)
Constructs a NodeTimeSpec with the specified duration.
Definition Operators.cpp:9
Vruta::TaskScheduler & m_scheduler
Reference to the scheduler that will manage timing.
Definition Operators.hpp:98
Nodes::NodeGraphManager & m_graph_manager
Reference to the graph manager that will manage node connections.
double get_seconds() const
Gets the duration of this operation.
Definition Operators.hpp:63
const std::vector< uint32_t > & get_channels() const
Gets the list of channels to activate.
Definition Operators.hpp:82
Represents a timed activation operation for processing nodes.
Definition Operators.hpp:33
Central manager for the computational processing node graph.
Token-based multimodal task scheduling system for unified coroutine processing.
Definition Scheduler.hpp:51
NodeConfig & get_node_config()
Definition Config.cpp:44
NodeTimeSpec Time(double seconds)
Definition Operators.cpp:52
std::shared_ptr< BufferPipeline > operator>>(std::shared_ptr< BufferPipeline > pipeline, BufferOperation &&operation)
std::shared_ptr< Nodes::NodeGraphManager > get_node_graph_manager()
Gets the node graph manager from the default engine.
Definition Graph.cpp:18
void register_audio_node(const std::shared_ptr< Nodes::Node > &node, uint32_t channel)
Adds a node to the root node of a specific channel.
Definition Graph.cpp:23
std::shared_ptr< Vruta::TaskScheduler > get_scheduler()
Gets the task scheduler from the default engine.
Definition Chronie.cpp:14
Main namespace for the Maya Flux audio engine.
Definition LiveAid.hpp:6