Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/faudio/include/FAudio.h
8665 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_OK 0x0
345
#define FAUDIO_E_FAIL 0x80004005
346
#define FAUDIO_E_OUT_OF_MEMORY 0x8007000e
347
#define FAUDIO_E_INVALID_ARG 0x80070057
348
#define FAUDIO_E_UNSUPPORTED_FORMAT 0x88890008
349
#define FAUDIO_E_INVALID_CALL 0x88960001
350
#define FAUDIO_E_DEVICE_INVALIDATED 0x88960004
351
#define FAPO_E_FORMAT_UNSUPPORTED 0x88970001
352
353
#define FAUDIO_MAX_BUFFER_BYTES 0x80000000
354
#define FAUDIO_MAX_QUEUED_BUFFERS 64
355
#define FAUDIO_MAX_AUDIO_CHANNELS 64
356
#define FAUDIO_MIN_SAMPLE_RATE 1000
357
#define FAUDIO_MAX_SAMPLE_RATE 200000
358
#define FAUDIO_MAX_VOLUME_LEVEL 16777216.0f
359
#define FAUDIO_MIN_FREQ_RATIO (1.0f / 1024.0f)
360
#define FAUDIO_MAX_FREQ_RATIO 1024.0f
361
#define FAUDIO_DEFAULT_FREQ_RATIO 2.0f
362
#define FAUDIO_MAX_FILTER_ONEOVERQ 1.5f
363
#define FAUDIO_MAX_FILTER_FREQUENCY 1.0f
364
#define FAUDIO_MAX_LOOP_COUNT 254
365
366
#define FAUDIO_COMMIT_NOW 0
367
#define FAUDIO_COMMIT_ALL 0
368
#define FAUDIO_INVALID_OPSET (uint32_t) (-1)
369
#define FAUDIO_NO_LOOP_REGION 0
370
#define FAUDIO_LOOP_INFINITE 255
371
#define FAUDIO_DEFAULT_CHANNELS 0
372
#define FAUDIO_DEFAULT_SAMPLERATE 0
373
374
#define FAUDIO_DEBUG_ENGINE 0x0001
375
#define FAUDIO_VOICE_NOPITCH 0x0002
376
#define FAUDIO_VOICE_NOSRC 0x0004
377
#define FAUDIO_VOICE_USEFILTER 0x0008
378
#define FAUDIO_VOICE_MUSIC 0x0010
379
#define FAUDIO_PLAY_TAILS 0x0020
380
#define FAUDIO_END_OF_STREAM 0x0040
381
#define FAUDIO_SEND_USEFILTER 0x0080
382
#define FAUDIO_VOICE_NOSAMPLESPLAYED 0x0100
383
#define FAUDIO_1024_QUANTUM 0x8000
384
385
#define FAUDIO_DEFAULT_FILTER_TYPE FAudioLowPassFilter
386
#define FAUDIO_DEFAULT_FILTER_FREQUENCY FAUDIO_MAX_FILTER_FREQUENCY
387
#define FAUDIO_DEFAULT_FILTER_ONEOVERQ 1.0f
388
#define FAUDIO_DEFAULT_FILTER_WETDRYMIX_EXT 1.0f
389
390
#define FAUDIO_LOG_ERRORS 0x0001
391
#define FAUDIO_LOG_WARNINGS 0x0002
392
#define FAUDIO_LOG_INFO 0x0004
393
#define FAUDIO_LOG_DETAIL 0x0008
394
#define FAUDIO_LOG_API_CALLS 0x0010
395
#define FAUDIO_LOG_FUNC_CALLS 0x0020
396
#define FAUDIO_LOG_TIMING 0x0040
397
#define FAUDIO_LOG_LOCKS 0x0080
398
#define FAUDIO_LOG_MEMORY 0x0100
399
#define FAUDIO_LOG_STREAMING 0x1000
400
401
#ifndef _SPEAKER_POSITIONS_
402
#define SPEAKER_FRONT_LEFT 0x00000001
403
#define SPEAKER_FRONT_RIGHT 0x00000002
404
#define SPEAKER_FRONT_CENTER 0x00000004
405
#define SPEAKER_LOW_FREQUENCY 0x00000008
406
#define SPEAKER_BACK_LEFT 0x00000010
407
#define SPEAKER_BACK_RIGHT 0x00000020
408
#define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040
409
#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080
410
#define SPEAKER_BACK_CENTER 0x00000100
411
#define SPEAKER_SIDE_LEFT 0x00000200
412
#define SPEAKER_SIDE_RIGHT 0x00000400
413
#define SPEAKER_TOP_CENTER 0x00000800
414
#define SPEAKER_TOP_FRONT_LEFT 0x00001000
415
#define SPEAKER_TOP_FRONT_CENTER 0x00002000
416
#define SPEAKER_TOP_FRONT_RIGHT 0x00004000
417
#define SPEAKER_TOP_BACK_LEFT 0x00008000
418
#define SPEAKER_TOP_BACK_CENTER 0x00010000
419
#define SPEAKER_TOP_BACK_RIGHT 0x00020000
420
#define _SPEAKER_POSITIONS_
421
#endif
422
423
#ifndef SPEAKER_MONO
424
#define SPEAKER_MONO SPEAKER_FRONT_CENTER
425
#define SPEAKER_STEREO (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT)
426
#define SPEAKER_2POINT1 \
427
( SPEAKER_FRONT_LEFT | \
428
SPEAKER_FRONT_RIGHT | \
429
SPEAKER_LOW_FREQUENCY )
430
#define SPEAKER_SURROUND \
431
( SPEAKER_FRONT_LEFT | \
432
SPEAKER_FRONT_RIGHT | \
433
SPEAKER_FRONT_CENTER | \
434
SPEAKER_BACK_CENTER )
435
#define SPEAKER_QUAD \
436
( SPEAKER_FRONT_LEFT | \
437
SPEAKER_FRONT_RIGHT | \
438
SPEAKER_BACK_LEFT | \
439
SPEAKER_BACK_RIGHT )
440
#define SPEAKER_4POINT1 \
441
( SPEAKER_FRONT_LEFT | \
442
SPEAKER_FRONT_RIGHT | \
443
SPEAKER_LOW_FREQUENCY | \
444
SPEAKER_BACK_LEFT | \
445
SPEAKER_BACK_RIGHT )
446
#define SPEAKER_5POINT1 \
447
( SPEAKER_FRONT_LEFT | \
448
SPEAKER_FRONT_RIGHT | \
449
SPEAKER_FRONT_CENTER | \
450
SPEAKER_LOW_FREQUENCY | \
451
SPEAKER_BACK_LEFT | \
452
SPEAKER_BACK_RIGHT )
453
#define SPEAKER_7POINT1 \
454
( SPEAKER_FRONT_LEFT | \
455
SPEAKER_FRONT_RIGHT | \
456
SPEAKER_FRONT_CENTER | \
457
SPEAKER_LOW_FREQUENCY | \
458
SPEAKER_BACK_LEFT | \
459
SPEAKER_BACK_RIGHT | \
460
SPEAKER_FRONT_LEFT_OF_CENTER | \
461
SPEAKER_FRONT_RIGHT_OF_CENTER )
462
#define SPEAKER_5POINT1_SURROUND \
463
( SPEAKER_FRONT_LEFT | \
464
SPEAKER_FRONT_RIGHT | \
465
SPEAKER_FRONT_CENTER | \
466
SPEAKER_LOW_FREQUENCY | \
467
SPEAKER_SIDE_LEFT | \
468
SPEAKER_SIDE_RIGHT )
469
#define SPEAKER_7POINT1_SURROUND \
470
( SPEAKER_FRONT_LEFT | \
471
SPEAKER_FRONT_RIGHT | \
472
SPEAKER_FRONT_CENTER | \
473
SPEAKER_LOW_FREQUENCY | \
474
SPEAKER_BACK_LEFT | \
475
SPEAKER_BACK_RIGHT | \
476
SPEAKER_SIDE_LEFT | \
477
SPEAKER_SIDE_RIGHT )
478
#define SPEAKER_XBOX SPEAKER_5POINT1
479
#endif
480
481
#define FAUDIO_FORMAT_PCM 1
482
#define FAUDIO_FORMAT_MSADPCM 2
483
#define FAUDIO_FORMAT_IEEE_FLOAT 3
484
#define FAUDIO_FORMAT_WMAUDIO2 0x0161
485
#define FAUDIO_FORMAT_WMAUDIO3 0x0162
486
#define FAUDIO_FORMAT_WMAUDIO_LOSSLESS 0x0163
487
#define FAUDIO_FORMAT_XMAUDIO2 0x0166
488
#define FAUDIO_FORMAT_EXTENSIBLE 0xFFFE
489
490
extern FAudioGUID DATAFORMAT_SUBTYPE_PCM;
491
extern FAudioGUID DATAFORMAT_SUBTYPE_IEEE_FLOAT;
492
493
/* FAudio Version API */
494
495
#define FAUDIO_TARGET_VERSION 8 /* Targeting compatibility with XAudio 2.8 */
496
497
#define FAUDIO_ABI_VERSION 0
498
#define FAUDIO_MAJOR_VERSION 26
499
#define FAUDIO_MINOR_VERSION 2
500
#define FAUDIO_PATCH_VERSION 0
501
502
#define FAUDIO_COMPILED_VERSION ( \
503
(FAUDIO_ABI_VERSION * 100 * 100 * 100) + \
504
(FAUDIO_MAJOR_VERSION * 100 * 100) + \
505
(FAUDIO_MINOR_VERSION * 100) + \
506
(FAUDIO_PATCH_VERSION) \
507
)
508
509
FAUDIOAPI uint32_t FAudioLinkedVersion(void);
510
511
/* FAudio Interface */
512
513
/* This should be your first FAudio call.
514
*
515
* ppFAudio: Filled with the FAudio core context.
516
* Flags: Can be 0 or a combination of FAUDIO_DEBUG_ENGINE and FAUDIO_1024_QUANTUM.
517
* XAudio2Processor: Set this to FAUDIO_DEFAULT_PROCESSOR.
518
*
519
* Returns 0 on success.
520
*/
521
FAUDIOAPI uint32_t FAudioCreate(
522
FAudio **ppFAudio,
523
uint32_t Flags,
524
FAudioProcessor XAudio2Processor
525
);
526
527
/* See "extensions/COMConstructEXT.txt" for more details */
528
FAUDIOAPI uint32_t FAudioCOMConstructEXT(FAudio **ppFAudio, uint8_t version);
529
530
/* Increments a reference counter. When counter is 0, audio is freed.
531
* Returns the reference count after incrementing.
532
*/
533
FAUDIOAPI uint32_t FAudio_AddRef(FAudio *audio);
534
535
/* Decrements a reference counter. When counter is 0, audio is freed.
536
* Returns the reference count after decrementing.
537
*/
538
FAUDIOAPI uint32_t FAudio_Release(FAudio *audio);
539
540
/* Queries the number of sound devices available for use.
541
*
542
* pCount: Filled with the number of available sound devices.
543
*
544
* Returns 0 on success.
545
*/
546
FAUDIOAPI uint32_t FAudio_GetDeviceCount(FAudio *audio, uint32_t *pCount);
547
548
/* Gets basic information about a sound device.
549
*
550
* Index: Can be between 0 and the result of GetDeviceCount.
551
* pDeviceDetails: Filled with the device information.
552
*
553
* Returns 0 on success.
554
*/
555
FAUDIOAPI uint32_t FAudio_GetDeviceDetails(
556
FAudio *audio,
557
uint32_t Index,
558
FAudioDeviceDetails *pDeviceDetails
559
);
560
561
/* You don't actually have to call this, unless you're using the COM APIs.
562
* See the FAudioCreate API for parameter information.
563
*/
564
FAUDIOAPI uint32_t FAudio_Initialize(
565
FAudio *audio,
566
uint32_t Flags,
567
FAudioProcessor XAudio2Processor
568
);
569
570
/* Register a new set of engine callbacks.
571
* There is no limit to the number of sets, but expect performance to degrade
572
* if you have a whole bunch of these. You most likely only need one.
573
*
574
* pCallback: The completely-initialized FAudioEngineCallback structure.
575
*
576
* Returns 0 on success.
577
*/
578
FAUDIOAPI uint32_t FAudio_RegisterForCallbacks(
579
FAudio *audio,
580
FAudioEngineCallback *pCallback
581
);
582
583
/* Remove an active set of engine callbacks.
584
* This checks the pointer value, NOT the callback values!
585
*
586
* pCallback: An FAudioEngineCallback structure previously sent to Register.
587
*
588
* Returns 0 on success.
589
*/
590
FAUDIOAPI void FAudio_UnregisterForCallbacks(
591
FAudio *audio,
592
FAudioEngineCallback *pCallback
593
);
594
595
/* Creates a "source" voice, used to play back wavedata.
596
*
597
* ppSourceVoice: Filled with the source voice pointer.
598
* pSourceFormat: The input wavedata format, see the documentation for
599
* FAudioWaveFormatEx.
600
* Flags: Can be 0 or a mix of the following FAUDIO_VOICE_* flags:
601
* NOPITCH/NOSRC: Resampling is disabled. If you set this,
602
* the source format sample rate MUST match
603
* the output voices' input sample rates.
604
* Also, SetFrequencyRatio will fail.
605
* USEFILTER: Enables the use of SetFilterParameters.
606
* MUSIC: Unsupported.
607
* MaxFrequencyRatio: AKA your max pitch. This allows us to optimize the size
608
* of the decode/resample cache sizes. For example, if you
609
* only expect to raise pitch by a single octave, you can
610
* set this value to 2.0f. 2.0f is the default value.
611
* Bounds: [FAUDIO_MIN_FREQ_RATIO, FAUDIO_MAX_FREQ_RATIO].
612
* pCallback: Voice callbacks, see FAudioVoiceCallback documentation.
613
* pSendList: List of output voices. If NULL, defaults to master.
614
* All output voices must have the same sample rate!
615
* pEffectChain: List of FAPO effects. This value can be NULL.
616
*
617
* Returns 0 on success.
618
*/
619
FAUDIOAPI uint32_t FAudio_CreateSourceVoice(
620
FAudio *audio,
621
FAudioSourceVoice **ppSourceVoice,
622
const FAudioWaveFormatEx *pSourceFormat,
623
uint32_t Flags,
624
float MaxFrequencyRatio,
625
FAudioVoiceCallback *pCallback,
626
const FAudioVoiceSends *pSendList,
627
const FAudioEffectChain *pEffectChain
628
);
629
630
/* Creates a "submix" voice, used to mix/process input voices.
631
* The typical use case for this is to perform CPU-intensive tasks on large
632
* groups of voices all at once. Examples include resampling and FAPO effects.
633
*
634
* ppSubmixVoice: Filled with the submix voice pointer.
635
* InputChannels: Input voices will convert to this channel count.
636
* InputSampleRate: Input voices will convert to this sample rate.
637
* Flags: Can be 0 or FAUDIO_VOICE_USEFILTER.
638
* ProcessingStage: If you have multiple submixes that depend on a specific
639
* order of processing, you can sort them by setting this
640
* value to prioritize them. For example, submixes with
641
* stage 0 will process first, then stage 1, 2, and so on.
642
* pSendList: List of output voices. If NULL, defaults to master.
643
* All output voices must have the same sample rate!
644
* pEffectChain: List of FAPO effects. This value can be NULL.
645
*
646
* Returns 0 on success.
647
*/
648
FAUDIOAPI uint32_t FAudio_CreateSubmixVoice(
649
FAudio *audio,
650
FAudioSubmixVoice **ppSubmixVoice,
651
uint32_t InputChannels,
652
uint32_t InputSampleRate,
653
uint32_t Flags,
654
uint32_t ProcessingStage,
655
const FAudioVoiceSends *pSendList,
656
const FAudioEffectChain *pEffectChain
657
);
658
659
/* This should be your second FAudio call, unless you care about which device
660
* you want to use. In that case, see GetDeviceDetails.
661
*
662
* ppMasteringVoice: Filled with the mastering voice pointer.
663
* InputChannels: Device channel count. Can be FAUDIO_DEFAULT_CHANNELS.
664
* InputSampleRate: Device sample rate. Can be FAUDIO_DEFAULT_SAMPLERATE.
665
* Flags: This value must be 0.
666
* DeviceIndex: 0 for the default device. See GetDeviceCount.
667
* pEffectChain: List of FAPO effects. This value can be NULL.
668
*
669
* Returns 0 on success.
670
*/
671
FAUDIOAPI uint32_t FAudio_CreateMasteringVoice(
672
FAudio *audio,
673
FAudioMasteringVoice **ppMasteringVoice,
674
uint32_t InputChannels,
675
uint32_t InputSampleRate,
676
uint32_t Flags,
677
uint32_t DeviceIndex,
678
const FAudioEffectChain *pEffectChain
679
);
680
681
/* This is the XAudio 2.8+ version of CreateMasteringVoice.
682
* Right now this doesn't do anything. Don't use this function.
683
*/
684
FAUDIOAPI uint32_t FAudio_CreateMasteringVoice8(
685
FAudio *audio,
686
FAudioMasteringVoice **ppMasteringVoice,
687
uint32_t InputChannels,
688
uint32_t InputSampleRate,
689
uint32_t Flags,
690
uint16_t *szDeviceId,
691
const FAudioEffectChain *pEffectChain,
692
FAudioStreamCategory StreamCategory
693
);
694
695
/* Starts the engine, begins processing the audio graph.
696
* Returns 0 on success.
697
*/
698
FAUDIOAPI uint32_t FAudio_StartEngine(FAudio *audio);
699
700
/* Stops the engine and halts all processing.
701
* The audio device will continue to run, but will produce silence.
702
* The graph will be frozen until you call StartEngine, where it will then
703
* resume all processing exactly as it would have had this never been called.
704
*/
705
FAUDIOAPI void FAudio_StopEngine(FAudio *audio);
706
707
/* Flushes a batch of FAudio calls compiled with a given "OperationSet" tag.
708
* This function is based on IXAudio2::CommitChanges from the XAudio2 spec.
709
* This is useful for pushing calls that need to be done perfectly in sync. For
710
* example, if you want to play two separate sources at the exact same time, you
711
* can call FAudioSourceVoice_Start with an OperationSet value of your choice,
712
* then call CommitChanges with that same value to start the sources together.
713
*
714
* OperationSet: Either a value known by you or FAUDIO_COMMIT_ALL
715
*
716
* Returns 0 on success.
717
*/
718
FAUDIOAPI uint32_t FAudio_CommitOperationSet(
719
FAudio *audio,
720
uint32_t OperationSet
721
);
722
723
/* DO NOT USE THIS FUNCTION OR I SWEAR TO GOD */
724
FAUDIODEPRECATED("This function will break your program! Use FAudio_CommitOperationSet instead!")
725
FAUDIOAPI uint32_t FAudio_CommitChanges(FAudio *audio);
726
727
/* Requests various bits of performance information from the engine.
728
*
729
* pPerfData: Filled with the data. See FAudioPerformanceData for details.
730
*/
731
FAUDIOAPI void FAudio_GetPerformanceData(
732
FAudio *audio,
733
FAudioPerformanceData *pPerfData
734
);
735
736
/* When using a Debug binary, this lets you configure what information gets
737
* logged to output. Be careful, this can spit out a LOT of text.
738
*
739
* pDebugConfiguration: See FAudioDebugConfiguration for details.
740
* pReserved: Set this to NULL.
741
*/
742
FAUDIOAPI void FAudio_SetDebugConfiguration(
743
FAudio *audio,
744
FAudioDebugConfiguration *pDebugConfiguration,
745
void* pReserved
746
);
747
748
/* Requests the values that determine's the engine's update size.
749
* For example, a 48KHz engine with a 1024-sample update period would return
750
* 1024 for the numerator and 48000 for the denominator. With this information,
751
* you can determine the precise update size in milliseconds.
752
*
753
* quantumNumerator - The engine's update size, in sample frames.
754
* quantumDenominator - The engine's sample rate, in Hz
755
*/
756
FAUDIOAPI void FAudio_GetProcessingQuantum(
757
FAudio *audio,
758
uint32_t *quantumNumerator,
759
uint32_t *quantumDenominator
760
);
761
762
/* FAudioVoice Interface */
763
764
/* Requests basic information about a voice.
765
*
766
* pVoiceDetails: See FAudioVoiceDetails for details.
767
*/
768
FAUDIOAPI void FAudioVoice_GetVoiceDetails(
769
FAudioVoice *voice,
770
FAudioVoiceDetails *pVoiceDetails
771
);
772
773
/* Change the output voices for this voice.
774
* This function is invalid for mastering voices.
775
*
776
* pSendList: List of output voices. If NULL, defaults to master.
777
* All output voices must have the same sample rate!
778
*
779
* Returns 0 on success.
780
*/
781
FAUDIOAPI uint32_t FAudioVoice_SetOutputVoices(
782
FAudioVoice *voice,
783
const FAudioVoiceSends *pSendList
784
);
785
786
/* Change/Remove the effect chain for this voice.
787
*
788
* pEffectChain: List of FAPO effects. This value can be NULL.
789
* Note that the final channel counts for this chain MUST
790
* match the input/output channel count that was
791
* determined at voice creation time!
792
*
793
* Returns 0 on success.
794
*/
795
FAUDIOAPI uint32_t FAudioVoice_SetEffectChain(
796
FAudioVoice *voice,
797
const FAudioEffectChain *pEffectChain
798
);
799
800
/* Enables an effect in the effect chain.
801
*
802
* EffectIndex: The index of the effect (based on the chain order).
803
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
804
*
805
* Returns 0 on success.
806
*/
807
FAUDIOAPI uint32_t FAudioVoice_EnableEffect(
808
FAudioVoice *voice,
809
uint32_t EffectIndex,
810
uint32_t OperationSet
811
);
812
813
/* Disables an effect in the effect chain.
814
*
815
* EffectIndex: The index of the effect (based on the chain order).
816
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
817
*
818
* Returns 0 on success.
819
*/
820
FAUDIOAPI uint32_t FAudioVoice_DisableEffect(
821
FAudioVoice *voice,
822
uint32_t EffectIndex,
823
uint32_t OperationSet
824
);
825
826
/* Queries the enabled/disabled state of an effect in the effect chain.
827
*
828
* EffectIndex: The index of the effect (based on the chain order).
829
* pEnabled: Filled with either 1 (Enabled) or 0 (Disabled).
830
*
831
* Returns 0 on success.
832
*/
833
FAUDIOAPI void FAudioVoice_GetEffectState(
834
FAudioVoice *voice,
835
uint32_t EffectIndex,
836
int32_t *pEnabled
837
);
838
839
/* Submits a block of memory to be sent to FAPO::SetParameters.
840
*
841
* EffectIndex: The index of the effect (based on the chain order).
842
* pParameters: The values to be copied and submitted to the FAPO.
843
* ParametersByteSize: This should match what the FAPO expects!
844
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
845
*
846
* Returns 0 on success.
847
*/
848
FAUDIOAPI uint32_t FAudioVoice_SetEffectParameters(
849
FAudioVoice *voice,
850
uint32_t EffectIndex,
851
const void *pParameters,
852
uint32_t ParametersByteSize,
853
uint32_t OperationSet
854
);
855
856
/* Requests the latest parameters from FAPO::GetParameters.
857
*
858
* EffectIndex: The index of the effect (based on the chain order).
859
* pParameters: Filled with the latest parameter values from the FAPO.
860
* ParametersByteSize: This should match what the FAPO expects!
861
*
862
* Returns 0 on success.
863
*/
864
FAUDIOAPI uint32_t FAudioVoice_GetEffectParameters(
865
FAudioVoice *voice,
866
uint32_t EffectIndex,
867
void *pParameters,
868
uint32_t ParametersByteSize
869
);
870
871
/* Sets the filter variables for a voice.
872
* This is only valid on voices with the USEFILTER flag.
873
*
874
* pParameters: See FAudioFilterParameters for details.
875
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
876
*
877
* Returns 0 on success.
878
*/
879
FAUDIOAPI uint32_t FAudioVoice_SetFilterParameters(
880
FAudioVoice *voice,
881
const FAudioFilterParameters *pParameters,
882
uint32_t OperationSet
883
);
884
885
/* Requests the filter variables for a voice.
886
* This is only valid on voices with the USEFILTER flag.
887
*
888
* pParameters: See FAudioFilterParameters for details.
889
*/
890
FAUDIOAPI void FAudioVoice_GetFilterParameters(
891
FAudioVoice *voice,
892
FAudioFilterParameters *pParameters
893
);
894
895
/* Sets the filter variables for a voice's output voice.
896
* This is only valid on sends with the USEFILTER flag.
897
*
898
* pDestinationVoice: An output voice from the voice's send list.
899
* pParameters: See FAudioFilterParameters for details.
900
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
901
*
902
* Returns 0 on success.
903
*/
904
FAUDIOAPI uint32_t FAudioVoice_SetOutputFilterParameters(
905
FAudioVoice *voice,
906
FAudioVoice *pDestinationVoice,
907
const FAudioFilterParameters *pParameters,
908
uint32_t OperationSet
909
);
910
911
/* Requests the filter variables for a voice's output voice.
912
* This is only valid on sends with the USEFILTER flag.
913
*
914
* pDestinationVoice: An output voice from the voice's send list.
915
* pParameters: See FAudioFilterParameters for details.
916
*/
917
FAUDIOAPI void FAudioVoice_GetOutputFilterParameters(
918
FAudioVoice *voice,
919
FAudioVoice *pDestinationVoice,
920
FAudioFilterParameters *pParameters
921
);
922
923
/* Sets the filter variables for a voice.
924
* This is only valid on voices with the USEFILTER flag.
925
*
926
* pParameters: See FAudioFilterParametersEXT for details.
927
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
928
*
929
* Returns 0 on success.
930
*/
931
FAUDIOAPI uint32_t FAudioVoice_SetFilterParametersEXT(
932
FAudioVoice* voice,
933
const FAudioFilterParametersEXT* pParameters,
934
uint32_t OperationSet
935
);
936
937
/* Requests the filter variables for a voice.
938
* This is only valid on voices with the USEFILTER flag.
939
*
940
* pParameters: See FAudioFilterParametersEXT for details.
941
*/
942
FAUDIOAPI void FAudioVoice_GetFilterParametersEXT(
943
FAudioVoice* voice,
944
FAudioFilterParametersEXT* pParameters
945
);
946
947
/* Sets the filter variables for a voice's output voice.
948
* This is only valid on sends with the USEFILTER flag.
949
*
950
* pDestinationVoice: An output voice from the voice's send list.
951
* pParameters: See FAudioFilterParametersEXT for details.
952
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
953
*
954
* Returns 0 on success.
955
*/
956
FAUDIOAPI uint32_t FAudioVoice_SetOutputFilterParametersEXT(
957
FAudioVoice* voice,
958
FAudioVoice* pDestinationVoice,
959
const FAudioFilterParametersEXT* pParameters,
960
uint32_t OperationSet
961
);
962
963
/* Requests the filter variables for a voice's output voice.
964
* This is only valid on sends with the USEFILTER flag.
965
*
966
* pDestinationVoice: An output voice from the voice's send list.
967
* pParameters: See FAudioFilterParametersEXT for details.
968
*/
969
FAUDIOAPI void FAudioVoice_GetOutputFilterParametersEXT(
970
FAudioVoice* voice,
971
FAudioVoice* pDestinationVoice,
972
FAudioFilterParametersEXT* pParameters
973
);
974
975
/* Sets the global volume of a voice.
976
*
977
* Volume: Amplitude ratio. 1.0f is default, 0.0f is silence.
978
* Note that you can actually set volume < 0.0f!
979
* Bounds: [-FAUDIO_MAX_VOLUME_LEVEL, FAUDIO_MAX_VOLUME_LEVEL]
980
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
981
*
982
* Returns 0 on success.
983
*/
984
FAUDIOAPI uint32_t FAudioVoice_SetVolume(
985
FAudioVoice *voice,
986
float Volume,
987
uint32_t OperationSet
988
);
989
990
/* Requests the global volume of a voice.
991
*
992
* pVolume: Filled with the current voice amplitude ratio.
993
*/
994
FAUDIOAPI void FAudioVoice_GetVolume(
995
FAudioVoice *voice,
996
float *pVolume
997
);
998
999
/* Sets the per-channel volumes of a voice.
1000
*
1001
* Channels: Must match the channel count of this voice!
1002
* pVolumes: Amplitude ratios for each channel. Same as SetVolume.
1003
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1004
*
1005
* Returns 0 on success.
1006
*/
1007
FAUDIOAPI uint32_t FAudioVoice_SetChannelVolumes(
1008
FAudioVoice *voice,
1009
uint32_t Channels,
1010
const float *pVolumes,
1011
uint32_t OperationSet
1012
);
1013
1014
/* Requests the per-channel volumes of a voice.
1015
*
1016
* Channels: Must match the channel count of this voice!
1017
* pVolumes: Filled with the current channel amplitude ratios.
1018
*/
1019
FAUDIOAPI void FAudioVoice_GetChannelVolumes(
1020
FAudioVoice *voice,
1021
uint32_t Channels,
1022
float *pVolumes
1023
);
1024
1025
/* Sets the volumes of a send's output channels. The matrix is based on the
1026
* voice's input channels. For example, the default matrix for a 2-channel
1027
* source and a 2-channel output voice is as follows:
1028
* [0] = 1.0f; <- Left input, left output
1029
* [1] = 0.0f; <- Right input, left output
1030
* [2] = 0.0f; <- Left input, right output
1031
* [3] = 1.0f; <- Right input, right output
1032
* This is typically only used for panning or 3D sound (via F3DAudio).
1033
*
1034
* pDestinationVoice: An output voice from the voice's send list.
1035
* SourceChannels: Must match the voice's input channel count!
1036
* DestinationChannels: Must match the destination's input channel count!
1037
* pLevelMatrix: A float[SourceChannels * DestinationChannels].
1038
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1039
*
1040
* Returns 0 on success.
1041
*/
1042
FAUDIOAPI uint32_t FAudioVoice_SetOutputMatrix(
1043
FAudioVoice *voice,
1044
FAudioVoice *pDestinationVoice,
1045
uint32_t SourceChannels,
1046
uint32_t DestinationChannels,
1047
const float *pLevelMatrix,
1048
uint32_t OperationSet
1049
);
1050
1051
/* Gets the volumes of a send's output channels. See SetOutputMatrix.
1052
*
1053
* pDestinationVoice: An output voice from the voice's send list.
1054
* SourceChannels: Must match the voice's input channel count!
1055
* DestinationChannels: Must match the voice's output channel count!
1056
* pLevelMatrix: A float[SourceChannels * DestinationChannels].
1057
*/
1058
FAUDIOAPI void FAudioVoice_GetOutputMatrix(
1059
FAudioVoice *voice,
1060
FAudioVoice *pDestinationVoice,
1061
uint32_t SourceChannels,
1062
uint32_t DestinationChannels,
1063
float *pLevelMatrix
1064
);
1065
1066
/* Removes this voice from the audio graph and frees memory. */
1067
FAUDIOAPI void FAudioVoice_DestroyVoice(FAudioVoice *voice);
1068
1069
/*
1070
* Returns S_OK on success and E_FAIL if voice could not be destroyed (e. g., because it is in use).
1071
*/
1072
FAUDIOAPI uint32_t FAudioVoice_DestroyVoiceSafeEXT(FAudioVoice *voice);
1073
1074
/* FAudioSourceVoice Interface */
1075
1076
/* Starts processing for a source voice.
1077
*
1078
* Flags: Must be 0.
1079
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1080
*
1081
* Returns 0 on success.
1082
*/
1083
FAUDIOAPI uint32_t FAudioSourceVoice_Start(
1084
FAudioSourceVoice *voice,
1085
uint32_t Flags,
1086
uint32_t OperationSet
1087
);
1088
1089
/* Pauses processing for a source voice. Yes, I said pausing.
1090
* If you want to _actually_ stop, call FlushSourceBuffers next.
1091
*
1092
* Flags: Can be 0 or FAUDIO_PLAY_TAILS, which allows effects to
1093
* keep emitting output even after processing has stopped.
1094
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1095
*
1096
* Returns 0 on success.
1097
*/
1098
FAUDIOAPI uint32_t FAudioSourceVoice_Stop(
1099
FAudioSourceVoice *voice,
1100
uint32_t Flags,
1101
uint32_t OperationSet
1102
);
1103
1104
/* Submits a block of wavedata for the source to process.
1105
*
1106
* pBuffer: See FAudioBuffer for details.
1107
* pBufferWMA: See FAudioBufferWMA for details. (Also, don't use WMA.)
1108
*
1109
* Returns 0 on success.
1110
*/
1111
FAUDIOAPI uint32_t FAudioSourceVoice_SubmitSourceBuffer(
1112
FAudioSourceVoice *voice,
1113
const FAudioBuffer *pBuffer,
1114
const FAudioBufferWMA *pBufferWMA
1115
);
1116
1117
/* Removes all buffers from a source, with a minor exception.
1118
* If the voice is still playing, the active buffer is left alone.
1119
* All buffers that are removed will spawn an OnBufferEnd callback.
1120
*
1121
* Returns 0 on success.
1122
*/
1123
FAUDIOAPI uint32_t FAudioSourceVoice_FlushSourceBuffers(
1124
FAudioSourceVoice *voice
1125
);
1126
1127
/* Takes the last buffer currently queued and sets the END_OF_STREAM flag.
1128
*
1129
* Returns 0 on success.
1130
*/
1131
FAUDIOAPI uint32_t FAudioSourceVoice_Discontinuity(
1132
FAudioSourceVoice *voice
1133
);
1134
1135
/* Sets the loop count of the active buffer to 0.
1136
*
1137
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1138
*
1139
* Returns 0 on success.
1140
*/
1141
FAUDIOAPI uint32_t FAudioSourceVoice_ExitLoop(
1142
FAudioSourceVoice *voice,
1143
uint32_t OperationSet
1144
);
1145
1146
/* Requests the state and some basic statistics for this source.
1147
*
1148
* pVoiceState: See FAudioVoiceState for details.
1149
* Flags: Can be 0 or FAUDIO_VOICE_NOSAMPLESPLAYED.
1150
*/
1151
FAUDIOAPI void FAudioSourceVoice_GetState(
1152
FAudioSourceVoice *voice,
1153
FAudioVoiceState *pVoiceState,
1154
uint32_t Flags
1155
);
1156
1157
/* Sets the frequency ratio (fancy phrase for pitch) of this source.
1158
*
1159
* Ratio: The frequency ratio, must be <= MaxFrequencyRatio.
1160
* OperationSet: See CommitChanges. Default is FAUDIO_COMMIT_NOW.
1161
*
1162
* Returns 0 on success.
1163
*/
1164
FAUDIOAPI uint32_t FAudioSourceVoice_SetFrequencyRatio(
1165
FAudioSourceVoice *voice,
1166
float Ratio,
1167
uint32_t OperationSet
1168
);
1169
1170
/* Requests the frequency ratio (fancy phrase for pitch) of this source.
1171
*
1172
* pRatio: Filled with the frequency ratio.
1173
*/
1174
FAUDIOAPI void FAudioSourceVoice_GetFrequencyRatio(
1175
FAudioSourceVoice *voice,
1176
float *pRatio
1177
);
1178
1179
/* Resets the core sample rate of this source.
1180
* You probably don't want this, it's more likely you want SetFrequencyRatio.
1181
* This is used to recycle voices without having to constantly reallocate them.
1182
* For example, if you have wavedata that's all float32 mono, but the sample
1183
* rates are different, you can take a source that was being used for a 48KHz
1184
* wave and call this so it can be used for a 44.1KHz wave.
1185
*
1186
* NewSourceSampleRate: The new sample rate for this source.
1187
*
1188
* Returns 0 on success.
1189
*/
1190
FAUDIOAPI uint32_t FAudioSourceVoice_SetSourceSampleRate(
1191
FAudioSourceVoice *voice,
1192
uint32_t NewSourceSampleRate
1193
);
1194
1195
/* FAudioMasteringVoice Interface */
1196
1197
/* Requests the channel mask for the mastering voice.
1198
* This is typically used with F3DAudioInitialize, but you may find it
1199
* interesting if you want to see the user's basic speaker layout.
1200
*
1201
* pChannelMask: Filled with the channel mask.
1202
*
1203
* Returns 0 on success.
1204
*/
1205
FAUDIOAPI uint32_t FAudioMasteringVoice_GetChannelMask(
1206
FAudioMasteringVoice *voice,
1207
uint32_t *pChannelMask
1208
);
1209
1210
/* FAudioEngineCallback Interface */
1211
1212
/* If something horrible happens, this will be called.
1213
*
1214
* Error: The error code that spawned this callback.
1215
*/
1216
typedef void (FAUDIOCALL * OnCriticalErrorFunc)(
1217
FAudioEngineCallback *callback,
1218
uint32_t Error
1219
);
1220
1221
/* This is called at the end of a processing update. */
1222
typedef void (FAUDIOCALL * OnProcessingPassEndFunc)(
1223
FAudioEngineCallback *callback
1224
);
1225
1226
/* This is called at the beginning of a processing update. */
1227
typedef void (FAUDIOCALL * OnProcessingPassStartFunc)(
1228
FAudioEngineCallback *callback
1229
);
1230
1231
struct FAudioEngineCallback
1232
{
1233
OnCriticalErrorFunc OnCriticalError;
1234
OnProcessingPassEndFunc OnProcessingPassEnd;
1235
OnProcessingPassStartFunc OnProcessingPassStart;
1236
};
1237
1238
/* FAudioVoiceCallback Interface */
1239
1240
/* When a buffer is no longer in use, this is called.
1241
*
1242
* pBufferContext: The pContext for the FAudioBuffer in question.
1243
*/
1244
typedef void (FAUDIOCALL * OnBufferEndFunc)(
1245
FAudioVoiceCallback *callback,
1246
void *pBufferContext
1247
);
1248
1249
/* When a buffer is now being used, this is called.
1250
*
1251
* pBufferContext: The pContext for the FAudioBuffer in question.
1252
*/
1253
typedef void (FAUDIOCALL * OnBufferStartFunc)(
1254
FAudioVoiceCallback *callback,
1255
void *pBufferContext
1256
);
1257
1258
/* When a buffer completes a loop, this is called.
1259
*
1260
* pBufferContext: The pContext for the FAudioBuffer in question.
1261
*/
1262
typedef void (FAUDIOCALL * OnLoopEndFunc)(
1263
FAudioVoiceCallback *callback,
1264
void *pBufferContext
1265
);
1266
1267
/* When a buffer that has the END_OF_STREAM flag is finished, this is called. */
1268
typedef void (FAUDIOCALL * OnStreamEndFunc)(
1269
FAudioVoiceCallback *callback
1270
);
1271
1272
/* If something horrible happens to a voice, this is called.
1273
*
1274
* pBufferContext: The pContext for the FAudioBuffer in question.
1275
* Error: The error code that spawned this callback.
1276
*/
1277
typedef void (FAUDIOCALL * OnVoiceErrorFunc)(
1278
FAudioVoiceCallback *callback,
1279
void *pBufferContext,
1280
uint32_t Error
1281
);
1282
1283
/* When this voice is done being processed, this is called. */
1284
typedef void (FAUDIOCALL * OnVoiceProcessingPassEndFunc)(
1285
FAudioVoiceCallback *callback
1286
);
1287
1288
/* When a voice is about to start being processed, this is called.
1289
*
1290
* BytesRequested: The number of bytes needed from the application to
1291
* complete a full update. For example, if we need 512
1292
* frames for a whole update, and the voice is a float32
1293
* stereo source, BytesRequired will be 4096.
1294
*/
1295
typedef void (FAUDIOCALL * OnVoiceProcessingPassStartFunc)(
1296
FAudioVoiceCallback *callback,
1297
uint32_t BytesRequired
1298
);
1299
1300
struct FAudioVoiceCallback
1301
{
1302
OnBufferEndFunc OnBufferEnd;
1303
OnBufferStartFunc OnBufferStart;
1304
OnLoopEndFunc OnLoopEnd;
1305
OnStreamEndFunc OnStreamEnd;
1306
OnVoiceErrorFunc OnVoiceError;
1307
OnVoiceProcessingPassEndFunc OnVoiceProcessingPassEnd;
1308
OnVoiceProcessingPassStartFunc OnVoiceProcessingPassStart;
1309
};
1310
1311
/* FAudio Custom Allocator API
1312
* See "extensions/CustomAllocatorEXT.txt" for more information.
1313
*/
1314
1315
typedef void* (FAUDIOCALL * FAudioMallocFunc)(size_t size);
1316
typedef void (FAUDIOCALL * FAudioFreeFunc)(void* ptr);
1317
typedef void* (FAUDIOCALL * FAudioReallocFunc)(void* ptr, size_t size);
1318
1319
FAUDIOAPI uint32_t FAudioCreateWithCustomAllocatorEXT(
1320
FAudio **ppFAudio,
1321
uint32_t Flags,
1322
FAudioProcessor XAudio2Processor,
1323
FAudioMallocFunc customMalloc,
1324
FAudioFreeFunc customFree,
1325
FAudioReallocFunc customRealloc
1326
);
1327
FAUDIOAPI uint32_t FAudioCOMConstructWithCustomAllocatorEXT(
1328
FAudio **ppFAudio,
1329
uint8_t version,
1330
FAudioMallocFunc customMalloc,
1331
FAudioFreeFunc customFree,
1332
FAudioReallocFunc customRealloc
1333
);
1334
1335
/* FAudio Engine Procedure API
1336
* See "extensions/EngineProcedureEXT.txt" for more information.
1337
*/
1338
typedef void (FAUDIOCALL *FAudioEngineCallEXT)(FAudio *audio, float *output);
1339
typedef void (FAUDIOCALL *FAudioEngineProcedureEXT)(FAudioEngineCallEXT defaultEngineProc, FAudio *audio, float *output, void *user);
1340
1341
FAUDIOAPI void FAudio_SetEngineProcedureEXT(
1342
FAudio *audio,
1343
FAudioEngineProcedureEXT clientEngineProc,
1344
void *user
1345
);
1346
1347
1348
/* FAudio I/O API */
1349
1350
#define FAUDIO_SEEK_SET 0
1351
#define FAUDIO_SEEK_CUR 1
1352
#define FAUDIO_SEEK_END 2
1353
#define FAUDIO_EOF -1
1354
1355
typedef size_t (FAUDIOCALL * FAudio_readfunc)(
1356
void *data,
1357
void *dst,
1358
size_t size,
1359
size_t count
1360
);
1361
typedef int64_t (FAUDIOCALL * FAudio_seekfunc)(
1362
void *data,
1363
int64_t offset,
1364
int whence
1365
);
1366
typedef int (FAUDIOCALL * FAudio_closefunc)(
1367
void *data
1368
);
1369
1370
typedef struct FAudioIOStream
1371
{
1372
void *data;
1373
FAudio_readfunc read;
1374
FAudio_seekfunc seek;
1375
FAudio_closefunc close;
1376
void *lock;
1377
} FAudioIOStream;
1378
1379
FAUDIOAPI FAudioIOStream* FAudio_fopen(const char *path);
1380
FAUDIOAPI FAudioIOStream* FAudio_memopen(void *mem, int len);
1381
FAUDIOAPI uint8_t* FAudio_memptr(FAudioIOStream *io, size_t offset);
1382
FAUDIOAPI void FAudio_close(FAudioIOStream *io);
1383
1384
#ifdef __cplusplus
1385
}
1386
#endif /* __cplusplus */
1387
1388
#endif /* FAUDIO_H */
1389
1390
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
1391
1392