faudio: Import upstream release 24.05.
[wine.git] / libs / faudio / include / FAudio.h
blobafe81424d12df1597afa98ea1fe91170e2f459b2
1 /* FAudio - XAudio Reimplementation for FNA
3 * Copyright (c) 2011-2024 Ethan Lee, Luigi Auriemma, and the MonoGame Team
5 * This software is provided 'as-is', without any express or implied warranty.
6 * In no event will the authors be held liable for any damages arising from
7 * the use of this software.
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software in a
15 * product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
21 * 3. This notice may not be removed or altered from any source distribution.
23 * Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
27 #ifndef FAUDIO_H
28 #define FAUDIO_H
30 #ifdef _WIN32
31 #define FAUDIOAPI
32 #define FAUDIOCALL
33 #else
34 #define FAUDIOAPI
35 #define FAUDIOCALL
36 #endif
38 #ifdef _MSC_VER
39 #define FAUDIODEPRECATED(msg) __declspec(deprecated(msg))
40 #else
41 #define FAUDIODEPRECATED(msg) __attribute__((deprecated(msg)))
42 #endif
44 /* -Wpedantic nameless union/struct silencing */
45 #ifndef FAUDIONAMELESS
46 #ifdef __GNUC__
47 #define FAUDIONAMELESS __extension__
48 #else
49 #define FAUDIONAMELESS
50 #endif /* __GNUC__ */
51 #endif /* FAUDIONAMELESS */
53 #include <stdint.h>
54 #include <stddef.h>
56 #ifdef __cplusplus
57 extern "C" {
58 #endif /* __cplusplus */
60 /* Type Declarations */
62 typedef struct FAudio FAudio;
63 typedef struct FAudioVoice FAudioVoice;
64 typedef FAudioVoice FAudioSourceVoice;
65 typedef FAudioVoice FAudioSubmixVoice;
66 typedef FAudioVoice FAudioMasteringVoice;
67 typedef struct FAudioEngineCallback FAudioEngineCallback;
68 typedef struct FAudioVoiceCallback FAudioVoiceCallback;
70 /* Enumerations */
72 typedef enum FAudioDeviceRole
74 FAudioNotDefaultDevice = 0x0,
75 FAudioDefaultConsoleDevice = 0x1,
76 FAudioDefaultMultimediaDevice = 0x2,
77 FAudioDefaultCommunicationsDevice = 0x4,
78 FAudioDefaultGameDevice = 0x8,
79 FAudioGlobalDefaultDevice = 0xF,
80 FAudioInvalidDeviceRole = ~FAudioGlobalDefaultDevice
81 } FAudioDeviceRole;
83 typedef enum FAudioFilterType
85 FAudioLowPassFilter,
86 FAudioBandPassFilter,
87 FAudioHighPassFilter,
88 FAudioNotchFilter
89 } FAudioFilterType;
91 typedef enum FAudioStreamCategory
93 FAudioStreamCategory_Other,
94 FAudioStreamCategory_ForegroundOnlyMedia,
95 FAudioStreamCategory_BackgroundCapableMedia,
96 FAudioStreamCategory_Communications,
97 FAudioStreamCategory_Alerts,
98 FAudioStreamCategory_SoundEffects,
99 FAudioStreamCategory_GameEffects,
100 FAudioStreamCategory_GameMedia,
101 FAudioStreamCategory_GameChat,
102 FAudioStreamCategory_Speech,
103 FAudioStreamCategory_Movie,
104 FAudioStreamCategory_Media
105 } FAudioStreamCategory;
107 /* FIXME: The original enum violates ISO C and is platform specific anyway... */
108 typedef uint32_t FAudioProcessor;
109 #define FAUDIO_DEFAULT_PROCESSOR 0xFFFFFFFF
111 /* Structures */
113 #pragma pack(push, 1)
115 typedef struct FAudioGUID
117 uint32_t Data1;
118 uint16_t Data2;
119 uint16_t Data3;
120 uint8_t Data4[8];
121 } FAudioGUID;
123 /* See MSDN:
124 * https://msdn.microsoft.com/en-us/library/windows/desktop/dd390970%28v=vs.85%29.aspx
126 typedef struct FAudioWaveFormatEx
128 uint16_t wFormatTag;
129 uint16_t nChannels;
130 uint32_t nSamplesPerSec;
131 uint32_t nAvgBytesPerSec;
132 uint16_t nBlockAlign;
133 uint16_t wBitsPerSample;
134 uint16_t cbSize;
135 } FAudioWaveFormatEx;
137 /* See MSDN:
138 * https://msdn.microsoft.com/en-us/library/windows/desktop/dd390971(v=vs.85).aspx
140 typedef struct FAudioWaveFormatExtensible
142 FAudioWaveFormatEx Format;
143 union
145 uint16_t wValidBitsPerSample;
146 uint16_t wSamplesPerBlock;
147 uint16_t wReserved;
148 } Samples;
149 uint32_t dwChannelMask;
150 FAudioGUID SubFormat;
151 } FAudioWaveFormatExtensible;
153 typedef struct FAudioADPCMCoefSet
155 int16_t iCoef1;
156 int16_t iCoef2;
157 } FAudioADPCMCoefSet;
159 typedef struct FAudioADPCMWaveFormat
161 FAudioWaveFormatEx wfx;
162 uint16_t wSamplesPerBlock;
163 uint16_t wNumCoef;
165 /* MSVC warns on empty arrays in structs */
166 #ifdef _MSC_VER
167 #pragma warning(push)
168 #pragma warning(disable: 4200)
169 #endif
171 FAudioADPCMCoefSet aCoef[];
172 /* MSADPCM has 7 coefficient pairs:
174 * { 256, 0 },
175 * { 512, -256 },
176 * { 0, 0 },
177 * { 192, 64 },
178 * { 240, 0 },
179 * { 460, -208 },
180 * { 392, -232 }
184 #ifdef _MSC_VER
185 #pragma warning(pop)
186 #endif
187 } FAudioADPCMWaveFormat;
189 typedef struct FAudioDeviceDetails
191 int16_t DeviceID[256]; /* Win32 wchar_t */
192 int16_t DisplayName[256]; /* Win32 wchar_t */
193 FAudioDeviceRole Role;
194 FAudioWaveFormatExtensible OutputFormat;
195 } FAudioDeviceDetails;
197 typedef struct FAudioVoiceDetails
199 uint32_t CreationFlags;
200 uint32_t ActiveFlags;
201 uint32_t InputChannels;
202 uint32_t InputSampleRate;
203 } FAudioVoiceDetails;
205 typedef struct FAudioSendDescriptor
207 uint32_t Flags; /* 0 or FAUDIO_SEND_USEFILTER */
208 FAudioVoice *pOutputVoice;
209 } FAudioSendDescriptor;
211 typedef struct FAudioVoiceSends
213 uint32_t SendCount;
214 FAudioSendDescriptor *pSends;
215 } FAudioVoiceSends;
217 #ifndef FAPO_DECL
218 #define FAPO_DECL
219 typedef struct FAPO FAPO;
220 #endif /* FAPO_DECL */
222 typedef struct FAudioEffectDescriptor
224 FAPO *pEffect;
225 int32_t InitialState; /* 1 - Enabled, 0 - Disabled */
226 uint32_t OutputChannels;
227 } FAudioEffectDescriptor;
229 typedef struct FAudioEffectChain
231 uint32_t EffectCount;
232 FAudioEffectDescriptor *pEffectDescriptors;
233 } FAudioEffectChain;
235 typedef struct FAudioFilterParameters
237 FAudioFilterType Type;
238 float Frequency; /* [0, FAUDIO_MAX_FILTER_FREQUENCY] */
239 float OneOverQ; /* [0, FAUDIO_MAX_FILTER_ONEOVERQ] */
240 } FAudioFilterParameters;
242 typedef struct FAudioFilterParametersEXT
244 FAudioFilterType Type;
245 float Frequency; /* [0, FAUDIO_MAX_FILTER_FREQUENCY] */
246 float OneOverQ; /* [0, FAUDIO_MAX_FILTER_ONEOVERQ] */
247 float WetDryMix; /* [0, 1] */
248 } FAudioFilterParametersEXT;
250 typedef struct FAudioBuffer
252 /* Either 0 or FAUDIO_END_OF_STREAM */
253 uint32_t Flags;
254 /* Pointer to wave data, memory block size.
255 * Note that pAudioData is not copied; FAudio reads directly from your
256 * pointer! This pointer must be valid until FAudio has finished using
257 * it, at which point an OnBufferEnd callback will be generated.
259 uint32_t AudioBytes;
260 const uint8_t *pAudioData;
261 /* Play region, in sample frames. */
262 uint32_t PlayBegin;
263 uint32_t PlayLength;
264 /* Loop region, in sample frames.
265 * This can be used to loop a subregion of the wave instead of looping
266 * the whole thing, i.e. if you have an intro/outro you can set these
267 * to loop the middle sections instead. If you don't need this, set both
268 * values to 0.
270 uint32_t LoopBegin;
271 uint32_t LoopLength;
272 /* [0, FAUDIO_LOOP_INFINITE] */
273 uint32_t LoopCount;
274 /* This is sent to callbacks as pBufferContext */
275 void *pContext;
276 } FAudioBuffer;
278 typedef struct FAudioBufferWMA
280 const uint32_t *pDecodedPacketCumulativeBytes;
281 uint32_t PacketCount;
282 } FAudioBufferWMA;
284 typedef struct FAudioVoiceState
286 void *pCurrentBufferContext;
287 uint32_t BuffersQueued;
288 uint64_t SamplesPlayed;
289 } FAudioVoiceState;
291 typedef struct FAudioPerformanceData
293 uint64_t AudioCyclesSinceLastQuery;
294 uint64_t TotalCyclesSinceLastQuery;
295 uint32_t MinimumCyclesPerQuantum;
296 uint32_t MaximumCyclesPerQuantum;
297 uint32_t MemoryUsageInBytes;
298 uint32_t CurrentLatencyInSamples;
299 uint32_t GlitchesSinceEngineStarted;
300 uint32_t ActiveSourceVoiceCount;
301 uint32_t TotalSourceVoiceCount;
302 uint32_t ActiveSubmixVoiceCount;
303 uint32_t ActiveResamplerCount;
304 uint32_t ActiveMatrixMixCount;
305 uint32_t ActiveXmaSourceVoices;
306 uint32_t ActiveXmaStreams;
307 } FAudioPerformanceData;
309 typedef struct FAudioDebugConfiguration
311 /* See FAUDIO_LOG_* */
312 uint32_t TraceMask;
313 uint32_t BreakMask;
314 /* 0 or 1 */
315 int32_t LogThreadID;
316 int32_t LogFileline;
317 int32_t LogFunctionName;
318 int32_t LogTiming;
319 } FAudioDebugConfiguration;
321 #pragma pack(pop)
323 /* This ISN'T packed. Strictly speaking it wouldn't have mattered anyway but eh.
324 * See https://github.com/microsoft/DirectXTK/issues/256
326 typedef struct FAudioXMA2WaveFormatEx
328 FAudioWaveFormatEx wfx;
329 uint16_t wNumStreams;
330 uint32_t dwChannelMask;
331 uint32_t dwSamplesEncoded;
332 uint32_t dwBytesPerBlock;
333 uint32_t dwPlayBegin;
334 uint32_t dwPlayLength;
335 uint32_t dwLoopBegin;
336 uint32_t dwLoopLength;
337 uint8_t bLoopCount;
338 uint8_t bEncoderVersion;
339 uint16_t wBlockCount;
340 } FAudioXMA2WaveFormat;
342 /* Constants */
344 #define FAUDIO_E_OUT_OF_MEMORY 0x8007000e
345 #define FAUDIO_E_INVALID_ARG 0x80070057
346 #define FAUDIO_E_UNSUPPORTED_FORMAT 0x88890008
347 #define FAUDIO_E_INVALID_CALL 0x88960001
348 #define FAUDIO_E_DEVICE_INVALIDATED 0x88960004
349 #define FAPO_E_FORMAT_UNSUPPORTED 0x88970001
351 #define FAUDIO_MAX_BUFFER_BYTES 0x80000000
352 #define FAUDIO_MAX_QUEUED_BUFFERS 64
353 #define FAUDIO_MAX_AUDIO_CHANNELS 64
354 #define FAUDIO_MIN_SAMPLE_RATE 1000
355 #define FAUDIO_MAX_SAMPLE_RATE 200000
356 #define FAUDIO_MAX_VOLUME_LEVEL 16777216.0f
357 #define FAUDIO_MIN_FREQ_RATIO (1.0f / 1024.0f)
358 #define FAUDIO_MAX_FREQ_RATIO 1024.0f
359 #define FAUDIO_DEFAULT_FREQ_RATIO 2.0f
360 #define FAUDIO_MAX_FILTER_ONEOVERQ 1.5f
361 #define FAUDIO_MAX_FILTER_FREQUENCY 1.0f
362 #define FAUDIO_MAX_LOOP_COUNT 254
364 #define FAUDIO_COMMIT_NOW 0
365 #define FAUDIO_COMMIT_ALL 0
366 #define FAUDIO_INVALID_OPSET (uint32_t) (-1)
367 #define FAUDIO_NO_LOOP_REGION 0
368 #define FAUDIO_LOOP_INFINITE 255
369 #define FAUDIO_DEFAULT_CHANNELS 0
370 #define FAUDIO_DEFAULT_SAMPLERATE 0
372 #define FAUDIO_DEBUG_ENGINE 0x0001
373 #define FAUDIO_VOICE_NOPITCH 0x0002
374 #define FAUDIO_VOICE_NOSRC 0x0004
375 #define FAUDIO_VOICE_USEFILTER 0x0008
376 #define FAUDIO_VOICE_MUSIC 0x0010
377 #define FAUDIO_PLAY_TAILS 0x0020
378 #define FAUDIO_END_OF_STREAM 0x0040
379 #define FAUDIO_SEND_USEFILTER 0x0080
380 #define FAUDIO_VOICE_NOSAMPLESPLAYED 0x0100
381 #define FAUDIO_1024_QUANTUM 0x8000
383 #define FAUDIO_DEFAULT_FILTER_TYPE FAudioLowPassFilter
384 #define FAUDIO_DEFAULT_FILTER_FREQUENCY FAUDIO_MAX_FILTER_FREQUENCY
385 #define FAUDIO_DEFAULT_FILTER_ONEOVERQ 1.0f
386 #define FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT 1.0f
388 #define FAUDIO_LOG_ERRORS 0x0001
389 #define FAUDIO_LOG_WARNINGS 0x0002
390 #define FAUDIO_LOG_INFO 0x0004
391 #define FAUDIO_LOG_DETAIL 0x0008
392 #define FAUDIO_LOG_API_CALLS 0x0010
393 #define FAUDIO_LOG_FUNC_CALLS 0x0020
394 #define FAUDIO_LOG_TIMING 0x0040
395 #define FAUDIO_LOG_LOCKS 0x0080
396 #define FAUDIO_LOG_MEMORY 0x0100
397 #define FAUDIO_LOG_STREAMING 0x1000
399 #ifndef _SPEAKER_POSITIONS_
400 #define SPEAKER_FRONT_LEFT 0x00000001
401 #define SPEAKER_FRONT_RIGHT 0x00000002
402 #define SPEAKER_FRONT_CENTER 0x00000004
403 #define SPEAKER_LOW_FREQUENCY 0x00000008
404 #define SPEAKER_BACK_LEFT 0x00000010
405 #define SPEAKER_BACK_RIGHT 0x00000020
406 #define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040
407 #define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080
408 #define SPEAKER_BACK_CENTER 0x00000100
409 #define SPEAKER_SIDE_LEFT 0x00000200
410 #define SPEAKER_SIDE_RIGHT 0x00000400
411 #define SPEAKER_TOP_CENTER 0x00000800
412 #define SPEAKER_TOP_FRONT_LEFT 0x00001000
413 #define SPEAKER_TOP_FRONT_CENTER 0x00002000
414 #define SPEAKER_TOP_FRONT_RIGHT 0x00004000
415 #define SPEAKER_TOP_BACK_LEFT 0x00008000
416 #define SPEAKER_TOP_BACK_CENTER 0x00010000
417 #define SPEAKER_TOP_BACK_RIGHT 0x00020000
418 #define _SPEAKER_POSITIONS_
419 #endif
421 #ifndef SPEAKER_MONO
422 #define SPEAKER_MONO SPEAKER_FRONT_CENTER
423 #define SPEAKER_STEREO (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT)
424 #define SPEAKER_2POINT1 \
425 ( SPEAKER_FRONT_LEFT | \
426 SPEAKER_FRONT_RIGHT | \
427 SPEAKER_LOW_FREQUENCY )
428 #define SPEAKER_SURROUND \
429 ( SPEAKER_FRONT_LEFT | \
430 SPEAKER_FRONT_RIGHT | \
431 SPEAKER_FRONT_CENTER | \
432 SPEAKER_BACK_CENTER )
433 #define SPEAKER_QUAD \
434 ( SPEAKER_FRONT_LEFT | \
435 SPEAKER_FRONT_RIGHT | \
436 SPEAKER_BACK_LEFT | \
437 SPEAKER_BACK_RIGHT )
438 #define SPEAKER_4POINT1 \
439 ( SPEAKER_FRONT_LEFT | \
440 SPEAKER_FRONT_RIGHT | \
441 SPEAKER_LOW_FREQUENCY | \
442 SPEAKER_BACK_LEFT | \
443 SPEAKER_BACK_RIGHT )
444 #define SPEAKER_5POINT1 \
445 ( SPEAKER_FRONT_LEFT | \
446 SPEAKER_FRONT_RIGHT | \
447 SPEAKER_FRONT_CENTER | \
448 SPEAKER_LOW_FREQUENCY | \
449 SPEAKER_BACK_LEFT | \
450 SPEAKER_BACK_RIGHT )
451 #define SPEAKER_7POINT1 \
452 ( SPEAKER_FRONT_LEFT | \
453 SPEAKER_FRONT_RIGHT | \
454 SPEAKER_FRONT_CENTER | \
455 SPEAKER_LOW_FREQUENCY | \
456 SPEAKER_BACK_LEFT | \
457 SPEAKER_BACK_RIGHT | \
458 SPEAKER_FRONT_LEFT_OF_CENTER | \
459 SPEAKER_FRONT_RIGHT_OF_CENTER )
460 #define SPEAKER_5POINT1_SURROUND \
461 ( SPEAKER_FRONT_LEFT | \
462 SPEAKER_FRONT_RIGHT | \
463 SPEAKER_FRONT_CENTER | \
464 SPEAKER_LOW_FREQUENCY | \
465 SPEAKER_SIDE_LEFT | \
466 SPEAKER_SIDE_RIGHT )
467 #define SPEAKER_7POINT1_SURROUND \
468 ( SPEAKER_FRONT_LEFT | \
469 SPEAKER_FRONT_RIGHT | \
470 SPEAKER_FRONT_CENTER | \
471 SPEAKER_LOW_FREQUENCY | \
472 SPEAKER_BACK_LEFT | \
473 SPEAKER_BACK_RIGHT | \
474 SPEAKER_SIDE_LEFT | \
475 SPEAKER_SIDE_RIGHT )
476 #define SPEAKER_XBOX SPEAKER_5POINT1
477 #endif
479 #define FAUDIO_FORMAT_PCM 1
480 #define FAUDIO_FORMAT_MSADPCM 2
481 #define FAUDIO_FORMAT_IEEE_FLOAT 3
482 #define FAUDIO_FORMAT_WMAUDIO2 0x0161
483 #define FAUDIO_FORMAT_WMAUDIO3 0x0162
484 #define FAUDIO_FORMAT_WMAUDIO_LOSSLESS 0x0163
485 #define FAUDIO_FORMAT_XMAUDIO2 0x0166
486 #define FAUDIO_FORMAT_EXTENSIBLE 0xFFFE
488 extern FAudioGUID DATAFORMAT_SUBTYPE_PCM;
489 extern FAudioGUID DATAFORMAT_SUBTYPE_IEEE_FLOAT;
491 /* FAudio Version API */
493 #define FAUDIO_TARGET_VERSION 8 /* Targeting compatibility with XAudio 2.8 */
495 #define FAUDIO_ABI_VERSION 0
496 #define FAUDIO_MAJOR_VERSION 24
497 #define FAUDIO_MINOR_VERSION 5
498 #define FAUDIO_PATCH_VERSION 0
500 #define FAUDIO_COMPILED_VERSION ( \
501 (FAUDIO_ABI_VERSION * 100 * 100 * 100) + \
502 (FAUDIO_MAJOR_VERSION * 100 * 100) + \
503 (FAUDIO_MINOR_VERSION * 100) + \
504 (FAUDIO_PATCH_VERSION) \
507 FAUDIOAPI uint32_t FAudioLinkedVersion(void);
509 /* FAudio Interface */
511 /* This should be your first FAudio call.
513 * ppFAudio: Filled with the FAudio core context.
514 * Flags: Can be 0 or FAUDIO_DEBUG_ENGINE.
515 * XAudio2Processor: Set this to FAUDIO_DEFAULT_PROCESSOR.
517 * Returns 0 on success.
519 FAUDIOAPI uint32_t FAudioCreate(
520 FAudio **ppFAudio,
521 uint32_t Flags,
522 FAudioProcessor XAudio2Processor
525 /* See "extensions/COMConstructEXT.txt" for more details */
526 FAUDIOAPI uint32_t FAudioCOMConstructEXT(FAudio **ppFAudio, uint8_t version);
528 /* Increments a reference counter. When counter is 0, audio is freed.
529 * Returns the reference count after incrementing.
531 FAUDIOAPI uint32_t FAudio_AddRef(FAudio *audio);
533 /* Decrements a reference counter. When counter is 0, audio is freed.
534 * Returns the reference count after decrementing.
536 FAUDIOAPI uint32_t FAudio_Release(FAudio *audio);
538 /* Queries the number of sound devices available for use.
540 * pCount: Filled with the number of available sound devices.
542 * Returns 0 on success.
544 FAUDIOAPI uint32_t FAudio_GetDeviceCount(FAudio *audio, uint32_t *pCount);
546 /* Gets basic information about a sound device.
548 * Index: Can be between 0 and the result of GetDeviceCount.
549 * pDeviceDetails: Filled with the device information.
551 * Returns 0 on success.
553 FAUDIOAPI uint32_t FAudio_GetDeviceDetails(
554 FAudio *audio,
555 uint32_t Index,
556 FAudioDeviceDetails *pDeviceDetails
559 /* You don't actually have to call this, unless you're using the COM APIs.
560 * See the FAudioCreate API for parameter information.
562 FAUDIOAPI uint32_t FAudio_Initialize(
563 FAudio *audio,
564 uint32_t Flags,
565 FAudioProcessor XAudio2Processor
568 /* Register a new set of engine callbacks.
569 * There is no limit to the number of sets, but expect performance to degrade
570 * if you have a whole bunch of these. You most likely only need one.
572 * pCallback: The completely-initialized FAudioEngineCallback structure.
574 * Returns 0 on success.
576 FAUDIOAPI uint32_t FAudio_RegisterForCallbacks(
577 FAudio *audio,
578 FAudioEngineCallback *pCallback
581 /* Remove an active set of engine callbacks.
582 * This checks the pointer value, NOT the callback values!
584 * pCallback: An FAudioEngineCallback structure previously sent to Register.
586 * Returns 0 on success.
588 FAUDIOAPI void FAudio_UnregisterForCallbacks(
589 FAudio *audio,
590 FAudioEngineCallback *pCallback
593 /* Creates a "source" voice, used to play back wavedata.
595 * ppSourceVoice: Filled with the source voice pointer.
596 * pSourceFormat: The input wavedata format, see the documentation for
597 * FAudioWaveFormatEx.
598 * Flags: Can be 0 or a mix of the following FAUDIO_VOICE_* flags:
599 * NOPITCH/NOSRC: Resampling is disabled. If you set this,
600 * the source format sample rate MUST match
601 * the output voices' input sample rates.
602 * Also, SetFrequencyRatio will fail.
603 * USEFILTER: Enables the use of SetFilterParameters.
604 * MUSIC: Unsupported.
605 * MaxFrequencyRatio: AKA your max pitch. This allows us to optimize the size
606 * of the decode/resample cache sizes. For example, if you
607 * only expect to raise pitch by a single octave, you can
608 * set this value to 2.0f. 2.0f is the default value.
609 * Bounds: [FAUDIO_MIN_FREQ_RATIO, FAUDIO_MAX_FREQ_RATIO].
610 * pCallback: Voice callbacks, see FAudioVoiceCallback documentation.
611 * pSendList: List of output voices. If NULL, defaults to master.
612 * All output voices must have the same sample rate!
613 * pEffectChain: List of FAPO effects. This value can be NULL.
615 * Returns 0 on success.
617 FAUDIOAPI uint32_t FAudio_CreateSourceVoice(
618 FAudio *audio,
619 FAudioSourceVoice **ppSourceVoice,
620 const FAudioWaveFormatEx *pSourceFormat,
621 uint32_t Flags,
622 float MaxFrequencyRatio,
623 FAudioVoiceCallback *pCallback,
624 const FAudioVoiceSends *pSendList,
625 const FAudioEffectChain *pEffectChain
628 /* Creates a "submix" voice, used to mix/process input voices.
629 * The typical use case for this is to perform CPU-intensive tasks on large
630 * groups of voices all at once. Examples include resampling and FAPO effects.
632 * ppSubmixVoice: Filled with the submix voice pointer.
633 * InputChannels: Input voices will convert to this channel count.
634 * InputSampleRate: Input voices will convert to this sample rate.
635 * Flags: Can be 0 or FAUDIO_VOICE_USEFILTER.
636 * ProcessingStage: If you have multiple submixes that depend on a specific
637 * order of processing, you can sort them by setting this
638 * value to prioritize them. For example, submixes with
639 * stage 0 will process first, then stage 1, 2, and so on.
640 * pSendList: List of output voices. If NULL, defaults to master.
641 * All output voices must have the same sample rate!
642 * pEffectChain: List of FAPO effects. This value can be NULL.
644 * Returns 0 on success.
646 FAUDIOAPI uint32_t FAudio_CreateSubmixVoice(
647 FAudio *audio,
648 FAudioSubmixVoice **ppSubmixVoice,
649 uint32_t InputChannels,
650 uint32_t InputSampleRate,
651 uint32_t Flags,
652 uint32_t ProcessingStage,
653 const FAudioVoiceSends *pSendList,
654 const FAudioEffectChain *pEffectChain
657 /* This should be your second FAudio call, unless you care about which device
658 * you want to use. In that case, see GetDeviceDetails.
660 * ppMasteringVoice: Filled with the mastering voice pointer.
661 * InputChannels: Device channel count. Can be FAUDIO_DEFAULT_CHANNELS.
662 * InputSampleRate: Device sample rate. Can be FAUDIO_DEFAULT_SAMPLERATE.
663 * Flags: This value must be 0.
664 * DeviceIndex: 0 for the default device. See GetDeviceCount.
665 * pEffectChain: List of FAPO effects. This value can be NULL.
667 * Returns 0 on success.
669 FAUDIOAPI uint32_t FAudio_CreateMasteringVoice(
670 FAudio *audio,
671 FAudioMasteringVoice **ppMasteringVoice,
672 uint32_t InputChannels,
673 uint32_t InputSampleRate,
674 uint32_t Flags,
675 uint32_t DeviceIndex,
676 const FAudioEffectChain *pEffectChain
679 /* This is the XAudio 2.8+ version of CreateMasteringVoice.
680 * Right now this doesn't do anything. Don't use this function.
682 FAUDIOAPI uint32_t FAudio_CreateMasteringVoice8(
683 FAudio *audio,
684 FAudioMasteringVoice **ppMasteringVoice,
685 uint32_t InputChannels,
686 uint32_t InputSampleRate,
687 uint32_t Flags,
688 uint16_t *szDeviceId,
689 const FAudioEffectChain *pEffectChain,
690 FAudioStreamCategory StreamCategory
693 /* Starts the engine, begins processing the audio graph.
694 * Returns 0 on success.
696 FAUDIOAPI uint32_t FAudio_StartEngine(FAudio *audio);
698 /* Stops the engine and halts all processing.
699 * The audio device will continue to run, but will produce silence.
700 * The graph will be frozen until you call StartEngine, where it will then
701 * resume all processing exactly as it would have had this never been called.
703 FAUDIOAPI void FAudio_StopEngine(FAudio *audio);
705 /* Flushes a batch of FAudio calls compiled with a given "OperationSet" tag.
706 * This function is based on IXAudio2::CommitChanges from the XAudio2 spec.
707 * This is useful for pushing calls that need to be done perfectly in sync. For
708 * example, if you want to play two separate sources at the exact same time, you
709 * can call FAudioSourceVoice_Start with an OperationSet value of your choice,
710 * then call CommitChanges with that same value to start the sources together.
712 * OperationSet: Either a value known by you or FAUDIO_COMMIT_ALL
714 * Returns 0 on success.
716 FAUDIOAPI uint32_t FAudio_CommitOperationSet(
717 FAudio *audio,
718 uint32_t OperationSet
721 /* DO NOT USE THIS FUNCTION OR I SWEAR TO GOD */
722 FAUDIODEPRECATED("This function will break your program! Use FAudio_CommitOperationSet instead!")
723 FAUDIOAPI uint32_t FAudio_CommitChanges(FAudio *audio);
725 /* Requests various bits of performance information from the engine.
727 * pPerfData: Filled with the data. See FAudioPerformanceData for details.
729 FAUDIOAPI void FAudio_GetPerformanceData(
730 FAudio *audio,
731 FAudioPerformanceData *pPerfData
734 /* When using a Debug binary, this lets you configure what information gets
735 * logged to output. Be careful, this can spit out a LOT of text.
737 * pDebugConfiguration: See FAudioDebugConfiguration for details.
738 * pReserved: Set this to NULL.
740 FAUDIOAPI void FAudio_SetDebugConfiguration(
741 FAudio *audio,
742 FAudioDebugConfiguration *pDebugConfiguration,
743 void* pReserved
746 /* Requests the values that determine's the engine's update size.
747 * For example, a 48KHz engine with a 1024-sample update period would return
748 * 1024 for the numerator and 48000 for the denominator. With this information,
749 * you can determine the precise update size in milliseconds.
751 * quantumNumerator - The engine's update size, in sample frames.
752 * quantumDenominator - The engine's sample rate, in Hz
754 FAUDIOAPI void FAudio_GetProcessingQuantum(
755 FAudio *audio,
756 uint32_t *quantumNumerator,
757 uint32_t *quantumDenominator
760 /* FAudioVoice Interface */
762 /* Requests basic information about a voice.
764 * pVoiceDetails: See FAudioVoiceDetails for details.
766 FAUDIOAPI void FAudioVoice_GetVoiceDetails(
767 FAudioVoice *voice,
768 FAudioVoiceDetails *pVoiceDetails
771 /* Change the output voices for this voice.
772 * This function is invalid for mastering voices.
774 * pSendList: List of output voices. If NULL, defaults to master.
775 * All output voices must have the same sample rate!
777 * Returns 0 on success.
779 FAUDIOAPI uint32_t FAudioVoice_SetOutputVoices(
780 FAudioVoice *voice,
781 const FAudioVoiceSends *pSendList
784 /* Change/Remove the effect chain for this voice.
786 * pEffectChain: List of FAPO effects. This value can be NULL.
787 * Note that the final channel counts for this chain MUST
788 * match the input/output channel count that was
789 * determined at voice creation time!
791 * Returns 0 on success.
793 FAUDIOAPI uint32_t FAudioVoice_SetEffectChain(
794 FAudioVoice *voice,
795 const FAudioEffectChain *pEffectChain
798 /* Enables an effect in the effect chain.
800 * EffectIndex: The index of the effect (based on the chain order).
801 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
803 * Returns 0 on success.
805 FAUDIOAPI uint32_t FAudioVoice_EnableEffect(
806 FAudioVoice *voice,
807 uint32_t EffectIndex,
808 uint32_t OperationSet
811 /* Disables an effect in the effect chain.
813 * EffectIndex: The index of the effect (based on the chain order).
814 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
816 * Returns 0 on success.
818 FAUDIOAPI uint32_t FAudioVoice_DisableEffect(
819 FAudioVoice *voice,
820 uint32_t EffectIndex,
821 uint32_t OperationSet
824 /* Queries the enabled/disabled state of an effect in the effect chain.
826 * EffectIndex: The index of the effect (based on the chain order).
827 * pEnabled: Filled with either 1 (Enabled) or 0 (Disabled).
829 * Returns 0 on success.
831 FAUDIOAPI void FAudioVoice_GetEffectState(
832 FAudioVoice *voice,
833 uint32_t EffectIndex,
834 int32_t *pEnabled
837 /* Submits a block of memory to be sent to FAPO::SetParameters.
839 * EffectIndex: The index of the effect (based on the chain order).
840 * pParameters: The values to be copied and submitted to the FAPO.
841 * ParametersByteSize: This should match what the FAPO expects!
842 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
844 * Returns 0 on success.
846 FAUDIOAPI uint32_t FAudioVoice_SetEffectParameters(
847 FAudioVoice *voice,
848 uint32_t EffectIndex,
849 const void *pParameters,
850 uint32_t ParametersByteSize,
851 uint32_t OperationSet
854 /* Requests the latest parameters from FAPO::GetParameters.
856 * EffectIndex: The index of the effect (based on the chain order).
857 * pParameters: Filled with the latest parameter values from the FAPO.
858 * ParametersByteSize: This should match what the FAPO expects!
860 * Returns 0 on success.
862 FAUDIOAPI uint32_t FAudioVoice_GetEffectParameters(
863 FAudioVoice *voice,
864 uint32_t EffectIndex,
865 void *pParameters,
866 uint32_t ParametersByteSize
869 /* Sets the filter variables for a voice.
870 * This is only valid on voices with the USEFILTER flag.
872 * pParameters: See FAudioFilterParameters for details.
873 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
875 * Returns 0 on success.
877 FAUDIOAPI uint32_t FAudioVoice_SetFilterParameters(
878 FAudioVoice *voice,
879 const FAudioFilterParameters *pParameters,
880 uint32_t OperationSet
883 /* Requests the filter variables for a voice.
884 * This is only valid on voices with the USEFILTER flag.
886 * pParameters: See FAudioFilterParameters for details.
888 FAUDIOAPI void FAudioVoice_GetFilterParameters(
889 FAudioVoice *voice,
890 FAudioFilterParameters *pParameters
893 /* Sets the filter variables for a voice's output voice.
894 * This is only valid on sends with the USEFILTER flag.
896 * pDestinationVoice: An output voice from the voice's send list.
897 * pParameters: See FAudioFilterParameters for details.
898 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
900 * Returns 0 on success.
902 FAUDIOAPI uint32_t FAudioVoice_SetOutputFilterParameters(
903 FAudioVoice *voice,
904 FAudioVoice *pDestinationVoice,
905 const FAudioFilterParameters *pParameters,
906 uint32_t OperationSet
909 /* Requests the filter variables for a voice's output voice.
910 * This is only valid on sends with the USEFILTER flag.
912 * pDestinationVoice: An output voice from the voice's send list.
913 * pParameters: See FAudioFilterParameters for details.
915 FAUDIOAPI void FAudioVoice_GetOutputFilterParameters(
916 FAudioVoice *voice,
917 FAudioVoice *pDestinationVoice,
918 FAudioFilterParameters *pParameters
921 /* Sets the filter variables for a voice.
922 * This is only valid on voices with the USEFILTER flag.
924 * pParameters: See FAudioFilterParametersEXT for details.
925 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
927 * Returns 0 on success.
929 FAUDIOAPI uint32_t FAudioVoice_SetFilterParametersEXT(
930 FAudioVoice* voice,
931 const FAudioFilterParametersEXT* pParameters,
932 uint32_t OperationSet
935 /* Requests the filter variables for a voice.
936 * This is only valid on voices with the USEFILTER flag.
938 * pParameters: See FAudioFilterParametersEXT for details.
940 FAUDIOAPI void FAudioVoice_GetFilterParametersEXT(
941 FAudioVoice* voice,
942 FAudioFilterParametersEXT* pParameters
945 /* Sets the filter variables for a voice's output voice.
946 * This is only valid on sends with the USEFILTER flag.
948 * pDestinationVoice: An output voice from the voice's send list.
949 * pParameters: See FAudioFilterParametersEXT for details.
950 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
952 * Returns 0 on success.
954 FAUDIOAPI uint32_t FAudioVoice_SetOutputFilterParametersEXT(
955 FAudioVoice* voice,
956 FAudioVoice* pDestinationVoice,
957 const FAudioFilterParametersEXT* pParameters,
958 uint32_t OperationSet
961 /* Requests the filter variables for a voice's output voice.
962 * This is only valid on sends with the USEFILTER flag.
964 * pDestinationVoice: An output voice from the voice's send list.
965 * pParameters: See FAudioFilterParametersEXT for details.
967 FAUDIOAPI void FAudioVoice_GetOutputFilterParametersEXT(
968 FAudioVoice* voice,
969 FAudioVoice* pDestinationVoice,
970 FAudioFilterParametersEXT* pParameters
973 /* Sets the global volume of a voice.
975 * Volume: Amplitude ratio. 1.0f is default, 0.0f is silence.
976 * Note that you can actually set volume < 0.0f!
977 * Bounds: [-FAUDIO_MAX_VOLUME_LEVEL, FAUDIO_MAX_VOLUME_LEVEL]
978 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
980 * Returns 0 on success.
982 FAUDIOAPI uint32_t FAudioVoice_SetVolume(
983 FAudioVoice *voice,
984 float Volume,
985 uint32_t OperationSet
988 /* Requests the global volume of a voice.
990 * pVolume: Filled with the current voice amplitude ratio.
992 FAUDIOAPI void FAudioVoice_GetVolume(
993 FAudioVoice *voice,
994 float *pVolume
997 /* Sets the per-channel volumes of a voice.
999 * Channels: Must match the channel count of this voice!
1000 * pVolumes: Amplitude ratios for each channel. Same as SetVolume.
1001 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1003 * Returns 0 on success.
1005 FAUDIOAPI uint32_t FAudioVoice_SetChannelVolumes(
1006 FAudioVoice *voice,
1007 uint32_t Channels,
1008 const float *pVolumes,
1009 uint32_t OperationSet
1012 /* Requests the per-channel volumes of a voice.
1014 * Channels: Must match the channel count of this voice!
1015 * pVolumes: Filled with the current channel amplitude ratios.
1017 FAUDIOAPI void FAudioVoice_GetChannelVolumes(
1018 FAudioVoice *voice,
1019 uint32_t Channels,
1020 float *pVolumes
1023 /* Sets the volumes of a send's output channels. The matrix is based on the
1024 * voice's input channels. For example, the default matrix for a 2-channel
1025 * source and a 2-channel output voice is as follows:
1026 * [0] = 1.0f; <- Left input, left output
1027 * [1] = 0.0f; <- Right input, left output
1028 * [2] = 0.0f; <- Left input, right output
1029 * [3] = 1.0f; <- Right input, right output
1030 * This is typically only used for panning or 3D sound (via F3DAudio).
1032 * pDestinationVoice: An output voice from the voice's send list.
1033 * SourceChannels: Must match the voice's input channel count!
1034 * DestinationChannels: Must match the destination's input channel count!
1035 * pLevelMatrix: A float[SourceChannels * DestinationChannels].
1036 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1038 * Returns 0 on success.
1040 FAUDIOAPI uint32_t FAudioVoice_SetOutputMatrix(
1041 FAudioVoice *voice,
1042 FAudioVoice *pDestinationVoice,
1043 uint32_t SourceChannels,
1044 uint32_t DestinationChannels,
1045 const float *pLevelMatrix,
1046 uint32_t OperationSet
1049 /* Gets the volumes of a send's output channels. See SetOutputMatrix.
1051 * pDestinationVoice: An output voice from the voice's send list.
1052 * SourceChannels: Must match the voice's input channel count!
1053 * DestinationChannels: Must match the voice's output channel count!
1054 * pLevelMatrix: A float[SourceChannels * DestinationChannels].
1056 FAUDIOAPI void FAudioVoice_GetOutputMatrix(
1057 FAudioVoice *voice,
1058 FAudioVoice *pDestinationVoice,
1059 uint32_t SourceChannels,
1060 uint32_t DestinationChannels,
1061 float *pLevelMatrix
1064 /* Removes this voice from the audio graph and frees memory. */
1065 FAUDIOAPI void FAudioVoice_DestroyVoice(FAudioVoice *voice);
1068 * Returns S_OK on success and E_FAIL if voice could not be destroyed (e. g., because it is in use).
1070 FAUDIOAPI uint32_t FAudioVoice_DestroyVoiceSafeEXT(FAudioVoice *voice);
1072 /* FAudioSourceVoice Interface */
1074 /* Starts processing for a source voice.
1076 * Flags: Must be 0.
1077 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1079 * Returns 0 on success.
1081 FAUDIOAPI uint32_t FAudioSourceVoice_Start(
1082 FAudioSourceVoice *voice,
1083 uint32_t Flags,
1084 uint32_t OperationSet
1087 /* Pauses processing for a source voice. Yes, I said pausing.
1088 * If you want to _actually_ stop, call FlushSourceBuffers next.
1090 * Flags: Can be 0 or FAUDIO_PLAY_TAILS, which allows effects to
1091 * keep emitting output even after processing has stopped.
1092 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1094 * Returns 0 on success.
1096 FAUDIOAPI uint32_t FAudioSourceVoice_Stop(
1097 FAudioSourceVoice *voice,
1098 uint32_t Flags,
1099 uint32_t OperationSet
1102 /* Submits a block of wavedata for the source to process.
1104 * pBuffer: See FAudioBuffer for details.
1105 * pBufferWMA: See FAudioBufferWMA for details. (Also, don't use WMA.)
1107 * Returns 0 on success.
1109 FAUDIOAPI uint32_t FAudioSourceVoice_SubmitSourceBuffer(
1110 FAudioSourceVoice *voice,
1111 const FAudioBuffer *pBuffer,
1112 const FAudioBufferWMA *pBufferWMA
1115 /* Removes all buffers from a source, with a minor exception.
1116 * If the voice is still playing, the active buffer is left alone.
1117 * All buffers that are removed will spawn an OnBufferEnd callback.
1119 * Returns 0 on success.
1121 FAUDIOAPI uint32_t FAudioSourceVoice_FlushSourceBuffers(
1122 FAudioSourceVoice *voice
1125 /* Takes the last buffer currently queued and sets the END_OF_STREAM flag.
1127 * Returns 0 on success.
1129 FAUDIOAPI uint32_t FAudioSourceVoice_Discontinuity(
1130 FAudioSourceVoice *voice
1133 /* Sets the loop count of the active buffer to 0.
1135 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1137 * Returns 0 on success.
1139 FAUDIOAPI uint32_t FAudioSourceVoice_ExitLoop(
1140 FAudioSourceVoice *voice,
1141 uint32_t OperationSet
1144 /* Requests the state and some basic statistics for this source.
1146 * pVoiceState: See FAudioVoiceState for details.
1147 * Flags: Can be 0 or FAUDIO_VOICE_NOSAMPLESPLAYED.
1149 FAUDIOAPI void FAudioSourceVoice_GetState(
1150 FAudioSourceVoice *voice,
1151 FAudioVoiceState *pVoiceState,
1152 uint32_t Flags
1155 /* Sets the frequency ratio (fancy phrase for pitch) of this source.
1157 * Ratio: The frequency ratio, must be <= MaxFrequencyRatio.
1158 * OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1160 * Returns 0 on success.
1162 FAUDIOAPI uint32_t FAudioSourceVoice_SetFrequencyRatio(
1163 FAudioSourceVoice *voice,
1164 float Ratio,
1165 uint32_t OperationSet
1168 /* Requests the frequency ratio (fancy phrase for pitch) of this source.
1170 * pRatio: Filled with the frequency ratio.
1172 FAUDIOAPI void FAudioSourceVoice_GetFrequencyRatio(
1173 FAudioSourceVoice *voice,
1174 float *pRatio
1177 /* Resets the core sample rate of this source.
1178 * You probably don't want this, it's more likely you want SetFrequencyRatio.
1179 * This is used to recycle voices without having to constantly reallocate them.
1180 * For example, if you have wavedata that's all float32 mono, but the sample
1181 * rates are different, you can take a source that was being used for a 48KHz
1182 * wave and call this so it can be used for a 44.1KHz wave.
1184 * NewSourceSampleRate: The new sample rate for this source.
1186 * Returns 0 on success.
1188 FAUDIOAPI uint32_t FAudioSourceVoice_SetSourceSampleRate(
1189 FAudioSourceVoice *voice,
1190 uint32_t NewSourceSampleRate
1193 /* FAudioMasteringVoice Interface */
1195 /* Requests the channel mask for the mastering voice.
1196 * This is typically used with F3DAudioInitialize, but you may find it
1197 * interesting if you want to see the user's basic speaker layout.
1199 * pChannelMask: Filled with the channel mask.
1201 * Returns 0 on success.
1203 FAUDIOAPI uint32_t FAudioMasteringVoice_GetChannelMask(
1204 FAudioMasteringVoice *voice,
1205 uint32_t *pChannelMask
1208 /* FAudioEngineCallback Interface */
1210 /* If something horrible happens, this will be called.
1212 * Error: The error code that spawned this callback.
1214 typedef void (FAUDIOCALL * OnCriticalErrorFunc)(
1215 FAudioEngineCallback *callback,
1216 uint32_t Error
1219 /* This is called at the end of a processing update. */
1220 typedef void (FAUDIOCALL * OnProcessingPassEndFunc)(
1221 FAudioEngineCallback *callback
1224 /* This is called at the beginning of a processing update. */
1225 typedef void (FAUDIOCALL * OnProcessingPassStartFunc)(
1226 FAudioEngineCallback *callback
1229 struct FAudioEngineCallback
1231 OnCriticalErrorFunc OnCriticalError;
1232 OnProcessingPassEndFunc OnProcessingPassEnd;
1233 OnProcessingPassStartFunc OnProcessingPassStart;
1236 /* FAudioVoiceCallback Interface */
1238 /* When a buffer is no longer in use, this is called.
1240 * pBufferContext: The pContext for the FAudioBuffer in question.
1242 typedef void (FAUDIOCALL * OnBufferEndFunc)(
1243 FAudioVoiceCallback *callback,
1244 void *pBufferContext
1247 /* When a buffer is now being used, this is called.
1249 * pBufferContext: The pContext for the FAudioBuffer in question.
1251 typedef void (FAUDIOCALL * OnBufferStartFunc)(
1252 FAudioVoiceCallback *callback,
1253 void *pBufferContext
1256 /* When a buffer completes a loop, this is called.
1258 * pBufferContext: The pContext for the FAudioBuffer in question.
1260 typedef void (FAUDIOCALL * OnLoopEndFunc)(
1261 FAudioVoiceCallback *callback,
1262 void *pBufferContext
1265 /* When a buffer that has the END_OF_STREAM flag is finished, this is called. */
1266 typedef void (FAUDIOCALL * OnStreamEndFunc)(
1267 FAudioVoiceCallback *callback
1270 /* If something horrible happens to a voice, this is called.
1272 * pBufferContext: The pContext for the FAudioBuffer in question.
1273 * Error: The error code that spawned this callback.
1275 typedef void (FAUDIOCALL * OnVoiceErrorFunc)(
1276 FAudioVoiceCallback *callback,
1277 void *pBufferContext,
1278 uint32_t Error
1281 /* When this voice is done being processed, this is called. */
1282 typedef void (FAUDIOCALL * OnVoiceProcessingPassEndFunc)(
1283 FAudioVoiceCallback *callback
1286 /* When a voice is about to start being processed, this is called.
1288 * BytesRequested: The number of bytes needed from the application to
1289 * complete a full update. For example, if we need 512
1290 * frames for a whole update, and the voice is a float32
1291 * stereo source, BytesRequired will be 4096.
1293 typedef void (FAUDIOCALL * OnVoiceProcessingPassStartFunc)(
1294 FAudioVoiceCallback *callback,
1295 uint32_t BytesRequired
1298 struct FAudioVoiceCallback
1300 OnBufferEndFunc OnBufferEnd;
1301 OnBufferStartFunc OnBufferStart;
1302 OnLoopEndFunc OnLoopEnd;
1303 OnStreamEndFunc OnStreamEnd;
1304 OnVoiceErrorFunc OnVoiceError;
1305 OnVoiceProcessingPassEndFunc OnVoiceProcessingPassEnd;
1306 OnVoiceProcessingPassStartFunc OnVoiceProcessingPassStart;
1309 /* FAudio Custom Allocator API
1310 * See "extensions/CustomAllocatorEXT.txt" for more information.
1313 typedef void* (FAUDIOCALL * FAudioMallocFunc)(size_t size);
1314 typedef void (FAUDIOCALL * FAudioFreeFunc)(void* ptr);
1315 typedef void* (FAUDIOCALL * FAudioReallocFunc)(void* ptr, size_t size);
1317 FAUDIOAPI uint32_t FAudioCreateWithCustomAllocatorEXT(
1318 FAudio **ppFAudio,
1319 uint32_t Flags,
1320 FAudioProcessor XAudio2Processor,
1321 FAudioMallocFunc customMalloc,
1322 FAudioFreeFunc customFree,
1323 FAudioReallocFunc customRealloc
1325 FAUDIOAPI uint32_t FAudioCOMConstructWithCustomAllocatorEXT(
1326 FAudio **ppFAudio,
1327 uint8_t version,
1328 FAudioMallocFunc customMalloc,
1329 FAudioFreeFunc customFree,
1330 FAudioReallocFunc customRealloc
1333 /* FAudio Engine Procedure API
1334 * See "extensions/EngineProcedureEXT.txt" for more information.
1336 typedef void (FAUDIOCALL *FAudioEngineCallEXT)(FAudio *audio, float *output);
1337 typedef void (FAUDIOCALL *FAudioEngineProcedureEXT)(FAudioEngineCallEXT defaultEngineProc, FAudio *audio, float *output, void *user);
1339 FAUDIOAPI void FAudio_SetEngineProcedureEXT(
1340 FAudio *audio,
1341 FAudioEngineProcedureEXT clientEngineProc,
1342 void *user
1346 /* FAudio I/O API */
1348 #define FAUDIO_SEEK_SET 0
1349 #define FAUDIO_SEEK_CUR 1
1350 #define FAUDIO_SEEK_END 2
1351 #define FAUDIO_EOF -1
1353 typedef size_t (FAUDIOCALL * FAudio_readfunc)(
1354 void *data,
1355 void *dst,
1356 size_t size,
1357 size_t count
1359 typedef int64_t (FAUDIOCALL * FAudio_seekfunc)(
1360 void *data,
1361 int64_t offset,
1362 int whence
1364 typedef int (FAUDIOCALL * FAudio_closefunc)(
1365 void *data
1368 typedef struct FAudioIOStream
1370 void *data;
1371 FAudio_readfunc read;
1372 FAudio_seekfunc seek;
1373 FAudio_closefunc close;
1374 void *lock;
1375 } FAudioIOStream;
1377 FAUDIOAPI FAudioIOStream* FAudio_fopen(const char *path);
1378 FAUDIOAPI FAudioIOStream* FAudio_memopen(void *mem, int len);
1379 FAUDIOAPI uint8_t* FAudio_memptr(FAudioIOStream *io, size_t offset);
1380 FAUDIOAPI void FAudio_close(FAudioIOStream *io);
1382 #ifdef __cplusplus
1384 #endif /* __cplusplus */
1386 #endif /* FAUDIO_H */
1388 /* vim: set noexpandtab shiftwidth=8 tabstop=8: */