1 #ifndef FACT_CPP_XACT3_H
2 #define FACT_CPP_XACT3_H
3 
4 #include "xaudio2.h"
5 #include <FACT.h>
6 
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif /* __cplusplus */
11 
12 #ifndef XACT3_VERSION
13 #define XACT3_VERSION 7
14 #endif
15 
16 typedef FACTRendererDetails XACT_RENDERER_DETAILS;
17 typedef FACTFileIOCallbacks XACT_FILEIO_CALLBACKS;
18 typedef FACTRuntimeParameters XACT_RUNTIME_PARAMETERS;
19 typedef FACTStreamingParameters XACT_STREAMING_PARAMETERS;
20 typedef FACTWaveBankRegion WAVEBANKREGION;
21 typedef FACTWaveBankSampleRegion WAVEBANKSAMPLEREGION;
22 typedef FACTWaveBankHeader WAVEBANKHEADER;
23 typedef FACTWaveBankMiniWaveFormat WAVEBANKMINIWAVEFORMAT;
24 typedef FACTWaveBankEntry WAVEBANKENTRY;
25 typedef FACTWaveBankEntryCompact WAVEBANKENTRYCOMPACT;
26 typedef FACTWaveBankData WAVEBANKDATA;
27 typedef FACTWaveProperties XACT_WAVE_PROPERTIES;
28 typedef FACTWaveInstanceProperties XACT_WAVE_INSTANCE_PROPERTIES;
29 typedef FACTCueProperties XACT_CUE_PROPERTIES;
30 typedef FACTTrackProperties XACT_TRACK_PROPERTIES;
31 typedef FACTVariationProperties XACT_VARIATION_PROPERTIES;
32 typedef FACTSoundProperties XACT_SOUND_PROPERTIES;
33 typedef FACTSoundVariationProperties XACT_SOUND_VARIATION_PROPERTIES;
34 typedef FACTCueInstanceProperties XACT_CUE_INSTANCE_PROPERTIES;
35 
36 typedef FACTReadFileCallback XACT_READFILE_CALLBACK;
37 typedef FACTGetOverlappedResultCallback XACT_GETOVERLAPPEDRESULT_CALLBACK;
38 
39 typedef FACTWaveBankSegIdx WAVEBANKSEGIDX;
40 
41 class IXACT3Engine;
42 class IXACT3SoundBank;
43 class IXACT3WaveBank;
44 class IXACT3Wave;
45 class IXACT3Cue;
46 
47 #pragma pack(push, 1)
48 
49 typedef struct XACT_NOTIFICATION_DESCRIPTION
50 {
51 	uint8_t type;
52 	uint8_t flags;
53 	IXACT3SoundBank *pSoundBank;
54 	IXACT3WaveBank *pWaveBank;
55 	IXACT3Cue *pCue;
56 	IXACT3Wave *pWave;
57 	uint16_t cueIndex;
58 	uint16_t waveIndex;
59 	void* pvContext;
60 } XACT_NOTIFICATION_DESCRIPTION;
61 
62 typedef struct XACT_NOTIFICATION_CUE
63 {
64 	uint16_t cueIndex;
65 	IXACT3SoundBank *pSoundBank;
66 	IXACT3Cue *pCue;
67 } XACT_NOTIFICATION_CUE;
68 
69 typedef struct XACT_NOTIFICATION_MARKER
70 {
71 	uint16_t cueIndex;
72 	IXACT3SoundBank *pSoundBank;
73 	IXACT3Cue *pCue;
74 	uint32_t marker;
75 } XACT_NOTIFICATION_MARKER;
76 
77 typedef struct XACT_NOTIFICATION_SOUNDBANK
78 {
79 	IXACT3SoundBank *pSoundBank;
80 } XACT_NOTIFICATION_SOUNDBANK;
81 
82 typedef struct XACT_NOTIFICATION_WAVEBANK
83 {
84 	IXACT3WaveBank *pWaveBank;
85 } XACT_NOTIFICATION_WAVEBANK;
86 
87 typedef struct XACT_NOTIFICATION_VARIABLE
88 {
89 	uint16_t cueIndex;
90 	IXACT3SoundBank *pSoundBank;
91 	IXACT3Cue *pCue;
92 	uint16_t variableIndex;
93 	float variableValue;
94 	uint8_t local;
95 } XACT_NOTIFICATION_VARIABLE;
96 
97 typedef struct XACT_NOTIFICATION_GUI
98 {
99 	uint32_t reserved;
100 } XACT_NOTIFICATION_GUI;
101 
102 typedef struct XACT_NOTIFICATION_WAVE
103 {
104 	IXACT3WaveBank *pWaveBank;
105 	uint16_t waveIndex;
106 	uint16_t cueIndex;
107 	IXACT3SoundBank *pSoundBank;
108 	IXACT3Cue *pCue;
109 	IXACT3Wave *pWave;
110 } XACT_NOTIFICATION_WAVE;
111 
112 typedef struct XACT_NOTIFICATION
113 {
114 	uint8_t type;
115 	int32_t timeStamp;
116 	void *pvContext;
117 	union
118 	{
119 		XACT_NOTIFICATION_CUE cue;
120 		XACT_NOTIFICATION_MARKER marker;
121 		XACT_NOTIFICATION_SOUNDBANK soundBank;
122 		XACT_NOTIFICATION_WAVEBANK waveBank;
123 		XACT_NOTIFICATION_VARIABLE variable;
124 		XACT_NOTIFICATION_GUI gui;
125 		XACT_NOTIFICATION_WAVE wave;
126 	};
127 } XACT_NOTIFICATION;
128 
129 #pragma pack(pop)
130 
131 class IXACT3Engine : public IUnknown
132 {
133 public:
134 	COM_METHOD(HRESULT) GetRendererCount(
135 		uint16_t *pnRendererCount
136 	) = 0;
137 	COM_METHOD(HRESULT) GetRendererDetails(
138 		uint16_t nRendererIndex,
139 		XACT_RENDERER_DETAILS *pRendererDetails
140 	) = 0;
141 	COM_METHOD(HRESULT) GetFinalMixFormat(
142 		WAVEFORMATEXTENSIBLE *pFinalMixFormat
143 	) = 0;
144 	COM_METHOD(HRESULT) Initialize(
145 		const XACT_RUNTIME_PARAMETERS *pParams
146 	) = 0;
147 	COM_METHOD(HRESULT) ShutDown() = 0;
148 	COM_METHOD(HRESULT) DoWork() = 0;
149 	COM_METHOD(HRESULT) CreateSoundBank(
150 		const void *pvBuffer,
151 		uint32_t dwSize,
152 		uint32_t dwFlags,
153 		uint32_t dwAllocAttributes,
154 		IXACT3SoundBank **ppSoundBank
155 	) = 0;
156 	COM_METHOD(HRESULT) CreateInMemoryWaveBank(
157 		const void *pvBuffer,
158 		uint32_t dwSize,
159 		uint32_t dwFlags,
160 		uint32_t dwAllocAttributes,
161 		IXACT3WaveBank **ppWaveBank
162 	) = 0;
163 	COM_METHOD(HRESULT) CreateStreamingWaveBank(
164 		const XACT_STREAMING_PARAMETERS *pParms,
165 		IXACT3WaveBank **ppWaveBank
166 	) = 0;
167 	COM_METHOD(HRESULT) PrepareWave(
168 		uint32_t dwFlags,
169 		const char *szWavePath,
170 		uint32_t wStreamingPacketSize,
171 		uint32_t dwAlignment,
172 		uint32_t dwPlayOffset,
173 		uint8_t nLoopCount,
174 		IXACT3Wave **ppWave
175 	) = 0;
176 	COM_METHOD(HRESULT) PrepareInMemoryWave(
177 		uint32_t dwFlags,
178 		WAVEBANKENTRY entry,
179 		uint32_t *pdwSeekTable, /* Optional! */
180 		uint8_t *pbWaveData,
181 		uint32_t dwPlayOffset,
182 		uint8_t nLoopCount,
183 		IXACT3Wave **ppWave
184 	) = 0;
185 	COM_METHOD(HRESULT) PrepareStreamingWave(
186 		uint32_t dwFlags,
187 		WAVEBANKENTRY entry,
188 		XACT_STREAMING_PARAMETERS streamingParams,
189 		uint32_t dwAlignment,
190 		uint32_t *pdwSeekTable, /* Optional! */
191 		uint8_t *pbWaveData,
192 		uint32_t dwPlayOffset,
193 		uint8_t nLoopCount,
194 		IXACT3Wave **ppWave
195 	) = 0;
196 	COM_METHOD(HRESULT) RegisterNotification(
197 		const XACT_NOTIFICATION_DESCRIPTION *pNotificationDescription
198 	) = 0;
199 	COM_METHOD(HRESULT) UnRegisterNotification(
200 		const XACT_NOTIFICATION_DESCRIPTION *pNotificationDescription
201 	) = 0;
202 	COM_METHOD(uint16_t) GetCategory(const char *szFriendlyName) = 0;
203 	COM_METHOD(HRESULT) Stop(uint16_t nCategory, uint32_t dwFlags) = 0;
204 	COM_METHOD(HRESULT) SetVolume(uint16_t nCategory, float volume) = 0;
205 	COM_METHOD(HRESULT) Pause(uint16_t nCategory, int32_t fPause) = 0;
206 	COM_METHOD(uint16_t) GetGlobalVariableIndex(
207 		const char *szFriendlyName
208 	) = 0;
209 	COM_METHOD(HRESULT) SetGlobalVariable(
210 		uint16_t nIndex,
211 		float nValue
212 	) = 0;
213 	COM_METHOD(HRESULT) GetGlobalVariable(
214 		uint16_t nIndex,
215 		float *pnValue
216 	) = 0;
217 };
218 
219 class IXACT3SoundBank
220 {
221 public:
222 	COM_METHOD(uint16_t) GetCueIndex(const char *szFriendlyName) = 0;
223 	COM_METHOD(HRESULT) GetNumCues(uint16_t *pnNumCues) = 0;
224 	COM_METHOD(HRESULT) GetCueProperties(
225 		uint16_t nCueIndex,
226 		XACT_CUE_PROPERTIES *pProperties
227 	) = 0;
228 	COM_METHOD(HRESULT) Prepare(
229 		uint16_t nCueIndex,
230 		uint32_t dwFlags,
231 		int32_t timeOffset,
232 		IXACT3Cue** ppCue
233 	) = 0;
234 	COM_METHOD(HRESULT) Play(
235 		uint16_t nCueIndex,
236 		uint32_t dwFlags,
237 		int32_t timeOffset,
238 		IXACT3Cue** ppCue /* Optional! */
239 	) = 0;
240 	COM_METHOD(HRESULT) Stop(uint16_t nCueIndex, uint32_t dwFlags) = 0;
241 	COM_METHOD(HRESULT) Destroy() = 0;
242 	COM_METHOD(HRESULT) GetState(uint32_t *pdwState) = 0;
243 };
244 
245 class IXACT3WaveBank
246 {
247 public:
248 	COM_METHOD(HRESULT) Destroy() = 0;
249 	COM_METHOD(HRESULT) GetNumWaves(uint16_t *pnNumWaves) = 0;
250 	COM_METHOD(uint16_t) GetWaveIndex(const char *szFriendlyName) = 0;
251 	COM_METHOD(HRESULT) GetWaveProperties(
252 		uint16_t nWaveIndex,
253 		XACT_WAVE_PROPERTIES *pWaveProperties
254 	) = 0;
255 	COM_METHOD(HRESULT) Prepare(
256 		uint16_t nWaveIndex,
257 		uint32_t dwFlags,
258 		uint32_t dwPlayOffset,
259 		uint8_t nLoopCount,
260 		IXACT3Wave **ppWave
261 	) = 0;
262 	COM_METHOD(HRESULT) Play(
263 		uint16_t nWaveIndex,
264 		uint32_t dwFlags,
265 		uint32_t dwPlayOffset,
266 		uint8_t nLoopCount,
267 		IXACT3Wave **ppWave
268 	) = 0;
269 	COM_METHOD(HRESULT) Stop(
270 		uint16_t nWaveIndex,
271 		uint32_t dwFlags
272 	) = 0;
273 	COM_METHOD(HRESULT) GetState(uint32_t *pdwState) = 0;
274 };
275 
276 class IXACT3Wave
277 {
278 public:
279 	COM_METHOD(HRESULT) Destroy() = 0;
280 	COM_METHOD(HRESULT) Play() = 0;
281 	COM_METHOD(HRESULT) Stop(uint32_t dwFlags) = 0;
282 	COM_METHOD(HRESULT) Pause(int32_t fPause) = 0;
283 	COM_METHOD(HRESULT) GetState(uint32_t *pdwState) = 0;
284 	COM_METHOD(HRESULT) SetPitch(int16_t pitch) = 0;
285 	COM_METHOD(HRESULT) SetVolume(float volume) = 0;
286 	COM_METHOD(HRESULT) SetMatrixCoefficients(
287 		uint32_t uSrcChannelCount,
288 		uint32_t uDstChannelCount,
289 		float *pMatrixCoefficients
290 	) = 0;
291 	COM_METHOD(HRESULT) GetProperties(
292 		XACT_WAVE_INSTANCE_PROPERTIES *pProperties
293 	) = 0;
294 };
295 
296 class IXACT3Cue
297 {
298 public:
299 	COM_METHOD(HRESULT) Play() = 0;
300 	COM_METHOD(HRESULT) Stop(uint32_t dwFlags) = 0;
301 	COM_METHOD(HRESULT) GetState(uint32_t *pdwState) = 0;
302 	COM_METHOD(HRESULT) Destroy() = 0;
303 	COM_METHOD(HRESULT) SetMatrixCoefficients(
304 		uint32_t uSrcChannelCount,
305 		uint32_t uDstChannelCount,
306 		float *pMatrixCoefficients
307 	) = 0;
308 	COM_METHOD(uint16_t) GetVariableIndex(const char *szFriendlyName) = 0;
309 	COM_METHOD(HRESULT) SetVariable(uint16_t nIndex, float nValue) = 0;
310 	COM_METHOD(HRESULT) GetVariable(uint16_t nIndex, float *nValue) = 0;
311 	COM_METHOD(HRESULT) Pause(int32_t fPause) = 0;
312 	COM_METHOD(HRESULT) GetProperties(
313 		XACT_CUE_INSTANCE_PROPERTIES **ppProperties
314 	) = 0;
315 #if XACT3_VERSION >= 5
316 	COM_METHOD(HRESULT) SetOutputVoices(
317 		const XAUDIO2_VOICE_SENDS *pSendList /* Optional! */
318 	) = 0;
319 	COM_METHOD(HRESULT) SetOutputVoiceMatrix(
320 		const IXAudio2Voice *pDestinationVoice, /* Optional! */
321 		uint32_t SourceChannels,
322 		uint32_t DestinationChannels,
323 		const float *pLevelMatrix /* SourceChannels * DestinationChannels */
324 	) = 0;
325 #endif /* XACT_VERSION >= 5 */
326 };
327 
328 
329 #ifdef __cplusplus
330 }
331 #endif /* __cplusplus */
332 
333 
334 #endif // FACT_CPP_XACT3_H
335