CommonLibSSE (Parapets fork)
XAudio2.h
Go to the documentation of this file.
1 #pragma once
2 
3 namespace RE
4 {
5  struct IUnknown;
6  struct IXAudio2Voice;
7  using BOOL = std::int32_t;
8 
9 #pragma pack(push, 1)
10 
11  // Numeric boundary values
12  inline constexpr auto XAUDIO2_MAX_BUFFER_BYTES = 0x80000000;
13  inline constexpr auto XAUDIO2_MAX_QUEUED_BUFFERS = 64;
14  inline constexpr auto XAUDIO2_MAX_BUFFERS_SYSTEM = 2;
15  inline constexpr auto XAUDIO2_MAX_AUDIO_CHANNELS = 64;
16  inline constexpr auto XAUDIO2_MIN_SAMPLE_RATE = 1000;
17  inline constexpr auto XAUDIO2_MAX_SAMPLE_RATE = 200000;
18  inline constexpr auto XAUDIO2_MAX_VOLUME_LEVEL = 16777216.0f;
19  inline constexpr auto XAUDIO2_MIN_FREQ_RATIO = (1 / 1024.0f);
20  inline constexpr auto XAUDIO2_MAX_FREQ_RATIO = 1024.0f;
21  inline constexpr auto XAUDIO2_DEFAULT_FREQ_RATIO = 2.0f;
22  inline constexpr auto XAUDIO2_MAX_FILTER_ONEOVERQ = 1.5f;
23  inline constexpr auto XAUDIO2_MAX_FILTER_FREQUENCY = 1.0f;
24  inline constexpr auto XAUDIO2_MAX_LOOP_COUNT = 254;
25  inline constexpr auto XAUDIO2_MAX_INSTANCES = 8;
26 
27  // Numeric values with special meanings
28  inline constexpr auto XAUDIO2_COMMIT_NOW = 0;
29  inline constexpr auto XAUDIO2_COMMIT_ALL = 0;
30  inline constexpr auto XAUDIO2_INVALID_OPSET = static_cast<std::uint32_t>(-1);
31  inline constexpr auto XAUDIO2_NO_LOOP_REGION = 0;
32  inline constexpr auto XAUDIO2_LOOP_INFINITE = 255;
33  inline constexpr auto XAUDIO2_DEFAULT_CHANNELS = 0;
34  inline constexpr auto XAUDIO2_DEFAULT_SAMPLERATE = 0;
35 
36  // Flags
38  {
46  XAUDIO2_SEND_USEFILTER = 0x0080
47  };
48 
49  // Used in IXAudio2::Initialize
51  {
53  {
54  Processor1 = 0x00000001,
55  Processor2 = 0x00000002,
56  Processor3 = 0x00000004,
57  Processor4 = 0x00000008,
58  Processor5 = 0x00000010,
59  Processor6 = 0x00000020,
60  Processor7 = 0x00000040,
61  Processor8 = 0x00000080,
62  Processor9 = 0x00000100,
63  Processor10 = 0x00000200,
64  Processor11 = 0x00000400,
65  Processor12 = 0x00000800,
66  Processor13 = 0x00001000,
67  Processor14 = 0x00002000,
68  Processor15 = 0x00004000,
69  Processor16 = 0x00008000,
70  Processor17 = 0x00010000,
71  Processor18 = 0x00020000,
72  Processor19 = 0x00040000,
73  Processor20 = 0x00080000,
74  Processor21 = 0x00100000,
75  Processor22 = 0x00200000,
76  Processor23 = 0x00400000,
77  Processor24 = 0x00800000,
78  Processor25 = 0x01000000,
79  Processor26 = 0x02000000,
80  Processor27 = 0x04000000,
81  Processor28 = 0x08000000,
82  Processor29 = 0x10000000,
83  Processor30 = 0x20000000,
84  Processor31 = 0x40000000,
85  Processor32 = 0x80000000,
86  ANY_PROCESSOR = 0xffffffff,
88  };
89  };
93 
94  // Used in XAUDIO2_DEVICE_DETAILS below to describe the types of applications
95  // that the user has specified each device as a default for. 0 means that the
96  // device isn't the default for any role.
98  {
100  {
108  };
109  };
111 
112  // Returned by IXAudio2::GetDeviceDetails
114  {
115  wchar_t DeviceID[256]; // 000 - String identifier for the audio device.
116  wchar_t DisplayName[256]; // 100 - Friendly name suitable for display to a human.
117  XAUDIO2_DEVICE_ROLE Role; // 200 - Roles that the device should be used for.
118  WAVEFORMATEXTENSIBLE OutputFormat; // 204 - The device's native PCM audio output format.
119  };
120  static_assert(sizeof(XAUDIO2_DEVICE_DETAILS) == 0x42C);
121 
122  // Returned by IXAudio2Voice::GetVoiceDetails
124  {
125  std::uint32_t CreationFlags; // 0 - Flags the voice was created with.
126  std::uint32_t InputChannels; // 4 - Channels in the voice's input audio.
127  std::uint32_t InputSampleRate; // 8 - Sample rate of the voice's input audio.
128  };
129 
130  // Used in XAUDIO2_VOICE_SENDS below
132  {
133  std::uint32_t Flags; // 0 - Either 0 or XAUDIO_SEND_USEFILTER.
134  IXAudio2Voice* pOutputVoice; // 4 - This send's destination voice.
135  };
136  static_assert(sizeof(XAUDIO2_SEND_DESCRIPTOR) == 0xC);
137 
138  // Used in the voice creation functions and in IXAudio2Voice::SetOutputVoices
140  {
141  std::uint32_t SendCount; // 0 - Number of sends from this voice.
142  XAUDIO2_SEND_DESCRIPTOR* pSends; // 4 - Array of SendCount send descriptors.
143  };
144 
145  // Used in XAUDIO2_EFFECT_CHAIN below
147  {
148  IUnknown* pEffect; // 0 - Pointer to the effect object's IUnknown interface.
149  BOOL InitialState; // 8 - TRUE if the effect should begin in the enabled state.
150  std::uint32_t OutputChannels; // 9 - How many output channels the effect should produce.
151  };
152 
153  // Used in the voice creation functions and in IXAudio2Voice::SetEffectChain
155  {
156  std::uint32_t EffectCount; // 0 - Number of effects in this voice's effect chain.
157  XAUDIO2_EFFECT_DESCRIPTOR* pEffectDescriptors; // 4 - Array of effect descriptors.
158  };
159 
160  // Used in XAUDIO2_FILTER_PARAMETERS below
162  {
164  {
165  LowPassFilter, // Attenuates frequencies above the cutoff frequency.
166  BandPassFilter, // Attenuates frequencies outside a given range.
167  HighPassFilter, // Attenuates frequencies below the cutoff frequency.
168  NotchFilter // Attenuates frequencies inside a given range.
169  };
170  };
172 
173  // Default parameters for the built-in filter
174  inline constexpr auto XAUDIO2_DEFAULT_FILTER_TYPE = XAUDIO2_FILTER_TYPE::LowPassFilter;
176  inline constexpr auto XAUDIO2_DEFAULT_FILTER_ONEOVERQ = 1.0f;
177 
178  // Used in IXAudio2::Set/GetFilterParameters and Set/GetOutputFilterParameters
180  {
181  XAUDIO2_FILTER_TYPE Type; // 0 - Low-pass, band-pass, or high-pass.
182 
183  float Frequency; // 4 - Radian frequency (2 * sin(pi*CutoffFrequency/SampleRate));
184  // must be >= 0 and <= XAUDIO2_MAX_FILTER_FREQUENCY
185  // (giving a maximum CutoffFrequency of SampleRate/6).
186  float OneOverQ; // 8 - Reciprocal of the filter's quality factor Q;
187  // must be > 0 and <= XAUDIO2_MAX_FILTER_ONEOVERQ.
188  };
189 
190  // Used in IXAudio2SourceVoice::SubmitSourceBuffer
192  {
193  std::uint32_t Flags; // 00 - Either 0 or XAUDIO2_END_OF_STREAM.
194  std::uint32_t AudioBytes; // 04 - Size of the audio data buffer in bytes.
195  const std::byte* pAudioData; // 08 - Pointer to the audio data buffer.
196 
197  std::uint32_t PlayBegin; // 10 - First sample in this buffer to be played.
198  std::uint32_t PlayLength; // 14 - Length of the region to be played in samples,
199  // or 0 to play the whole buffer.
200  std::uint32_t LoopBegin; // 18 - First sample of the region to be looped.
201  std::uint32_t LoopLength; // 1C - Length of the desired loop region in samples,
202  // or 0 to loop the entire buffer.
203  std::uint32_t LoopCount; // 20 - Number of times to repeat the loop region,
204  // or XAUDIO2_LOOP_INFINITE to loop forever.
205  void* pContext; // 24 - Context value to be passed back in callbacks.
206  };
207 
208  // Used in IXAudio2SourceVoice::SubmitSourceBuffer when submitting XWMA data.
209  // NOTE: If an XWMA sound is submitted in more than one buffer, each buffer's
210  // pDecodedPacketCumulativeBytes[PacketCount-1] value must be subtracted from
211  // all the entries in the next buffer's pDecodedPacketCumulativeBytes array.
212  // And whether a sound is submitted in more than one buffer or not, the final
213  // buffer of the sound should use the XAUDIO2_END_OF_STREAM flag, or else the
214  // client must call IXAudio2SourceVoice::Discontinuity after submitting it.
216  {
217  const std::uint32_t* pDecodePacketCumulativeBytes; // 00 - Decoded packet's cumulative size array.
218  // Each element is the number of bytes accumulated
219  // when the corresponding XWMA packet is decoded in
220  // order. The array must have PacketCount elements.
221 
222  std::uint32_t PacketCount; // 08 - Number of XWMA packets submitted. Must be >= 1 and
223  // divide evenly into XAUDIO2_BUFFER.AudioBytes.
224  };
225 
226  // Returned by IXAudio2SourceVoice::GetState
228  {
229  void* pCurrentBufferContext; // 00 - The pContext value provided in the XAUDIO2_BUFFER
230  // that is currently being processed, or NULL if
231  // there are no buffers in the queue.
232  std::uint32_t BuffersQueued; // 08 - Number of buffers currently queued on the voice
233  // (including the one that is being processed).
234  std::uint64_t SamplesPlayed; // 0C - Total number of samples produced by the voice since
235  // it began processing the current audio stream.
236  };
237 
238  // Returned by IXAudio2::GetPerformanceData
240  {
241  // CPU usage information
242  std::uint64_t AudioCyclesSinceLastQuery; // 00 - CPU cycles spent on audio processing since the
243  // last call to StartEngine or GetPerformanceData.
244  std::uint64_t TotalCyclesSinceLastQuery; // 08 - Total CPU cycles elapsed since the last call
245  // (only counts the CPU XAudio2 is running on).
246  std::uint32_t MinimumCyclesPerQuantum; // 10 - Fewest CPU cycles spent processing any one
247  // audio quantum since the last call.
248  std::uint32_t MaximumCyclesPerQuantum; // 14 - Most CPU cycles spent processing any one
249  // audio quantum since the last call.
250 
251  // Memory usage information
252  std::uint32_t MemoryUsageInBytes; // 18 - Total heap space currently in use.
253 
254  // Audio latency and glitching information
255  std::uint32_t CurrentLatencyInSamples; // 1C - Minimum delay from when a sample is read from a
256  // source buffer to when it reaches the speakers.
257  std::uint32_t GlitchesSinceEngineStarted; // 20 - Audio dropouts since the engine was started.
258 
259  // Data about XAudio2's current workload
260  std::uint32_t ActiveSourceVoiceCount; // 24 - Source voices currently playing.
261  std::uint32_t TotalSourceVoiceCount; // 28 - Source voices currently existing.
262  std::uint32_t ActiveSubmixVoiceCount; // 2C - Submix voices currently playing/existing.
263 
264  std::uint32_t ActiveResamplerCount; // 30 - Resample xAPOs currently active.
265  std::uint32_t ActiveMatrixMixCount; // 34 - MatrixMix xAPOs currently active.
266 
267  // Usage of the hardware XMA decoder (Xbox 360 only)
268  std::uint32_t ActiveXmaSourceVoices; // 38 - Number of source voices decoding XMA data.
269  std::uint32_t ActiveXmaStreams; // 3C - A voice can use more than one XMA stream.
270  };
271 
272  // Used in IXAudio2::SetDebugConfiguration
274  {
275  std::uint32_t TraceMask; // 00 - Bitmap of enabled debug message types.
276  std::uint32_t BreakMask; // 04 - Message types that will break into the debugger.
277  BOOL LogThreadID; // 08 - Whether to log the thread ID with each message.
278  BOOL LogFileline; // 0C - Whether to log the source file and line number.
279  BOOL LogFunctionName; // 10 - Whether to log the function name.
280  BOOL LogTiming; // 14 - Whether to log message timestamps.
281  };
282 #pragma pack(pop)
283 }
Definition: AbsorbEffect.h:6
constexpr auto XAUDIO2_MAX_INSTANCES
Definition: XAudio2.h:25
constexpr auto XAUDIO2_MAX_LOOP_COUNT
Definition: XAudio2.h:24
constexpr auto XAUDIO2_DEFAULT_FREQ_RATIO
Definition: XAudio2.h:21
constexpr auto XAUDIO2_MAX_VOLUME_LEVEL
Definition: XAudio2.h:18
constexpr auto XAUDIO2_MAX_BUFFERS_SYSTEM
Definition: XAudio2.h:14
constexpr auto XAUDIO2_DEFAULT_PROCESSOR
Definition: XAudio2.h:92
constexpr auto XAUDIO2_LOOP_INFINITE
Definition: XAudio2.h:32
XAUDIO2_FLAGS
Definition: XAudio2.h:38
@ XAUDIO2_END_OF_STREAM
Definition: XAudio2.h:45
@ XAUDIO2_VOICE_MUSIC
Definition: XAudio2.h:43
@ XAUDIO2_VOICE_USEFILTER
Definition: XAudio2.h:42
@ XAUDIO2_DEBUG_ENGINE
Definition: XAudio2.h:39
@ XAUDIO2_PLAY_TAILS
Definition: XAudio2.h:44
@ XAUDIO2_VOICE_NOSRC
Definition: XAudio2.h:41
@ XAUDIO2_SEND_USEFILTER
Definition: XAudio2.h:46
@ XAUDIO2_VOICE_NOPITCH
Definition: XAudio2.h:40
constexpr auto XAUDIO2_COMMIT_ALL
Definition: XAudio2.h:29
constexpr auto XAUDIO2_MAX_FILTER_FREQUENCY
Definition: XAudio2.h:23
constexpr auto XAUDIO2_DEFAULT_FILTER_ONEOVERQ
Definition: XAudio2.h:176
constexpr auto XAUDIO2_DEFAULT_CHANNELS
Definition: XAudio2.h:33
constexpr auto XAUDIO2_MAX_BUFFER_BYTES
Definition: XAudio2.h:12
constexpr auto XAUDIO2_DEFAULT_FILTER_TYPE
Definition: XAudio2.h:174
constexpr auto XAUDIO2_DEFAULT_FILTER_FREQUENCY
Definition: XAudio2.h:175
constexpr auto XAUDIO2_ANY_PROCESSOR
Definition: XAudio2.h:91
constexpr auto XAUDIO2_NO_LOOP_REGION
Definition: XAudio2.h:31
constexpr auto XAUDIO2_INVALID_OPSET
Definition: XAudio2.h:30
constexpr auto XAUDIO2_MAX_FILTER_ONEOVERQ
Definition: XAudio2.h:22
constexpr auto XAUDIO2_COMMIT_NOW
Definition: XAudio2.h:28
constexpr auto XAUDIO2_DEFAULT_SAMPLERATE
Definition: XAudio2.h:34
constexpr auto XAUDIO2_MAX_AUDIO_CHANNELS
Definition: XAudio2.h:15
constexpr auto XAUDIO2_MAX_QUEUED_BUFFERS
Definition: XAudio2.h:13
constexpr auto XAUDIO2_MAX_SAMPLE_RATE
Definition: XAudio2.h:17
constexpr auto XAUDIO2_MIN_SAMPLE_RATE
Definition: XAudio2.h:16
constexpr auto XAUDIO2_MIN_FREQ_RATIO
Definition: XAudio2.h:19
constexpr auto XAUDIO2_MAX_FREQ_RATIO
Definition: XAudio2.h:20
std::int32_t BOOL
Definition: XAPO.h:8
Definition: AudioDefs.h:21
Definition: XAudio2.h:216
const std::uint32_t * pDecodePacketCumulativeBytes
Definition: XAudio2.h:217
std::uint32_t PacketCount
Definition: XAudio2.h:222
Definition: XAudio2.h:192
std::uint32_t LoopBegin
Definition: XAudio2.h:200
std::uint32_t AudioBytes
Definition: XAudio2.h:194
std::uint32_t LoopLength
Definition: XAudio2.h:201
void * pContext
Definition: XAudio2.h:205
std::uint32_t Flags
Definition: XAudio2.h:193
const std::byte * pAudioData
Definition: XAudio2.h:195
std::uint32_t PlayBegin
Definition: XAudio2.h:197
std::uint32_t PlayLength
Definition: XAudio2.h:198
std::uint32_t LoopCount
Definition: XAudio2.h:203
Definition: XAudio2.h:274
BOOL LogFunctionName
Definition: XAudio2.h:279
std::uint32_t TraceMask
Definition: XAudio2.h:275
BOOL LogTiming
Definition: XAudio2.h:280
std::uint32_t BreakMask
Definition: XAudio2.h:276
BOOL LogThreadID
Definition: XAudio2.h:277
BOOL LogFileline
Definition: XAudio2.h:278
Definition: XAudio2.h:114
wchar_t DisplayName[256]
Definition: XAudio2.h:116
wchar_t DeviceID[256]
Definition: XAudio2.h:115
XAUDIO2_DEVICE_ROLE Role
Definition: XAudio2.h:117
WAVEFORMATEXTENSIBLE OutputFormat
Definition: XAudio2.h:118
Definition: XAudio2.h:98
XAUDIO2_DEVICE_ROLE
Definition: XAudio2.h:100
@ DefaultCommunicationsDevice
Definition: XAudio2.h:104
@ GlobalDefaultDevice
Definition: XAudio2.h:106
@ DefaultMultimediaDevice
Definition: XAudio2.h:103
@ InvalidDeviceRole
Definition: XAudio2.h:107
@ NotDefaultDevice
Definition: XAudio2.h:101
@ DefaultGameDevice
Definition: XAudio2.h:105
@ DefaultConsoleDevice
Definition: XAudio2.h:102
Definition: XAudio2.h:155
XAUDIO2_EFFECT_DESCRIPTOR * pEffectDescriptors
Definition: XAudio2.h:157
std::uint32_t EffectCount
Definition: XAudio2.h:156
Definition: XAudio2.h:147
std::uint32_t OutputChannels
Definition: XAudio2.h:150
IUnknown * pEffect
Definition: XAudio2.h:148
BOOL InitialState
Definition: XAudio2.h:149
Definition: XAudio2.h:180
float OneOverQ
Definition: XAudio2.h:186
float Frequency
Definition: XAudio2.h:183
XAUDIO2_FILTER_TYPE Type
Definition: XAudio2.h:181
Definition: XAudio2.h:162
XAUDIO2_FILTER_TYPE
Definition: XAudio2.h:164
@ BandPassFilter
Definition: XAudio2.h:166
@ HighPassFilter
Definition: XAudio2.h:167
@ NotchFilter
Definition: XAudio2.h:168
@ LowPassFilter
Definition: XAudio2.h:165
Definition: XAudio2.h:240
std::uint32_t CurrentLatencyInSamples
Definition: XAudio2.h:255
std::uint64_t TotalCyclesSinceLastQuery
Definition: XAudio2.h:244
std::uint32_t TotalSourceVoiceCount
Definition: XAudio2.h:261
std::uint32_t MemoryUsageInBytes
Definition: XAudio2.h:252
std::uint32_t ActiveSourceVoiceCount
Definition: XAudio2.h:260
std::uint32_t MinimumCyclesPerQuantum
Definition: XAudio2.h:246
std::uint32_t MaximumCyclesPerQuantum
Definition: XAudio2.h:248
std::uint32_t ActiveXmaSourceVoices
Definition: XAudio2.h:268
std::uint32_t ActiveSubmixVoiceCount
Definition: XAudio2.h:262
std::uint32_t ActiveMatrixMixCount
Definition: XAudio2.h:265
std::uint32_t GlitchesSinceEngineStarted
Definition: XAudio2.h:257
std::uint32_t ActiveXmaStreams
Definition: XAudio2.h:269
std::uint64_t AudioCyclesSinceLastQuery
Definition: XAudio2.h:242
std::uint32_t ActiveResamplerCount
Definition: XAudio2.h:264
Definition: XAudio2.h:51
XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER
Definition: XAudio2.h:53
@ Processor26
Definition: XAudio2.h:79
@ Processor15
Definition: XAudio2.h:68
@ DEFAULT_PROCESSOR
Definition: XAudio2.h:87
@ Processor6
Definition: XAudio2.h:59
@ Processor23
Definition: XAudio2.h:76
@ ANY_PROCESSOR
Definition: XAudio2.h:86
@ Processor28
Definition: XAudio2.h:81
@ Processor10
Definition: XAudio2.h:63
@ Processor18
Definition: XAudio2.h:71
@ Processor32
Definition: XAudio2.h:85
@ Processor7
Definition: XAudio2.h:60
@ Processor8
Definition: XAudio2.h:61
@ Processor19
Definition: XAudio2.h:72
@ Processor30
Definition: XAudio2.h:83
@ Processor11
Definition: XAudio2.h:64
@ Processor27
Definition: XAudio2.h:80
@ Processor14
Definition: XAudio2.h:67
@ Processor24
Definition: XAudio2.h:77
@ Processor5
Definition: XAudio2.h:58
@ Processor25
Definition: XAudio2.h:78
@ Processor21
Definition: XAudio2.h:74
@ Processor12
Definition: XAudio2.h:65
@ Processor31
Definition: XAudio2.h:84
@ Processor20
Definition: XAudio2.h:73
@ Processor4
Definition: XAudio2.h:57
@ Processor1
Definition: XAudio2.h:54
@ Processor2
Definition: XAudio2.h:55
@ Processor9
Definition: XAudio2.h:62
@ Processor17
Definition: XAudio2.h:70
@ Processor29
Definition: XAudio2.h:82
@ Processor3
Definition: XAudio2.h:56
@ Processor16
Definition: XAudio2.h:69
@ Processor13
Definition: XAudio2.h:66
@ Processor22
Definition: XAudio2.h:75
Definition: XAudio2.h:132
std::uint32_t Flags
Definition: XAudio2.h:133
IXAudio2Voice * pOutputVoice
Definition: XAudio2.h:134
Definition: XAudio2.h:124
std::uint32_t InputChannels
Definition: XAudio2.h:126
std::uint32_t CreationFlags
Definition: XAudio2.h:125
std::uint32_t InputSampleRate
Definition: XAudio2.h:127
Definition: XAudio2.h:140
XAUDIO2_SEND_DESCRIPTOR * pSends
Definition: XAudio2.h:142
std::uint32_t SendCount
Definition: XAudio2.h:141
Definition: XAudio2.h:228
std::uint32_t BuffersQueued
Definition: XAudio2.h:232
void * pCurrentBufferContext
Definition: XAudio2.h:229
std::uint64_t SamplesPlayed
Definition: XAudio2.h:234