MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
ProcessingTokens.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace MayaFlux::Vruta {
4
5enum class ProcessingToken {
6 SAMPLE_ACCURATE, ///< Coroutine is sample-accurate
7 FRAME_ACCURATE, ///< Coroutine is frame-accurate
8 /**
9 * @brief Event-driven execution - process when events arrive
10 *
11 * Unlike FRAME_ACCURATE (which waits for vsync) or SAMPLE_ACCURATE
12 * (which waits for audio callback), EVENT_DRIVEN coroutines resume
13 * whenever their associated events fire. Used for input handling,
14 * UI interactions, or any sporadic/asynchronous processing.
15 */
17 MULTI_RATE, ///< Coroutine can handle multiple sample rates. Picks the frame-accurate processing token by default
18 ON_DEMAND, ///< Coroutine is executed on demand, not scheduled
19 /**
20 * @brief Condition-driven execution - resume when a caller-supplied predicate returns true.
21 *
22 * FreeRoutine coroutines carry this token. The scheduler owns a dedicated
23 * thread for this domain that loops continuously, calling try_resume() on
24 * each CONDITIONAL task. try_resume() evaluates the condition stored in the
25 * promise by the most recent ConditionAwaiter; if it returns true the
26 * coroutine is resumed on the scheduler thread. No clock is created for
27 * this domain.
28 */
30 CUSTOM
31};
32
33/**
34 * @enum DelayContext
35 * @brief Discriminator for different temporal delay mechanisms
36 *
37 * Allows routines to specify which timing mechanism should trigger
38 * their resumption, preventing cross-contamination between different
39 * temporal domains within the same processing token.
40 */
41enum class DelayContext : uint8_t {
42 NONE, ///< No active delay, try resume immediately
43 SAMPLE_BASED, ///< Sample-accurate delay (audio domain)
44 BUFFER_BASED, ///< Buffer-cycle delay (audio hardware boundary)
45 FRAME_BASED, ///< Frame-rate delay (Graphics domain)
46 EVENT_BASED, ///< Event-driven delay (user events, etc.)
47 AWAIT, ///< Awaiter-induced delay (temporary suspension)
48 MULTIPLE ///< Armed on both sample and frame clocks; first to arrive resumes (CrossRoutine)
49};
50}
51
52namespace MayaFlux::Nodes {
53/**
54 * @enum ProcessingToken
55 * @brief Enumerates the different processing domains for nodes
56 *
57 * This enum defines the various processing rates or domains that nodes can operate in.
58 * Each token represents a specific type of processing, such as audio rate, visual rate,
59 * or custom processing rates. Nodes can be registered under these tokens to indicate
60 * their intended processing behavior within a RootNode.
61 */
62enum class ProcessingToken {
63 AUDIO_RATE, ///< Nodes that process at the audio sample rate
64 VISUAL_RATE, ///< Nodes that process at the visual frame rate
65 EVENT_RATE, ///< Nodes that process based on event triggers (e.g., input events)
66 CUSTOM_RATE ///< Nodes that process at a custom-defined rate
67};
68}
69
70namespace MayaFlux::Buffers {
71
72/**
73 * @enum ProcessingToken
74 * @brief Bitfield enum defining processing characteristics and backend requirements for buffer operations
75 *
76 * ProcessingToken provides a flexible bitfield system for specifying how buffers and their processors
77 * should be handled within the MayaFlux engine. These tokens enable fine-grained control over processing
78 * rate, execution location, and concurrency patterns, allowing the system to optimize resource allocation
79 * and execution strategies based on specific requirements.
80 *
81 * The token system is designed as a bitfield to allow combination of orthogonal characteristics:
82 * - **Rate Tokens**: Define the temporal processing characteristics (SAMPLE_RATE vs FRAME_RATE)
83 * - **Device Tokens**: Specify execution location (CPU_PROCESS vs GPU_PROCESS)
84 * - **Concurrency Tokens**: Control execution pattern (SEQUENTIAL vs PARALLEL)
85 * - **Backend Tokens**: Predefined combinations optimized for specific use cases
86 *
87 * This architecture enables the buffer system to make intelligent decisions about processor compatibility,
88 * resource allocation, and execution optimization while maintaining flexibility for custom processing
89 * scenarios.
90 */
91enum ProcessingToken : uint32_t {
92 /**
93 * @brief Processes data at audio sample rate with buffer-sized chunks
94 *
95 * Evaluates one audio buffer size (typically 512 samples) at a time, executing at
96 * sample_rate/buffer_size frequency. This is the standard token for audio processing
97 * operations that work with discrete audio blocks in real-time processing scenarios.
98 */
100
101 /**
102 * @brief Processes data at video frame rate
103 *
104 * Evaluates one video frame at a time, typically at 30-120 Hz depending on the
105 * video processing requirements. This token is optimized for video buffer operations
106 * and graphics processing workflows that operate on complete frame data.
107 */
109
110 /**
111 * @brief Processes data on event arrival (async/sporadic)
112 *
113 * Unlike SAMPLE_RATE (fixed audio callback) or FRAME_RATE (vsync),
114 * EVENT_RATE processes when external events arrive. Used for input
115 * devices, network messages, or other async data sources.
116 * Processing is triggered by event, not by timer.
117 */
119
120 /**
121 * @brief Executes processing operations on CPU threads
122 *
123 * Specifies that the processing should occur on CPU cores using traditional
124 * threading models. This is optimal for operations that benefit from CPU's
125 * sequential processing capabilities or require complex branching logic.
126 */
128
129 /**
130 * @brief Executes processing operations on GPU hardware
131 *
132 * Specifies that the processing should leverage GPU compute capabilities,
133 * typically through compute shaders, CUDA, or OpenCL. This is optimal for
134 * massively parallel operations that can benefit from GPU's parallel architecture.
135 */
137
138 /**
139 * @brief Processes operations sequentially, one after another
140 *
141 * Ensures that processing operations are executed in a deterministic order
142 * without parallelization. This is essential for operations where execution
143 * order affects the final result or when shared resources require serialized access.
144 */
146
147 /**
148 * @brief Processes operations in parallel when possible
149 *
150 * Enables concurrent execution of processing operations when they can be
151 * safely parallelized. This maximizes throughput for operations that can
152 * benefit from parallel execution without introducing race conditions.
153 */
154 PARALLEL = 0x20,
155
156 /**
157 * @brief Standard audio processing backend configuration
158 *
159 * Combines SAMPLE_RATE | CPU_PROCESS | SEQUENTIAL for traditional audio processing.
160 * This processes audio on the chosen backend using CPU threads
161 * in sequential order within the audio callback loop. This is the most common
162 * configuration for real-time audio processing applications.
163 */
165
166 /**
167 * @brief Standard graphics processing backend configuration
168 *
169 * Combines FRAME_RATE | GPU_PROCESS | PARALLEL for graphics processing.
170 * This processes video/graphics data on the chosen backend (default GLFW) using
171 * GPU hardware with parallel execution within the graphics callback loop.
172 * Optimal for real-time graphics processing and video effects.
173 */
175
176 /**
177 * @brief High-performance audio processing with GPU acceleration
178 *
179 * Combines SAMPLE_RATE | GPU_PROCESS | PARALLEL for GPU-accelerated audio processing.
180 * This offloads audio processing to GPU hardware, typically using compute shaders
181 * for parallel execution. Useful for computationally intensive audio operations
182 * like convolution, FFT processing, or complex effects that benefit from GPU parallelization.
183 */
185
186 /**
187 * @brief Window event stream processing
188 *
189 * Processes window lifecycle events (resize, close, focus) and input events
190 * (keyboard, mouse) at frame rate using CPU in sequential order. This is
191 * distinct from graphics rendering - it handles the window container itself,
192 * not its visual content.
193 */
195
196 /**
197 * @brief Input device processing backend configuration
198 *
199 * Combines EVENT_RATE | CPU_PROCESS | SEQUENTIAL for input handling.
200 * Processes input from HID, MIDI, OSC, Serial backends on the CPU
201 * in sequential order as events arrive. Input is inherently event-driven
202 * and doesn't follow fixed sample/frame timing.
203 */
205
206 /**
207 * @brief Control data processing (LFOs, envelopes, modulation)
208 *
209 * Combines EVENT_RATE | CPU_PROCESS | PARALLEL for control signals.
210 * Control-rate data updates less frequently than audio but needs
211 * to be processed promptly when it changes.
212 */
214};
215
216}
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
@ GPU_PROCESS
Executes processing operations on GPU hardware.
@ SAMPLE_RATE
Processes data at audio sample rate with buffer-sized chunks.
@ CPU_PROCESS
Executes processing operations on CPU threads.
@ AUDIO_BACKEND
Standard audio processing backend configuration.
@ PARALLEL
Processes operations in parallel when possible.
@ SEQUENTIAL
Processes operations sequentially, one after another.
@ EVENT_RATE
Processes data on event arrival (async/sporadic)
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.
@ FRAME_RATE
Processes data at video frame rate.
@ WINDOW_EVENTS
Window event stream processing.
@ INPUT_BACKEND
Input device processing backend configuration.
@ CONTROL_DATA
Control data processing (LFOs, envelopes, modulation)
@ AUDIO_PARALLEL
High-performance audio processing with GPU acceleration.
ProcessingToken
Enumerates the different processing domains for nodes.
@ AUDIO_RATE
Nodes that process at the audio sample rate.
@ CUSTOM_RATE
Nodes that process at a custom-defined rate.
@ VISUAL_RATE
Nodes that process at the visual frame rate.
@ EVENT_RATE
Nodes that process based on event triggers (e.g., input events)
Contains the node-based computational processing system components.
Definition Chronie.hpp:14
@ MULTI_RATE
Coroutine can handle multiple sample rates. Picks the frame-accurate processing token by default.
@ EVENT_DRIVEN
Event-driven execution - process when events arrive.
@ CONDITIONAL
Condition-driven execution - resume when a caller-supplied predicate returns true.
@ FRAME_ACCURATE
Coroutine is frame-accurate.
@ SAMPLE_ACCURATE
Coroutine is sample-accurate.
@ ON_DEMAND
Coroutine is executed on demand, not scheduled.
DelayContext
Discriminator for different temporal delay mechanisms.
@ MULTIPLE
Armed on both sample and frame clocks; first to arrive resumes (CrossRoutine)
@ FRAME_BASED
Frame-rate delay (Graphics domain)
@ NONE
No active delay, try resume immediately.
@ SAMPLE_BASED
Sample-accurate delay (audio domain)
@ BUFFER_BASED
Buffer-cycle delay (audio hardware boundary)
@ AWAIT
Awaiter-induced delay (temporary suspension)
@ EVENT_BASED
Event-driven delay (user events, etc.)