1 /* FAudio - XAudio Reimplementation for FNA
2  *
3  * Copyright (c) 2011-2021 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 <flibitijibibo@flibitijibibo.com>
24  *
25  */
26 
27 /* This file has no documentation since you are expected to already know how
28  * XACT works if you are still using these APIs!
29  */
30 
31 #ifndef FACT_H
32 #define FACT_H
33 
34 #include "FAudio.h"
35 
36 #define FACTAPI FAUDIOAPI
37 #ifdef _WIN32
38 #define FACTCALL __stdcall
39 #else
40 #define FACTCALL
41 #endif
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif /* __cplusplus */
46 
47 /* Type Declarations */
48 
49 typedef struct FACTAudioEngine FACTAudioEngine;
50 typedef struct FACTSoundBank FACTSoundBank;
51 typedef struct FACTWaveBank FACTWaveBank;
52 typedef struct FACTWave FACTWave;
53 typedef struct FACTCue FACTCue;
54 typedef struct FACTNotification FACTNotification;
55 
56 typedef struct FACTRendererDetails
57 {
58 	int16_t rendererID[0xFF]; /* Win32 wchar_t */
59 	int16_t displayName[0xFF]; /* Win32 wchar_t */
60 	int32_t defaultDevice;
61 } FACTRendererDetails;
62 
63 typedef struct FACTOverlapped
64 {
65 	void *Internal; /* ULONG_PTR */
66 	void *InternalHigh; /* ULONG_PTR */
67 	FAUDIONAMELESS union
68 	{
69 		FAUDIONAMELESS struct
70 		{
71 			uint32_t Offset;
72 			uint32_t OffsetHigh;
73 		};
74 		void *Pointer;
75 	};
76 	void *hEvent;
77 } FACTOverlapped;
78 
79 typedef int32_t (FACTCALL * FACTReadFileCallback)(
80 	void *hFile,
81 	void *buffer,
82 	uint32_t nNumberOfBytesToRead,
83 	uint32_t *lpNumberOfBytesRead,
84 	FACTOverlapped *lpOverlapped
85 );
86 
87 typedef int32_t (FACTCALL * FACTGetOverlappedResultCallback)(
88 	void *hFile,
89 	FACTOverlapped *lpOverlapped,
90 	uint32_t *lpNumberOfBytesTransferred,
91 	int32_t bWait
92 );
93 
94 typedef struct FACTFileIOCallbacks
95 {
96 	FACTReadFileCallback readFileCallback;
97 	FACTGetOverlappedResultCallback getOverlappedResultCallback;
98 } FACTFileIOCallbacks;
99 
100 typedef void (FACTCALL * FACTNotificationCallback)(
101 	const FACTNotification *pNotification
102 );
103 
104 /* FIXME: ABI bug! This should be pack(1) explicitly. Do not memcpy this! */
105 typedef struct FACTRuntimeParameters
106 {
107 	uint32_t lookAheadTime;
108 	void *pGlobalSettingsBuffer;
109 	uint32_t globalSettingsBufferSize;
110 	uint32_t globalSettingsFlags;
111 	uint32_t globalSettingsAllocAttributes;
112 	FACTFileIOCallbacks fileIOCallbacks;
113 	FACTNotificationCallback fnNotificationCallback;
114 	int16_t *pRendererID; /* Win32 wchar_t* */
115 	FAudio *pXAudio2;
116 	FAudioMasteringVoice *pMasteringVoice;
117 } FACTRuntimeParameters;
118 
119 typedef struct FACTStreamingParameters
120 {
121 	void *file;
122 	uint32_t offset;
123 	uint32_t flags;
124 	uint16_t packetSize; /* Measured in DVD sectors, or 2048 bytes */
125 } FACTStreamingParameters;
126 
127 #define FACT_WAVEBANK_TYPE_BUFFER		0x00000000
128 #define FACT_WAVEBANK_TYPE_STREAMING		0x00000001
129 #define FACT_WAVEBANK_TYPE_MASK			0x00000001
130 
131 #define FACT_WAVEBANK_FLAGS_ENTRYNAMES		0x00010000
132 #define FACT_WAVEBANK_FLAGS_COMPACT		0x00020000
133 #define FACT_WAVEBANK_FLAGS_SYNC_DISABLED	0x00040000
134 #define FACT_WAVEBANK_FLAGS_SEEKTABLES		0x00080000
135 #define FACT_WAVEBANK_FLAGS_MASK		0x000F0000
136 
137 typedef enum FACTWaveBankSegIdx
138 {
139 	FACT_WAVEBANK_SEGIDX_BANKDATA = 0,
140 	FACT_WAVEBANK_SEGIDX_ENTRYMETADATA,
141 	FACT_WAVEBANK_SEGIDX_SEEKTABLES,
142 	FACT_WAVEBANK_SEGIDX_ENTRYNAMES,
143 	FACT_WAVEBANK_SEGIDX_ENTRYWAVEDATA,
144 	FACT_WAVEBANK_SEGIDX_COUNT
145 } FACTWaveBankSegIdx;
146 
147 #pragma pack(push, 1)
148 
149 typedef struct FACTWaveBankRegion
150 {
151 	uint32_t dwOffset;
152 	uint32_t dwLength;
153 } FACTWaveBankRegion;
154 
155 typedef struct FACTWaveBankSampleRegion
156 {
157 	uint32_t dwStartSample;
158 	uint32_t dwTotalSamples;
159 } FACTWaveBankSampleRegion;
160 
161 typedef struct FACTWaveBankHeader
162 {
163 	uint32_t dwSignature;
164 	uint32_t dwVersion;
165 	uint32_t dwHeaderVersion;
166 	FACTWaveBankRegion Segments[FACT_WAVEBANK_SEGIDX_COUNT];
167 } FACTWaveBankHeader;
168 
169 typedef union FACTWaveBankMiniWaveFormat
170 {
171 	FAUDIONAMELESS struct
172 	{
173 		uint32_t wFormatTag : 2;
174 		uint32_t nChannels : 3;
175 		uint32_t nSamplesPerSec : 18;
176 		uint32_t wBlockAlign : 8;
177 		uint32_t wBitsPerSample : 1;
178 	};
179 	uint32_t dwValue;
180 } FACTWaveBankMiniWaveFormat;
181 
182 typedef struct FACTWaveBankEntry
183 {
184 	FAUDIONAMELESS union
185 	{
186 		FAUDIONAMELESS struct
187 		{
188 			uint32_t dwFlags : 4;
189 			uint32_t Duration : 28;
190 		};
191 		uint32_t dwFlagsAndDuration;
192 	};
193 	FACTWaveBankMiniWaveFormat Format;
194 	FACTWaveBankRegion PlayRegion;
195 	FACTWaveBankSampleRegion LoopRegion;
196 } FACTWaveBankEntry;
197 
198 typedef struct FACTWaveBankEntryCompact
199 {
200 	uint32_t dwOffset : 21;
201 	uint32_t dwLengthDeviation : 11;
202 } FACTWaveBankEntryCompact;
203 
204 typedef struct FACTWaveBankData
205 {
206 	uint32_t dwFlags;
207 	uint32_t dwEntryCount;
208 	char szBankName[64];
209 	uint32_t dwEntryMetaDataElementSize;
210 	uint32_t dwEntryNameElementSize;
211 	uint32_t dwAlignment;
212 	FACTWaveBankMiniWaveFormat CompactFormat;
213 	uint64_t BuildTime;
214 } FACTWaveBankData;
215 
216 #pragma pack(pop)
217 
218 typedef struct FACTWaveProperties
219 {
220 	char friendlyName[64];
221 	FACTWaveBankMiniWaveFormat format;
222 	uint32_t durationInSamples;
223 	FACTWaveBankSampleRegion loopRegion;
224 	int32_t streaming;
225 } FACTWaveProperties;
226 
227 typedef struct FACTWaveInstanceProperties
228 {
229 	FACTWaveProperties properties;
230 	int32_t backgroundMusic;
231 } FACTWaveInstanceProperties;
232 
233 typedef struct FACTCueProperties
234 {
235 	char friendlyName[0xFF];
236 	int32_t interactive;
237 	uint16_t iaVariableIndex;
238 	uint16_t numVariations;
239 	uint8_t maxInstances;
240 	uint8_t currentInstances;
241 } FACTCueProperties;
242 
243 typedef struct FACTTrackProperties
244 {
245 	uint32_t duration;
246 	uint16_t numVariations;
247 	uint8_t numChannels;
248 	uint16_t waveVariation;
249 	uint8_t loopCount;
250 } FACTTrackProperties;
251 
252 typedef struct FACTVariationProperties
253 {
254 	uint16_t index;
255 	uint8_t weight;
256 	float iaVariableMin;
257 	float iaVariableMax;
258 	int32_t linger;
259 } FACTVariationProperties;
260 
261 typedef struct FACTSoundProperties
262 {
263 	uint16_t category;
264 	uint8_t priority;
265 	int16_t pitch;
266 	float volume;
267 	uint16_t numTracks;
268 	FACTTrackProperties arrTrackProperties[1];
269 } FACTSoundProperties;
270 
271 typedef struct FACTSoundVariationProperties
272 {
273 	FACTVariationProperties variationProperties;
274 	FACTSoundProperties soundProperties;
275 } FACTSoundVariationProperties;
276 
277 typedef struct FACTCueInstanceProperties
278 {
279 	uint32_t allocAttributes;
280 	FACTCueProperties cueProperties;
281 	FACTSoundVariationProperties activeVariationProperties;
282 } FACTCueInstanceProperties;
283 
284 #pragma pack(push, 1)
285 
286 typedef struct FACTNotificationDescription
287 {
288 	uint8_t type;
289 	uint8_t flags;
290 	FACTSoundBank *pSoundBank;
291 	FACTWaveBank *pWaveBank;
292 	FACTCue *pCue;
293 	FACTWave *pWave;
294 	uint16_t cueIndex;
295 	uint16_t waveIndex;
296 	void* pvContext;
297 } FACTNotificationDescription;
298 
299 typedef struct FACTNotificationCue
300 {
301 	uint16_t cueIndex;
302 	FACTSoundBank *pSoundBank;
303 	FACTCue *pCue;
304 } FACTNotificationCue;
305 
306 typedef struct FACTNotificationMarker
307 {
308 	uint16_t cueIndex;
309 	FACTSoundBank *pSoundBank;
310 	FACTCue *pCue;
311 	uint32_t marker;
312 } FACTNotificationMarker;
313 
314 typedef struct FACTNotificationSoundBank
315 {
316 	FACTSoundBank *pSoundBank;
317 } FACTNotificationSoundBank;
318 
319 typedef struct FACTNotificationWaveBank
320 {
321 	FACTWaveBank *pWaveBank;
322 } FACTNotificationWaveBank;
323 
324 typedef struct FACTNotificationVariable
325 {
326 	uint16_t cueIndex;
327 	FACTSoundBank *pSoundBank;
328 	FACTCue *pCue;
329 	uint16_t variableIndex;
330 	float variableValue;
331 	int32_t local;
332 } FACTNotificationVariable;
333 
334 typedef struct FACTNotificationGUI
335 {
336 	uint32_t reserved;
337 } FACTNotificationGUI;
338 
339 typedef struct FACTNotificationWave
340 {
341 	FACTWaveBank *pWaveBank;
342 	uint16_t waveIndex;
343 	uint16_t cueIndex;
344 	FACTSoundBank *pSoundBank;
345 	FACTCue *pCue;
346 	FACTWave *pWave;
347 } FACTNotificationWave;
348 
349 struct FACTNotification
350 {
351 	uint8_t type;
352 	int32_t timeStamp;
353 	void *pvContext;
354 	FAUDIONAMELESS union
355 	{
356 		FACTNotificationCue cue;
357 		FACTNotificationMarker marker;
358 		FACTNotificationSoundBank soundBank;
359 		FACTNotificationWaveBank waveBank;
360 		FACTNotificationVariable variable;
361 		FACTNotificationGUI gui;
362 		FACTNotificationWave wave;
363 	};
364 };
365 
366 #pragma pack(pop)
367 
368 /* Constants */
369 
370 #define FACT_CONTENT_VERSION 46
371 
372 static const uint32_t FACT_FLAG_MANAGEDATA =		0x00000001;
373 
374 static const uint32_t FACT_FLAG_STOP_RELEASE =		0x00000000;
375 static const uint32_t FACT_FLAG_STOP_IMMEDIATE =	0x00000001;
376 
377 static const uint32_t FACT_FLAG_BACKGROUND_MUSIC =	0x00000002;
378 static const uint32_t FACT_FLAG_UNITS_MS =		0x00000004;
379 static const uint32_t FACT_FLAG_UNITS_SAMPLES =		0x00000008;
380 
381 static const uint32_t FACT_STATE_CREATED =		0x00000001;
382 static const uint32_t FACT_STATE_PREPARING =		0x00000002;
383 static const uint32_t FACT_STATE_PREPARED =		0x00000004;
384 static const uint32_t FACT_STATE_PLAYING =		0x00000008;
385 static const uint32_t FACT_STATE_STOPPING =		0x00000010;
386 static const uint32_t FACT_STATE_STOPPED =		0x00000020;
387 static const uint32_t FACT_STATE_PAUSED =		0x00000040;
388 static const uint32_t FACT_STATE_INUSE =		0x00000080;
389 static const uint32_t FACT_STATE_PREPAREFAILED =	0x80000000;
390 
391 static const int16_t FACTPITCH_MIN =		-1200;
392 static const int16_t FACTPITCH_MAX =		 1200;
393 static const int16_t FACTPITCH_MIN_TOTAL =	-2400;
394 static const int16_t FACTPITCH_MAX_TOTAL =	 2400;
395 
396 static const float FACTVOLUME_MIN = 0.0f;
397 static const float FACTVOLUME_MAX = 16777216.0f;
398 
399 static const uint16_t FACTINDEX_INVALID =		0xFFFF;
400 static const uint16_t FACTVARIABLEINDEX_INVALID =	0xFFFF;
401 static const uint16_t FACTCATEGORY_INVALID =		0xFFFF;
402 
403 static const uint8_t FACTNOTIFICATIONTYPE_CUEPREPARED =				1;
404 static const uint8_t FACTNOTIFICATIONTYPE_CUEPLAY =				2;
405 static const uint8_t FACTNOTIFICATIONTYPE_CUESTOP =				3;
406 static const uint8_t FACTNOTIFICATIONTYPE_CUEDESTROYED =			4;
407 static const uint8_t FACTNOTIFICATIONTYPE_MARKER =				5;
408 static const uint8_t FACTNOTIFICATIONTYPE_SOUNDBANKDESTROYED =			6;
409 static const uint8_t FACTNOTIFICATIONTYPE_WAVEBANKDESTROYED =			7;
410 static const uint8_t FACTNOTIFICATIONTYPE_LOCALVARIABLECHANGED =		8;
411 static const uint8_t FACTNOTIFICATIONTYPE_GLOBALVARIABLECHANGED =		9;
412 static const uint8_t FACTNOTIFICATIONTYPE_GUICONNECTED =			10;
413 static const uint8_t FACTNOTIFICATIONTYPE_GUIDISCONNECTED =			11;
414 static const uint8_t FACTNOTIFICATIONTYPE_WAVEPREPARED =			12;
415 static const uint8_t FACTNOTIFICATIONTYPE_WAVEPLAY =				13;
416 static const uint8_t FACTNOTIFICATIONTYPE_WAVESTOP =				14;
417 static const uint8_t FACTNOTIFICATIONTYPE_WAVELOOPED =				15;
418 static const uint8_t FACTNOTIFICATIONTYPE_WAVEDESTROYED =			16;
419 static const uint8_t FACTNOTIFICATIONTYPE_WAVEBANKPREPARED =			17;
420 static const uint8_t FACTNOTIFICATIONTYPE_WAVEBANKSTREAMING_INVALIDCONTENT =	18;
421 
422 static const uint8_t FACT_FLAG_NOTIFICATION_PERSIST = 0x01;
423 
424 #define FACT_ENGINE_LOOKAHEAD_DEFAULT 250
425 
426 #define FACT_MAX_WMA_AVG_BYTES_PER_SEC_ENTRIES 7
427 static const uint32_t aWMAAvgBytesPerSec[] =
428 {
429 	12000,
430 	24000,
431 	4000,
432 	6000,
433 	8000,
434 	20000,
435 	2500
436 };
437 
438 #define FACT_MAX_WMA_BLOCK_ALIGN_ENTRIES 17
439 static const uint32_t aWMABlockAlign[] =
440 {
441 	929,
442 	1487,
443 	1280,
444 	2230,
445 	8917,
446 	8192,
447 	4459,
448 	5945,
449 	2304,
450 	1536,
451 	1485,
452 	1008,
453 	2731,
454 	4096,
455 	6827,
456 	5462,
457 	1280
458 };
459 
460 /* AudioEngine Interface */
461 
462 FACTAPI uint32_t FACTCreateEngine(
463 	uint32_t dwCreationFlags,
464 	FACTAudioEngine **ppEngine
465 );
466 
467 /* See "extensions/CustomAllocatorEXT.txt" for more details. */
468 FACTAPI uint32_t FACTCreateEngineWithCustomAllocatorEXT(
469 	uint32_t dwCreationFlags,
470 	FACTAudioEngine **ppEngine,
471 	FAudioMallocFunc customMalloc,
472 	FAudioFreeFunc customFree,
473 	FAudioReallocFunc customRealloc
474 );
475 
476 FACTAPI uint32_t FACTAudioEngine_AddRef(FACTAudioEngine *pEngine);
477 
478 FACTAPI uint32_t FACTAudioEngine_Release(FACTAudioEngine *pEngine);
479 
480 /* FIXME: QueryInterface? Or just ignore COM garbage... -flibit */
481 
482 FACTAPI uint32_t FACTAudioEngine_GetRendererCount(
483 	FACTAudioEngine *pEngine,
484 	uint16_t *pnRendererCount
485 );
486 
487 FACTAPI uint32_t FACTAudioEngine_GetRendererDetails(
488 	FACTAudioEngine *pEngine,
489 	uint16_t nRendererIndex,
490 	FACTRendererDetails *pRendererDetails
491 );
492 
493 FACTAPI uint32_t FACTAudioEngine_GetFinalMixFormat(
494 	FACTAudioEngine *pEngine,
495 	FAudioWaveFormatExtensible *pFinalMixFormat
496 );
497 
498 FACTAPI uint32_t FACTAudioEngine_Initialize(
499 	FACTAudioEngine *pEngine,
500 	const FACTRuntimeParameters *pParams
501 );
502 
503 FACTAPI uint32_t FACTAudioEngine_ShutDown(FACTAudioEngine *pEngine);
504 
505 FACTAPI uint32_t FACTAudioEngine_DoWork(FACTAudioEngine *pEngine);
506 
507 FACTAPI uint32_t FACTAudioEngine_CreateSoundBank(
508 	FACTAudioEngine *pEngine,
509 	const void *pvBuffer,
510 	uint32_t dwSize,
511 	uint32_t dwFlags,
512 	uint32_t dwAllocAttributes,
513 	FACTSoundBank **ppSoundBank
514 );
515 
516 FACTAPI uint32_t FACTAudioEngine_CreateInMemoryWaveBank(
517 	FACTAudioEngine *pEngine,
518 	const void *pvBuffer,
519 	uint32_t dwSize,
520 	uint32_t dwFlags,
521 	uint32_t dwAllocAttributes,
522 	FACTWaveBank **ppWaveBank
523 );
524 
525 FACTAPI uint32_t FACTAudioEngine_CreateStreamingWaveBank(
526 	FACTAudioEngine *pEngine,
527 	const FACTStreamingParameters *pParms,
528 	FACTWaveBank **ppWaveBank
529 );
530 
531 FACTAPI uint32_t FACTAudioEngine_PrepareWave(
532 	FACTAudioEngine *pEngine,
533 	uint32_t dwFlags,
534 	const char *szWavePath,
535 	uint32_t wStreamingPacketSize,
536 	uint32_t dwAlignment,
537 	uint32_t dwPlayOffset,
538 	uint8_t nLoopCount,
539 	FACTWave **ppWave
540 );
541 
542 FACTAPI uint32_t FACTAudioEngine_PrepareInMemoryWave(
543 	FACTAudioEngine *pEngine,
544 	uint32_t dwFlags,
545 	FACTWaveBankEntry entry,
546 	uint32_t *pdwSeekTable, /* Optional! */
547 	uint8_t *pbWaveData,
548 	uint32_t dwPlayOffset,
549 	uint8_t nLoopCount,
550 	FACTWave **ppWave
551 );
552 
553 FACTAPI uint32_t FACTAudioEngine_PrepareStreamingWave(
554 	FACTAudioEngine *pEngine,
555 	uint32_t dwFlags,
556 	FACTWaveBankEntry entry,
557 	FACTStreamingParameters streamingParams,
558 	uint32_t dwAlignment,
559 	uint32_t *pdwSeekTable, /* Optional! */
560 	uint8_t *pbWaveData, /* ABI bug, do not use! */
561 	uint32_t dwPlayOffset,
562 	uint8_t nLoopCount,
563 	FACTWave **ppWave
564 );
565 
566 FACTAPI uint32_t FACTAudioEngine_RegisterNotification(
567 	FACTAudioEngine *pEngine,
568 	const FACTNotificationDescription *pNotificationDescription
569 );
570 
571 FACTAPI uint32_t FACTAudioEngine_UnRegisterNotification(
572 	FACTAudioEngine *pEngine,
573 	const FACTNotificationDescription *pNotificationDescription
574 );
575 
576 FACTAPI uint16_t FACTAudioEngine_GetCategory(
577 	FACTAudioEngine *pEngine,
578 	const char *szFriendlyName
579 );
580 
581 FACTAPI uint32_t FACTAudioEngine_Stop(
582 	FACTAudioEngine *pEngine,
583 	uint16_t nCategory,
584 	uint32_t dwFlags
585 );
586 
587 FACTAPI uint32_t FACTAudioEngine_SetVolume(
588 	FACTAudioEngine *pEngine,
589 	uint16_t nCategory,
590 	float volume
591 );
592 
593 FACTAPI uint32_t FACTAudioEngine_Pause(
594 	FACTAudioEngine *pEngine,
595 	uint16_t nCategory,
596 	int32_t fPause
597 );
598 
599 FACTAPI uint16_t FACTAudioEngine_GetGlobalVariableIndex(
600 	FACTAudioEngine *pEngine,
601 	const char *szFriendlyName
602 );
603 
604 FACTAPI uint32_t FACTAudioEngine_SetGlobalVariable(
605 	FACTAudioEngine *pEngine,
606 	uint16_t nIndex,
607 	float nValue
608 );
609 
610 FACTAPI uint32_t FACTAudioEngine_GetGlobalVariable(
611 	FACTAudioEngine *pEngine,
612 	uint16_t nIndex,
613 	float *pnValue
614 );
615 
616 /* SoundBank Interface */
617 
618 FACTAPI uint16_t FACTSoundBank_GetCueIndex(
619 	FACTSoundBank *pSoundBank,
620 	const char *szFriendlyName
621 );
622 
623 FACTAPI uint32_t FACTSoundBank_GetNumCues(
624 	FACTSoundBank *pSoundBank,
625 	uint16_t *pnNumCues
626 );
627 
628 FACTAPI uint32_t FACTSoundBank_GetCueProperties(
629 	FACTSoundBank *pSoundBank,
630 	uint16_t nCueIndex,
631 	FACTCueProperties *pProperties
632 );
633 
634 FACTAPI uint32_t FACTSoundBank_Prepare(
635 	FACTSoundBank *pSoundBank,
636 	uint16_t nCueIndex,
637 	uint32_t dwFlags,
638 	int32_t timeOffset,
639 	FACTCue** ppCue
640 );
641 
642 FACTAPI uint32_t FACTSoundBank_Play(
643 	FACTSoundBank *pSoundBank,
644 	uint16_t nCueIndex,
645 	uint32_t dwFlags,
646 	int32_t timeOffset,
647 	FACTCue** ppCue /* Optional! */
648 );
649 
650 #ifndef F3DAUDIO_DSP_SETTINGS_DECL
651 #define F3DAUDIO_DSP_SETTINGS_DECL
652 typedef struct F3DAUDIO_DSP_SETTINGS F3DAUDIO_DSP_SETTINGS;
653 #endif /* F3DAUDIO_DSP_SETTINGS_DECL */
654 
655 FACTAPI uint32_t FACTSoundBank_Play3D(
656 	FACTSoundBank *pSoundBank,
657 	uint16_t nCueIndex,
658 	uint32_t dwFlags,
659 	int32_t timeOffset,
660 	F3DAUDIO_DSP_SETTINGS *pDSPSettings,
661 	FACTCue** ppCue /* Optional! */
662 );
663 
664 FACTAPI uint32_t FACTSoundBank_Stop(
665 	FACTSoundBank *pSoundBank,
666 	uint16_t nCueIndex,
667 	uint32_t dwFlags
668 );
669 
670 FACTAPI uint32_t FACTSoundBank_Destroy(FACTSoundBank *pSoundBank);
671 
672 FACTAPI uint32_t FACTSoundBank_GetState(
673 	FACTSoundBank *pSoundBank,
674 	uint32_t *pdwState
675 );
676 
677 /* WaveBank Interface */
678 
679 FACTAPI uint32_t FACTWaveBank_Destroy(FACTWaveBank *pWaveBank);
680 
681 FACTAPI uint32_t FACTWaveBank_GetState(
682 	FACTWaveBank *pWaveBank,
683 	uint32_t *pdwState
684 );
685 
686 FACTAPI uint32_t FACTWaveBank_GetNumWaves(
687 	FACTWaveBank *pWaveBank,
688 	uint16_t *pnNumWaves
689 );
690 
691 FACTAPI uint16_t FACTWaveBank_GetWaveIndex(
692 	FACTWaveBank *pWaveBank,
693 	const char *szFriendlyName
694 );
695 
696 FACTAPI uint32_t FACTWaveBank_GetWaveProperties(
697 	FACTWaveBank *pWaveBank,
698 	uint16_t nWaveIndex,
699 	FACTWaveProperties *pWaveProperties
700 );
701 
702 FACTAPI uint32_t FACTWaveBank_Prepare(
703 	FACTWaveBank *pWaveBank,
704 	uint16_t nWaveIndex,
705 	uint32_t dwFlags,
706 	uint32_t dwPlayOffset,
707 	uint8_t nLoopCount,
708 	FACTWave **ppWave
709 );
710 
711 FACTAPI uint32_t FACTWaveBank_Play(
712 	FACTWaveBank *pWaveBank,
713 	uint16_t nWaveIndex,
714 	uint32_t dwFlags,
715 	uint32_t dwPlayOffset,
716 	uint8_t nLoopCount,
717 	FACTWave **ppWave
718 );
719 
720 FACTAPI uint32_t FACTWaveBank_Stop(
721 	FACTWaveBank *pWaveBank,
722 	uint16_t nWaveIndex,
723 	uint32_t dwFlags
724 );
725 
726 /* Wave Interface */
727 
728 FACTAPI uint32_t FACTWave_Destroy(FACTWave *pWave);
729 
730 FACTAPI uint32_t FACTWave_Play(FACTWave *pWave);
731 
732 FACTAPI uint32_t FACTWave_Stop(FACTWave *pWave, uint32_t dwFlags);
733 
734 FACTAPI uint32_t FACTWave_Pause(FACTWave *pWave, int32_t fPause);
735 
736 FACTAPI uint32_t FACTWave_GetState(FACTWave *pWave, uint32_t *pdwState);
737 
738 FACTAPI uint32_t FACTWave_SetPitch(FACTWave *pWave, int16_t pitch);
739 
740 FACTAPI uint32_t FACTWave_SetVolume(FACTWave *pWave, float volume);
741 
742 FACTAPI uint32_t FACTWave_SetMatrixCoefficients(
743 	FACTWave *pWave,
744 	uint32_t uSrcChannelCount,
745 	uint32_t uDstChannelCount,
746 	float *pMatrixCoefficients
747 );
748 
749 FACTAPI uint32_t FACTWave_GetProperties(
750 	FACTWave *pWave,
751 	FACTWaveInstanceProperties *pProperties
752 );
753 
754 /* Cue Interface */
755 
756 FACTAPI uint32_t FACTCue_Destroy(FACTCue *pCue);
757 
758 FACTAPI uint32_t FACTCue_Play(FACTCue *pCue);
759 
760 FACTAPI uint32_t FACTCue_Stop(FACTCue *pCue, uint32_t dwFlags);
761 
762 FACTAPI uint32_t FACTCue_GetState(FACTCue *pCue, uint32_t *pdwState);
763 
764 FACTAPI uint32_t FACTCue_SetMatrixCoefficients(
765 	FACTCue *pCue,
766 	uint32_t uSrcChannelCount,
767 	uint32_t uDstChannelCount,
768 	float *pMatrixCoefficients
769 );
770 
771 FACTAPI uint16_t FACTCue_GetVariableIndex(
772 	FACTCue *pCue,
773 	const char *szFriendlyName
774 );
775 
776 FACTAPI uint32_t FACTCue_SetVariable(
777 	FACTCue *pCue,
778 	uint16_t nIndex,
779 	float nValue
780 );
781 
782 FACTAPI uint32_t FACTCue_GetVariable(
783 	FACTCue *pCue,
784 	uint16_t nIndex,
785 	float *nValue
786 );
787 
788 FACTAPI uint32_t FACTCue_Pause(FACTCue *pCue, int32_t fPause);
789 
790 FACTAPI uint32_t FACTCue_GetProperties(
791 	FACTCue *pCue,
792 	FACTCueInstanceProperties **ppProperties
793 );
794 
795 FACTAPI uint32_t FACTCue_SetOutputVoices(
796 	FACTCue *pCue,
797 	const FAudioVoiceSends *pSendList /* Optional! */
798 );
799 
800 FACTAPI uint32_t FACTCue_SetOutputVoiceMatrix(
801 	FACTCue *pCue,
802 	const FAudioVoice *pDestinationVoice, /* Optional! */
803 	uint32_t SourceChannels,
804 	uint32_t DestinationChannels,
805 	const float *pLevelMatrix /* SourceChannels * DestinationChannels */
806 );
807 
808 #ifdef __cplusplus
809 }
810 #endif /* __cplusplus */
811 
812 #endif /* FACT_H */
813 
814 /* vim: set noexpandtab shiftwidth=8 tabstop=8: */
815