MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
GlobalStreamInfo.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace MayaFlux::Core {
4
5enum AudioBackendType : uint8_t {
7};
8
9/**
10 * @struct GlobalStreamInfo
11 * @brief Comprehensive configuration for digital audio stream processing
12 *
13 * Defines the technical parameters and operational characteristics for
14 * audio data flow throughout the system, including format specifications,
15 * buffer configurations, and I/O endpoint settings.
16 */
18 /** @brief Number of samples processed per second (Hz) */
19 uint32_t sample_rate = 48000;
20
21 /** @brief Number of samples per processing block */
22 uint32_t buffer_size = 512;
23
24 /**
25 * @enum AudioFormat
26 * @brief Defines the binary representation of audio sample data
27 *
28 * Specifies the numerical precision and memory layout for digital
29 * audio samples throughout the processing chain.
30 */
31 enum class AudioFormat : uint8_t {
32 FLOAT32, ///< 32-bit floating point representation (-1.0 to 1.0)
33 FLOAT64, ///< 64-bit floating point representation (-1.0 to 1.0)
34 INT16, ///< 16-bit integer representation (-32768 to 32767)
35 INT24, ///< 24-bit integer representation (-8388608 to 8388607)
36 INT32 ///< 32-bit integer representation (-2147483648 to 2147483647)
37 };
38
39 /**
40 * @enum AudioApi
41 * @brief Enumeration of supported audio APIs for wrapper backends like RtAudio
42 */
43 enum class AudioApi : uint8_t {
44 DEFAULT,
45 ALSA,
46 PULSE,
47 JACK,
48 CORE,
49 WASAPI,
50 ASIO,
51 DS,
52 OSS
53 };
54
55 /** @brief Selected audio backend implementation */
57
58 /** @brief Selected audio API for stream processing */
60
61 /** @brief Sample data format for stream processing */
63
64 /** @brief Channel organization mode (true: planar, false: interleaved) */
65 bool non_interleaved = false;
66
67 /**
68 * @struct ChannelConfig
69 * @brief Configuration for input or output data channels
70 *
71 * Defines the parameters for a set of audio channels that either
72 * capture input signals or render output signals.
73 */
75 /** @brief Whether this channel set is active in the stream */
76 bool enabled = true;
77
78 /** @brief Number of discrete channels in this set */
79 uint32_t channels = 2;
80
81 /** @brief System identifier for the associated device (-1 for default) */
82 int device_id = -1;
83
84 /** @brief Human-readable identifier for the associated device */
85 std::string device_name;
86 };
87
88 /** @brief Configuration for output signal channels */
90
91 /** @brief Configuration for input signal channels (disabled by default) */
92 ChannelConfig input = { .enabled = false, .channels = 2, .device_id = -1, .device_name = "" };
93
94 /**
95 * @enum StreamPriority
96 * @brief Processing priority levels for the audio stream
97 *
98 * Defines the system resource allocation priority for the audio
99 * processing thread relative to other system processes.
100 */
101 enum class StreamPriority : uint8_t {
102 LOW, ///< Minimal resource priority
103 NORMAL, ///< Standard resource priority
104 HIGH, ///< Elevated resource priority
105 REALTIME ///< Maximum resource priority with timing guarantees
106 };
107
108 /** @brief System resource priority for audio processing */
110
111 /** @brief Number of buffers in the processing queue (0 for system default) */
112 double buffer_count = 0.F;
113
114 /** @brief Whether to automatically convert between sample formats */
116
117 /** @brief Whether to handle buffer underrun/overrun conditions */
118 bool handle_xruns = true;
119
120 /** @brief Whether to use callback-based processing (vs. blocking I/O) */
121 bool use_callback = true;
122
123 /** @brief Target latency for stream processing in milliseconds */
124 double stream_latency_ms = 0.0;
125
126 /**
127 * @enum DitherMethod
128 * @brief Noise shaping algorithms for quantization error mitigation
129 *
130 * Defines the mathematical approach used to distribute quantization
131 * errors when converting between different sample formats.
132 */
133 enum class DitherMethod : uint8_t {
134 NONE, ///< No dithering applied
135 RECTANGULAR, ///< Uniform random distribution
136 TRIANGULAR, ///< Weighted triangular distribution
137 GAUSSIAN, ///< Normal (bell curve) distribution
138 SHAPED ///< Psychoacoustically optimized noise shaping
139 };
140
141 /** @brief Dithering algorithm for format conversions */
143
144 /**
145 * @struct MidiConfig
146 * @brief Configuration for MIDI data channels
147 *
148 * Defines the parameters for digital musical instrument control
149 * data transmission and reception.
150 */
151 struct MidiConfig {
152 /** @brief Whether this MIDI channel is active */
153 bool enabled = false;
154
155 /** @brief System identifier for the associated MIDI device (-1 for default) */
156 int device_id = -1;
157 };
158
159 /** @brief Configuration for MIDI input data */
161
162 /** @brief Configuration for MIDI output data */
164
165 /** @brief Whether to measure and report actual stream latency */
166 bool measure_latency = false;
167
168 /** @brief Whether to output detailed diagnostic information */
169 bool verbose_logging = false;
170
171 /** @brief Backend-specific configuration parameters */
172 std::unordered_map<std::string, std::any> backend_options;
173
174 /**
175 * @brief Calculates the total number of active channels across all directions
176 * @return Sum of all enabled input and output channels
177 */
178 uint32_t get_total_channels() const
179 {
180 return (output.enabled ? output.channels : 0) + (input.enabled ? input.channels : 0);
181 }
182
183 /**
184 * @brief Retrieves the number of output channels
185 * @return Number of output channels configured in the stream
186 */
187 uint32_t get_num_channels() const { return output.channels; }
188};
189
190}
int device_id
System identifier for the associated device (-1 for default)
uint32_t channels
Number of discrete channels in this set.
bool enabled
Whether this channel set is active in the stream.
std::string device_name
Human-readable identifier for the associated device.
Configuration for input or output data channels.
int device_id
System identifier for the associated MIDI device (-1 for default)
bool enabled
Whether this MIDI channel is active.
Configuration for MIDI data channels.
AudioApi requested_api
Selected audio API for stream processing.
DitherMethod dither
Dithering algorithm for format conversions.
uint32_t buffer_size
Number of samples per processing block.
bool measure_latency
Whether to measure and report actual stream latency.
ChannelConfig input
Configuration for input signal channels (disabled by default)
AudioApi
Enumeration of supported audio APIs for wrapper backends like RtAudio.
MidiConfig midi_input
Configuration for MIDI input data.
AudioBackendType backend
Selected audio backend implementation.
uint32_t sample_rate
Number of samples processed per second (Hz)
AudioFormat
Defines the binary representation of audio sample data.
@ FLOAT64
64-bit floating point representation (-1.0 to 1.0)
@ INT16
16-bit integer representation (-32768 to 32767)
@ INT32
32-bit integer representation (-2147483648 to 2147483647)
@ INT24
24-bit integer representation (-8388608 to 8388607)
@ FLOAT32
32-bit floating point representation (-1.0 to 1.0)
ChannelConfig output
Configuration for output signal channels.
bool verbose_logging
Whether to output detailed diagnostic information.
AudioFormat format
Sample data format for stream processing.
StreamPriority
Processing priority levels for the audio stream.
@ REALTIME
Maximum resource priority with timing guarantees.
StreamPriority priority
System resource priority for audio processing.
MidiConfig midi_output
Configuration for MIDI output data.
uint32_t get_num_channels() const
Retrieves the number of output channels.
bool use_callback
Whether to use callback-based processing (vs.
DitherMethod
Noise shaping algorithms for quantization error mitigation.
@ SHAPED
Psychoacoustically optimized noise shaping.
@ GAUSSIAN
Normal (bell curve) distribution.
@ TRIANGULAR
Weighted triangular distribution.
@ RECTANGULAR
Uniform random distribution.
bool handle_xruns
Whether to handle buffer underrun/overrun conditions.
uint32_t get_total_channels() const
Calculates the total number of active channels across all directions.
double buffer_count
Number of buffers in the processing queue (0 for system default)
std::unordered_map< std::string, std::any > backend_options
Backend-specific configuration parameters.
double stream_latency_ms
Target latency for stream processing in milliseconds.
bool non_interleaved
Channel organization mode (true: planar, false: interleaved)
bool auto_convert_format
Whether to automatically convert between sample formats.
Comprehensive configuration for digital audio stream processing.