MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
CycleCoordinator.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace MayaFlux::Kriya {
7
8class BufferPipeline;
9
10/**
11 * @class CycleCoordinator
12 * @brief Cross-pipeline synchronization and coordination system.
13 *
14 * CycleCoordinator provides synchronization mechanisms for coordinating multiple
15 * BufferPipeline instances and managing transient data lifecycles. It integrates
16 * with the Vruta scheduling system to provide sample-accurate timing coordination
17 * across complex processing networks.
18 *
19 * **Example Usage:**
20 * ```cpp
21 * CycleCoordinator coordinator(*scheduler);
22 *
23 * // Synchronize multiple analysis pipelines
24 * auto sync_routine = coordinator.sync_pipelines({
25 * std::ref(spectral_pipeline),
26 * std::ref(temporal_pipeline),
27 * std::ref(feature_pipeline)
28 * }, 4); // Sync every 4 cycles
29 *
30 * // Manage transient capture data
31 * auto data_routine = coordinator.manage_transient_data(
32 * capture_buffer,
33 * [](uint32_t cycle) { std::cout << "Data ready: " << cycle << std::endl; },
34 * [](uint32_t cycle) { cleanup_expired_data(cycle); }
35 * );
36 *
37 * scheduler->add_task(sync_routine);
38 * scheduler->add_task(data_routine);
39 * ```
40 *
41 * @see BufferPipeline For pipeline construction
42 * @see BufferCapture For data capture strategies
43 * @see Vruta::TaskScheduler For execution scheduling
44 */
45class MAYAFLUX_API CycleCoordinator {
46public:
47 /**
48 * @brief Construct coordinator with task scheduler integration.
49 * @param scheduler Vruta task scheduler for timing coordination
50 */
51 explicit CycleCoordinator(Vruta::TaskScheduler& scheduler);
52
53 /**
54 * @brief Create a synchronization routine for multiple pipelines.
55 * @param pipelines Vector of pipeline references to synchronize
56 * @param sync_every_n_cycles Synchronization interval in cycles
57 * @param samples_per_cycle Number of samples per cycle for timing
58 * @return SoundRoutine that manages pipeline synchronization
59 */
60 Vruta::SoundRoutine sync_pipelines(
61 std::vector<std::reference_wrapper<BufferPipeline>> pipelines,
62 uint32_t sync_every_n_cycles = 1, uint64_t samples_per_cycle = 1);
63
64 /**
65 * @brief Create a synchronization routine based on real-time rate.
66 * @param pipelines Vector of pipeline references to synchronize
67 * @param sync_every_n_cycles Synchronization interval in cycles
68 * @param seconds_per_cycle Duration of each cycle in seconds
69 * @return SoundRoutine that manages pipeline synchronization
70 */
71 std::shared_ptr<Vruta::SoundRoutine> sync_pipelines_at_rate(
72 std::vector<std::reference_wrapper<BufferPipeline>> pipelines,
73 uint32_t sync_every_n_cycles,
74 double seconds_per_cycle);
75
76 /**
77 * @brief Create a transient data management routine.
78 * @param buffer AudioBuffer with transient data lifecycle
79 * @param on_data_ready Callback when data becomes available
80 * @param on_data_expired Callback when data expires
81 * @return SoundRoutine that manages data lifecycle
82 */
83 Vruta::SoundRoutine manage_transient_data(
84 std::shared_ptr<Buffers::AudioBuffer> buffer,
85 std::function<void(uint32_t)> on_data_ready,
86 std::function<void(uint32_t)> on_data_expired);
87
88private:
90};
91}
Cross-pipeline synchronization and coordination system.
A C++20 coroutine-based audio processing task with sample-accurate timing.
Definition Routine.hpp:309
Token-based multimodal task scheduling system for unified coroutine processing.
Definition Scheduler.hpp:51