FACT.h 19 KB

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