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