Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/faudio/include/FAudio.h
4389 views
1
/* FAudio - XAudio Reimplementation for FNA
2
*
3
* Copyright (c) 2011-2024 Ethan Lee, Luigi Auriemma, and the MonoGame Team
4
*
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.
8
*
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:
12
*
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.
17
*
18
* 2. Altered source versions must be plainly marked as such, and must not be
19
* misrepresented as being the original software.
20
*
21
* 3. This notice may not be removed or altered from any source distribution.
22
*
23
* Ethan "flibitijibibo" Lee <[email protected]>
24
*
25
*/
26
27
#ifndef FAUDIO_H
28
#define FAUDIO_H
29
30
#ifdef _WIN32
31
#define FAUDIOAPI
32
#define FAUDIOCALL
33
#else
34
#define FAUDIOAPI
35
#define FAUDIOCALL
36
#endif
37
38
#ifdef _MSC_VER
39
#define FAUDIODEPRECATED(msg) __declspec(deprecated(msg))
40
#else
41
#define FAUDIODEPRECATED(msg) __attribute__((deprecated(msg)))
42
#endif
43
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 */
52
53
#include <stdint.h>
54
#include <stddef.h>
55
56
#ifdef __cplusplus
57
extern "C" {
58
#endif /* __cplusplus */
59
60
/* Type Declarations */
61
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;
69
70
/* Enumerations */
71
72
typedef enum FAudioDeviceRole
73
{
74
FAudioNotDefaultDevice = 0x0,
75
FAudioDefaultConsoleDevice = 0x1,
76
FAudioDefaultMultimediaDevice = 0x2,
77
FAudioDefaultCommunicationsDevice = 0x4,
78
FAudioDefaultGameDevice = 0x8,
79
FAudioGlobalDefaultDevice = 0xF,
80
FAudioInvalidDeviceRole = ~FAudioGlobalDefaultDevice
81
} FAudioDeviceRole;
82
83
typedef enum FAudioFilterType
84
{
85
FAudioLowPassFilter,
86
FAudioBandPassFilter,
87
FAudioHighPassFilter,
88
FAudioNotchFilter
89
} FAudioFilterType;
90
91
typedef enum FAudioStreamCategory
92
{
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;
106
107
/* FIXME: The original enum violates ISO C and is platform specific anyway... */
108
typedef uint32_t FAudioProcessor;
109
#define FAUDIO_DEFAULT_PROCESSOR 0xFFFFFFFF
110
111
/* Structures */
112
113
#pragma pack(push, 1)
114
115
typedef struct FAudioGUID
116
{
117
uint32_t Data1;
118
uint16_t Data2;
119
uint16_t Data3;
120
uint8_t Data4[8];
121
} FAudioGUID;
122
123
/* See MSDN:
124
* https://msdn.microsoft.com/en-us/library/windows/desktop/dd390970%28v=vs.85%29.aspx
125
*/
126
typedef struct FAudioWaveFormatEx
127
{
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;
136
137
/* See MSDN:
138
* https://msdn.microsoft.com/en-us/library/windows/desktop/dd390971(v=vs.85).aspx
139
*/
140
typedef struct FAudioWaveFormatExtensible
141
{
142
FAudioWaveFormatEx Format;
143
union
144
{
145
uint16_t wValidBitsPerSample;
146
uint16_t wSamplesPerBlock;
147
uint16_t wReserved;
148
} Samples;
149
uint32_t dwChannelMask;
150
FAudioGUID SubFormat;
151
} FAudioWaveFormatExtensible;
152
153
typedef struct FAudioADPCMCoefSet
154
{
155
int16_t iCoef1;
156
int16_t iCoef2;
157
} FAudioADPCMCoefSet;
158
159
typedef struct FAudioADPCMWaveFormat
160
{
161
FAudioWaveFormatEx wfx;
162
uint16_t wSamplesPerBlock;
163
uint16_t wNumCoef;
164
165
/* MSVC warns on empty arrays in structs */
166
#ifdef _MSC_VER
167
#pragma warning(push)
168
#pragma warning(disable: 4200)
169
#endif
170
171
FAudioADPCMCoefSet aCoef[];
172
/* MSADPCM has 7 coefficient pairs:
173
* {
174
* { 256, 0 },
175
* { 512, -256 },
176
* { 0, 0 },
177
* { 192, 64 },
178
* { 240, 0 },
179
* { 460, -208 },
180
* { 392, -232 }
181
* }
182
*/
183
184
#ifdef _MSC_VER
185
#pragma warning(pop)
186
#endif
187
} FAudioADPCMWaveFormat;
188
189
typedef struct FAudioDeviceDetails
190
{
191
int16_t DeviceID[256]; /* Win32 wchar_t */
192
int16_t DisplayName[256]; /* Win32 wchar_t */
193
FAudioDeviceRole Role;
194
FAudioWaveFormatExtensible OutputFormat;
195
} FAudioDeviceDetails;
196
197
typedef struct FAudioVoiceDetails
198
{
199
uint32_t CreationFlags;
200
uint32_t ActiveFlags;
201
uint32_t InputChannels;
202
uint32_t InputSampleRate;
203
} FAudioVoiceDetails;
204
205
typedef struct FAudioSendDescriptor
206
{
207
uint32_t Flags; /* 0 or FAUDIO_SEND_USEFILTER */
208
FAudioVoice *pOutputVoice;
209
} FAudioSendDescriptor;
210
211
typedef struct FAudioVoiceSends
212
{
213
uint32_t SendCount;
214
FAudioSendDescriptor *pSends;
215
} FAudioVoiceSends;
216
217
#ifndef FAPO_DECL
218
#define FAPO_DECL
219
typedef struct FAPO FAPO;
220
#endif /* FAPO_DECL */
221
222
typedef struct FAudioEffectDescriptor
223
{
224
FAPO *pEffect;
225
int32_t InitialState; /* 1 - Enabled, 0 - Disabled */
226
uint32_t OutputChannels;
227
} FAudioEffectDescriptor;
228
229
typedef struct FAudioEffectChain
230
{
231
uint32_t EffectCount;
232
FAudioEffectDescriptor *pEffectDescriptors;
233
} FAudioEffectChain;
234
235
typedef struct FAudioFilterParameters
236
{
237
FAudioFilterType Type;
238
float Frequency; /* [0, FAUDIO_MAX_FILTER_FREQUENCY] */
239
float OneOverQ; /* [0, FAUDIO_MAX_FILTER_ONEOVERQ] */
240
} FAudioFilterParameters;
241
242
typedef struct FAudioFilterParametersEXT
243
{
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;
249
250
typedef struct FAudioBuffer
251
{
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.
258
*/
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.
269
*/
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;
277
278
typedef struct FAudioBufferWMA
279
{
280
const uint32_t *pDecodedPacketCumulativeBytes;
281
uint32_t PacketCount;
282
} FAudioBufferWMA;
283
284
typedef struct FAudioVoiceState
285
{
286
void *pCurrentBufferContext;
287
uint32_t BuffersQueued;
288
uint64_t SamplesPlayed;
289
} FAudioVoiceState;
290
291
typedef struct FAudioPerformanceData
292
{
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;
308
309
typedef struct FAudioDebugConfiguration
310
{
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;
320
321
#pragma pack(pop)
322
323
/* This ISN'T packed. Strictly speaking it wouldn't have mattered anyway but eh.
324
* See https://github.com/microsoft/DirectXTK/issues/256
325
*/
326
typedef struct FAudioXMA2WaveFormatEx
327
{
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;
341
342
/* Constants */
343
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
350
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
363
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
371
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
382
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
387
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
398
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
420
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
478
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
487
488
extern FAudioGUID DATAFORMAT_SUBTYPE_PCM;
489
extern FAudioGUID DATAFORMAT_SUBTYPE_IEEE_FLOAT;
490
491
/* FAudio Version API */
492
493
#define FAUDIO_TARGET_VERSION 8 /* Targeting compatibility with XAudio 2.8 */
494
495
#define FAUDIO_ABI_VERSION 0
496
#define FAUDIO_MAJOR_VERSION 25
497
#define FAUDIO_MINOR_VERSION 9
498
#define FAUDIO_PATCH_VERSION 0
499
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) \
505
)
506
507
FAUDIOAPI uint32_t FAudioLinkedVersion(void);
508
509
/* FAudio Interface */
510
511
/* This should be your first FAudio call.
512
*
513
* ppFAudio: Filled with the FAudio core context.
514
* Flags: Can be 0 or a combination of FAUDIO_DEBUG_ENGINE and FAUDIO_1024_QUANTUM.
515
* XAudio2Processor: Set this to FAUDIO_DEFAULT_PROCESSOR.
516
*
517
* Returns 0 on success.
518
*/
519
FAUDIOAPI uint32_t FAudioCreate(
520
FAudio **ppFAudio,
521
uint32_t Flags,
522
FAudioProcessor XAudio2Processor
523
);
524
525
/* See "extensions/COMConstructEXT.txt" for more details */
526
FAUDIOAPI uint32_t FAudioCOMConstructEXT(FAudio **ppFAudio, uint8_t version);
527
528
/* Increments a reference counter. When counter is 0, audio is freed.
529
* Returns the reference count after incrementing.
530
*/
531
FAUDIOAPI uint32_t FAudio_AddRef(FAudio *audio);
532
533
/* Decrements a reference counter. When counter is 0, audio is freed.
534
* Returns the reference count after decrementing.
535
*/
536
FAUDIOAPI uint32_t FAudio_Release(FAudio *audio);
537
538
/* Queries the number of sound devices available for use.
539
*
540
* pCount: Filled with the number of available sound devices.
541
*
542
* Returns 0 on success.
543
*/
544
FAUDIOAPI uint32_t FAudio_GetDeviceCount(FAudio *audio, uint32_t *pCount);
545
546
/* Gets basic information about a sound device.
547
*
548
* Index: Can be between 0 and the result of GetDeviceCount.
549
* pDeviceDetails: Filled with the device information.
550
*
551
* Returns 0 on success.
552
*/
553
FAUDIOAPI uint32_t FAudio_GetDeviceDetails(
554
FAudio *audio,
555
uint32_t Index,
556
FAudioDeviceDetails *pDeviceDetails
557
);
558
559
/* You don't actually have to call this, unless you're using the COM APIs.
560
* See the FAudioCreate API for parameter information.
561
*/
562
FAUDIOAPI uint32_t FAudio_Initialize(
563
FAudio *audio,
564
uint32_t Flags,
565
FAudioProcessor XAudio2Processor
566
);
567
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.
571
*
572
* pCallback: The completely-initialized FAudioEngineCallback structure.
573
*
574
* Returns 0 on success.
575
*/
576
FAUDIOAPI uint32_t FAudio_RegisterForCallbacks(
577
FAudio *audio,
578
FAudioEngineCallback *pCallback
579
);
580
581
/* Remove an active set of engine callbacks.
582
* This checks the pointer value, NOT the callback values!
583
*
584
* pCallback: An FAudioEngineCallback structure previously sent to Register.
585
*
586
* Returns 0 on success.
587
*/
588
FAUDIOAPI void FAudio_UnregisterForCallbacks(
589
FAudio *audio,
590
FAudioEngineCallback *pCallback
591
);
592
593
/* Creates a "source" voice, used to play back wavedata.
594
*
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.
614
*
615
* Returns 0 on success.
616
*/
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
626
);
627
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.
631
*
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.
643
*
644
* Returns 0 on success.
645
*/
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
655
);
656
657
/* This should be your second FAudio call, unless you care about which device
658
* you want to use. In that case, see GetDeviceDetails.
659
*
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.
666
*
667
* Returns 0 on success.
668
*/
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
677
);
678
679
/* This is the XAudio 2.8+ version of CreateMasteringVoice.
680
* Right now this doesn't do anything. Don't use this function.
681
*/
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
691
);
692
693
/* Starts the engine, begins processing the audio graph.
694
* Returns 0 on success.
695
*/
696
FAUDIOAPI uint32_t FAudio_StartEngine(FAudio *audio);
697
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.
702
*/
703
FAUDIOAPI void FAudio_StopEngine(FAudio *audio);
704
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.
711
*
712
* OperationSet: Either a value known by you or FAUDIO_COMMIT_ALL
713
*
714
* Returns 0 on success.
715
*/
716
FAUDIOAPI uint32_t FAudio_CommitOperationSet(
717
FAudio *audio,
718
uint32_t OperationSet
719
);
720
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);
724
725
/* Requests various bits of performance information from the engine.
726
*
727
* pPerfData: Filled with the data. See FAudioPerformanceData for details.
728
*/
729
FAUDIOAPI void FAudio_GetPerformanceData(
730
FAudio *audio,
731
FAudioPerformanceData *pPerfData
732
);
733
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.
736
*
737
* pDebugConfiguration: See FAudioDebugConfiguration for details.
738
* pReserved: Set this to NULL.
739
*/
740
FAUDIOAPI void FAudio_SetDebugConfiguration(
741
FAudio *audio,
742
FAudioDebugConfiguration *pDebugConfiguration,
743
void* pReserved
744
);
745
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.
750
*
751
* quantumNumerator - The engine's update size, in sample frames.
752
* quantumDenominator - The engine's sample rate, in Hz
753
*/
754
FAUDIOAPI void FAudio_GetProcessingQuantum(
755
FAudio *audio,
756
uint32_t *quantumNumerator,
757
uint32_t *quantumDenominator
758
);
759
760
/* FAudioVoice Interface */
761
762
/* Requests basic information about a voice.
763
*
764
* pVoiceDetails: See FAudioVoiceDetails for details.
765
*/
766
FAUDIOAPI void FAudioVoice_GetVoiceDetails(
767
FAudioVoice *voice,
768
FAudioVoiceDetails *pVoiceDetails
769
);
770
771
/* Change the output voices for this voice.
772
* This function is invalid for mastering voices.
773
*
774
* pSendList: List of output voices. If NULL, defaults to master.
775
* All output voices must have the same sample rate!
776
*
777
* Returns 0 on success.
778
*/
779
FAUDIOAPI uint32_t FAudioVoice_SetOutputVoices(
780
FAudioVoice *voice,
781
const FAudioVoiceSends *pSendList
782
);
783
784
/* Change/Remove the effect chain for this voice.
785
*
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!
790
*
791
* Returns 0 on success.
792
*/
793
FAUDIOAPI uint32_t FAudioVoice_SetEffectChain(
794
FAudioVoice *voice,
795
const FAudioEffectChain *pEffectChain
796
);
797
798
/* Enables an effect in the effect chain.
799
*
800
* EffectIndex: The index of the effect (based on the chain order).
801
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
802
*
803
* Returns 0 on success.
804
*/
805
FAUDIOAPI uint32_t FAudioVoice_EnableEffect(
806
FAudioVoice *voice,
807
uint32_t EffectIndex,
808
uint32_t OperationSet
809
);
810
811
/* Disables an effect in the effect chain.
812
*
813
* EffectIndex: The index of the effect (based on the chain order).
814
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
815
*
816
* Returns 0 on success.
817
*/
818
FAUDIOAPI uint32_t FAudioVoice_DisableEffect(
819
FAudioVoice *voice,
820
uint32_t EffectIndex,
821
uint32_t OperationSet
822
);
823
824
/* Queries the enabled/disabled state of an effect in the effect chain.
825
*
826
* EffectIndex: The index of the effect (based on the chain order).
827
* pEnabled: Filled with either 1 (Enabled) or 0 (Disabled).
828
*
829
* Returns 0 on success.
830
*/
831
FAUDIOAPI void FAudioVoice_GetEffectState(
832
FAudioVoice *voice,
833
uint32_t EffectIndex,
834
int32_t *pEnabled
835
);
836
837
/* Submits a block of memory to be sent to FAPO::SetParameters.
838
*
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.
843
*
844
* Returns 0 on success.
845
*/
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
852
);
853
854
/* Requests the latest parameters from FAPO::GetParameters.
855
*
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!
859
*
860
* Returns 0 on success.
861
*/
862
FAUDIOAPI uint32_t FAudioVoice_GetEffectParameters(
863
FAudioVoice *voice,
864
uint32_t EffectIndex,
865
void *pParameters,
866
uint32_t ParametersByteSize
867
);
868
869
/* Sets the filter variables for a voice.
870
* This is only valid on voices with the USEFILTER flag.
871
*
872
* pParameters: See FAudioFilterParameters for details.
873
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
874
*
875
* Returns 0 on success.
876
*/
877
FAUDIOAPI uint32_t FAudioVoice_SetFilterParameters(
878
FAudioVoice *voice,
879
const FAudioFilterParameters *pParameters,
880
uint32_t OperationSet
881
);
882
883
/* Requests the filter variables for a voice.
884
* This is only valid on voices with the USEFILTER flag.
885
*
886
* pParameters: See FAudioFilterParameters for details.
887
*/
888
FAUDIOAPI void FAudioVoice_GetFilterParameters(
889
FAudioVoice *voice,
890
FAudioFilterParameters *pParameters
891
);
892
893
/* Sets the filter variables for a voice's output voice.
894
* This is only valid on sends with the USEFILTER flag.
895
*
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.
899
*
900
* Returns 0 on success.
901
*/
902
FAUDIOAPI uint32_t FAudioVoice_SetOutputFilterParameters(
903
FAudioVoice *voice,
904
FAudioVoice *pDestinationVoice,
905
const FAudioFilterParameters *pParameters,
906
uint32_t OperationSet
907
);
908
909
/* Requests the filter variables for a voice's output voice.
910
* This is only valid on sends with the USEFILTER flag.
911
*
912
* pDestinationVoice: An output voice from the voice's send list.
913
* pParameters: See FAudioFilterParameters for details.
914
*/
915
FAUDIOAPI void FAudioVoice_GetOutputFilterParameters(
916
FAudioVoice *voice,
917
FAudioVoice *pDestinationVoice,
918
FAudioFilterParameters *pParameters
919
);
920
921
/* Sets the filter variables for a voice.
922
* This is only valid on voices with the USEFILTER flag.
923
*
924
* pParameters: See FAudioFilterParametersEXT for details.
925
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
926
*
927
* Returns 0 on success.
928
*/
929
FAUDIOAPI uint32_t FAudioVoice_SetFilterParametersEXT(
930
FAudioVoice* voice,
931
const FAudioFilterParametersEXT* pParameters,
932
uint32_t OperationSet
933
);
934
935
/* Requests the filter variables for a voice.
936
* This is only valid on voices with the USEFILTER flag.
937
*
938
* pParameters: See FAudioFilterParametersEXT for details.
939
*/
940
FAUDIOAPI void FAudioVoice_GetFilterParametersEXT(
941
FAudioVoice* voice,
942
FAudioFilterParametersEXT* pParameters
943
);
944
945
/* Sets the filter variables for a voice's output voice.
946
* This is only valid on sends with the USEFILTER flag.
947
*
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.
951
*
952
* Returns 0 on success.
953
*/
954
FAUDIOAPI uint32_t FAudioVoice_SetOutputFilterParametersEXT(
955
FAudioVoice* voice,
956
FAudioVoice* pDestinationVoice,
957
const FAudioFilterParametersEXT* pParameters,
958
uint32_t OperationSet
959
);
960
961
/* Requests the filter variables for a voice's output voice.
962
* This is only valid on sends with the USEFILTER flag.
963
*
964
* pDestinationVoice: An output voice from the voice's send list.
965
* pParameters: See FAudioFilterParametersEXT for details.
966
*/
967
FAUDIOAPI void FAudioVoice_GetOutputFilterParametersEXT(
968
FAudioVoice* voice,
969
FAudioVoice* pDestinationVoice,
970
FAudioFilterParametersEXT* pParameters
971
);
972
973
/* Sets the global volume of a voice.
974
*
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.
979
*
980
* Returns 0 on success.
981
*/
982
FAUDIOAPI uint32_t FAudioVoice_SetVolume(
983
FAudioVoice *voice,
984
float Volume,
985
uint32_t OperationSet
986
);
987
988
/* Requests the global volume of a voice.
989
*
990
* pVolume: Filled with the current voice amplitude ratio.
991
*/
992
FAUDIOAPI void FAudioVoice_GetVolume(
993
FAudioVoice *voice,
994
float *pVolume
995
);
996
997
/* Sets the per-channel volumes of a voice.
998
*
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.
1002
*
1003
* Returns 0 on success.
1004
*/
1005
FAUDIOAPI uint32_t FAudioVoice_SetChannelVolumes(
1006
FAudioVoice *voice,
1007
uint32_t Channels,
1008
const float *pVolumes,
1009
uint32_t OperationSet
1010
);
1011
1012
/* Requests the per-channel volumes of a voice.
1013
*
1014
* Channels: Must match the channel count of this voice!
1015
* pVolumes: Filled with the current channel amplitude ratios.
1016
*/
1017
FAUDIOAPI void FAudioVoice_GetChannelVolumes(
1018
FAudioVoice *voice,
1019
uint32_t Channels,
1020
float *pVolumes
1021
);
1022
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).
1031
*
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.
1037
*
1038
* Returns 0 on success.
1039
*/
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
1047
);
1048
1049
/* Gets the volumes of a send's output channels. See SetOutputMatrix.
1050
*
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].
1055
*/
1056
FAUDIOAPI void FAudioVoice_GetOutputMatrix(
1057
FAudioVoice *voice,
1058
FAudioVoice *pDestinationVoice,
1059
uint32_t SourceChannels,
1060
uint32_t DestinationChannels,
1061
float *pLevelMatrix
1062
);
1063
1064
/* Removes this voice from the audio graph and frees memory. */
1065
FAUDIOAPI void FAudioVoice_DestroyVoice(FAudioVoice *voice);
1066
1067
/*
1068
* Returns S_OK on success and E_FAIL if voice could not be destroyed (e. g., because it is in use).
1069
*/
1070
FAUDIOAPI uint32_t FAudioVoice_DestroyVoiceSafeEXT(FAudioVoice *voice);
1071
1072
/* FAudioSourceVoice Interface */
1073
1074
/* Starts processing for a source voice.
1075
*
1076
* Flags: Must be 0.
1077
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1078
*
1079
* Returns 0 on success.
1080
*/
1081
FAUDIOAPI uint32_t FAudioSourceVoice_Start(
1082
FAudioSourceVoice *voice,
1083
uint32_t Flags,
1084
uint32_t OperationSet
1085
);
1086
1087
/* Pauses processing for a source voice. Yes, I said pausing.
1088
* If you want to _actually_ stop, call FlushSourceBuffers next.
1089
*
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.
1093
*
1094
* Returns 0 on success.
1095
*/
1096
FAUDIOAPI uint32_t FAudioSourceVoice_Stop(
1097
FAudioSourceVoice *voice,
1098
uint32_t Flags,
1099
uint32_t OperationSet
1100
);
1101
1102
/* Submits a block of wavedata for the source to process.
1103
*
1104
* pBuffer: See FAudioBuffer for details.
1105
* pBufferWMA: See FAudioBufferWMA for details. (Also, don't use WMA.)
1106
*
1107
* Returns 0 on success.
1108
*/
1109
FAUDIOAPI uint32_t FAudioSourceVoice_SubmitSourceBuffer(
1110
FAudioSourceVoice *voice,
1111
const FAudioBuffer *pBuffer,
1112
const FAudioBufferWMA *pBufferWMA
1113
);
1114
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.
1118
*
1119
* Returns 0 on success.
1120
*/
1121
FAUDIOAPI uint32_t FAudioSourceVoice_FlushSourceBuffers(
1122
FAudioSourceVoice *voice
1123
);
1124
1125
/* Takes the last buffer currently queued and sets the END_OF_STREAM flag.
1126
*
1127
* Returns 0 on success.
1128
*/
1129
FAUDIOAPI uint32_t FAudioSourceVoice_Discontinuity(
1130
FAudioSourceVoice *voice
1131
);
1132
1133
/* Sets the loop count of the active buffer to 0.
1134
*
1135
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1136
*
1137
* Returns 0 on success.
1138
*/
1139
FAUDIOAPI uint32_t FAudioSourceVoice_ExitLoop(
1140
FAudioSourceVoice *voice,
1141
uint32_t OperationSet
1142
);
1143
1144
/* Requests the state and some basic statistics for this source.
1145
*
1146
* pVoiceState: See FAudioVoiceState for details.
1147
* Flags: Can be 0 or FAUDIO_VOICE_NOSAMPLESPLAYED.
1148
*/
1149
FAUDIOAPI void FAudioSourceVoice_GetState(
1150
FAudioSourceVoice *voice,
1151
FAudioVoiceState *pVoiceState,
1152
uint32_t Flags
1153
);
1154
1155
/* Sets the frequency ratio (fancy phrase for pitch) of this source.
1156
*
1157
* Ratio: The frequency ratio, must be <= MaxFrequencyRatio.
1158
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1159
*
1160
* Returns 0 on success.
1161
*/
1162
FAUDIOAPI uint32_t FAudioSourceVoice_SetFrequencyRatio(
1163
FAudioSourceVoice *voice,
1164
float Ratio,
1165
uint32_t OperationSet
1166
);
1167
1168
/* Requests the frequency ratio (fancy phrase for pitch) of this source.
1169
*
1170
* pRatio: Filled with the frequency ratio.
1171
*/
1172
FAUDIOAPI void FAudioSourceVoice_GetFrequencyRatio(
1173
FAudioSourceVoice *voice,
1174
float *pRatio
1175
);
1176
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.
1183
*
1184
* NewSourceSampleRate: The new sample rate for this source.
1185
*
1186
* Returns 0 on success.
1187
*/
1188
FAUDIOAPI uint32_t FAudioSourceVoice_SetSourceSampleRate(
1189
FAudioSourceVoice *voice,
1190
uint32_t NewSourceSampleRate
1191
);
1192
1193
/* FAudioMasteringVoice Interface */
1194
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.
1198
*
1199
* pChannelMask: Filled with the channel mask.
1200
*
1201
* Returns 0 on success.
1202
*/
1203
FAUDIOAPI uint32_t FAudioMasteringVoice_GetChannelMask(
1204
FAudioMasteringVoice *voice,
1205
uint32_t *pChannelMask
1206
);
1207
1208
/* FAudioEngineCallback Interface */
1209
1210
/* If something horrible happens, this will be called.
1211
*
1212
* Error: The error code that spawned this callback.
1213
*/
1214
typedef void (FAUDIOCALL * OnCriticalErrorFunc)(
1215
FAudioEngineCallback *callback,
1216
uint32_t Error
1217
);
1218
1219
/* This is called at the end of a processing update. */
1220
typedef void (FAUDIOCALL * OnProcessingPassEndFunc)(
1221
FAudioEngineCallback *callback
1222
);
1223
1224
/* This is called at the beginning of a processing update. */
1225
typedef void (FAUDIOCALL * OnProcessingPassStartFunc)(
1226
FAudioEngineCallback *callback
1227
);
1228
1229
struct FAudioEngineCallback
1230
{
1231
OnCriticalErrorFunc OnCriticalError;
1232
OnProcessingPassEndFunc OnProcessingPassEnd;
1233
OnProcessingPassStartFunc OnProcessingPassStart;
1234
};
1235
1236
/* FAudioVoiceCallback Interface */
1237
1238
/* When a buffer is no longer in use, this is called.
1239
*
1240
* pBufferContext: The pContext for the FAudioBuffer in question.
1241
*/
1242
typedef void (FAUDIOCALL * OnBufferEndFunc)(
1243
FAudioVoiceCallback *callback,
1244
void *pBufferContext
1245
);
1246
1247
/* When a buffer is now being used, this is called.
1248
*
1249
* pBufferContext: The pContext for the FAudioBuffer in question.
1250
*/
1251
typedef void (FAUDIOCALL * OnBufferStartFunc)(
1252
FAudioVoiceCallback *callback,
1253
void *pBufferContext
1254
);
1255
1256
/* When a buffer completes a loop, this is called.
1257
*
1258
* pBufferContext: The pContext for the FAudioBuffer in question.
1259
*/
1260
typedef void (FAUDIOCALL * OnLoopEndFunc)(
1261
FAudioVoiceCallback *callback,
1262
void *pBufferContext
1263
);
1264
1265
/* When a buffer that has the END_OF_STREAM flag is finished, this is called. */
1266
typedef void (FAUDIOCALL * OnStreamEndFunc)(
1267
FAudioVoiceCallback *callback
1268
);
1269
1270
/* If something horrible happens to a voice, this is called.
1271
*
1272
* pBufferContext: The pContext for the FAudioBuffer in question.
1273
* Error: The error code that spawned this callback.
1274
*/
1275
typedef void (FAUDIOCALL * OnVoiceErrorFunc)(
1276
FAudioVoiceCallback *callback,
1277
void *pBufferContext,
1278
uint32_t Error
1279
);
1280
1281
/* When this voice is done being processed, this is called. */
1282
typedef void (FAUDIOCALL * OnVoiceProcessingPassEndFunc)(
1283
FAudioVoiceCallback *callback
1284
);
1285
1286
/* When a voice is about to start being processed, this is called.
1287
*
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.
1292
*/
1293
typedef void (FAUDIOCALL * OnVoiceProcessingPassStartFunc)(
1294
FAudioVoiceCallback *callback,
1295
uint32_t BytesRequired
1296
);
1297
1298
struct FAudioVoiceCallback
1299
{
1300
OnBufferEndFunc OnBufferEnd;
1301
OnBufferStartFunc OnBufferStart;
1302
OnLoopEndFunc OnLoopEnd;
1303
OnStreamEndFunc OnStreamEnd;
1304
OnVoiceErrorFunc OnVoiceError;
1305
OnVoiceProcessingPassEndFunc OnVoiceProcessingPassEnd;
1306
OnVoiceProcessingPassStartFunc OnVoiceProcessingPassStart;
1307
};
1308
1309
/* FAudio Custom Allocator API
1310
* See "extensions/CustomAllocatorEXT.txt" for more information.
1311
*/
1312
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);
1316
1317
FAUDIOAPI uint32_t FAudioCreateWithCustomAllocatorEXT(
1318
FAudio **ppFAudio,
1319
uint32_t Flags,
1320
FAudioProcessor XAudio2Processor,
1321
FAudioMallocFunc customMalloc,
1322
FAudioFreeFunc customFree,
1323
FAudioReallocFunc customRealloc
1324
);
1325
FAUDIOAPI uint32_t FAudioCOMConstructWithCustomAllocatorEXT(
1326
FAudio **ppFAudio,
1327
uint8_t version,
1328
FAudioMallocFunc customMalloc,
1329
FAudioFreeFunc customFree,
1330
FAudioReallocFunc customRealloc
1331
);
1332
1333
/* FAudio Engine Procedure API
1334
* See "extensions/EngineProcedureEXT.txt" for more information.
1335
*/
1336
typedef void (FAUDIOCALL *FAudioEngineCallEXT)(FAudio *audio, float *output);
1337
typedef void (FAUDIOCALL *FAudioEngineProcedureEXT)(FAudioEngineCallEXT defaultEngineProc, FAudio *audio, float *output, void *user);
1338
1339
FAUDIOAPI void FAudio_SetEngineProcedureEXT(
1340
FAudio *audio,
1341
FAudioEngineProcedureEXT clientEngineProc,
1342
void *user
1343
);
1344
1345
1346
/* FAudio I/O API */
1347
1348
#define FAUDIO_SEEK_SET 0
1349
#define FAUDIO_SEEK_CUR 1
1350
#define FAUDIO_SEEK_END 2
1351
#define FAUDIO_EOF -1
1352
1353
typedef size_t (FAUDIOCALL * FAudio_readfunc)(
1354
void *data,
1355
void *dst,
1356
size_t size,
1357
size_t count
1358
);
1359
typedef int64_t (FAUDIOCALL * FAudio_seekfunc)(
1360
void *data,
1361
int64_t offset,
1362
int whence
1363
);
1364
typedef int (FAUDIOCALL * FAudio_closefunc)(
1365
void *data
1366
);
1367
1368
typedef struct FAudioIOStream
1369
{
1370
void *data;
1371
FAudio_readfunc read;
1372
FAudio_seekfunc seek;
1373
FAudio_closefunc close;
1374
void *lock;
1375
} FAudioIOStream;
1376
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);
1381
1382
#ifdef __cplusplus
1383
}
1384
#endif /* __cplusplus */
1385
1386
#endif /* FAUDIO_H */
1387
1388
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
1389
1390