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

◆ start()

void MayaFlux::Kriya::EventChain::start ( )

Starts executing the event chain.

This method begins the execution of the event chain, scheduling each event to occur at its specified time. The events are executed in the order they were added, with the specified delays between them.

The timing is sample-accurate, ensuring that each event occurs at precisely the right moment in the computational timeline.

Definition at line 28 of file Chain.cpp.

29{
30 if (m_events.empty())
31 return;
32
33 auto shared_this = std::make_shared<EventChain>(*this);
34
35 auto coroutine_func = [](Vruta::TaskScheduler& scheduler, std::shared_ptr<EventChain> chain) -> MayaFlux::Vruta::SoundRoutine {
36 for (const auto& event : chain->m_events) {
37 co_await SampleDelay { scheduler.seconds_to_samples(event.delay_seconds) };
38 try {
39 if (event.action) {
40 event.action();
41 }
42 } catch (const std::exception& e) {
43 std::cerr << "Exception in EventChain action: " << e.what() << '\n';
44 } catch (...) {
45 std::cerr << "Unknown exception in EventChain action" << '\n';
46 }
47 }
48 };
49
50 m_routine = std::make_shared<Vruta::SoundRoutine>(coroutine_func(m_Scheduler, shared_this));
52}
Vruta::TaskScheduler & m_Scheduler
Reference to the scheduler that manages timing.
Definition Chain.hpp:113
std::vector< TimedEvent > m_events
Collection of events in this chain.
Definition Chain.hpp:105
std::shared_ptr< Vruta::SoundRoutine > m_routine
The underlying computational routine that implements the chain.
Definition Chain.hpp:121
A C++20 coroutine-based audio processing task with sample-accurate timing.
Definition Routine.hpp:309
void add_task(std::shared_ptr< Routine > routine, const std::string &name="", bool initialize=false)
Add a routine to the scheduler based on its processing token.
Definition Scheduler.cpp:17

References MayaFlux::Vruta::TaskScheduler::add_task(), m_events, m_routine, m_Scheduler, and MayaFlux::Vruta::TaskScheduler::seconds_to_samples().

Referenced by MayaFlux::Kriya::Sequence::execute().

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