10 : m_scheduler(scheduler)
15 std::vector<std::reference_wrapper<BufferPipeline>> pipelines,
16 uint32_t sync_every_n_cycles,
17 uint64_t samples_per_cycle)
24 if (promise.should_terminate) {
28 if (cycle % sync_every_n_cycles == 0) {
29 for (
auto& pipeline_ref : pipelines) {
30 auto& pipeline = pipeline_ref.get();
31 if (pipeline.has_pending_data()) {
32 std::cout <<
"Sync point: Pipeline has stale data at cycle " << cycle <<
'\n';
37 for (
auto& pipeline_ref : pipelines) {
38 pipeline_ref.get().execute_once();
47 std::vector<std::reference_wrapper<BufferPipeline>> pipelines,
48 uint32_t sync_every_n_cycles,
49 double seconds_per_cycle)
52 auto routine =
sync_pipelines(pipelines, sync_every_n_cycles, samples_per_cycle);
53 return std::make_shared<Vruta::SoundRoutine>(std::move(routine));
57 std::shared_ptr<Buffers::AudioBuffer> buffer,
58 std::function<
void(uint32_t)> on_data_ready,
59 std::function<
void(uint32_t)> on_data_expired)
66 if (promise.should_terminate) {
70 if (buffer->has_data_for_cycle()) {
74 if (buffer->has_data_for_cycle()) {
75 on_data_expired(cycle + 1);
Vruta::SoundRoutine sync_pipelines(std::vector< std::reference_wrapper< BufferPipeline > > pipelines, uint32_t sync_every_n_cycles=1, uint64_t samples_per_cycle=1)
Create a synchronization routine for multiple pipelines.
Vruta::SoundRoutine manage_transient_data(std::shared_ptr< Buffers::AudioBuffer > buffer, std::function< void(uint32_t)> on_data_ready, std::function< void(uint32_t)> on_data_expired)
Create a transient data management routine.
CycleCoordinator(Vruta::TaskScheduler &scheduler)
Construct coordinator with task scheduler integration.
std::shared_ptr< Vruta::SoundRoutine > sync_pipelines_at_rate(std::vector< std::reference_wrapper< BufferPipeline > > pipelines, uint32_t sync_every_n_cycles, double seconds_per_cycle)
Create a synchronization routine based on real-time rate.
Vruta::TaskScheduler & m_scheduler
A C++20 coroutine-based audio processing task with sample-accurate timing.
uint64_t seconds_to_samples(double seconds) const
Converts a time in seconds to a number of samples.
Token-based multimodal task scheduling system for unified coroutine processing.
Templated awaitable for accessing a coroutine's promise object.
Awaitable object for precise sample-accurate timing delays.