MayaFlux 0.3.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 CUSTOM
20};
21
22/**
23 * @enum DelayContext
24 * @brief Discriminator for different temporal delay mechanisms
25 *
26 * Allows routines to specify which timing mechanism should trigger
27 * their resumption, preventing cross-contamination between different
28 * temporal domains within the same processing token.
29 */
30enum class DelayContext : uint8_t {
31 NONE, ///< No active delay, resume immediately
32 SAMPLE_BASED, ///< Sample-accurate delay (audio domain)
33 BUFFER_BASED, ///< Buffer-cycle delay (audio hardware boundary)
34 FRAME_BASED, ///< Frame-rate delay (Graphics domain)
35 EVENT_BASED, ///< Event-driven delay (user events, etc.)
36 AWAIT ///< Awaiter-induced delay (temporary suspension)
37};
38}
39
40namespace MayaFlux::Nodes {
41/**
42 * @enum ProcessingToken
43 * @brief Enumerates the different processing domains for nodes
44 *
45 * This enum defines the various processing rates or domains that nodes can operate in.
46 * Each token represents a specific type of processing, such as audio rate, visual rate,
47 * or custom processing rates. Nodes can be registered under these tokens to indicate
48 * their intended processing behavior within a RootNode.
49 */
50enum class ProcessingToken {
51 AUDIO_RATE, ///< Nodes that process at the audio sample rate
52 VISUAL_RATE, ///< Nodes that process at the visual frame rate
53 EVENT_RATE, ///< Nodes that process based on event triggers (e.g., input events)
54 CUSTOM_RATE ///< Nodes that process at a custom-defined rate
55};
56}
57
58namespace MayaFlux::Buffers {
59
60/**
61 * @enum ProcessingToken
62 * @brief Bitfield enum defining processing characteristics and backend requirements for buffer operations
63 *
64 * ProcessingToken provides a flexible bitfield system for specifying how buffers and their processors
65 * should be handled within the MayaFlux engine. These tokens enable fine-grained control over processing
66 * rate, execution location, and concurrency patterns, allowing the system to optimize resource allocation
67 * and execution strategies based on specific requirements.
68 *
69 * The token system is designed as a bitfield to allow combination of orthogonal characteristics:
70 * - **Rate Tokens**: Define the temporal processing characteristics (SAMPLE_RATE vs FRAME_RATE)
71 * - **Device Tokens**: Specify execution location (CPU_PROCESS vs GPU_PROCESS)
72 * - **Concurrency Tokens**: Control execution pattern (SEQUENTIAL vs PARALLEL)
73 * - **Backend Tokens**: Predefined combinations optimized for specific use cases
74 *
75 * This architecture enables the buffer system to make intelligent decisions about processor compatibility,
76 * resource allocation, and execution optimization while maintaining flexibility for custom processing
77 * scenarios.
78 */
79enum ProcessingToken : uint32_t {
80 /**
81 * @brief Processes data at audio sample rate with buffer-sized chunks
82 *
83 * Evaluates one audio buffer size (typically 512 samples) at a time, executing at
84 * sample_rate/buffer_size frequency. This is the standard token for audio processing
85 * operations that work with discrete audio blocks in real-time processing scenarios.
86 */
88
89 /**
90 * @brief Processes data at video frame rate
91 *
92 * Evaluates one video frame at a time, typically at 30-120 Hz depending on the
93 * video processing requirements. This token is optimized for video buffer operations
94 * and graphics processing workflows that operate on complete frame data.
95 */
97
98 /**
99 * @brief Processes data on event arrival (async/sporadic)
100 *
101 * Unlike SAMPLE_RATE (fixed audio callback) or FRAME_RATE (vsync),
102 * EVENT_RATE processes when external events arrive. Used for input
103 * devices, network messages, or other async data sources.
104 * Processing is triggered by event, not by timer.
105 */
107
108 /**
109 * @brief Executes processing operations on CPU threads
110 *
111 * Specifies that the processing should occur on CPU cores using traditional
112 * threading models. This is optimal for operations that benefit from CPU's
113 * sequential processing capabilities or require complex branching logic.
114 */
116
117 /**
118 * @brief Executes processing operations on GPU hardware
119 *
120 * Specifies that the processing should leverage GPU compute capabilities,
121 * typically through compute shaders, CUDA, or OpenCL. This is optimal for
122 * massively parallel operations that can benefit from GPU's parallel architecture.
123 */
125
126 /**
127 * @brief Processes operations sequentially, one after another
128 *
129 * Ensures that processing operations are executed in a deterministic order
130 * without parallelization. This is essential for operations where execution
131 * order affects the final result or when shared resources require serialized access.
132 */
134
135 /**
136 * @brief Processes operations in parallel when possible
137 *
138 * Enables concurrent execution of processing operations when they can be
139 * safely parallelized. This maximizes throughput for operations that can
140 * benefit from parallel execution without introducing race conditions.
141 */
142 PARALLEL = 0x20,
143
144 /**
145 * @brief Standard audio processing backend configuration
146 *
147 * Combines SAMPLE_RATE | CPU_PROCESS | SEQUENTIAL for traditional audio processing.
148 * This processes audio on the chosen backend (default RtAudio) using CPU threads
149 * in sequential order within the audio callback loop. This is the most common
150 * configuration for real-time audio processing applications.
151 */
153
154 /**
155 * @brief Standard graphics processing backend configuration
156 *
157 * Combines FRAME_RATE | GPU_PROCESS | PARALLEL for graphics processing.
158 * This processes video/graphics data on the chosen backend (default GLFW) using
159 * GPU hardware with parallel execution within the graphics callback loop.
160 * Optimal for real-time graphics processing and video effects.
161 */
163
164 /**
165 * @brief High-performance audio processing with GPU acceleration
166 *
167 * Combines SAMPLE_RATE | GPU_PROCESS | PARALLEL for GPU-accelerated audio processing.
168 * This offloads audio processing to GPU hardware, typically using compute shaders
169 * for parallel execution. Useful for computationally intensive audio operations
170 * like convolution, FFT processing, or complex effects that benefit from GPU parallelization.
171 */
173
174 /**
175 * @brief Window event stream processing
176 *
177 * Processes window lifecycle events (resize, close, focus) and input events
178 * (keyboard, mouse) at frame rate using CPU in sequential order. This is
179 * distinct from graphics rendering - it handles the window container itself,
180 * not its visual content.
181 */
183
184 /**
185 * @brief Input device processing backend configuration
186 *
187 * Combines EVENT_RATE | CPU_PROCESS | SEQUENTIAL for input handling.
188 * Processes input from HID, MIDI, OSC, Serial backends on the CPU
189 * in sequential order as events arrive. Input is inherently event-driven
190 * and doesn't follow fixed sample/frame timing.
191 */
193
194 /**
195 * @brief Control data processing (LFOs, envelopes, modulation)
196 *
197 * Combines EVENT_RATE | CPU_PROCESS | PARALLEL for control signals.
198 * Control-rate data updates less frequently than audio but needs
199 * to be processed promptly when it changes.
200 */
202};
203
204}
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:11
@ 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.
@ 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.
@ FRAME_BASED
Frame-rate delay (Graphics domain)
@ NONE
No active delay, 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.)