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