xaudio2.h 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212
  1. /**************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. *
  5. * File: xaudio2.h
  6. * Content: Declarations for the XAudio2 game audio API.
  7. *
  8. **************************************************************************/
  9. #ifdef _MSC_VER
  10. #pragma once
  11. #endif
  12. #ifndef __XAUDIO2_INCLUDED__
  13. #define __XAUDIO2_INCLUDED__
  14. #include <sdkddkver.h>
  15. #if(_WIN32_WINNT < _WIN32_WINNT_WIN8)
  16. #error "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from the DirectX SDK with applications that target Windows 7 and earlier versions."
  17. #endif // (_WIN32_WINNT < _WIN32_WINNT_WIN8)
  18. #include <winapifamily.h>
  19. #pragma region Application Family
  20. #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_TV_APP | WINAPI_PARTITION_TV_TITLE)
  21. // Current name of the DLL shipped in the same SDK as this header.
  22. // The name reflects the current version
  23. #if(_WIN32_WINNT >= _WIN32_WINNT_WIN10)
  24. #define XAUDIO2_DLL_A "xaudio2_9.dll"
  25. #define XAUDIO2_DLL_W L"xaudio2_9.dll"
  26. #define XAUDIO2D_DLL_A "xaudio2_9d.dll"
  27. #define XAUDIO2D_DLL_W L"xaudio2_9d.dll"
  28. #else
  29. #define XAUDIO2_DLL_A "xaudio2_8.dll"
  30. #define XAUDIO2_DLL_W L"xaudio2_8.dll"
  31. #define XAUDIO2D_DLL_A "xaudio2_8.dll"
  32. #define XAUDIO2D_DLL_W L"xaudio2_8.dll"
  33. #endif
  34. #ifdef UNICODE
  35. #define XAUDIO2_DLL XAUDIO2_DLL_W
  36. #define XAUDIO2D_DLL XAUDIO2D_DLL_W
  37. #else
  38. #define XAUDIO2_DLL XAUDIO2_DLL_A
  39. #define XAUDIO2D_DLL XAUDIO2D_DLL_A
  40. #endif
  41. /**************************************************************************
  42. *
  43. * XAudio2 COM object class and interface IDs.
  44. *
  45. **************************************************************************/
  46. #include <basetyps.h>
  47. #if(_WIN32_WINNT >= _WIN32_WINNT_WIN10)
  48. // XAudio 2.9
  49. interface __declspec(uuid("2B02E3CF-2E0B-4ec3-BE45-1B2A3FE7210D")) IXAudio2;
  50. #else
  51. // XAudio 2.8
  52. interface __declspec(uuid("60d8dac8-5aa1-4e8e-b597-2f5e2883d484")) IXAudio2;
  53. #endif
  54. // Ignore the rest of this header if only the GUID definitions were requested
  55. #ifndef GUID_DEFS_ONLY
  56. #include <objbase.h> // Windows COM declarations
  57. #include <sal.h> // Markers for documenting API semantics
  58. #include <mmreg.h> // Basic data types and constants for audio work
  59. #include <audiosessiontypes.h> // For AUDIO_STREAM_CATEGORY
  60. // All structures defined in this file use tight field packing
  61. #pragma pack(push, 1)
  62. /**************************************************************************
  63. *
  64. * XAudio2 constants, flags and error codes.
  65. *
  66. **************************************************************************/
  67. // Numeric boundary values
  68. #define XAUDIO2_MAX_BUFFER_BYTES 0x80000000 // Maximum bytes allowed in a source buffer
  69. #define XAUDIO2_MAX_QUEUED_BUFFERS 64 // Maximum buffers allowed in a voice queue
  70. #define XAUDIO2_MAX_BUFFERS_SYSTEM 2 // Maximum buffers allowed for system threads (Xbox 360 only)
  71. #define XAUDIO2_MAX_AUDIO_CHANNELS 64 // Maximum channels in an audio stream
  72. #define XAUDIO2_MIN_SAMPLE_RATE 1000 // Minimum audio sample rate supported
  73. #define XAUDIO2_MAX_SAMPLE_RATE 200000 // Maximum audio sample rate supported
  74. #define XAUDIO2_MAX_VOLUME_LEVEL 16777216.0f // Maximum acceptable volume level (2^24)
  75. #define XAUDIO2_MIN_FREQ_RATIO (1/1024.0f) // Minimum SetFrequencyRatio argument
  76. #define XAUDIO2_MAX_FREQ_RATIO 1024.0f // Maximum MaxFrequencyRatio argument
  77. #define XAUDIO2_DEFAULT_FREQ_RATIO 2.0f // Default MaxFrequencyRatio argument
  78. #define XAUDIO2_MAX_FILTER_ONEOVERQ 1.5f // Maximum XAUDIO2_FILTER_PARAMETERS.OneOverQ
  79. #define XAUDIO2_MAX_FILTER_FREQUENCY 1.0f // Maximum XAUDIO2_FILTER_PARAMETERS.Frequency
  80. #define XAUDIO2_MAX_LOOP_COUNT 254 // Maximum non-infinite XAUDIO2_BUFFER.LoopCount
  81. #define XAUDIO2_MAX_INSTANCES 8 // Maximum simultaneous XAudio2 objects on Xbox 360
  82. // For XMA voices on Xbox 360 there is an additional restriction on the MaxFrequencyRatio
  83. // argument and the voice's sample rate: the product of these numbers cannot exceed 600000
  84. // for one-channel voices or 300000 for voices with more than one channel.
  85. #define XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MONO 600000
  86. #define XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MULTICHANNEL 300000
  87. // Numeric values with special meanings
  88. #define XAUDIO2_COMMIT_NOW 0 // Used as an OperationSet argument
  89. #define XAUDIO2_COMMIT_ALL 0 // Used in IXAudio2::CommitChanges
  90. #define XAUDIO2_INVALID_OPSET (UINT32)(-1) // Not allowed for OperationSet arguments
  91. #define XAUDIO2_NO_LOOP_REGION 0 // Used in XAUDIO2_BUFFER.LoopCount
  92. #define XAUDIO2_LOOP_INFINITE 255 // Used in XAUDIO2_BUFFER.LoopCount
  93. #define XAUDIO2_DEFAULT_CHANNELS 0 // Used in CreateMasteringVoice
  94. #define XAUDIO2_DEFAULT_SAMPLERATE 0 // Used in CreateMasteringVoice
  95. // Flags
  96. #define XAUDIO2_DEBUG_ENGINE 0x0001 // Used in XAudio2Create
  97. #define XAUDIO2_VOICE_NOPITCH 0x0002 // Used in IXAudio2::CreateSourceVoice
  98. #define XAUDIO2_VOICE_NOSRC 0x0004 // Used in IXAudio2::CreateSourceVoice
  99. #define XAUDIO2_VOICE_USEFILTER 0x0008 // Used in IXAudio2::CreateSource/SubmixVoice
  100. #define XAUDIO2_PLAY_TAILS 0x0020 // Used in IXAudio2SourceVoice::Stop
  101. #define XAUDIO2_END_OF_STREAM 0x0040 // Used in XAUDIO2_BUFFER.Flags
  102. #define XAUDIO2_SEND_USEFILTER 0x0080 // Used in XAUDIO2_SEND_DESCRIPTOR.Flags
  103. #define XAUDIO2_VOICE_NOSAMPLESPLAYED 0x0100 // Used in IXAudio2SourceVoice::GetState
  104. #define XAUDIO2_STOP_ENGINE_WHEN_IDLE 0x2000 // Used in XAudio2Create to force the engine to Stop when no source voices are Started, and Start when a voice is Started
  105. #define XAUDIO2_1024_QUANTUM 0x8000 // Used in XAudio2Create to specify nondefault processing quantum of 21.33 ms (1024 samples at 48KHz)
  106. #define XAUDIO2_NO_VIRTUAL_AUDIO_CLIENT 0x10000 // Used in CreateMasteringVoice to create a virtual audio client
  107. // Default parameters for the built-in filter
  108. #define XAUDIO2_DEFAULT_FILTER_TYPE LowPassFilter
  109. #define XAUDIO2_DEFAULT_FILTER_FREQUENCY XAUDIO2_MAX_FILTER_FREQUENCY
  110. #define XAUDIO2_DEFAULT_FILTER_ONEOVERQ 1.0f
  111. // Internal XAudio2 constants
  112. // The audio frame quantum can be calculated by reducing the fraction:
  113. // SamplesPerAudioFrame / SamplesPerSecond
  114. #define XAUDIO2_QUANTUM_NUMERATOR 1 // On Windows, XAudio2 processes audio
  115. #define XAUDIO2_QUANTUM_DENOMINATOR 100 // in 10ms chunks (= 1/100 seconds)
  116. #define XAUDIO2_QUANTUM_MS (1000.0f * XAUDIO2_QUANTUM_NUMERATOR / XAUDIO2_QUANTUM_DENOMINATOR)
  117. // XAudio2 error codes
  118. #define FACILITY_XAUDIO2 0x896
  119. #define XAUDIO2_E_INVALID_CALL 0x88960001 // An API call or one of its arguments was illegal
  120. #define XAUDIO2_E_XMA_DECODER_ERROR 0x88960002 // The XMA hardware suffered an unrecoverable error
  121. #define XAUDIO2_E_XAPO_CREATION_FAILED 0x88960003 // XAudio2 failed to initialize an XAPO effect
  122. #define XAUDIO2_E_DEVICE_INVALIDATED 0x88960004 // An audio device became unusable (unplugged, etc)
  123. /**************************************************************************
  124. *
  125. * Forward declarations for the XAudio2 interfaces.
  126. *
  127. **************************************************************************/
  128. #ifdef __cplusplus
  129. #define FWD_DECLARE(x) interface x
  130. #else
  131. #define FWD_DECLARE(x) typedef interface x x
  132. #endif
  133. FWD_DECLARE(IXAudio2);
  134. FWD_DECLARE(IXAudio2Voice);
  135. FWD_DECLARE(IXAudio2SourceVoice);
  136. FWD_DECLARE(IXAudio2SubmixVoice);
  137. FWD_DECLARE(IXAudio2MasteringVoice);
  138. FWD_DECLARE(IXAudio2EngineCallback);
  139. FWD_DECLARE(IXAudio2VoiceCallback);
  140. /**************************************************************************
  141. *
  142. * XAudio2 structures and enumerations.
  143. *
  144. **************************************************************************/
  145. // Used in XAudio2Create, specifies which CPU(s) to use.
  146. typedef UINT32 XAUDIO2_PROCESSOR;
  147. #define Processor1 0x00000001
  148. #define Processor2 0x00000002
  149. #define Processor3 0x00000004
  150. #define Processor4 0x00000008
  151. #define Processor5 0x00000010
  152. #define Processor6 0x00000020
  153. #define Processor7 0x00000040
  154. #define Processor8 0x00000080
  155. #define Processor9 0x00000100
  156. #define Processor10 0x00000200
  157. #define Processor11 0x00000400
  158. #define Processor12 0x00000800
  159. #define Processor13 0x00001000
  160. #define Processor14 0x00002000
  161. #define Processor15 0x00004000
  162. #define Processor16 0x00008000
  163. #define Processor17 0x00010000
  164. #define Processor18 0x00020000
  165. #define Processor19 0x00040000
  166. #define Processor20 0x00080000
  167. #define Processor21 0x00100000
  168. #define Processor22 0x00200000
  169. #define Processor23 0x00400000
  170. #define Processor24 0x00800000
  171. #define Processor25 0x01000000
  172. #define Processor26 0x02000000
  173. #define Processor27 0x04000000
  174. #define Processor28 0x08000000
  175. #define Processor29 0x10000000
  176. #define Processor30 0x20000000
  177. #define Processor31 0x40000000
  178. #define Processor32 0x80000000
  179. #define XAUDIO2_ANY_PROCESSOR 0xffffffff
  180. #define XAUDIO2_DEFAULT_PROCESSOR Processor1
  181. // Returned by IXAudio2Voice::GetVoiceDetails
  182. typedef struct XAUDIO2_VOICE_DETAILS
  183. {
  184. UINT32 CreationFlags; // Flags the voice was created with.
  185. UINT32 ActiveFlags; // Flags currently active.
  186. UINT32 InputChannels; // Channels in the voice's input audio.
  187. UINT32 InputSampleRate; // Sample rate of the voice's input audio.
  188. } XAUDIO2_VOICE_DETAILS;
  189. // Used in XAUDIO2_VOICE_SENDS below
  190. typedef struct XAUDIO2_SEND_DESCRIPTOR
  191. {
  192. UINT32 Flags; // Either 0 or XAUDIO2_SEND_USEFILTER.
  193. IXAudio2Voice* pOutputVoice; // This send's destination voice.
  194. } XAUDIO2_SEND_DESCRIPTOR;
  195. // Used in the voice creation functions and in IXAudio2Voice::SetOutputVoices
  196. typedef struct XAUDIO2_VOICE_SENDS
  197. {
  198. UINT32 SendCount; // Number of sends from this voice.
  199. XAUDIO2_SEND_DESCRIPTOR* pSends; // Array of SendCount send descriptors.
  200. } XAUDIO2_VOICE_SENDS;
  201. // Used in XAUDIO2_EFFECT_CHAIN below
  202. typedef struct XAUDIO2_EFFECT_DESCRIPTOR
  203. {
  204. IUnknown* pEffect; // Pointer to the effect object's IUnknown interface.
  205. BOOL InitialState; // TRUE if the effect should begin in the enabled state.
  206. UINT32 OutputChannels; // How many output channels the effect should produce.
  207. } XAUDIO2_EFFECT_DESCRIPTOR;
  208. // Used in the voice creation functions and in IXAudio2Voice::SetEffectChain
  209. typedef struct XAUDIO2_EFFECT_CHAIN
  210. {
  211. UINT32 EffectCount; // Number of effects in this voice's effect chain.
  212. XAUDIO2_EFFECT_DESCRIPTOR* pEffectDescriptors; // Array of effect descriptors.
  213. } XAUDIO2_EFFECT_CHAIN;
  214. // Used in XAUDIO2_FILTER_PARAMETERS below
  215. typedef enum XAUDIO2_FILTER_TYPE
  216. {
  217. LowPassFilter, // Attenuates frequencies above the cutoff frequency (state-variable filter).
  218. BandPassFilter, // Attenuates frequencies outside a given range (state-variable filter).
  219. HighPassFilter, // Attenuates frequencies below the cutoff frequency (state-variable filter).
  220. NotchFilter, // Attenuates frequencies inside a given range (state-variable filter).
  221. LowPassOnePoleFilter, // Attenuates frequencies above the cutoff frequency (one-pole filter, XAUDIO2_FILTER_PARAMETERS.OneOverQ has no effect)
  222. HighPassOnePoleFilter // Attenuates frequencies below the cutoff frequency (one-pole filter, XAUDIO2_FILTER_PARAMETERS.OneOverQ has no effect)
  223. } XAUDIO2_FILTER_TYPE;
  224. // Used in IXAudio2Voice::Set/GetFilterParameters and Set/GetOutputFilterParameters
  225. typedef struct XAUDIO2_FILTER_PARAMETERS
  226. {
  227. XAUDIO2_FILTER_TYPE Type; // Filter type.
  228. float Frequency; // Filter coefficient.
  229. // must be >= 0 and <= XAUDIO2_MAX_FILTER_FREQUENCY
  230. // See XAudio2CutoffFrequencyToRadians() for state-variable filter types and
  231. // XAudio2CutoffFrequencyToOnePoleCoefficient() for one-pole filter types.
  232. float OneOverQ; // Reciprocal of the filter's quality factor Q;
  233. // must be > 0 and <= XAUDIO2_MAX_FILTER_ONEOVERQ.
  234. // Has no effect for one-pole filters.
  235. } XAUDIO2_FILTER_PARAMETERS;
  236. // Used in IXAudio2SourceVoice::SubmitSourceBuffer
  237. typedef struct XAUDIO2_BUFFER
  238. {
  239. UINT32 Flags; // Either 0 or XAUDIO2_END_OF_STREAM.
  240. UINT32 AudioBytes; // Size of the audio data buffer in bytes.
  241. const BYTE* pAudioData; // Pointer to the audio data buffer.
  242. UINT32 PlayBegin; // First sample in this buffer to be played.
  243. UINT32 PlayLength; // Length of the region to be played in samples,
  244. // or 0 to play the whole buffer.
  245. UINT32 LoopBegin; // First sample of the region to be looped.
  246. UINT32 LoopLength; // Length of the desired loop region in samples,
  247. // or 0 to loop the entire buffer.
  248. UINT32 LoopCount; // Number of times to repeat the loop region,
  249. // or XAUDIO2_LOOP_INFINITE to loop forever.
  250. void* pContext; // Context value to be passed back in callbacks.
  251. } XAUDIO2_BUFFER;
  252. // Used in IXAudio2SourceVoice::SubmitSourceBuffer when submitting XWMA data.
  253. // NOTE: If an XWMA sound is submitted in more than one buffer, each buffer's
  254. // pDecodedPacketCumulativeBytes[PacketCount-1] value must be subtracted from
  255. // all the entries in the next buffer's pDecodedPacketCumulativeBytes array.
  256. // And whether a sound is submitted in more than one buffer or not, the final
  257. // buffer of the sound should use the XAUDIO2_END_OF_STREAM flag, or else the
  258. // client must call IXAudio2SourceVoice::Discontinuity after submitting it.
  259. typedef struct XAUDIO2_BUFFER_WMA
  260. {
  261. const UINT32* pDecodedPacketCumulativeBytes; // Decoded packet's cumulative size array.
  262. // Each element is the number of bytes accumulated
  263. // when the corresponding XWMA packet is decoded in
  264. // order. The array must have PacketCount elements.
  265. UINT32 PacketCount; // Number of XWMA packets submitted. Must be >= 1 and
  266. // divide evenly into XAUDIO2_BUFFER.AudioBytes.
  267. } XAUDIO2_BUFFER_WMA;
  268. // Returned by IXAudio2SourceVoice::GetState
  269. typedef struct XAUDIO2_VOICE_STATE
  270. {
  271. void* pCurrentBufferContext; // The pContext value provided in the XAUDIO2_BUFFER
  272. // that is currently being processed, or NULL if
  273. // there are no buffers in the queue.
  274. UINT32 BuffersQueued; // Number of buffers currently queued on the voice
  275. // (including the one that is being processed).
  276. UINT64 SamplesPlayed; // Total number of samples produced by the voice since
  277. // it began processing the current audio stream.
  278. // If XAUDIO2_VOICE_NOSAMPLESPLAYED is specified
  279. // in the call to IXAudio2SourceVoice::GetState,
  280. // this member will not be calculated, saving CPU.
  281. } XAUDIO2_VOICE_STATE;
  282. // Returned by IXAudio2::GetPerformanceData
  283. typedef struct XAUDIO2_PERFORMANCE_DATA
  284. {
  285. // CPU usage information
  286. UINT64 AudioCyclesSinceLastQuery; // CPU cycles spent on audio processing since the
  287. // last call to StartEngine or GetPerformanceData.
  288. UINT64 TotalCyclesSinceLastQuery; // Total CPU cycles elapsed since the last call
  289. // (only counts the CPU XAudio2 is running on).
  290. UINT32 MinimumCyclesPerQuantum; // Fewest CPU cycles spent processing any one
  291. // audio quantum since the last call.
  292. UINT32 MaximumCyclesPerQuantum; // Most CPU cycles spent processing any one
  293. // audio quantum since the last call.
  294. // Memory usage information
  295. UINT32 MemoryUsageInBytes; // Total heap space currently in use.
  296. // Audio latency and glitching information
  297. UINT32 CurrentLatencyInSamples; // Minimum delay from when a sample is read from a
  298. // source buffer to when it reaches the speakers.
  299. UINT32 GlitchesSinceEngineStarted; // Audio dropouts since the engine was started.
  300. // Data about XAudio2's current workload
  301. UINT32 ActiveSourceVoiceCount; // Source voices currently playing.
  302. UINT32 TotalSourceVoiceCount; // Source voices currently existing.
  303. UINT32 ActiveSubmixVoiceCount; // Submix voices currently playing/existing.
  304. UINT32 ActiveResamplerCount; // Resample xAPOs currently active.
  305. UINT32 ActiveMatrixMixCount; // MatrixMix xAPOs currently active.
  306. // Usage of the hardware XMA decoder (Xbox 360 only)
  307. UINT32 ActiveXmaSourceVoices; // Number of source voices decoding XMA data.
  308. UINT32 ActiveXmaStreams; // A voice can use more than one XMA stream.
  309. } XAUDIO2_PERFORMANCE_DATA;
  310. // Used in IXAudio2::SetDebugConfiguration
  311. typedef struct XAUDIO2_DEBUG_CONFIGURATION
  312. {
  313. UINT32 TraceMask; // Bitmap of enabled debug message types.
  314. UINT32 BreakMask; // Message types that will break into the debugger.
  315. BOOL LogThreadID; // Whether to log the thread ID with each message.
  316. BOOL LogFileline; // Whether to log the source file and line number.
  317. BOOL LogFunctionName; // Whether to log the function name.
  318. BOOL LogTiming; // Whether to log message timestamps.
  319. } XAUDIO2_DEBUG_CONFIGURATION;
  320. // Values for the TraceMask and BreakMask bitmaps. Only ERRORS and WARNINGS
  321. // are valid in BreakMask. WARNINGS implies ERRORS, DETAIL implies INFO, and
  322. // FUNC_CALLS implies API_CALLS. By default, TraceMask is ERRORS and WARNINGS
  323. // and all the other settings are zero.
  324. #define XAUDIO2_LOG_ERRORS 0x0001 // For handled errors with serious effects.
  325. #define XAUDIO2_LOG_WARNINGS 0x0002 // For handled errors that may be recoverable.
  326. #define XAUDIO2_LOG_INFO 0x0004 // Informational chit-chat (e.g. state changes).
  327. #define XAUDIO2_LOG_DETAIL 0x0008 // More detailed chit-chat.
  328. #define XAUDIO2_LOG_API_CALLS 0x0010 // Public API function entries and exits.
  329. #define XAUDIO2_LOG_FUNC_CALLS 0x0020 // Internal function entries and exits.
  330. #define XAUDIO2_LOG_TIMING 0x0040 // Delays detected and other timing data.
  331. #define XAUDIO2_LOG_LOCKS 0x0080 // Usage of critical sections and mutexes.
  332. #define XAUDIO2_LOG_MEMORY 0x0100 // Memory heap usage information.
  333. #define XAUDIO2_LOG_STREAMING 0x1000 // Audio streaming information.
  334. /**************************************************************************
  335. *
  336. * IXAudio2: Top-level XAudio2 COM interface.
  337. *
  338. **************************************************************************/
  339. // Use default arguments if compiling as C++
  340. #ifdef __cplusplus
  341. #define X2DEFAULT(x) =x
  342. #else
  343. #define X2DEFAULT(x)
  344. #endif
  345. #undef INTERFACE
  346. #define INTERFACE IXAudio2
  347. DECLARE_INTERFACE_(IXAudio2, IUnknown)
  348. {
  349. // NAME: IXAudio2::QueryInterface
  350. // DESCRIPTION: Queries for a given COM interface on the XAudio2 object.
  351. // Only IID_IUnknown and IID_IXAudio2 are supported.
  352. //
  353. // ARGUMENTS:
  354. // riid - IID of the interface to be obtained.
  355. // ppvInterface - Returns a pointer to the requested interface.
  356. //
  357. STDMETHOD(QueryInterface) (THIS_ REFIID riid, _Outptr_ void** ppvInterface) PURE;
  358. // NAME: IXAudio2::AddRef
  359. // DESCRIPTION: Adds a reference to the XAudio2 object.
  360. //
  361. STDMETHOD_(ULONG, AddRef) (THIS) PURE;
  362. // NAME: IXAudio2::Release
  363. // DESCRIPTION: Releases a reference to the XAudio2 object.
  364. //
  365. STDMETHOD_(ULONG, Release) (THIS) PURE;
  366. // NAME: IXAudio2::RegisterForCallbacks
  367. // DESCRIPTION: Adds a new client to receive XAudio2's engine callbacks.
  368. //
  369. // ARGUMENTS:
  370. // pCallback - Callback interface to be called during each processing pass.
  371. //
  372. STDMETHOD(RegisterForCallbacks) (_In_ IXAudio2EngineCallback* pCallback) PURE;
  373. // NAME: IXAudio2::UnregisterForCallbacks
  374. // DESCRIPTION: Removes an existing receiver of XAudio2 engine callbacks.
  375. //
  376. // ARGUMENTS:
  377. // pCallback - Previously registered callback interface to be removed.
  378. //
  379. STDMETHOD_(void, UnregisterForCallbacks) (_In_ IXAudio2EngineCallback* pCallback) PURE;
  380. // NAME: IXAudio2::CreateSourceVoice
  381. // DESCRIPTION: Creates and configures a source voice.
  382. //
  383. // ARGUMENTS:
  384. // ppSourceVoice - Returns the new object's IXAudio2SourceVoice interface.
  385. // pSourceFormat - Format of the audio that will be fed to the voice.
  386. // Flags - XAUDIO2_VOICE flags specifying the source voice's behavior.
  387. // MaxFrequencyRatio - Maximum SetFrequencyRatio argument to be allowed.
  388. // pCallback - Optional pointer to a client-provided callback interface.
  389. // pSendList - Optional list of voices this voice should send audio to.
  390. // pEffectChain - Optional list of effects to apply to the audio data.
  391. //
  392. STDMETHOD(CreateSourceVoice) (THIS_ _Outptr_ IXAudio2SourceVoice** ppSourceVoice,
  393. _In_ const WAVEFORMATEX* pSourceFormat,
  394. UINT32 Flags X2DEFAULT(0),
  395. float MaxFrequencyRatio X2DEFAULT(XAUDIO2_DEFAULT_FREQ_RATIO),
  396. _In_opt_ IXAudio2VoiceCallback* pCallback X2DEFAULT(NULL),
  397. _In_opt_ const XAUDIO2_VOICE_SENDS* pSendList X2DEFAULT(NULL),
  398. _In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL)) PURE;
  399. // NAME: IXAudio2::CreateSubmixVoice
  400. // DESCRIPTION: Creates and configures a submix voice.
  401. //
  402. // ARGUMENTS:
  403. // ppSubmixVoice - Returns the new object's IXAudio2SubmixVoice interface.
  404. // InputChannels - Number of channels in this voice's input audio data.
  405. // InputSampleRate - Sample rate of this voice's input audio data.
  406. // Flags - XAUDIO2_VOICE flags specifying the submix voice's behavior.
  407. // ProcessingStage - Arbitrary number that determines the processing order.
  408. // pSendList - Optional list of voices this voice should send audio to.
  409. // pEffectChain - Optional list of effects to apply to the audio data.
  410. //
  411. STDMETHOD(CreateSubmixVoice) (THIS_ _Outptr_ IXAudio2SubmixVoice** ppSubmixVoice,
  412. UINT32 InputChannels, UINT32 InputSampleRate,
  413. UINT32 Flags X2DEFAULT(0), UINT32 ProcessingStage X2DEFAULT(0),
  414. _In_opt_ const XAUDIO2_VOICE_SENDS* pSendList X2DEFAULT(NULL),
  415. _In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL)) PURE;
  416. // NAME: IXAudio2::CreateMasteringVoice
  417. // DESCRIPTION: Creates and configures a mastering voice.
  418. //
  419. // ARGUMENTS:
  420. // ppMasteringVoice - Returns the new object's IXAudio2MasteringVoice interface.
  421. // InputChannels - Number of channels in this voice's input audio data.
  422. // InputSampleRate - Sample rate of this voice's input audio data.
  423. // Flags - XAUDIO2_VOICE flags specifying the mastering voice's behavior.
  424. // szDeviceId - Identifier of the device to receive the output audio.
  425. // pEffectChain - Optional list of effects to apply to the audio data.
  426. // StreamCategory - The audio stream category to use for this mastering voice
  427. //
  428. STDMETHOD(CreateMasteringVoice) (THIS_ _Outptr_ IXAudio2MasteringVoice** ppMasteringVoice,
  429. UINT32 InputChannels X2DEFAULT(XAUDIO2_DEFAULT_CHANNELS),
  430. UINT32 InputSampleRate X2DEFAULT(XAUDIO2_DEFAULT_SAMPLERATE),
  431. UINT32 Flags X2DEFAULT(0), _In_opt_z_ LPCWSTR szDeviceId X2DEFAULT(NULL),
  432. _In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL),
  433. _In_ AUDIO_STREAM_CATEGORY StreamCategory X2DEFAULT(AudioCategory_GameEffects)) PURE;
  434. // NAME: IXAudio2::StartEngine
  435. // DESCRIPTION: Creates and starts the audio processing thread.
  436. //
  437. STDMETHOD(StartEngine) (THIS) PURE;
  438. // NAME: IXAudio2::StopEngine
  439. // DESCRIPTION: Stops and destroys the audio processing thread.
  440. //
  441. STDMETHOD_(void, StopEngine) (THIS) PURE;
  442. // NAME: IXAudio2::CommitChanges
  443. // DESCRIPTION: Atomically applies a set of operations previously tagged
  444. // with a given identifier.
  445. //
  446. // ARGUMENTS:
  447. // OperationSet - Identifier of the set of operations to be applied.
  448. //
  449. STDMETHOD(CommitChanges) (THIS_ UINT32 OperationSet) PURE;
  450. // NAME: IXAudio2::GetPerformanceData
  451. // DESCRIPTION: Returns current resource usage details: memory, CPU, etc.
  452. //
  453. // ARGUMENTS:
  454. // pPerfData - Returns the performance data structure.
  455. //
  456. STDMETHOD_(void, GetPerformanceData) (THIS_ _Out_ XAUDIO2_PERFORMANCE_DATA* pPerfData) PURE;
  457. // NAME: IXAudio2::SetDebugConfiguration
  458. // DESCRIPTION: Configures XAudio2's debug output (in debug builds only).
  459. //
  460. // ARGUMENTS:
  461. // pDebugConfiguration - Structure describing the debug output behavior.
  462. // pReserved - Optional parameter; must be NULL.
  463. //
  464. STDMETHOD_(void, SetDebugConfiguration) (THIS_ _In_opt_ const XAUDIO2_DEBUG_CONFIGURATION* pDebugConfiguration,
  465. _Reserved_ void* pReserved X2DEFAULT(NULL)) PURE;
  466. };
  467. /**************************************************************************
  468. *
  469. * IXAudio2Voice: Base voice management interface.
  470. *
  471. **************************************************************************/
  472. #undef INTERFACE
  473. #define INTERFACE IXAudio2Voice
  474. DECLARE_INTERFACE(IXAudio2Voice)
  475. {
  476. // These methods are declared in a macro so that the same declarations
  477. // can be used in the derived voice types (IXAudio2SourceVoice, etc).
  478. #define Declare_IXAudio2Voice_Methods() \
  479. \
  480. /* NAME: IXAudio2Voice::GetVoiceDetails
  481. // DESCRIPTION: Returns the basic characteristics of this voice.
  482. //
  483. // ARGUMENTS:
  484. // pVoiceDetails - Returns the voice's details.
  485. */\
  486. STDMETHOD_(void, GetVoiceDetails) (THIS_ _Out_ XAUDIO2_VOICE_DETAILS* pVoiceDetails) PURE; \
  487. \
  488. /* NAME: IXAudio2Voice::SetOutputVoices
  489. // DESCRIPTION: Replaces the set of submix/mastering voices that receive
  490. // this voice's output.
  491. //
  492. // ARGUMENTS:
  493. // pSendList - Optional list of voices this voice should send audio to.
  494. */\
  495. STDMETHOD(SetOutputVoices) (THIS_ _In_opt_ const XAUDIO2_VOICE_SENDS* pSendList) PURE; \
  496. \
  497. /* NAME: IXAudio2Voice::SetEffectChain
  498. // DESCRIPTION: Replaces this voice's current effect chain with a new one.
  499. //
  500. // ARGUMENTS:
  501. // pEffectChain - Structure describing the new effect chain to be used.
  502. */\
  503. STDMETHOD(SetEffectChain) (THIS_ _In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain) PURE; \
  504. \
  505. /* NAME: IXAudio2Voice::EnableEffect
  506. // DESCRIPTION: Enables an effect in this voice's effect chain.
  507. //
  508. // ARGUMENTS:
  509. // EffectIndex - Index of an effect within this voice's effect chain.
  510. // OperationSet - Used to identify this call as part of a deferred batch.
  511. */\
  512. STDMETHOD(EnableEffect) (THIS_ UINT32 EffectIndex, \
  513. UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
  514. \
  515. /* NAME: IXAudio2Voice::DisableEffect
  516. // DESCRIPTION: Disables an effect in this voice's effect chain.
  517. //
  518. // ARGUMENTS:
  519. // EffectIndex - Index of an effect within this voice's effect chain.
  520. // OperationSet - Used to identify this call as part of a deferred batch.
  521. */\
  522. STDMETHOD(DisableEffect) (THIS_ UINT32 EffectIndex, \
  523. UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
  524. \
  525. /* NAME: IXAudio2Voice::GetEffectState
  526. // DESCRIPTION: Returns the running state of an effect.
  527. //
  528. // ARGUMENTS:
  529. // EffectIndex - Index of an effect within this voice's effect chain.
  530. // pEnabled - Returns the enabled/disabled state of the given effect.
  531. */\
  532. STDMETHOD_(void, GetEffectState) (THIS_ UINT32 EffectIndex, _Out_ BOOL* pEnabled) PURE; \
  533. \
  534. /* NAME: IXAudio2Voice::SetEffectParameters
  535. // DESCRIPTION: Sets effect-specific parameters.
  536. //
  537. // REMARKS: Unlike IXAPOParameters::SetParameters, this method may
  538. // be called from any thread. XAudio2 implements
  539. // appropriate synchronization to copy the parameters to the
  540. // realtime audio processing thread.
  541. //
  542. // ARGUMENTS:
  543. // EffectIndex - Index of an effect within this voice's effect chain.
  544. // pParameters - Pointer to an effect-specific parameters block.
  545. // ParametersByteSize - Size of the pParameters array in bytes.
  546. // OperationSet - Used to identify this call as part of a deferred batch.
  547. */\
  548. STDMETHOD(SetEffectParameters) (THIS_ UINT32 EffectIndex, \
  549. _In_reads_bytes_(ParametersByteSize) const void* pParameters, \
  550. UINT32 ParametersByteSize, \
  551. UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
  552. \
  553. /* NAME: IXAudio2Voice::GetEffectParameters
  554. // DESCRIPTION: Obtains the current effect-specific parameters.
  555. //
  556. // ARGUMENTS:
  557. // EffectIndex - Index of an effect within this voice's effect chain.
  558. // pParameters - Returns the current values of the effect-specific parameters.
  559. // ParametersByteSize - Size of the pParameters array in bytes.
  560. */\
  561. STDMETHOD(GetEffectParameters) (THIS_ UINT32 EffectIndex, \
  562. _Out_writes_bytes_(ParametersByteSize) void* pParameters, \
  563. UINT32 ParametersByteSize) PURE; \
  564. \
  565. /* NAME: IXAudio2Voice::SetFilterParameters
  566. // DESCRIPTION: Sets this voice's filter parameters.
  567. //
  568. // ARGUMENTS:
  569. // pParameters - Pointer to the filter's parameter structure.
  570. // OperationSet - Used to identify this call as part of a deferred batch.
  571. */\
  572. STDMETHOD(SetFilterParameters) (THIS_ _In_ const XAUDIO2_FILTER_PARAMETERS* pParameters, \
  573. UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
  574. \
  575. /* NAME: IXAudio2Voice::GetFilterParameters
  576. // DESCRIPTION: Returns this voice's current filter parameters.
  577. //
  578. // ARGUMENTS:
  579. // pParameters - Returns the filter parameters.
  580. */\
  581. STDMETHOD_(void, GetFilterParameters) (THIS_ _Out_ XAUDIO2_FILTER_PARAMETERS* pParameters) PURE; \
  582. \
  583. /* NAME: IXAudio2Voice::SetOutputFilterParameters
  584. // DESCRIPTION: Sets the filter parameters on one of this voice's sends.
  585. //
  586. // ARGUMENTS:
  587. // pDestinationVoice - Destination voice of the send whose filter parameters will be set.
  588. // pParameters - Pointer to the filter's parameter structure.
  589. // OperationSet - Used to identify this call as part of a deferred batch.
  590. */\
  591. STDMETHOD(SetOutputFilterParameters) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
  592. _In_ const XAUDIO2_FILTER_PARAMETERS* pParameters, \
  593. UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
  594. \
  595. /* NAME: IXAudio2Voice::GetOutputFilterParameters
  596. // DESCRIPTION: Returns the filter parameters from one of this voice's sends.
  597. //
  598. // ARGUMENTS:
  599. // pDestinationVoice - Destination voice of the send whose filter parameters will be read.
  600. // pParameters - Returns the filter parameters.
  601. */\
  602. STDMETHOD_(void, GetOutputFilterParameters) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
  603. _Out_ XAUDIO2_FILTER_PARAMETERS* pParameters) PURE; \
  604. \
  605. /* NAME: IXAudio2Voice::SetVolume
  606. // DESCRIPTION: Sets this voice's overall volume level.
  607. //
  608. // ARGUMENTS:
  609. // Volume - New overall volume level to be used, as an amplitude factor.
  610. // OperationSet - Used to identify this call as part of a deferred batch.
  611. */\
  612. STDMETHOD(SetVolume) (THIS_ float Volume, \
  613. UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
  614. \
  615. /* NAME: IXAudio2Voice::GetVolume
  616. // DESCRIPTION: Obtains this voice's current overall volume level.
  617. //
  618. // ARGUMENTS:
  619. // pVolume: Returns the voice's current overall volume level.
  620. */\
  621. STDMETHOD_(void, GetVolume) (THIS_ _Out_ float* pVolume) PURE; \
  622. \
  623. /* NAME: IXAudio2Voice::SetChannelVolumes
  624. // DESCRIPTION: Sets this voice's per-channel volume levels.
  625. //
  626. // ARGUMENTS:
  627. // Channels - Used to confirm the voice's channel count.
  628. // pVolumes - Array of per-channel volume levels to be used.
  629. // OperationSet - Used to identify this call as part of a deferred batch.
  630. */\
  631. STDMETHOD(SetChannelVolumes) (THIS_ UINT32 Channels, _In_reads_(Channels) const float* pVolumes, \
  632. UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
  633. \
  634. /* NAME: IXAudio2Voice::GetChannelVolumes
  635. // DESCRIPTION: Returns this voice's current per-channel volume levels.
  636. //
  637. // ARGUMENTS:
  638. // Channels - Used to confirm the voice's channel count.
  639. // pVolumes - Returns an array of the current per-channel volume levels.
  640. */\
  641. STDMETHOD_(void, GetChannelVolumes) (THIS_ UINT32 Channels, _Out_writes_(Channels) float* pVolumes) PURE; \
  642. \
  643. /* NAME: IXAudio2Voice::SetOutputMatrix
  644. // DESCRIPTION: Sets the volume levels used to mix from each channel of this
  645. // voice's output audio to each channel of a given destination
  646. // voice's input audio.
  647. //
  648. // ARGUMENTS:
  649. // pDestinationVoice - The destination voice whose mix matrix to change.
  650. // SourceChannels - Used to confirm this voice's output channel count
  651. // (the number of channels produced by the last effect in the chain).
  652. // DestinationChannels - Confirms the destination voice's input channels.
  653. // pLevelMatrix - Array of [SourceChannels * DestinationChannels] send
  654. // levels. The level used to send from source channel S to destination
  655. // channel D should be in pLevelMatrix[S + SourceChannels * D].
  656. // OperationSet - Used to identify this call as part of a deferred batch.
  657. */\
  658. STDMETHOD(SetOutputMatrix) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
  659. UINT32 SourceChannels, UINT32 DestinationChannels, \
  660. _In_reads_(SourceChannels * DestinationChannels) const float* pLevelMatrix, \
  661. UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
  662. \
  663. /* NAME: IXAudio2Voice::GetOutputMatrix
  664. // DESCRIPTION: Obtains the volume levels used to send each channel of this
  665. // voice's output audio to each channel of a given destination
  666. // voice's input audio.
  667. //
  668. // ARGUMENTS:
  669. // pDestinationVoice - The destination voice whose mix matrix to obtain.
  670. // SourceChannels - Used to confirm this voice's output channel count
  671. // (the number of channels produced by the last effect in the chain).
  672. // DestinationChannels - Confirms the destination voice's input channels.
  673. // pLevelMatrix - Array of send levels, as above.
  674. */\
  675. STDMETHOD_(void, GetOutputMatrix) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
  676. UINT32 SourceChannels, UINT32 DestinationChannels, \
  677. _Out_writes_(SourceChannels * DestinationChannels) float* pLevelMatrix) PURE; \
  678. \
  679. /* NAME: IXAudio2Voice::DestroyVoice
  680. // DESCRIPTION: Destroys this voice, stopping it if necessary and removing
  681. // it from the XAudio2 graph.
  682. */\
  683. STDMETHOD_(void, DestroyVoice) (THIS) PURE
  684. Declare_IXAudio2Voice_Methods();
  685. };
  686. /**************************************************************************
  687. *
  688. * IXAudio2SourceVoice: Source voice management interface.
  689. *
  690. **************************************************************************/
  691. #undef INTERFACE
  692. #define INTERFACE IXAudio2SourceVoice
  693. DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice)
  694. {
  695. // Methods from IXAudio2Voice base interface
  696. Declare_IXAudio2Voice_Methods();
  697. // NAME: IXAudio2SourceVoice::Start
  698. // DESCRIPTION: Makes this voice start consuming and processing audio.
  699. //
  700. // ARGUMENTS:
  701. // Flags - Flags controlling how the voice should be started.
  702. // OperationSet - Used to identify this call as part of a deferred batch.
  703. //
  704. STDMETHOD(Start) (THIS_ UINT32 Flags X2DEFAULT(0), UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
  705. // NAME: IXAudio2SourceVoice::Stop
  706. // DESCRIPTION: Makes this voice stop consuming audio.
  707. //
  708. // ARGUMENTS:
  709. // Flags - Flags controlling how the voice should be stopped.
  710. // OperationSet - Used to identify this call as part of a deferred batch.
  711. //
  712. STDMETHOD(Stop) (THIS_ UINT32 Flags X2DEFAULT(0), UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
  713. // NAME: IXAudio2SourceVoice::SubmitSourceBuffer
  714. // DESCRIPTION: Adds a new audio buffer to this voice's input queue.
  715. //
  716. // ARGUMENTS:
  717. // pBuffer - Pointer to the buffer structure to be queued.
  718. // pBufferWMA - Additional structure used only when submitting XWMA data.
  719. //
  720. STDMETHOD(SubmitSourceBuffer) (THIS_ _In_ const XAUDIO2_BUFFER* pBuffer, _In_opt_ const XAUDIO2_BUFFER_WMA* pBufferWMA X2DEFAULT(NULL)) PURE;
  721. // NAME: IXAudio2SourceVoice::FlushSourceBuffers
  722. // DESCRIPTION: Removes all pending audio buffers from this voice's queue.
  723. //
  724. STDMETHOD(FlushSourceBuffers) (THIS) PURE;
  725. // NAME: IXAudio2SourceVoice::Discontinuity
  726. // DESCRIPTION: Notifies the voice of an intentional break in the stream of
  727. // audio buffers (e.g. the end of a sound), to prevent XAudio2
  728. // from interpreting an empty buffer queue as a glitch.
  729. //
  730. STDMETHOD(Discontinuity) (THIS) PURE;
  731. // NAME: IXAudio2SourceVoice::ExitLoop
  732. // DESCRIPTION: Breaks out of the current loop when its end is reached.
  733. //
  734. // ARGUMENTS:
  735. // OperationSet - Used to identify this call as part of a deferred batch.
  736. //
  737. STDMETHOD(ExitLoop) (THIS_ UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
  738. // NAME: IXAudio2SourceVoice::GetState
  739. // DESCRIPTION: Returns the number of buffers currently queued on this voice,
  740. // the pContext value associated with the currently processing
  741. // buffer (if any), and other voice state information.
  742. //
  743. // ARGUMENTS:
  744. // pVoiceState - Returns the state information.
  745. // Flags - Flags controlling what voice state is returned.
  746. //
  747. STDMETHOD_(void, GetState) (THIS_ _Out_ XAUDIO2_VOICE_STATE* pVoiceState, UINT32 Flags X2DEFAULT(0)) PURE;
  748. // NAME: IXAudio2SourceVoice::SetFrequencyRatio
  749. // DESCRIPTION: Sets this voice's frequency adjustment, i.e. its pitch.
  750. //
  751. // ARGUMENTS:
  752. // Ratio - Frequency change, expressed as source frequency / target frequency.
  753. // OperationSet - Used to identify this call as part of a deferred batch.
  754. //
  755. STDMETHOD(SetFrequencyRatio) (THIS_ float Ratio,
  756. UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
  757. // NAME: IXAudio2SourceVoice::GetFrequencyRatio
  758. // DESCRIPTION: Returns this voice's current frequency adjustment ratio.
  759. //
  760. // ARGUMENTS:
  761. // pRatio - Returns the frequency adjustment.
  762. //
  763. STDMETHOD_(void, GetFrequencyRatio) (THIS_ _Out_ float* pRatio) PURE;
  764. // NAME: IXAudio2SourceVoice::SetSourceSampleRate
  765. // DESCRIPTION: Reconfigures this voice to treat its source data as being
  766. // at a different sample rate than the original one specified
  767. // in CreateSourceVoice's pSourceFormat argument.
  768. //
  769. // ARGUMENTS:
  770. // UINT32 - The intended sample rate of further submitted source data.
  771. //
  772. STDMETHOD(SetSourceSampleRate) (THIS_ UINT32 NewSourceSampleRate) PURE;
  773. };
  774. /**************************************************************************
  775. *
  776. * IXAudio2SubmixVoice: Submixing voice management interface.
  777. *
  778. **************************************************************************/
  779. #undef INTERFACE
  780. #define INTERFACE IXAudio2SubmixVoice
  781. DECLARE_INTERFACE_(IXAudio2SubmixVoice, IXAudio2Voice)
  782. {
  783. // Methods from IXAudio2Voice base interface
  784. Declare_IXAudio2Voice_Methods();
  785. // There are currently no methods specific to submix voices.
  786. };
  787. /**************************************************************************
  788. *
  789. * IXAudio2MasteringVoice: Mastering voice management interface.
  790. *
  791. **************************************************************************/
  792. #undef INTERFACE
  793. #define INTERFACE IXAudio2MasteringVoice
  794. DECLARE_INTERFACE_(IXAudio2MasteringVoice, IXAudio2Voice)
  795. {
  796. // Methods from IXAudio2Voice base interface
  797. Declare_IXAudio2Voice_Methods();
  798. // NAME: IXAudio2MasteringVoice::GetChannelMask
  799. // DESCRIPTION: Returns the channel mask for this voice
  800. //
  801. // ARGUMENTS:
  802. // pChannelMask - returns the channel mask for this voice. This corresponds
  803. // to the dwChannelMask member of WAVEFORMATEXTENSIBLE.
  804. //
  805. STDMETHOD(GetChannelMask) (THIS_ _Out_ DWORD* pChannelmask) PURE;
  806. };
  807. /**************************************************************************
  808. *
  809. * IXAudio2EngineCallback: Client notification interface for engine events.
  810. *
  811. * REMARKS: Contains methods to notify the client when certain events happen
  812. * in the XAudio2 engine. This interface should be implemented by
  813. * the client. XAudio2 will call these methods via the interface
  814. * pointer provided by the client when it calls
  815. * IXAudio2::RegisterForCallbacks.
  816. *
  817. **************************************************************************/
  818. #undef INTERFACE
  819. #define INTERFACE IXAudio2EngineCallback
  820. DECLARE_INTERFACE(IXAudio2EngineCallback)
  821. {
  822. // Called by XAudio2 just before an audio processing pass begins.
  823. STDMETHOD_(void, OnProcessingPassStart) (THIS) PURE;
  824. // Called just after an audio processing pass ends.
  825. STDMETHOD_(void, OnProcessingPassEnd) (THIS) PURE;
  826. // Called in the event of a critical system error which requires XAudio2
  827. // to be closed down and restarted. The error code is given in Error.
  828. STDMETHOD_(void, OnCriticalError) (THIS_ HRESULT Error) PURE;
  829. };
  830. /**************************************************************************
  831. *
  832. * IXAudio2VoiceCallback: Client notification interface for voice events.
  833. *
  834. * REMARKS: Contains methods to notify the client when certain events happen
  835. * in an XAudio2 voice. This interface should be implemented by the
  836. * client. XAudio2 will call these methods via an interface pointer
  837. * provided by the client in the IXAudio2::CreateSourceVoice call.
  838. *
  839. **************************************************************************/
  840. #undef INTERFACE
  841. #define INTERFACE IXAudio2VoiceCallback
  842. DECLARE_INTERFACE(IXAudio2VoiceCallback)
  843. {
  844. // Called just before this voice's processing pass begins.
  845. STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired) PURE;
  846. // Called just after this voice's processing pass ends.
  847. STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS) PURE;
  848. // Called when this voice has just finished playing a buffer stream
  849. // (as marked with the XAUDIO2_END_OF_STREAM flag on the last buffer).
  850. STDMETHOD_(void, OnStreamEnd) (THIS) PURE;
  851. // Called when this voice is about to start processing a new buffer.
  852. STDMETHOD_(void, OnBufferStart) (THIS_ void* pBufferContext) PURE;
  853. // Called when this voice has just finished processing a buffer.
  854. // The buffer can now be reused or destroyed.
  855. STDMETHOD_(void, OnBufferEnd) (THIS_ void* pBufferContext) PURE;
  856. // Called when this voice has just reached the end position of a loop.
  857. STDMETHOD_(void, OnLoopEnd) (THIS_ void* pBufferContext) PURE;
  858. // Called in the event of a critical error during voice processing,
  859. // such as a failing xAPO or an error from the hardware XMA decoder.
  860. // The voice may have to be destroyed and re-created to recover from
  861. // the error. The callback arguments report which buffer was being
  862. // processed when the error occurred, and its HRESULT code.
  863. STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error) PURE;
  864. };
  865. /**************************************************************************
  866. *
  867. * Macros to make it easier to use the XAudio2 COM interfaces in C code.
  868. *
  869. **************************************************************************/
  870. #ifndef __cplusplus
  871. // IXAudio2
  872. #define IXAudio2_QueryInterface(This,riid,ppvInterface) ((This)->lpVtbl->QueryInterface(This,riid,ppvInterface))
  873. #define IXAudio2_AddRef(This) ((This)->lpVtbl->AddRef(This))
  874. #define IXAudio2_Release(This) ((This)->lpVtbl->Release(This))
  875. #define IXAudio2_CreateSourceVoice(This,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) ((This)->lpVtbl->CreateSourceVoice(This,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain))
  876. #define IXAudio2_CreateSubmixVoice(This,ppSubmixVoice,InputChannels,InputSampleRate,Flags,ProcessingStage,pSendList,pEffectChain) ((This)->lpVtbl->CreateSubmixVoice(This,ppSubmixVoice,InputChannels,InputSampleRate,Flags,ProcessingStage,pSendList,pEffectChain))
  877. #define IXAudio2_CreateMasteringVoice(This,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceId,pEffectChain,StreamCategory) ((This)->lpVtbl->CreateMasteringVoice(This,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceId,pEffectChain,StreamCategory))
  878. #define IXAudio2_StartEngine(This) ((This)->lpVtbl->StartEngine(This))
  879. #define IXAudio2_StopEngine(This) ((This)->lpVtbl->StopEngine(This))
  880. #define IXAudio2_CommitChanges(This,OperationSet) ((This)->lpVtbl->CommitChanges(This,OperationSet))
  881. #define IXAudio2_GetPerformanceData(This,pPerfData) ((This)->lpVtbl->GetPerformanceData(This,pPerfData))
  882. #define IXAudio2_SetDebugConfiguration(This,pDebugConfiguration,pReserved) ((This)->lpVtbl->SetDebugConfiguration(This,pDebugConfiguration,pReserved))
  883. // IXAudio2Voice
  884. #define IXAudio2Voice_GetVoiceDetails(This,pVoiceDetails) ((This)->lpVtbl->GetVoiceDetails(This,pVoiceDetails))
  885. #define IXAudio2Voice_SetOutputVoices(This,pSendList) ((This)->lpVtbl->SetOutputVoices(This,pSendList))
  886. #define IXAudio2Voice_SetEffectChain(This,pEffectChain) ((This)->lpVtbl->SetEffectChain(This,pEffectChain))
  887. #define IXAudio2Voice_EnableEffect(This,EffectIndex,OperationSet) ((This)->lpVtbl->EnableEffect(This,EffectIndex,OperationSet))
  888. #define IXAudio2Voice_DisableEffect(This,EffectIndex,OperationSet) ((This)->lpVtbl->DisableEffect(This,EffectIndex,OperationSet))
  889. #define IXAudio2Voice_GetEffectState(This,EffectIndex,pEnabled) ((This)->lpVtbl->GetEffectState(This,EffectIndex,pEnabled))
  890. #define IXAudio2Voice_SetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize, OperationSet) ((This)->lpVtbl->SetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize,OperationSet))
  891. #define IXAudio2Voice_GetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize) ((This)->lpVtbl->GetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize))
  892. #define IXAudio2Voice_SetFilterParameters(This,pParameters,OperationSet) ((This)->lpVtbl->SetFilterParameters(This,pParameters,OperationSet))
  893. #define IXAudio2Voice_GetFilterParameters(This,pParameters) ((This)->lpVtbl->GetFilterParameters(This,pParameters))
  894. #define IXAudio2Voice_SetOutputFilterParameters(This,pDestinationVoice,pParameters,OperationSet) ((This)->lpVtbl->SetOutputFilterParameters(This,pDestinationVoice,pParameters,OperationSet))
  895. #define IXAudio2Voice_GetOutputFilterParameters(This,pDestinationVoice,pParameters) ((This)->lpVtbl->GetOutputFilterParameters(This,pDestinationVoice,pParameters))
  896. #define IXAudio2Voice_SetVolume(This,Volume,OperationSet) ((This)->lpVtbl->SetVolume(This,Volume,OperationSet))
  897. #define IXAudio2Voice_GetVolume(This,pVolume) ((This)->lpVtbl->GetVolume(This,pVolume))
  898. #define IXAudio2Voice_SetChannelVolumes(This,Channels,pVolumes,OperationSet) ((This)->lpVtbl->SetChannelVolumes(This,Channels,pVolumes,OperationSet))
  899. #define IXAudio2Voice_GetChannelVolumes(This,Channels,pVolumes) ((This)->lpVtbl->GetChannelVolumes(This,Channels,pVolumes))
  900. #define IXAudio2Voice_SetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix,OperationSet) ((This)->lpVtbl->SetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix,OperationSet))
  901. #define IXAudio2Voice_GetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix) ((This)->lpVtbl->GetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix))
  902. #define IXAudio2Voice_DestroyVoice(This) ((This)->lpVtbl->DestroyVoice(This))
  903. // IXAudio2SourceVoice
  904. #define IXAudio2SourceVoice_GetVoiceDetails IXAudio2Voice_GetVoiceDetails
  905. #define IXAudio2SourceVoice_SetOutputVoices IXAudio2Voice_SetOutputVoices
  906. #define IXAudio2SourceVoice_SetEffectChain IXAudio2Voice_SetEffectChain
  907. #define IXAudio2SourceVoice_EnableEffect IXAudio2Voice_EnableEffect
  908. #define IXAudio2SourceVoice_DisableEffect IXAudio2Voice_DisableEffect
  909. #define IXAudio2SourceVoice_GetEffectState IXAudio2Voice_GetEffectState
  910. #define IXAudio2SourceVoice_SetEffectParameters IXAudio2Voice_SetEffectParameters
  911. #define IXAudio2SourceVoice_GetEffectParameters IXAudio2Voice_GetEffectParameters
  912. #define IXAudio2SourceVoice_SetFilterParameters IXAudio2Voice_SetFilterParameters
  913. #define IXAudio2SourceVoice_GetFilterParameters IXAudio2Voice_GetFilterParameters
  914. #define IXAudio2SourceVoice_SetOutputFilterParameters IXAudio2Voice_SetOutputFilterParameters
  915. #define IXAudio2SourceVoice_GetOutputFilterParameters IXAudio2Voice_GetOutputFilterParameters
  916. #define IXAudio2SourceVoice_SetVolume IXAudio2Voice_SetVolume
  917. #define IXAudio2SourceVoice_GetVolume IXAudio2Voice_GetVolume
  918. #define IXAudio2SourceVoice_SetChannelVolumes IXAudio2Voice_SetChannelVolumes
  919. #define IXAudio2SourceVoice_GetChannelVolumes IXAudio2Voice_GetChannelVolumes
  920. #define IXAudio2SourceVoice_SetOutputMatrix IXAudio2Voice_SetOutputMatrix
  921. #define IXAudio2SourceVoice_GetOutputMatrix IXAudio2Voice_GetOutputMatrix
  922. #define IXAudio2SourceVoice_DestroyVoice IXAudio2Voice_DestroyVoice
  923. #define IXAudio2SourceVoice_Start(This,Flags,OperationSet) ((This)->lpVtbl->Start(This,Flags,OperationSet))
  924. #define IXAudio2SourceVoice_Stop(This,Flags,OperationSet) ((This)->lpVtbl->Stop(This,Flags,OperationSet))
  925. #define IXAudio2SourceVoice_SubmitSourceBuffer(This,pBuffer,pBufferWMA) ((This)->lpVtbl->SubmitSourceBuffer(This,pBuffer,pBufferWMA))
  926. #define IXAudio2SourceVoice_FlushSourceBuffers(This) ((This)->lpVtbl->FlushSourceBuffers(This))
  927. #define IXAudio2SourceVoice_Discontinuity(This) ((This)->lpVtbl->Discontinuity(This))
  928. #define IXAudio2SourceVoice_ExitLoop(This,OperationSet) ((This)->lpVtbl->ExitLoop(This,OperationSet))
  929. #define IXAudio2SourceVoice_GetState(This,pVoiceState,Flags) ((This)->lpVtbl->GetState(This,pVoiceState,Flags))
  930. #define IXAudio2SourceVoice_SetFrequencyRatio(This,Ratio,OperationSet) ((This)->lpVtbl->SetFrequencyRatio(This,Ratio,OperationSet))
  931. #define IXAudio2SourceVoice_GetFrequencyRatio(This,pRatio) ((This)->lpVtbl->GetFrequencyRatio(This,pRatio))
  932. #define IXAudio2SourceVoice_SetSourceSampleRate(This,NewSourceSampleRate) ((This)->lpVtbl->SetSourceSampleRate(This,NewSourceSampleRate))
  933. // IXAudio2SubmixVoice
  934. #define IXAudio2SubmixVoice_GetVoiceDetails IXAudio2Voice_GetVoiceDetails
  935. #define IXAudio2SubmixVoice_SetOutputVoices IXAudio2Voice_SetOutputVoices
  936. #define IXAudio2SubmixVoice_SetEffectChain IXAudio2Voice_SetEffectChain
  937. #define IXAudio2SubmixVoice_EnableEffect IXAudio2Voice_EnableEffect
  938. #define IXAudio2SubmixVoice_DisableEffect IXAudio2Voice_DisableEffect
  939. #define IXAudio2SubmixVoice_GetEffectState IXAudio2Voice_GetEffectState
  940. #define IXAudio2SubmixVoice_SetEffectParameters IXAudio2Voice_SetEffectParameters
  941. #define IXAudio2SubmixVoice_GetEffectParameters IXAudio2Voice_GetEffectParameters
  942. #define IXAudio2SubmixVoice_SetFilterParameters IXAudio2Voice_SetFilterParameters
  943. #define IXAudio2SubmixVoice_GetFilterParameters IXAudio2Voice_GetFilterParameters
  944. #define IXAudio2SubmixVoice_SetOutputFilterParameters IXAudio2Voice_SetOutputFilterParameters
  945. #define IXAudio2SubmixVoice_GetOutputFilterParameters IXAudio2Voice_GetOutputFilterParameters
  946. #define IXAudio2SubmixVoice_SetVolume IXAudio2Voice_SetVolume
  947. #define IXAudio2SubmixVoice_GetVolume IXAudio2Voice_GetVolume
  948. #define IXAudio2SubmixVoice_SetChannelVolumes IXAudio2Voice_SetChannelVolumes
  949. #define IXAudio2SubmixVoice_GetChannelVolumes IXAudio2Voice_GetChannelVolumes
  950. #define IXAudio2SubmixVoice_SetOutputMatrix IXAudio2Voice_SetOutputMatrix
  951. #define IXAudio2SubmixVoice_GetOutputMatrix IXAudio2Voice_GetOutputMatrix
  952. #define IXAudio2SubmixVoice_DestroyVoice IXAudio2Voice_DestroyVoice
  953. // IXAudio2MasteringVoice
  954. #define IXAudio2MasteringVoice_GetVoiceDetails IXAudio2Voice_GetVoiceDetails
  955. #define IXAudio2MasteringVoice_SetOutputVoices IXAudio2Voice_SetOutputVoices
  956. #define IXAudio2MasteringVoice_SetEffectChain IXAudio2Voice_SetEffectChain
  957. #define IXAudio2MasteringVoice_EnableEffect IXAudio2Voice_EnableEffect
  958. #define IXAudio2MasteringVoice_DisableEffect IXAudio2Voice_DisableEffect
  959. #define IXAudio2MasteringVoice_GetEffectState IXAudio2Voice_GetEffectState
  960. #define IXAudio2MasteringVoice_SetEffectParameters IXAudio2Voice_SetEffectParameters
  961. #define IXAudio2MasteringVoice_GetEffectParameters IXAudio2Voice_GetEffectParameters
  962. #define IXAudio2MasteringVoice_SetFilterParameters IXAudio2Voice_SetFilterParameters
  963. #define IXAudio2MasteringVoice_GetFilterParameters IXAudio2Voice_GetFilterParameters
  964. #define IXAudio2MasteringVoice_SetOutputFilterParameters IXAudio2Voice_SetOutputFilterParameters
  965. #define IXAudio2MasteringVoice_GetOutputFilterParameters IXAudio2Voice_GetOutputFilterParameters
  966. #define IXAudio2MasteringVoice_SetVolume IXAudio2Voice_SetVolume
  967. #define IXAudio2MasteringVoice_GetVolume IXAudio2Voice_GetVolume
  968. #define IXAudio2MasteringVoice_SetChannelVolumes IXAudio2Voice_SetChannelVolumes
  969. #define IXAudio2MasteringVoice_GetChannelVolumes IXAudio2Voice_GetChannelVolumes
  970. #define IXAudio2MasteringVoice_SetOutputMatrix IXAudio2Voice_SetOutputMatrix
  971. #define IXAudio2MasteringVoice_GetOutputMatrix IXAudio2Voice_GetOutputMatrix
  972. #define IXAudio2MasteringVoice_DestroyVoice IXAudio2Voice_DestroyVoice
  973. #define IXAudio2MasteringVoice_GetChannelMask(This,pChannelMask) ((This)->lpVtbl->GetChannelMask(This,pChannelMask))
  974. #endif // #ifndef __cplusplus
  975. /**************************************************************************
  976. *
  977. * Utility functions used to convert from pitch in semitones and volume
  978. * in decibels to the frequency and amplitude ratio units used by XAudio2.
  979. * These are only defined if the client #defines XAUDIO2_HELPER_FUNCTIONS
  980. * prior to #including xaudio2.h.
  981. *
  982. **************************************************************************/
  983. #ifdef XAUDIO2_HELPER_FUNCTIONS
  984. #define _USE_MATH_DEFINES // Make math.h define M_PI
  985. #include <math.h> // For powf, log10f, sinf and asinf
  986. // Calculate the argument to SetVolume from a decibel value
  987. __inline float XAudio2DecibelsToAmplitudeRatio(float Decibels)
  988. {
  989. return powf(10.0f, Decibels / 20.0f);
  990. }
  991. // Recover a volume in decibels from an amplitude factor
  992. __inline float XAudio2AmplitudeRatioToDecibels(float Volume)
  993. {
  994. if (Volume == 0)
  995. {
  996. return -3.402823466e+38f; // Smallest float value (-FLT_MAX)
  997. }
  998. return 20.0f * log10f(Volume);
  999. }
  1000. // Calculate the argument to SetFrequencyRatio from a semitone value
  1001. __inline float XAudio2SemitonesToFrequencyRatio(float Semitones)
  1002. {
  1003. // FrequencyRatio = 2 ^ Octaves
  1004. // = 2 ^ (Semitones / 12)
  1005. return powf(2.0f, Semitones / 12.0f);
  1006. }
  1007. // Recover a pitch in semitones from a frequency ratio
  1008. __inline float XAudio2FrequencyRatioToSemitones(float FrequencyRatio)
  1009. {
  1010. // Semitones = 12 * log2(FrequencyRatio)
  1011. // = 12 * log2(10) * log10(FrequencyRatio)
  1012. return 39.86313713864835f * log10f(FrequencyRatio);
  1013. }
  1014. // Convert from filter cutoff frequencies expressed in Hertz to the radian
  1015. // frequency values used in XAUDIO2_FILTER_PARAMETERS.Frequency, state-variable
  1016. // filter types only. Use XAudio2CutoffFrequencyToOnePoleCoefficient() for one-pole filter types.
  1017. // Note that the highest CutoffFrequency supported is SampleRate/6.
  1018. // Higher values of CutoffFrequency will return XAUDIO2_MAX_FILTER_FREQUENCY.
  1019. __inline float XAudio2CutoffFrequencyToRadians(float CutoffFrequency, UINT32 SampleRate)
  1020. {
  1021. if ((UINT32)(CutoffFrequency * 6.0f) >= SampleRate)
  1022. {
  1023. return XAUDIO2_MAX_FILTER_FREQUENCY;
  1024. }
  1025. return 2.0f * sinf((float)M_PI * CutoffFrequency / SampleRate);
  1026. }
  1027. // Convert from radian frequencies back to absolute frequencies in Hertz
  1028. __inline float XAudio2RadiansToCutoffFrequency(float Radians, float SampleRate)
  1029. {
  1030. return SampleRate * asinf(Radians / 2.0f) / (float)M_PI;
  1031. }
  1032. // Convert from filter cutoff frequencies expressed in Hertz to the filter
  1033. // coefficients used with XAUDIO2_FILTER_PARAMETERS.Frequency,
  1034. // LowPassOnePoleFilter and HighPassOnePoleFilter filter types only.
  1035. // Use XAudio2CutoffFrequencyToRadians() for state-variable filter types.
  1036. __inline float XAudio2CutoffFrequencyToOnePoleCoefficient(float CutoffFrequency, UINT32 SampleRate)
  1037. {
  1038. if ((UINT32)CutoffFrequency >= SampleRate)
  1039. {
  1040. return XAUDIO2_MAX_FILTER_FREQUENCY;
  1041. }
  1042. return ( 1.0f - powf(1.0f - 2.0f * CutoffFrequency / SampleRate, 2.0f) );
  1043. }
  1044. #endif // #ifdef XAUDIO2_HELPER_FUNCTIONS
  1045. /**************************************************************************
  1046. *
  1047. * XAudio2Create: Top-level function that creates an XAudio2 instance.
  1048. *
  1049. * ARGUMENTS:
  1050. *
  1051. * Flags - Flags specifying the XAudio2 object's behavior.
  1052. *
  1053. * XAudio2Processor - An XAUDIO2_PROCESSOR value that specifies the
  1054. * hardware threads (Xbox) or processors (Windows) that XAudio2
  1055. * will use. Note that XAudio2 supports concurrent processing on
  1056. * multiple threads, using any combination of XAUDIO2_PROCESSOR
  1057. * flags. The values are platform-specific; platform-independent
  1058. * code can use XAUDIO2_DEFAULT_PROCESSOR to use the default on
  1059. * each platform.
  1060. *
  1061. **************************************************************************/
  1062. #if (defined XAUDIO2_EXPORT)
  1063. // We're building xaudio2.dll
  1064. #define XAUDIO2_STDAPI extern "C" __declspec(dllexport) HRESULT __stdcall
  1065. #else
  1066. // We're an xaudio2 client
  1067. #define XAUDIO2_STDAPI extern "C" __declspec(dllimport) HRESULT __stdcall
  1068. #endif
  1069. XAUDIO2_STDAPI XAudio2Create(_Outptr_ IXAudio2** ppXAudio2, UINT32 Flags X2DEFAULT(0),
  1070. XAUDIO2_PROCESSOR XAudio2Processor X2DEFAULT(XAUDIO2_DEFAULT_PROCESSOR));
  1071. // Undo the #pragma pack(push, 1) directive at the top of this file
  1072. #pragma pack(pop)
  1073. #endif // #ifndef GUID_DEFS_ONLY
  1074. #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_TV_APP | WINAPI_PARTITION_TV_TITLE) */
  1075. #pragma endregion
  1076. #endif // #ifndef __XAUDIO2_INCLUDED__