AkAudioDevice.h 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. /*=============================================================================
  16. AkAudioDevice.h: Audiokinetic audio interface object.
  17. =============================================================================*/
  18. #pragma once
  19. /*------------------------------------------------------------------------------------
  20. AkAudioDevice system headers
  21. ------------------------------------------------------------------------------------*/
  22. #include "AkEnvironmentIndex.h"
  23. #include "AkGameplayTypes.h"
  24. #include "AkGroupValue.h"
  25. #include "AkInclude.h"
  26. #include "AkJobWorkerScheduler.h"
  27. #include "Wwise/WwiseSharedLanguageId.h"
  28. #include "Engine/EngineTypes.h"
  29. #include "Wwise/Stats/AkAudio.h"
  30. #if WITH_EDITORONLY_DATA
  31. #include "EditorViewportClient.h"
  32. #endif
  33. #define GET_AK_EVENT_NAME(AkEvent, EventName) ((AkEvent) ? ((AkEvent)->GetName()) : (EventName))
  34. DECLARE_EVENT(FAkAudioDevice, SoundbanksLoaded);
  35. DECLARE_EVENT(FAkAudioDevice, FOnWwiseProjectModification);
  36. DECLARE_EVENT_OneParam(FAkAudioDevice, FOnSwitchValueLoaded, UAkGroupValue*);
  37. DECLARE_DELEGATE_OneParam(FOnSetCurrentAudioCultureCompleted, bool);
  38. /*------------------------------------------------------------------------------------
  39. Dependencies, helpers & forward declarations.
  40. ------------------------------------------------------------------------------------*/
  41. class UAkPortalComponent;
  42. class AkCallbackInfoPool;
  43. class AkLegacyFileCustomParamPolicy;
  44. class CAkDiskPackage;
  45. class FAkComponentCallbackManager;
  46. class FWwiseIOHook;
  47. class UAkComponent;
  48. class UAkGameObject;
  49. class UAkGroupValue;
  50. class UAkLateReverbComponent;
  51. class UAkRoomComponent;
  52. class UAkStateValue;
  53. class UAkSwitchValue;
  54. class UAkAudioType;
  55. class UAkAudioEvent;
  56. class UAkEffectShareSet;
  57. class AkXMLErrorMessageTranslator;
  58. class AkWAAPIErrorMessageTranslator;
  59. class AkUnrealErrorTranslator;
  60. typedef TSet<UAkComponent*> UAkComponentSet;
  61. #define DUMMY_GAMEOBJ ((AkGameObjectID)0x2)
  62. #define SOUNDATLOCATION_GAMEOBJ ((AkGameObjectID)0x3)
  63. /** Define hashing for AkGameObjectID. */
  64. template<typename ValueType, bool bInAllowDuplicateKeys>
  65. struct AkGameObjectIdKeyFuncs : TDefaultMapKeyFuncs<AkGameObjectID, ValueType, bInAllowDuplicateKeys>
  66. {
  67. static FORCEINLINE uint32 GetKeyHash(AkGameObjectID Key)
  68. {
  69. if (sizeof(Key) <= 4)
  70. {
  71. return (uint32)Key;
  72. }
  73. else
  74. {
  75. return GetTypeHash((uint64)Key);
  76. }
  77. }
  78. };
  79. struct AKAUDIO_API FAkAudioDeviceDelegates
  80. {
  81. DECLARE_MULTICAST_DELEGATE_TwoParams(FOnAkGlobalCallback, AK::IAkGlobalPluginContext*, AkGlobalCallbackLocation);
  82. };
  83. /*------------------------------------------------------------------------------------
  84. Audiokinetic audio device.
  85. ------------------------------------------------------------------------------------*/
  86. class AKAUDIO_API FAkAudioDevice final
  87. {
  88. public:
  89. UE_NONCOPYABLE(FAkAudioDevice);
  90. FAkAudioDevice() {}
  91. /**
  92. * Initializes the audio device and creates sources.
  93. *
  94. * @return true if initialization was successful, false otherwise
  95. */
  96. bool Init( void );
  97. /**
  98. * Update the audio device and calculates the cached inverse transform later
  99. * on used for spatialization.
  100. */
  101. bool Update( float DeltaTime );
  102. /**
  103. * Tears down audio device by stopping all sounds, removing all buffers,
  104. * destroying all sources, ... Called by both Destroy and ShutdownAfterError
  105. * to perform the actual tear down.
  106. */
  107. void Teardown();
  108. /**
  109. * Stops all game sounds (and possibly UI) sounds
  110. *
  111. * @param bShouldStopUISounds If true, this function will stop UI sounds as well
  112. */
  113. void StopAllSounds( bool bShouldStopUISounds = false );
  114. /**
  115. * Stops all game sounds (and possibly UI) sounds
  116. *
  117. * @param AudioContext Stop sounds associated with this Context only
  118. */
  119. void StopAllSounds(EAkAudioContext AudioContext);
  120. /**
  121. * Stop all audio associated with a scene
  122. *
  123. * @param WorldToFlush Interface of the scene to flush
  124. */
  125. void Flush(UWorld* WorldToFlush);
  126. /**
  127. * Determine if any rooms or reverb volumes have been added to World during the current frame
  128. */
  129. bool WorldSpatialAudioVolumesUpdated(UWorld* World);
  130. /**
  131. * Clears all loaded soundbanks
  132. *
  133. * @return Result from ak sound engine
  134. */
  135. AK_DEPRECATED(2022.1.0, "This method is now deprecated, please use ClearSoundBanksAndMedia.")
  136. AKRESULT ClearBanks();
  137. /**
  138. * Clears all loaded SoundBanks and associated media
  139. *
  140. * @return Result from ak sound engine
  141. */
  142. AKRESULT ClearSoundBanksAndMedia();
  143. /**
  144. * Load a soundbank by name
  145. *
  146. * @param in_BankName The name of the bank to load
  147. * @param out_bankID Returned bank ID
  148. * @return Result from ak sound engine
  149. */
  150. AKRESULT LoadBank(
  151. const FString& in_BankName,
  152. AkBankID & out_bankID
  153. );
  154. /**
  155. * Load a soundbank asynchronously
  156. *
  157. * @param in_BankName The bank to load
  158. * @param in_pfnBankCallback Callback function
  159. * @param in_pCookie Callback cookie (reserved to user, passed to the callback function)
  160. * @param out_bankID Returned bank ID
  161. * @return Result from ak sound engine
  162. */
  163. AKRESULT LoadBank(
  164. const FString& in_BankName,
  165. AkBankCallbackFunc in_pfnBankCallback,
  166. void * in_pCookie,
  167. AkBankID & out_bankID
  168. );
  169. /**
  170. * Load a soundbank asynchronously, flagging completion in the latent action
  171. *
  172. * @param in_BankName The bank to load
  173. * @param LoadBankLatentAction Blueprint Latent action to flag completion
  174. * @param out_bankID Returned bank ID
  175. * @return Result from ak sound engine
  176. */
  177. AKRESULT LoadBank(
  178. const FString& in_BankName,
  179. FWaitEndBankAction* LoadBankLatentAction
  180. );
  181. /**
  182. * Load a sound bank from a memory pointer
  183. *
  184. * @param in_MemoryPtr Pointer to the bank data
  185. * @param in_MemorySize Size of the bank data
  186. * @param out_banKID Returned bank ID
  187. */
  188. AKRESULT LoadBankFromMemory(
  189. const void* MemoryPtr,
  190. uint32 MemorySize,
  191. AkBankType BankType,
  192. AkBankID& OutBankID
  193. );
  194. /**
  195. * Load a soundbank asynchronously, using a Blueprint Delegate for completion
  196. *
  197. * @param in_BankName The bank to load
  198. * @param BankLoadedCallback Blueprint Delegate called upon completion
  199. * @param out_bankID Returned bank ID
  200. * @return Result from ak sound engine
  201. */
  202. AKRESULT LoadBankAsync(
  203. const FString& in_BankName,
  204. const FOnAkBankCallback& BankLoadedCallback,
  205. AkBankID & out_bankID
  206. );
  207. /**
  208. * Unload a soundbank by its name
  209. *
  210. * @param in_BankName The name of the bank to unload
  211. * @return Result from ak sound engine
  212. */
  213. AKRESULT UnloadBank(
  214. const FString& in_BankName
  215. );
  216. /**
  217. * Unload a soundbank asynchronously
  218. *
  219. * @param in_BankName The bank to unload
  220. * @param in_pfnBankCallback Callback function
  221. * @param in_pCookie Callback cookie (reserved to user, passed to the callback function)
  222. * @return Result from ak sound engine
  223. */
  224. AKRESULT UnloadBank(
  225. const FString& in_BankName,
  226. AkBankCallbackFunc in_pfnBankCallback,
  227. void * in_pCookie
  228. );
  229. /**
  230. * Unload a soundbank asynchronously, flagging completion in the latent action
  231. *
  232. * @param in_BankName The bank to unload
  233. * @param UnloadBankLatentAction Blueprint Latent action to flag completion
  234. * @return Result from ak sound engine
  235. */
  236. AKRESULT UnloadBank(
  237. const FString& in_BankName,
  238. FWaitEndBankAction* UnloadBankLatentAction
  239. );
  240. /**
  241. * Unload bank with bank data pointer
  242. *
  243. * @param in_bankID The BankID returned by the LoadBankFromMemory call.
  244. * @param in_memoryPtr The same bank data pointer used with th LoadBankFromMemory call.
  245. */
  246. AKRESULT UnloadBankFromMemory(
  247. AkBankID in_bankID,
  248. const void* in_memoryPtr
  249. );
  250. /**
  251. * Unload bank with bank data pointer
  252. *
  253. * @param in_bankID The BankID returned by the LoadBankFromMemory call.
  254. * @param in_memoryPtr The same bank data pointer used with th LoadBankFromMemory call.
  255. */
  256. AKRESULT UnloadBankFromMemoryAsync(
  257. AkBankID in_bankID,
  258. const void* in_memoryPtr,
  259. AkBankCallbackFunc in_pfnBankCallback,
  260. void* in_pCookie,
  261. uint32 BankType
  262. );
  263. /**
  264. * Unload a soundbank asynchronously, using a Blueprint Delegate for completion
  265. *
  266. * @param in_BankName The bank to load
  267. * @param BankUnloadedCallback Blueprint Delegate called upon completion
  268. * @param out_bankID Returned bank ID
  269. * @return Result from ak sound engine
  270. */
  271. AKRESULT UnloadBankAsync(
  272. const FString& in_BankName,
  273. const FOnAkBankCallback& BankUnloadedCallback
  274. );
  275. /**
  276. * FString-friendly GetIDFromString
  277. */
  278. static AkUInt32 GetShortIDFromString(const FString& InString);
  279. /**
  280. * NUll-check asset and if invalid return ID based on BackupName
  281. */
  282. static AkUInt32 GetShortID(UAkAudioType* AudioAsset, const FString& BackupName);
  283. /**
  284. * Indicates the location of a specific Media ID in memory.
  285. *
  286. * @param in_pSourceSettings Array of Source Settings
  287. * @param in_uNumSourceSettings Number of Source Settings in the array
  288. */
  289. AKRESULT SetMedia(AkSourceSettings* in_pSourceSettings, uint32 in_uNumSourceSettings);
  290. /**
  291. * Removes the specified source from the list of loaded media, even if this media is already in use.
  292. *
  293. * @param in_pSourceSettings Array of Source Settings
  294. * @param in_uNumSourceSettings Number of Source Settings in the array
  295. * @param out_pUnsetResults Array of AKRESULT results per Source Settings
  296. */
  297. AKRESULT TryUnsetMedia(AkSourceSettings* in_pSourceSettings, uint32 in_uNumSourceSettings, AKRESULT* out_pUnsetResults = nullptr);
  298. /**
  299. * Removes the specified source from the list of loaded media.
  300. *
  301. * @param in_pSourceSettings Array of Source Settings
  302. * @param un_uNumSourceSettings Number of Source Settings in the array
  303. */
  304. AKRESULT UnsetMedia(AkSourceSettings* in_pSourceSettings, uint32 in_uNumSourceSettings);
  305. /**
  306. * Get the currently selected audio culture
  307. */
  308. FString GetCurrentAudioCulture() const;
  309. /**
  310. * Get the default language set in the Wwise project
  311. */
  312. FString GetDefaultLanguage();
  313. /**
  314. * Get the list of available audio cultures
  315. */
  316. TArray<FString> GetAvailableAudioCultures() const;
  317. /**
  318. * Get a FWwiseSharedLanguageId from the name as set in Wwise
  319. */
  320. FWwiseLanguageCookedData GetLanguageCookedDataFromString(const FString& WwiseLanguage);
  321. /**
  322. * Change the audio culture
  323. */
  324. void SetCurrentAudioCulture(const FString& AudioCulture);
  325. /**
  326. * Change the audio culture asynchronously and signal the latent action when done
  327. */
  328. void SetCurrentAudioCultureAsync(const FString& AudioCulture, FSetCurrentAudioCultureAction* LatentAction);
  329. /**
  330. * Change the audio culture asynchronous and call the callback when done
  331. */
  332. void SetCurrentAudioCultureAsync(const FString& AudioCulture, const FOnSetCurrentAudioCultureCompleted& CompletedCallback);
  333. /**
  334. * Post an event to ak soundengine
  335. *
  336. * @warning This function is deprecated. Please see \ref UAkAudioEvent::PostOnActor.
  337. *
  338. * @param AkEvent Event to post
  339. * @param Actor Actor on which to play the event
  340. * @param Flags Bitmask: see \ref AkCallbackType
  341. * @param Callback Callback function
  342. * @param Cookie Callback cookie that will be sent to the callback function along with additional information.
  343. * @param bStopWhenOwnerDestroyed If true, then the sound should be stopped if the owning actor is destroyed
  344. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  345. * @return ID assigned by ak soundengine
  346. */
  347. AK_DEPRECATED(2022.1, "Use UAkAudioEvent::PostOnActor")
  348. AkPlayingID PostAkAudioEventOnActor(
  349. class UAkAudioEvent * AkEvent,
  350. AActor * Actor,
  351. AkUInt32 Flags = 0,
  352. AkCallbackFunc Callback = NULL,
  353. void * Cookie = NULL,
  354. bool bStopWhenOwnerDestroyed = false,
  355. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  356. );
  357. /**
  358. * Post an event to ak soundengine
  359. *
  360. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostOnComponent.
  361. *
  362. * @param AkEvent Event to post
  363. * @param Actor Actor on which to play the event
  364. * @param Flags Bitmask: see \ref AkCallbackType
  365. * @param Callback Callback function
  366. * @param Cookie Callback cookie that will be sent to the callback function along with additional information.
  367. * @param bStopWhenOwnerDestroyed If true, then the sound should be stopped if the owning actor is destroyed
  368. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  369. * @return ID assigned by ak soundengine
  370. */
  371. AkPlayingID PostAkAudioEventOnComponent(
  372. UAkAudioEvent* AkEvent,
  373. UAkComponent* Component,
  374. AkUInt32 Flags = 0,
  375. AkCallbackFunc Callback = NULL,
  376. void* Cookie = NULL,
  377. bool bStopWhenOwnerDestroyed = false,
  378. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  379. );
  380. /**
  381. * Post an event to ak soundengine by ID
  382. *
  383. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostOnActor.
  384. *
  385. * @param EventShortID ID of the event to post
  386. * @param Actor Actor on which to play the event
  387. * @param Flags Bitmask: see \ref AkCallbackType
  388. * @param Callback Callback function
  389. * @param Cookie Callback cookie that will be sent to the callback function along with additional information.
  390. * @param bStopWhenOwnerDestroyed If true, then the sound should be stopped if the owning actor is destroyed
  391. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  392. * @return ID assigned by ak soundengine
  393. */
  394. AkPlayingID PostEventOnActor(
  395. const AkUInt32 EventShortID,
  396. AActor * Actor,
  397. AkUInt32 Flags = 0,
  398. AkCallbackFunc Callback = NULL,
  399. void * Cookie = NULL,
  400. bool bStopWhenOwnerDestroyed = false,
  401. const TArray<AkExternalSourceInfo> ExternalSources = TArray<AkExternalSourceInfo>(),
  402. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  403. );
  404. /**
  405. * Post an event to ak soundengine by ID
  406. *
  407. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostOnActor.
  408. *
  409. * @param EventShortID ID of the event to post
  410. * @param Actor Actor on which to play the event
  411. * @param PostEventCallback Callback delegate
  412. * @param Flags Bitmask: see \ref EAkCallbackType
  413. * @param bStopWhenOwnerDestroyed If true, then the sound should be stopped if the owning actor is destroyed
  414. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  415. * @return ID assigned by ak soundengine
  416. */
  417. AkPlayingID PostEventOnActor(
  418. const AkUInt32 EventShortID,
  419. AActor * Actor,
  420. const FOnAkPostEventCallback& PostEventCallback,
  421. AkUInt32 Flags = 0,
  422. bool bStopWhenOwnerDestroyed = false,
  423. const TArray<AkExternalSourceInfo>& ExternalSources = TArray<AkExternalSourceInfo>(),
  424. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  425. );
  426. /**
  427. * Post an event to ak soundengine by ID
  428. *
  429. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostOnGameObjectID.
  430. *
  431. * @param EventShortID ID of the event to post
  432. * @param Actor Actor on which to play the event
  433. * @param Flags Bitmask: see \ref AkCallbackType
  434. * @param Callback Callback function
  435. * @param Cookie Callback cookie that will be sent to the callback function along with additional information.
  436. * @param bStopWhenOwnerDestroyed If true, then the sound should be stopped if the owning actor is destroyed
  437. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  438. * @return ID assigned by ak soundengine
  439. */
  440. AkPlayingID PostEventOnGameObjectID(
  441. const AkUInt32 EventShortID,
  442. AkGameObjectID GameObject,
  443. AkUInt32 Flags /*= 0*/,
  444. AkCallbackFunc Callback /*= NULL*/,
  445. void* Cookie,
  446. /*= NULL*/
  447. const TArray<AkExternalSourceInfo>& ExternalSources, /*= TArray<AkExternalSourceInfo>()*/
  448. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  449. );
  450. /**
  451. * Post an event to ak soundengine by ID
  452. *
  453. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostOnActor.
  454. *
  455. * @param EventShortID ID of the event to post
  456. * @param Actor Actor on which to play the event
  457. * @param bStopWhenOwnerDestroyed If true, then the sound should be stopped if the owning actor is destroyed
  458. * @param LatentAction Pointer to a Blueprint latent action.Used in the EndOfEvent callback.
  459. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  460. * @return ID assigned by ak soundengine
  461. */
  462. AkPlayingID PostEventOnActorWithLatentAction(
  463. const AkUInt32 EventShortID,
  464. AActor * Actor,
  465. bool bStopWhenOwnerDestroyed,
  466. FWaitEndOfEventAction* LatentAction,
  467. const TArray<AkExternalSourceInfo>& ExternalSources = TArray<AkExternalSourceInfo>(),
  468. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  469. );
  470. /**
  471. * Post an event to ak soundengine by name
  472. *
  473. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostOnComponent.
  474. *
  475. * @param EventShortID ID of the event to post
  476. * @param AkComponent AkComponent on which to play the event
  477. * @param LatentAction Pointer to a Blueprint latent action. Used in the EndOfEvent callback.
  478. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  479. * @return ID assigned by ak soundengine
  480. */
  481. AkPlayingID PostEventOnComponentWithLatentAction(
  482. const AkUInt32 EventShortID,
  483. UAkComponent* AkComponent,
  484. FWaitEndOfEventAction* LatentAction,
  485. const TArray<AkExternalSourceInfo>& ExternalSources = TArray<AkExternalSourceInfo>(),
  486. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  487. );
  488. /**
  489. * Post an event to ak soundengine by ID
  490. *
  491. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostOnComponent.
  492. *
  493. * @param EventShortID ID of the event to post
  494. * @param Component AkComponent on which to play the event
  495. * @param Flags Bitmask: see \ref AkCallbackType
  496. * @param Callback Callback function
  497. * @param Cookie Callback cookie that will be sent to the callback function along with additional information.
  498. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  499. * @return ID assigned by ak soundengine
  500. */
  501. AkPlayingID PostEventOnAkComponent(
  502. const AkUInt32 EventShortID,
  503. UAkComponent* Component,
  504. AkUInt32 Flags = 0,
  505. AkCallbackFunc Callback = NULL,
  506. void * Cookie = NULL,
  507. const TArray<AkExternalSourceInfo>& ExternalSources = TArray<AkExternalSourceInfo>(),
  508. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  509. );
  510. /**
  511. * Post an event to ak soundengine by ID
  512. *
  513. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostOnGameObject.
  514. *
  515. * @param EventShortID ID of the event to post
  516. * @param AkGameObject UAkGameObject on which to play the event
  517. * @param PostEventCallback Callback delegate
  518. * @param Flags Bitmask: see \ref EAkCallbackType
  519. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  520. * @return ID assigned by ak soundengine
  521. */
  522. AkPlayingID PostEventOnAkGameObject(
  523. const AkUInt32 EventShortID,
  524. UAkGameObject* AkGameObject,
  525. const FOnAkPostEventCallback& PostEventCallback,
  526. AkUInt32 Flags = 0,
  527. const TArray<AkExternalSourceInfo>& ExternalSources = TArray<AkExternalSourceInfo>(),
  528. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  529. );
  530. /**
  531. * Post an event at location to ak soundengine
  532. *
  533. * @warning This function is deprecated. Please see \ref UAkAudioEvent::PostAtLocation.
  534. *
  535. * @param Event Event to post
  536. * @param Location Location at which to play the event
  537. * @param Orientation
  538. * @param World
  539. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  540. * @return ID assigned by ak soundengine
  541. */
  542. AK_DEPRECATED(2022.1, "Use UAkAudioEvent::PostAtLocation")
  543. AkPlayingID PostAkAudioEventAtLocation(
  544. UAkAudioEvent* Event,
  545. FVector Location,
  546. FRotator Orientation,
  547. UWorld* World,
  548. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  549. );
  550. /**
  551. * Post an event by name at location to ak soundengine
  552. *
  553. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostAtLocation.
  554. *
  555. * @param EventName Name of the event to post (Used to register the game object)
  556. * @param EventShortID ID of the event to post
  557. * @param Location Location at which to play the event
  558. * @param Orientation
  559. * @param World
  560. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  561. * @return ID assigned by ak soundengine
  562. */
  563. AkPlayingID PostEventAtLocation(
  564. const FString& EventName,
  565. const AkUInt32 EventShortID,
  566. FVector Location,
  567. FRotator Orientation,
  568. UWorld* World,
  569. const TArray<AkExternalSourceInfo>& ExternalSources = TArray<AkExternalSourceInfo>(),
  570. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  571. );
  572. /**
  573. * Post an event at location to ak soundengine
  574. *
  575. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostAtLocation.
  576. * Async operations are deprecated.
  577. *
  578. * @param Event Event to post
  579. * @param Location Location at which to play the event
  580. * @param Orientation
  581. * @param World
  582. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  583. * @return ID assigned by ak soundengine
  584. */
  585. TFuture<AkPlayingID> PostAkAudioEventAtLocationAsync(
  586. UAkAudioEvent* Event,
  587. FVector Location,
  588. FRotator Orientation,
  589. UWorld* World,
  590. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  591. );
  592. /**
  593. * Wait for event asset to be fully loaded and then post the event to ak soundengine
  594. *
  595. * @warning This function is deprecated. Please see \ref UAkAudioEvent::PostOnActor.
  596. * Async operations are deprecated.
  597. *
  598. * @param AudioEvent The event to post
  599. * @param Actor Actor on which to play the event
  600. * @param PostEventCallback Callback function
  601. * @param CallbackFlags Bitmask: see \ref AkCallbackType
  602. * @param bStopWhenOwnerDestroyed If true, then the sound should be stopped if the owning actor is destroyed
  603. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  604. * @return ID assigned by ak soundengine
  605. */
  606. TFuture<AkPlayingID> PostAkAudioEventOnActorAsync(
  607. class UAkAudioEvent* AudioEvent,
  608. AActor* Actor,
  609. const FOnAkPostEventCallback& PostEventCallback,
  610. AkUInt32 CallbackFlags = 0,
  611. bool bStopWhenOwnerDestroyed = false,
  612. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  613. );
  614. /**
  615. * Wait for event asset to be fully loaded and then post the event to ak soundengine
  616. *
  617. * @warning This function is deprecated. Please see \ref UAkAudioEvent::PostOnAkGameObject.
  618. * Async operations are deprecated.
  619. *
  620. * @param AudioEvent The event to post
  621. * @param GameObject UAkGameObject on which to play the event
  622. * @param PostEventCallback Callback delegate
  623. * @param CallbackFlags Bitmask: see \ref EAkCallbackType
  624. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  625. * @return ID assigned by ak soundengine
  626. */
  627. TFuture<AkPlayingID> PostAkAudioEventOnAkGameObjectAsync(
  628. class UAkAudioEvent* AudioEvent,
  629. UAkGameObject* GameObject,
  630. const FOnAkPostEventCallback& PostEventCallback,
  631. AkUInt32 CallbackFlags = 0,
  632. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  633. );
  634. /**
  635. * Post an event to ak soundengine
  636. *
  637. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostOnActor.
  638. * Async operations are deprecated.
  639. *
  640. * @param AudioEvent The event to post
  641. * @param Actor Actor on which to play the event
  642. * @param bStopWhenOwnerDestroyed If true, then the sound should be stopped if the owning actor is destroyed
  643. * @param LatentAction Pointer to a Blueprint latent action. Used in the EndOfEvent callback.
  644. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  645. * @return ID assigned by ak soundengine
  646. */
  647. TFuture<AkPlayingID> PostAkAudioEventWithLatentActionOnActorAsync(
  648. class UAkAudioEvent* AudioEvent,
  649. AActor* Actor,
  650. bool bStopWhenOwnerDestroyed,
  651. FWaitEndOfEventAction* LatentAction,
  652. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  653. );
  654. /**
  655. * Post an event to ak soundengine
  656. *
  657. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::PostOnComponent.
  658. * Async operations are deprecated.
  659. *
  660. * @param AudioEvent The event to post
  661. * @param AkComponent AkComponent on which to play the event
  662. * @param bStopWhenOwnerDestroyed If true, then the sound should be stopped if the owning actor is destroyed
  663. * @param LatentAction Pointer to a Blueprint latent action.Used in the EndOfEvent callback.
  664. * @param AudioContext Context in which sound is played. Only gameplay sounds are affected by PIE pause/stop
  665. * @return ID assigned by ak soundengine
  666. */
  667. TFuture<AkPlayingID> PostAkAudioEventWithLatentActionOnAkComponentAsync(
  668. class UAkAudioEvent* AudioEvent,
  669. UAkComponent* AkComponent,
  670. bool bStopWhenOwnerDestroyed,
  671. FWaitEndOfEventAction* LatentAction,
  672. EAkAudioContext AudioContext = EAkAudioContext::GameplayAudio
  673. );
  674. /** Spawn an AkComponent at a location. Allows, for example, to set a switch on a fire and forget sound.
  675. * @param AkEvent - Wwise Event to post.
  676. * @param Location - Location from which to post the Wwise Event.
  677. * @param Orientation - Orientation of the event.
  678. * @param AutoPost - Automatically post the event once the AkComponent is created.
  679. * @param EarlyReflectionsBusName - Use the provided auxiliary bus to process early reflections. If empty, no early reflections will be processed.
  680. * @param AutoDestroy - Automatically destroy the AkComponent once the event is finished.
  681. */
  682. class UAkComponent* SpawnAkComponentAtLocation( class UAkAudioEvent* AkEvent, FVector Location, FRotator Orientation, bool AutoPost, const FString& EventName, bool AutoDestroy, class UWorld* in_World );
  683. /**
  684. * Executes an action on all nodes that are referenced in the specified event in an action of type play.
  685. *
  686. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::ExecuteAction.
  687. *
  688. * @param EventShortID ID of the event to post
  689. * @param ActionType Action to execute on all the elements that were played using the specified event.
  690. * @param Actor Associated actor
  691. * @param TransitionDuration Fade duration
  692. * @param FadeCurve Curve type to be used for the transition
  693. * @param PlayingID Associated PlayingID
  694. */
  695. AKRESULT ExecuteActionOnEvent(
  696. const AkUInt32 EventShortID,
  697. AkActionOnEventType ActionType,
  698. AActor* Actor,
  699. AkTimeMs TransitionDuration = 0,
  700. EAkCurveInterpolation FadeCurve = EAkCurveInterpolation::Linear,
  701. AkPlayingID PlayingID = AK_INVALID_PLAYING_ID
  702. );
  703. /**
  704. *
  705. * @warning This function is deprecated. You are expected to use an UAkAudioEvent. Please see \ref UAkAudioEvent::ExecuteAction.
  706. *
  707. * Executes an Action on the content associated to the specified playing ID.
  708. * @param in_ActionType Action to execute on the specified playing ID.
  709. * @param in_PlayingID Playing ID on which to execute the action.
  710. * @param in_uTransitionDuration Fade duration
  711. * @param in_eFadeCurve Curve type to be used for the transition
  712. */
  713. void ExecuteActionOnPlayingID(
  714. AkActionOnEventType in_ActionType,
  715. AkPlayingID in_PlayingID,
  716. AkTimeMs in_uTransitionDuration = 0,
  717. EAkCurveInterpolation in_eFadeCuve = EAkCurveInterpolation::Linear
  718. );
  719. /** Seek on an event in the ak soundengine.
  720. * @param EventShortID ID of the event on which to seek.
  721. * @param Component The associated Actor.
  722. * @param Position Desired percent where playback should restart.
  723. * @param bSeekToNearestMarker If true, the final seeking position will be made equal to the nearest marker.
  724. *
  725. * @return Success or failure.
  726. */
  727. AKRESULT SeekOnEvent(
  728. const AkUInt32 EventShortID,
  729. AActor* Actor,
  730. AkReal32 Percent,
  731. bool bSeekToNearestMarker = false,
  732. AkPlayingID PlayingID = AK_INVALID_PLAYING_ID
  733. );
  734. /** Seek on an event in the ak soundengine.
  735. * @param EventShortID ID of the event on which to seek.
  736. * @param Component The associated AkComponent.
  737. * @param Percent Desired percent where playback should restart.
  738. * @param bSeekToNearestMarker If true, the final seeking position will be made equal to the nearest marker.
  739. *
  740. * @return Success or failure.
  741. */
  742. AKRESULT SeekOnEvent(
  743. const AkUInt32 EventShortID,
  744. UAkComponent* Component,
  745. AkReal32 Percent,
  746. bool bSeekToNearestMarker = false,
  747. AkPlayingID PlayingID = AK_INVALID_PLAYING_ID
  748. );
  749. /**
  750. * Post a trigger to ak soundengine
  751. *
  752. * @param in_pszTrigger Name of the trigger
  753. * @param in_pAkComponent AkComponent on which to post the trigger
  754. * @return Result from ak sound engine
  755. */
  756. AKRESULT PostTrigger(
  757. const TCHAR * in_pszTrigger,
  758. AActor * in_pActor
  759. );
  760. /**
  761. * Post a trigger to ak soundengine
  762. *
  763. * @param in_TriggerValue Trigger value
  764. * @param in_pAkComponent AkComponent on which to post the trigger
  765. * @return Result from ak sound engine
  766. */
  767. AKRESULT PostTrigger(
  768. class UAkTrigger const* in_TriggerValue,
  769. AActor * in_pActor
  770. );
  771. /**
  772. * Set a RTPC in ak soundengine
  773. *
  774. * @param in_pszRtpcName Name of the RTPC
  775. * @param in_value Value to set
  776. * @param in_interpolationTimeMs - Duration during which the RTPC is interpolated towards in_value (in ms)
  777. * @param in_pActor AActor on which to set the RTPC
  778. * @return Result from ak sound engine
  779. */
  780. AKRESULT SetRTPCValue(
  781. const TCHAR * in_pszRtpcName,
  782. AkRtpcValue in_value,
  783. int32 in_interpolationTimeMs,
  784. AActor * in_pActor
  785. );
  786. /**
  787. * Set a RTPC in ak soundengine
  788. *
  789. * @param in_Rtpc RTPC Short ID
  790. * @param in_value Value to set
  791. * @param in_interpolationTimeMs - Duration during which the RTPC is interpolated towards in_value (in ms)
  792. * @param in_pActor AActor on which to set the RTPC
  793. * @return Result from ak sound engine
  794. */
  795. AKRESULT SetRTPCValue(
  796. AkRtpcID in_Rtpc,
  797. AkRtpcValue in_value,
  798. int32 in_interpolationTimeMs,
  799. AActor * in_pActor
  800. );
  801. /**
  802. * Set a RTPC in ak soundengine
  803. *
  804. * @param in_RtpcValue RTPC Value
  805. * @param in_value Value to set
  806. * @param in_interpolationTimeMs - Duration during which the RTPC is interpolated towards in_value (in ms)
  807. * @param in_pActor AActor on which to set the RTPC
  808. * @return Result from ak sound engine
  809. */
  810. AKRESULT SetRTPCValue(
  811. class UAkRtpc const* in_RtpcValue,
  812. AkRtpcValue in_value,
  813. int32 in_interpolationTimeMs,
  814. AActor * in_pActor
  815. );
  816. /**
  817. * Set a RTPC in ak soundengine by PlayingID
  818. *
  819. * @param in_Rtpc RTPC Short ID
  820. * @param in_value Value to set
  821. * @param in_playingID PlayingID on which to set the value
  822. * @param in_interpolationTimeMs - Duration during which the RTPC is interpolated towards in_value (in ms)
  823. * @return Result from ak sound engine
  824. */
  825. AKRESULT SetRTPCValueByPlayingID(
  826. AkRtpcID in_Rtpc,
  827. AkRtpcValue in_value,
  828. AkPlayingID in_playingID,
  829. int32 in_interpolationTimeMs
  830. );
  831. /**
  832. * Get the value of a real-time parameter control (by ID)
  833. * An RTPC can have a any combination of a global value, a unique value for each game object, or a unique value for each playing ID.
  834. * The value requested is determined by RTPCValue_type, in_gameObjectID and in_playingID.
  835. * If a value at the requested scope (determined by RTPCValue_type) is not found, the value that is available at the the next broadest scope will be returned, and io_rValueType will be changed to indicate this.
  836. * @note
  837. * When looking up RTPC values via playing ID (ie. io_rValueType is RTPC_PlayingID), in_gameObjectID can be set to a specific game object (if it is available to the caller) to use as a fall back value.
  838. * If the game object is unknown or unavailable, AK_INVALID_GAME_OBJECT can be passed in in_gameObjectID, and the game object will be looked up via in_playingID.
  839. * However in this case, it is not possible to retrieve a game object value as a fall back value if the playing id does not exist. It is best to pass in the game object if possible.
  840. *
  841. * @return AK_Success if succeeded, AK_IDNotFound if the game object was not registered, or AK_Fail if the RTPC value could not be obtained
  842. */
  843. AKRESULT GetRTPCValue(
  844. const TCHAR * in_pszRtpcName,
  845. AkGameObjectID in_gameObjectID, ///< Associated game object ID, ignored if io_rValueType is RTPCValue_Global.
  846. AkPlayingID in_playingID, ///< Associated playing ID, ignored if io_rValueType is not RTPC_PlayingID.
  847. AkRtpcValue& out_rValue, ///< Value returned
  848. AK::SoundEngine::Query::RTPCValue_type& io_rValueType ///< In/Out value, the user must specify the requested type. The function will return in this variable the type of the returned value. );
  849. );
  850. /**
  851. * Get the value of a real-time parameter control (by ID)
  852. * An RTPC can have a any combination of a global value, a unique value for each game object, or a unique value for each playing ID.
  853. * The value requested is determined by RTPCValue_type, in_gameObjectID and in_playingID.
  854. * If a value at the requested scope (determined by RTPCValue_type) is not found, the value that is available at the the next broadest scope will be returned, and io_rValueType will be changed to indicate this.
  855. * @note
  856. * When looking up RTPC values via playing ID (ie. io_rValueType is RTPC_PlayingID), in_gameObjectID can be set to a specific game object (if it is available to the caller) to use as a fall back value.
  857. * If the game object is unknown or unavailable, AK_INVALID_GAME_OBJECT can be passed in in_gameObjectID, and the game object will be looked up via in_playingID.
  858. * However in this case, it is not possible to retrieve a game object value as a fall back value if the playing id does not exist. It is best to pass in the game object if possible.
  859. *
  860. * @return AK_Success if succeeded, AK_IDNotFound if the game object was not registered, or AK_Fail if the RTPC value could not be obtained
  861. */
  862. AKRESULT GetRTPCValue(
  863. AkRtpcID in_Rtpc,
  864. AkGameObjectID in_gameObjectID, ///< Associated game object ID, ignored if io_rValueType is RTPCValue_Global.
  865. AkPlayingID in_playingID, ///< Associated playing ID, ignored if io_rValueType is not RTPC_PlayingID.
  866. AkRtpcValue& out_rValue, ///< Value returned
  867. AK::SoundEngine::Query::RTPCValue_type& io_rValueType ///< In/Out value, the user must specify the requested type. The function will return in this variable the type of the returned value. );
  868. );
  869. /**
  870. * Get the value of a real-time parameter control (by ID)
  871. * An RTPC can have a any combination of a global value, a unique value for each game object, or a unique value for each playing ID.
  872. * The value requested is determined by RTPCValue_type, in_gameObjectID and in_playingID.
  873. * If a value at the requested scope (determined by RTPCValue_type) is not found, the value that is available at the the next broadest scope will be returned, and io_rValueType will be changed to indicate this.
  874. * @note
  875. * When looking up RTPC values via playing ID (ie. io_rValueType is RTPC_PlayingID), in_gameObjectID can be set to a specific game object (if it is available to the caller) to use as a fall back value.
  876. * If the game object is unknown or unavailable, AK_INVALID_GAME_OBJECT can be passed in in_gameObjectID, and the game object will be looked up via in_playingID.
  877. * However in this case, it is not possible to retrieve a game object value as a fall back value if the playing id does not exist. It is best to pass in the game object if possible.
  878. *
  879. * @return AK_Success if succeeded, AK_IDNotFound if the game object was not registered, or AK_Fail if the RTPC value could not be obtained
  880. */
  881. AKRESULT GetRTPCValue(
  882. class UAkRtpc const* in_RtpcValue,
  883. AkGameObjectID in_gameObjectID, ///< Associated game object ID, ignored if io_rValueType is RTPCValue_Global.
  884. AkPlayingID in_playingID, ///< Associated playing ID, ignored if io_rValueType is not RTPC_PlayingID.
  885. AkRtpcValue& out_rValue, ///< Value returned
  886. AK::SoundEngine::Query::RTPCValue_type& io_rValueType ///< In/Out value, the user must specify the requested type. The function will return in this variable the type of the returned value. );
  887. );
  888. /// Resets the value of the game parameter to its default value, as specified in the Wwise project.
  889. /// With this function, you may reset a game parameter to its default value with global scope or with game object scope.
  890. /// Game object scope supersedes global scope. Game parameter values reset with global scope are applied to all
  891. /// game objects that were not overridden with a value with game object scope.
  892. /// To reset a game parameter value with global scope, pass AK_INVALID_GAME_OBJECT as the game object.
  893. /// With this function, you may also reset the value of a game parameter over time. To do so, specify a non-zero
  894. /// value for in_interpolationTimeMs. At each audio frame, the game parameter value will be updated internally
  895. /// according to the interpolation curve. If you call SetRTPCValue() or ResetRTPCValue() with in_interpolationTimeMs = 0 in the
  896. /// middle of an interpolation, the interpolation stops and the new value is set directly.
  897. AKRESULT ResetRTPCValue(
  898. const UAkRtpc* in_RtpcValue,
  899. AkGameObjectID in_gameObjectID,
  900. int32 in_interpolationTimeMs
  901. );
  902. /// Resets the value of the game parameter to its default value, as specified in the Wwise project.
  903. /// With this function, you may reset a game parameter to its default value with global scope or with game object scope.
  904. /// Game object scope supersedes global scope. Game parameter values reset with global scope are applied to all
  905. /// game objects that were not overridden with a value with game object scope.
  906. /// To reset a game parameter value with global scope, pass AK_INVALID_GAME_OBJECT as the game object.
  907. /// With this function, you may also reset the value of a game parameter over time. To do so, specify a non-zero
  908. /// value for in_interpolationTimeMs. At each audio frame, the game parameter value will be updated internally
  909. /// according to the interpolation curve. If you call SetRTPCValue() or ResetRTPCValue() with in_interpolationTimeMs = 0 in the
  910. /// middle of an interpolation, the interpolation stops and the new value is set directly.
  911. AKRESULT ResetRTPCValue(
  912. AkRtpcID in_rtpcID, ///< ID of the game parameter
  913. AkGameObjectID in_gameObjectID, ///< Associated game object ID
  914. int32 in_interpolationTimeMs ///< Duration during which the game parameter is interpolated towards its default value
  915. );
  916. /// Resets the value of the game parameter to its default value, as specified in the Wwise project.
  917. /// With this function, you may reset a game parameter to its default value with global scope or with game object scope.
  918. /// Game object scope supersedes global scope. Game parameter values reset with global scope are applied to all
  919. /// game objects that were not overridden with a value with game object scope.
  920. /// To reset a game parameter value with global scope, pass AK_INVALID_GAME_OBJECT as the game object.
  921. /// With this function, you may also reset the value of a game parameter over time. To do so, specify a non-zero
  922. /// value for in_interpolationTimeMs. At each audio frame, the game parameter value will be updated internally
  923. /// according to the interpolation curve. If you call SetRTPCValue() or ResetRTPCValue() with in_interpolationTimeMs = 0 in the
  924. /// middle of an interpolation, the interpolation stops and the new value is set directly.
  925. AKRESULT ResetRTPCValue(
  926. const TCHAR * in_pszRtpcName, ///< Name of the game parameter
  927. AkGameObjectID in_gameObjectID, ///< Associated game object ID
  928. int32 in_interpolationTimeMs ///< Duration during which the game parameter is interpolated towards its default value
  929. );
  930. /**
  931. * Set a state in ak soundengine
  932. *
  933. * @param in_pszStateGroup Name of the state group
  934. * @param in_pszState Name of the state
  935. * @return Result from ak sound engine
  936. */
  937. AKRESULT SetState(
  938. const TCHAR* in_pszStateGroup,
  939. const TCHAR* in_pszState
  940. );
  941. /**
  942. * Set a state in ak soundengine
  943. *
  944. * @param in_StateGroup State group short ID
  945. * @param in_State State short ID
  946. * @return Result from ak sound engine
  947. */
  948. AKRESULT SetState(
  949. AkStateGroupID in_StateGroup,
  950. AkStateID in_State
  951. );
  952. /**
  953. * Set a state in ak soundengine
  954. *
  955. * @param in_stateValue State to set
  956. * @return Result from ak sound engine
  957. */
  958. AKRESULT SetState(
  959. const UAkStateValue* in_stateValue
  960. );
  961. /**
  962. * Set a switch in ak soundengine
  963. *
  964. * @param in_pszSwitchGroup Name of the switch group
  965. * @param in_pszSwitchState Name of the switch
  966. * @param in_pComponent AkComponent on which to set the switch
  967. * @return Result from ak sound engine
  968. */
  969. AKRESULT SetSwitch(
  970. const TCHAR * in_pszSwitchGroup,
  971. const TCHAR * in_pszSwitchState,
  972. AActor * in_pActor
  973. );
  974. /**
  975. * Set a switch in ak soundengine
  976. *
  977. * @param in_SwitchGroup Short ID of the switch group
  978. * @param in_SwitchState Short ID of the switch
  979. * @param in_pComponent AkComponent on which to set the switch
  980. * @return Result from ak sound engine
  981. */
  982. AKRESULT SetSwitch(
  983. AkSwitchGroupID in_SwitchGroup,
  984. AkSwitchStateID in_SwitchState,
  985. AActor* in_pActor
  986. );
  987. /**
  988. * Set a switch in ak soundengine
  989. *
  990. * @param in_switchValue Switch to set
  991. * @param in_pActor AkActor on which to set the switch
  992. * @return Result from ak sound engine
  993. */
  994. AKRESULT SetSwitch(
  995. const UAkSwitchValue* in_switchValue,
  996. AActor * in_pActor
  997. );
  998. /** Sets multiple positions to a single game object.
  999. * Setting multiple positions on a single game object is a way to simulate multiple emission sources while using the resources of only one voice.
  1000. * This can be used to simulate wall openings, area sounds, or multiple objects emitting the same sound in the same area.
  1001. * Note: Calling AK::SoundEngine::SetMultiplePositions() with only one position is the same as calling AK::SoundEngine::SetPosition()
  1002. * @param in_pGameObjectAkComponent UAkComponent of the game object.
  1003. * @param in_aPositions Array of positions to apply.
  1004. * @param in_eMultiPositionType Position type
  1005. * @return AK_Success when successful, AK_InvalidParameter if parameters are not valid.
  1006. */
  1007. AKRESULT SetMultiplePositions(
  1008. UAkComponent* in_pGameObjectAkComponent,
  1009. TArray<FTransform> in_aPositions,
  1010. AkMultiPositionType in_eMultiPositionType = AkMultiPositionType::MultiDirections
  1011. );
  1012. /** Sets multiple positions to a single game object, with flexible assignment of input channels.
  1013. * Setting multiple positions on a single game object is a way to simulate multiple emission sources while using the resources of only one voice.
  1014. * This can be used to simulate wall openings, area sounds, or multiple objects emitting the same sound in the same area.
  1015. * Note: Calling AK::SoundEngine::SetMultiplePositions() with only one position is the same as calling AK::SoundEngine::SetPosition()
  1016. * @param in_pGameObjectAkComponent Game Object AkComponent.
  1017. * @param in_aChannelConfigurations Array of channel configurations for each position.
  1018. * @param in_pPositions Array of positions to apply.
  1019. * @param in_eMultiPositionType Position type
  1020. * @return AK_Success when successful, AK_InvalidParameter if parameters are not valid.
  1021. */
  1022. AKRESULT SetMultiplePositions(
  1023. UAkComponent* in_pGameObjectAkComponent,
  1024. const TArray<AkChannelConfiguration>& in_aChannelConfigurations,
  1025. const TArray<FTransform>& in_aPositions,
  1026. AkMultiPositionType in_eMultiPositionType = AkMultiPositionType::MultiDirections
  1027. );
  1028. /** Sets multiple positions to a single game object, with flexible assignment of input channels.
  1029. * Setting multiple positions on a single game object is a way to simulate multiple emission sources while using the resources of only one voice.
  1030. * This can be used to simulate wall openings, area sounds, or multiple objects emitting the same sound in the same area.
  1031. * Note: Calling AK::SoundEngine::SetMultiplePositions() with only one position is the same as calling AK::SoundEngine::SetPosition()
  1032. * @param in_pGameObjectAkComponent Game Object AkComponent.
  1033. * @param in_channelMasks Array of channel mask for each position.
  1034. * @param in_pPositions Array of positions to apply.
  1035. * @param in_eMultiPositionType Position type
  1036. * @return AK_Success when successful, AK_InvalidParameter if parameters are not valid.
  1037. */
  1038. AKRESULT SetMultiplePositions(
  1039. UAkComponent* in_pGameObjectAkComponent,
  1040. const TArray<FAkChannelMask>& in_channelMasks,
  1041. const TArray<FTransform>& in_aPositions,
  1042. AkMultiPositionType in_eMultiPositionType = AkMultiPositionType::MultiDirections
  1043. );
  1044. /** Sets multiple positions to a single game object.
  1045. * Setting multiple positions on a single game object is a way to simulate multiple emission sources while using the resources of only one voice.
  1046. * This can be used to simulate wall openings, area sounds, or multiple objects emitting the same sound in the same area.
  1047. * Note: Calling AK::SoundEngine::SetMultiplePositions() with only one position is the same as calling AK::SoundEngine::SetPosition()
  1048. * @param in_GameObjectID Game Object identifier.
  1049. * @param in_pPositions Array of positions to apply.
  1050. * @param in_NumPositions Number of positions specified in the provided array.
  1051. * @param in_eMultiPositionType Position type
  1052. * @return AK_Success when successful, AK_InvalidParameter if parameters are not valid.
  1053. *
  1054. */
  1055. AKRESULT SetMultiplePositions(
  1056. AkGameObjectID in_GameObjectID,
  1057. const AkSoundPosition * in_pPositions,
  1058. AkUInt16 in_NumPositions,
  1059. AK::SoundEngine::MultiPositionType in_eMultiPositionType = AK::SoundEngine::MultiPositionType_MultiDirections
  1060. );
  1061. /** Sets multiple positions to a single game object, with flexible assignment of input channels.
  1062. * Setting multiple positions on a single game object is a way to simulate multiple emission sources while using the resources of only one voice.
  1063. * This can be used to simulate wall openings, area sounds, or multiple objects emitting the same sound in the same area.
  1064. * Note: Calling AK::SoundEngine::SetMultiplePositions() with only one position is the same as calling AK::SoundEngine::SetPosition()
  1065. * @param in_GameObjectID Game Object identifier.
  1066. * @param in_pPositions Array of positions to apply.
  1067. * @param in_NumPositions Number of positions specified in the provided array.
  1068. * @param in_eMultiPositionType Position type
  1069. * @return AK_Success when successful, AK_InvalidParameter if parameters are not valid.
  1070. */
  1071. AKRESULT SetMultiplePositions(
  1072. AkGameObjectID in_GameObjectID,
  1073. const AkChannelEmitter * in_pPositions,
  1074. AkUInt16 in_NumPositions,
  1075. AK::SoundEngine::MultiPositionType in_eMultiPositionType = AK::SoundEngine::MultiPositionType_MultiDirections
  1076. );
  1077. /**
  1078. * Set auxiliary sends
  1079. *
  1080. * @param in_GameObjId Wwise Game Object ID
  1081. * @param in_AuxSendValues Array of AkAuxSendValue, containing all Aux Sends to set on the game object
  1082. * @return Result from ak sound engine
  1083. */
  1084. AKRESULT SetAuxSends(
  1085. const UAkComponent* in_akComponent,
  1086. TArray<AkAuxSendValue>& in_AuxSendValues
  1087. );
  1088. /**
  1089. * Set spatial audio room
  1090. *
  1091. * @param in_GameObjId Wwise Game Object ID
  1092. * @param in_RoomID ID of the room that the game object is inside.
  1093. * @return Result from ak sound engine
  1094. */
  1095. AKRESULT SetInSpatialAudioRoom(
  1096. const AkGameObjectID in_GameObjId,
  1097. AkRoomID in_RoomID
  1098. );
  1099. /**
  1100. * Force channel configuration for the specified bus.
  1101. * This function has unspecified behavior when changing the configuration of a bus that
  1102. * is currently playing.
  1103. * You cannot change the configuration of the master bus.
  1104. *
  1105. * @param in_BusName Bus Name
  1106. * @param in_Config Desired channel configuration. An invalid configuration (from default constructor) means "as parent".
  1107. * @return Always returns AK_Success
  1108. */
  1109. AKRESULT SetBusConfig(
  1110. const FString& in_BusName,
  1111. AkChannelConfig in_Config
  1112. );
  1113. /**
  1114. * Set the panning rule of the specified output.
  1115. * This may be changed anytime once the sound engine is initialized.
  1116. * \warning This function posts a message through the sound engine's internal message queue, whereas GetPanningRule() queries the current panning rule directly.
  1117. */
  1118. AKRESULT SetPanningRule(
  1119. AkPanningRule in_ePanningRule ///< Panning rule.
  1120. );
  1121. /**
  1122. * Gets the compounded output ID from ShareSet and device id.
  1123. * Outputs are defined by their type (Audio Device ShareSet) and their specific system ID.
  1124. * A system ID could be reused for other device types on some OS or platforms, hence the compounded ID.
  1125. *
  1126. * @param in_szShareSet Audio Device ShareSet Name, as defined in the Wwise Project. If Null, will select the Default Output ShareSet (always available)
  1127. * @param in_idDevice Device specific identifier, when multiple devices of the same type are possible. If only one device is possible, leave to 0.
  1128. * @return The id of the output
  1129. */
  1130. AkOutputDeviceID GetOutputID(
  1131. const FString& in_szShareSet,
  1132. AkUInt32 in_idDevice = 0
  1133. );
  1134. /**
  1135. * Replaces the main output device previously created during engine initialization with a new output device.
  1136. * In addition to simply removing one output device and adding a new one, the new output device will also be used on all of the master busses
  1137. * that the old output device was associated with, and preserve all listeners that were attached to the old output device.
  1138. *
  1139. * @param MainOutputSettings Creation parameters for this output
  1140. *
  1141. * @return
  1142. * - AK_InvalidID: The audioDeviceShareSet on in_settings was not valid.
  1143. * - AK_IDNotFound: The audioDeviceShareSet on in_settings doesn't exist. Possibly, the Init bank isn't loaded yet or was not updated with latest changes.
  1144. * - AK_DeviceNotReady: The idDevice on in_settings doesn't match with a valid hardware device. Either the device doesn't exist or is disabled. Disconnected devices (headphones) are not considered "not ready" therefore won't cause this error.
  1145. * - AK_DeviceNotFound: The in_outputDeviceId provided does not match with any of the output devices that the sound engine is currently using.
  1146. * - AK_InvalidParameter: Out of range parameters or unsupported parameter combinations on in_settings
  1147. * - AK_Success: parameters were valid, and the remove and add will occur.
  1148. */
  1149. AKRESULT ReplaceMainOutput(const AkOutputSettings& MainOutputSettings);
  1150. /**
  1151. * Gets speaker angles of the specified device. Speaker angles are used for 3D positioning of sounds over standard configurations.
  1152. * Note that the current version of Wwise only supports positioning on the plane.
  1153. * The speaker angles are expressed as an array of loudspeaker pairs, in degrees, relative to azimuth ]0,180].
  1154. * Supported loudspeaker setups are always symmetric; the center speaker is always in the middle and thus not specified by angles.
  1155. * Angles must be set in ascending order.
  1156. * Typical usage:
  1157. * - AkReal32 heightAngle;
  1158. * - TArray<AkReal32> speakerAngles;
  1159. * - GetSpeakerAngles(speakerAngles, heightAngle, AkOutput_Main );
  1160. * \aknote
  1161. * On most platforms, the angle set on the plane consists of 3 angles, to account for 7.1.
  1162. * - When panning to stereo (speaker mode, see <tt>AK::SoundEngine::SetPanningRule()</tt>), only angle[0] is used, and 3D sounds in the back of the listener are mirrored to the front.
  1163. * - When panning to 5.1, the front speakers use angle[0], and the surround speakers use (angle[2] - angle[1]) / 2.
  1164. * \endaknote
  1165. * \warning Call this function only after the sound engine has been properly initialized.
  1166. *
  1167. * @param io_pfSpeakerAngles Returned array of loudspeaker pair angles, in degrees relative to azimuth [0,180]. Pass NULL to get the required size of the array.
  1168. * @param out_fHeightAngle Elevation of the height layer, in degrees relative to the plane [-90,90].
  1169. * @param in_idOutput Output ID to set the bus on. As returned from AddOutput or GetOutputID. You can pass 0 for the main (default) output
  1170. * @return AK_Success if device exists
  1171. *
  1172. */
  1173. AKRESULT GetSpeakerAngles(
  1174. TArray<AkReal32>& io_pfSpeakerAngles,
  1175. AkReal32& out_fHeightAngle,
  1176. AkOutputDeviceID in_idOutput = 0
  1177. );
  1178. /**
  1179. * Sets speaker angles of the specified device. Speaker angles are used for 3D positioning of sounds over standard configurations.
  1180. * Note that the current version of Wwise only supports positioning on the plane.
  1181. * The speaker angles are expressed as an array of loudspeaker pairs, in degrees, relative to azimuth ]0,180].
  1182. * Supported loudspeaker setups are always symmetric; the center speaker is always in the middle and thus not specified by angles.
  1183. * Angles must be set in ascending order.
  1184. * Typical usage:
  1185. * - Initialize the sound engine and/or add secondary output(s).
  1186. * - Get number of speaker angles and their value into an array using GetSpeakerAngles().
  1187. * - Modify the angles and call SetSpeakerAngles().
  1188. * This function posts a message to the audio thread through the command queue, so it is thread safe. However the result may not be immediately read with GetSpeakerAngles().
  1189. * \warning This function only applies to configurations (or subset of these configurations) that are standard and whose speakers are on the plane (2D).
  1190. * \sa GetSpeakerAngles()
  1191. *
  1192. * @param in_pfSpeakerAngles Array of loudspeaker pair angles, in degrees relative to azimuth [0,180]
  1193. * @param in_fHeightAngle Elevation of the height layer, in degrees relative to the plane [-90,90]
  1194. * @param in_idOutput Output ID to set the bus on. As returned from AddOutput or GetOutputID. You can pass 0 for the main (default) output
  1195. * @return AK_Success if successful (device exists and angles are valid), AK_NotCompatible if the channel configuration of the device is not standard (AK_ChannelConfigType_Standard), AK_Fail otherwise.
  1196. *
  1197. */
  1198. AKRESULT SetSpeakerAngles(
  1199. const TArray<AkReal32>& in_pfSpeakerAngles,
  1200. AkReal32 in_fHeightAngle,
  1201. AkOutputDeviceID in_idOutput = 0
  1202. );
  1203. /**
  1204. * Set the output bus volume (direct) to be used for the specified game object.
  1205. * The control value is a number ranging from 0.0f to 1.0f.
  1206. *
  1207. * @param in_GameObjId Wwise Game Object ID
  1208. * @param in_fControlValue Control value to set
  1209. * @return Always returns Ak_Success
  1210. */
  1211. AKRESULT SetGameObjectOutputBusVolume(
  1212. const UAkComponent* in_pEmitter,
  1213. const UAkComponent* in_pListener,
  1214. float in_fControlValue
  1215. );
  1216. /**
  1217. * Registers a callback that can run within the global callback at a specific AkGlobalCallbackLocation.
  1218. *
  1219. * @param Callback The callback that will be called.
  1220. * @param Location The location in the sound engine processing loop
  1221. * @return Returns the handle of the delegate that must be used to unregister the callback.
  1222. */
  1223. FDelegateHandle RegisterGlobalCallback(FAkAudioDeviceDelegates::FOnAkGlobalCallback::FDelegate Callback, AkGlobalCallbackLocation Location);
  1224. /**
  1225. * Unregisters a callback that can run within the global callback at a specific AkGlobalCallbackLocation.
  1226. *
  1227. * @param Handle The handle of the registered callback
  1228. * @param Location The location in the sound engine processing loop
  1229. */
  1230. void UnregisterGlobalCallback(FDelegateHandle Handle, AkGlobalCallbackLocation Location);
  1231. /**
  1232. * Registers a callback to be called to allow the game to access metering data from any output device.
  1233. * @param OutputID Output ID, as returned from AddOutput or GetOutputID. You can pass 0 for the main (default) output
  1234. * @param Callback Callback function
  1235. * @param MeteringFlags Metering flags
  1236. * @param Cookie User cookie
  1237. * @return AK_Success if callback has been registered
  1238. */
  1239. AKRESULT RegisterOutputDeviceMeteringCallback(AkOutputDeviceID OutputID,
  1240. AkOutputDeviceMeteringCallbackFunc Callback,
  1241. AkMeteringFlags MeteringFlags,
  1242. void* Cookie);
  1243. /**
  1244. * Unregisters the output device's metering callback
  1245. * @param OutputID
  1246. * @return AK_Success if callback has been unregistered
  1247. */
  1248. AKRESULT UnregisterOutputDeviceMeteringCallback(AkOutputDeviceID OutputID);
  1249. /**
  1250. * Obtain a pointer to the singleton instance of FAkAudioDevice
  1251. *
  1252. * @return Pointer to the singleton instance of FAkAudioDevice
  1253. */
  1254. static FAkAudioDevice* Get();
  1255. /**
  1256. * Is the Wwise SoundEngine initialized?
  1257. */
  1258. static bool IsInitialized() { return m_bSoundEngineInitialized; }
  1259. /**
  1260. * Gets the system sample rate
  1261. *
  1262. * @return Sample rate
  1263. */
  1264. AkUInt32 GetSampleRate();
  1265. /**
  1266. * Enables/disables offline rendering
  1267. *
  1268. * @param bEnable Set to true to enable offline rendering
  1269. */
  1270. AKRESULT SetOfflineRendering(bool bEnable);
  1271. /**
  1272. * Sets the offline rendering frame time in seconds.
  1273. *
  1274. * @param FrameTimeInSeconds Frame time in seconds used during offline rendering
  1275. */
  1276. AKRESULT SetOfflineRenderingFrameTime(AkReal32 FrameTimeInSeconds);
  1277. /**
  1278. * Registers a callback used for retrieving audio samples.
  1279. *
  1280. * @param Callback Capture callback function to register
  1281. * @param OutputId The audio device specific id, return by AK::SoundEngine::AddOutput or AK::SoundEngine::GetOutputID
  1282. * @param Cookie Callback cookie that will be sent to the callback function along with additional information
  1283. */
  1284. AKRESULT RegisterCaptureCallback(AkCaptureCallbackFunc Callback, AkOutputDeviceID OutputId = AK_INVALID_OUTPUT_DEVICE_ID, void* Cookie = nullptr);
  1285. /**
  1286. * Unregisters a callback used for retrieving audio samples.
  1287. *
  1288. * @param Callback Capture callback function to register
  1289. * @param OutputId The audio device specific id, return by AK::SoundEngine::AddOutput or AK::SoundEngine::GetOutputID
  1290. * @param Cookie Callback cookie that will be sent to the callback function along with additional information
  1291. */
  1292. AKRESULT UnregisterCaptureCallback(AkCaptureCallbackFunc Callback, AkOutputDeviceID OutputId = AK_INVALID_OUTPUT_DEVICE_ID, void* Cookie = nullptr);
  1293. /**
  1294. * Stop all audio associated with a game object
  1295. *
  1296. * @param in_pComponent AkComponent which should be stopped
  1297. */
  1298. void StopGameObject(UAkComponent * in_pComponent);
  1299. /**
  1300. * Stop all audio associated with a playing ID
  1301. *
  1302. * @param in_playingID AkPlayingID which should be stopped
  1303. */
  1304. void StopPlayingID( AkPlayingID in_playingID,
  1305. AkTimeMs in_uTransitionDuration = 0,
  1306. AkCurveInterpolation in_eFadeCurve = AkCurveInterpolation_Linear);
  1307. /**
  1308. * Register an ak audio component with ak sound engine
  1309. *
  1310. * @param in_pComponent Pointer to the component to register
  1311. */
  1312. void RegisterComponent(UAkComponent * in_pComponent);
  1313. /**
  1314. * Register a game object with ak sound engine
  1315. *
  1316. * @param GameObjectID ID of the game object to register
  1317. */
  1318. void RegisterComponent(AkGameObjectID GameObjectID);
  1319. /**
  1320. * Unregister an ak audio component with ak sound engine
  1321. *
  1322. * @param in_pComponent Pointer to the component to unregister
  1323. */
  1324. void UnregisterComponent(UAkComponent * in_pComponent);
  1325. /**
  1326. * Unregister an ak game object with ak sound engine
  1327. *
  1328. * @param GameObjectID ID of the game object to unregister
  1329. */
  1330. void UnregisterComponent(AkGameObjectID GameObjectID);
  1331. /**
  1332. * Send a set of triangles to the Spatial Audio Engine
  1333. */
  1334. AKRESULT SetGeometry(AkGeometrySetID GeometrySetID, const AkGeometryParams& Params);
  1335. /**
  1336. * Create a geometry instance in Spatial Audio
  1337. */
  1338. AKRESULT SetGeometryInstance(AkGeometryInstanceID GeometryInstanceID, const AkGeometryInstanceParams& Params);
  1339. /**
  1340. * Remove a set of triangles from the Spatial Audio Engine
  1341. */
  1342. AKRESULT RemoveGeometrySet(AkGeometrySetID GeometrySetID);
  1343. /**
  1344. * Remove a geometry instance from Spatial Audio
  1345. */
  1346. AKRESULT RemoveGeometryInstance(AkGeometryInstanceID GeometryInstanceID);
  1347. /**
  1348. * Set the early reflections aux bus for an AK Component
  1349. */
  1350. AKRESULT SetEarlyReflectionsAuxBus(UAkComponent* in_pComponent, const AkUInt32 AuxBusID);
  1351. /**
  1352. * Set the early reflections send volume for an AK Component
  1353. */
  1354. AKRESULT SetEarlyReflectionsVolume(UAkComponent* in_pComponent, float in_fSendVolume);
  1355. /**
  1356. * Set the reflections order for the project
  1357. */
  1358. AKRESULT SetReflectionsOrder(int Order, bool RefreshPaths);
  1359. /**
  1360. * Sets a game object's obstruction and occlusion levels.
  1361. */
  1362. AKRESULT SetObjectObstructionAndOcclusion(AkGameObjectID in_Object, AkGameObjectID in_listener, AkReal32 Obstruction, AkReal32 Occlusion);
  1363. /**
  1364. * Sets a game object's obstruction and occlusion levels for each position defined by SetMultiplePositions.
  1365. */
  1366. AKRESULT SetMultipleObstructionAndOcclusion(AkGameObjectID in_Object, AkGameObjectID in_listener, AkObstructionOcclusionValues* ObstructionAndOcclusionValues, AkUInt32 in_uNumObstructionAndOcclusion);
  1367. /**
  1368. * Set obstruction and occlusion on sounds going through this portal
  1369. */
  1370. AKRESULT SetPortalObstructionAndOcclusion(UAkPortalComponent* in_pPortal, float in_fObstructionValue, float in_fOcclusionValue);
  1371. /**
  1372. * Set obstruction on sounds from this game object going through this portal
  1373. */
  1374. AKRESULT SetGameObjectToPortalObstruction(UAkComponent* in_pComponent, UAkPortalComponent* in_pPortal, float in_fObstructionValue);
  1375. /**
  1376. * Set obstruction on sounds from a first portal going through the next portal
  1377. */
  1378. AKRESULT SetPortalToPortalObstruction(UAkPortalComponent* in_pPortal0, UAkPortalComponent* in_pPortal1, float in_fObstructionValue);
  1379. /** @brief Sets an effect ShareSet on an output device
  1380. *
  1381. * Make sure the new effect ShareSet is included in a soundbank, and that sound bank is loaded. Otherwise you will see errors in the Capture Log.
  1382. * This function will replace existing effects of the audio device ShareSet.
  1383. * Audio device effects support is limited to one ShareSet per plug-in type at any time.
  1384. * Errors are reported in the Wwise Capture Log if the effect cannot be set on the output device.
  1385. * ShareSet must be in a loaded bank.
  1386. *
  1387. * @param InDeviceID Output ID, as returned from AddOutput or GetOutputID. You can pass 0 for the main (default) output
  1388. * @param InFXIndex Effect slot index (0-3)
  1389. * @param InFXShareSetID Effect ShareSet ID; pass AK_INVALID_UNIQUE_ID to use the effect from the Audio Device ShareSet.
  1390. * @return Always returns AK_Success
  1391. */
  1392. AKRESULT SetOutputDeviceEffect(AkOutputDeviceID InDeviceID, AkUInt32 InFXIndex, AkUniqueID InFXShareSetID);
  1393. /** @brief Sets an Effect ShareSet at the specified Bus and Effect slot index.
  1394. *
  1395. * The Bus can either be an Audio Bus or an Auxiliary Bus.
  1396. * This adds a reference on the audio node to an existing ShareSet.
  1397. * This function has unspecified behavior when adding an Effect to a currently playing
  1398. * Bus which does not have any effects, or removing the last Effect on a currently playing bus.
  1399. * Make sure the new effect ShareSet is included in a soundbank, and that sound bank is loaded. Otherwise you will see errors in the Capture Log.
  1400. * This function will replace existing Effects on the node. If the target node is not at
  1401. * the top of the hierarchy and is in the Actor-Mixer Hierarchy, the option "Override Parent" in
  1402. * the Effect section in Wwise must be enabled for this node, otherwise the parent's Effect will
  1403. * still be the one in use and the call to SetBusEffect will have no impact.
  1404. * ShareSet must be in a loaded bank.
  1405. *
  1406. * @param InBusName Bus name
  1407. * @param InFXIndex Effect slot index (0-3)
  1408. * @param InFXShareSetID Effect ShareSet ID; pass AK_INVALID_UNIQUE_ID to clear the Effect slot
  1409. * @return - AK_Success when successfully posted, AK_IDNotFound if the Bus name doesn't point to a valid bus, AK_InvalidParameter if in_uFXIndex isn't in range.
  1410. */
  1411. AKRESULT SetBusEffect(const FString& InBusName, AkUInt32 InFXIndex, AkUniqueID InFXShareSetID);
  1412. /** @briefSets an Effect ShareSet at the specified Bus and Effect slot index.
  1413. *
  1414. * The Bus can either be an Audio Bus or an Auxiliary Bus.
  1415. * This adds a reference on the audio node to an existing ShareSet.
  1416. * This function has unspecified behavior when adding an Effect to a currently playing
  1417. * Bus which does not have any effects, or removing the last Effect on a currently playing bus.
  1418. * Make sure the new effect ShareSet is included in a soundbank, and that sound bank is loaded. Otherwise you will see errors in the Capture Log.
  1419. * This function will replace existing Effects on the node. If the target node is not at
  1420. * the top of the hierarchy and is in the Actor-Mixer Hierarchy, the option "Override Parent" in
  1421. * the Effect section in Wwise must be enabled for this node, otherwise the parent's Effect will
  1422. * still be the one in use and the call to SetBusEffect will have no impact.
  1423. * ShareSet must be in a loaded bank.
  1424. *
  1425. * @param InBusID Bus Short ID.
  1426. * @param InFXIndex Effect slot index (0-3)
  1427. * @param InFXShareSetID Effect ShareSet ID; pass AK_INVALID_UNIQUE_ID to clear the Effect slot
  1428. * @return AK_Success when successfully posted, AK_IDNotFound if the Bus name doesn't point to a valid bus, AK_InvalidParameter if in_uFXIndex isn't in range.
  1429. */
  1430. AKRESULT SetBusEffect(AkUniqueID InBusID, AkUInt32 InFXIndex, AkUniqueID InFXShareSetID);
  1431. /** @brief Sets an Effect ShareSet at the specified audio node and Effect slot index.
  1432. *
  1433. * The target node cannot be a Bus, to set effects on a bus, use SetBusEffect() instead.
  1434. * The option "Override Parent" in the Effect section in Wwise must be enabled for this node, otherwise the parent's effect will
  1435. * still be the one in use and the call to SetActorMixerEffect will have no impact.
  1436. * ShareSet must be in a loaded bank.
  1437. *
  1438. * @param InAudioNodeID Can be a member of the Actor-Mixer or Interactive Music Hierarchy (not a bus).
  1439. * @param InFXIndex Effect slot index (0-3)
  1440. * @param InShareSetID ShareSets ID; pass AK_INVALID_UNIQUE_ID to clear the effect slot
  1441. * @return Always returns AK_Success
  1442. */
  1443. AKRESULT SetActorMixerEffect(AkUniqueID InAudioNodeID, AkUInt32 InFXIndex, AkUniqueID InShareSetID);
  1444. AKRESULT SetActorMixerEffect(const FString& InBusName, AkUInt32 InFXIndex, AkUniqueID InFXShareSetID);
  1445. /**
  1446. * Get an ak audio component, or create it if none exists that fit the attachment criteria.
  1447. */
  1448. static class UAkComponent* GetAkComponent(
  1449. class USceneComponent* AttachToComponent, FName AttachPointName, const FVector * Location, EAttachLocation::Type LocationType);
  1450. static class UAkComponent* GetAkComponent(
  1451. class USceneComponent* AttachToComponent, FName AttachPointName, const FVector * Location, EAttachLocation::Type LocationType, bool& ComponentCreated);
  1452. /**
  1453. * Cancel the callback cookie for a dispatched event
  1454. *
  1455. * @param in_cookie The cookie to cancel
  1456. */
  1457. void CancelEventCallbackCookie(void* in_cookie);
  1458. void CancelEventCallbackDelegate(const FOnAkPostEventCallback& in_Delegate);
  1459. /**
  1460. * Set the scaling factor of a game object.
  1461. * Modify the attenuation computations on this game object to simulate sounds with a a larger or smaller area of effect.
  1462. */
  1463. AKRESULT SetAttenuationScalingFactor(AActor* Actor, float ScalingFactor);
  1464. /**
  1465. * Set the scaling factor of a AkComponent.
  1466. * Modify the attenuation computations on this game object to simulate sounds with a a larger or smaller area of effect.
  1467. */
  1468. AKRESULT SetAttenuationScalingFactor(UAkComponent* AkComponent, float ScalingFactor);
  1469. /**
  1470. * Use the position of a separate AkComponent for distance calculations for a specified listener.
  1471. * When <tt>SetDistanceProbe()</tt> is called, Wwise calculates distance attenuation and filtering
  1472. * based on the distance between the distance probe AkComponent and the sound source.
  1473. * In third-person perspective applications, the distance probe may be set to the player character's position,
  1474. * and the listener position to that of the camera. In this scenario, attenuation is based on
  1475. * the distance between the character and the sound, whereas panning, spatialization, and spread and focus calculations are base on the camera.
  1476. */
  1477. AKRESULT SetDistanceProbe(UAkComponent* Listener, UAkComponent* DistanceProbe);
  1478. /**
  1479. * Starts a Wwise output capture. The output file will be located in the same folder as the SoundBanks.
  1480. * @param Filename - The name to give to the output file.
  1481. */
  1482. void StartOutputCapture(const FString& Filename);
  1483. /**
  1484. * Add text marker in output capture file.
  1485. * @param MarkerText - The name text to put in the marker.
  1486. */
  1487. void AddOutputCaptureMarker(const FString& MarkerText);
  1488. /**
  1489. * Stops a Wwise output capture. The output file will be located in the same folder as the SoundBanks.
  1490. */
  1491. void StopOutputCapture();
  1492. /**
  1493. * Starts a Wwise profiler capture. The output file will be located in the same folder as the SoundBanks.
  1494. * @param Filename - The name to give to the output file.
  1495. */
  1496. void StartProfilerCapture(const FString& Filename);
  1497. /**
  1498. * Stops a Wwise profiler capture. The output file will be located in the same folder as the SoundBanks.
  1499. */
  1500. void StopProfilerCapture();
  1501. /**
  1502. * Allows to register a Wwise plugin from a DLL name and path
  1503. */
  1504. AKRESULT RegisterPluginDLL(const FString& in_DllName, const FString& in_DllPath);
  1505. /**
  1506. * Gets the path where the SoundBanks are located on disk
  1507. */
  1508. FString GetBasePath();
  1509. /**
  1510. * Suspends the SoundEngine
  1511. * @param in_bRenderAnyway If set to true, audio processing will still occur, but not outputted. When set to false, no audio will be processed at all, even upon reception of RenderAudio().
  1512. */
  1513. void Suspend(bool in_bRenderAnyway = false);
  1514. /**
  1515. * Return from a suspended state
  1516. */
  1517. void WakeupFromSuspend();
  1518. /**
  1519. * Event called when the Wwise project is modified
  1520. */
  1521. FOnWwiseProjectModification OnWwiseProjectModification;
  1522. static inline void FVectorToAKVector( const FVector & in_vect, AkVector & out_vect )
  1523. {
  1524. #if UE_5_0_OR_LATER
  1525. checkf(in_vect.X <= FLT_MAX && in_vect.Y <= FLT_MAX && in_vect.Z <= FLT_MAX, TEXT("FVectorToAKVector: Data truncation when converting from FVector to AkVector."));
  1526. #endif
  1527. out_vect.X = in_vect.X;
  1528. out_vect.Y = in_vect.Y;
  1529. out_vect.Z = in_vect.Z;
  1530. }
  1531. static inline AkVector FVectorToAKVector(const FVector& in_vect)
  1532. {
  1533. #if UE_5_0_OR_LATER
  1534. checkf(in_vect.X <= FLT_MAX && in_vect.Y <= FLT_MAX && in_vect.Z <= FLT_MAX, TEXT("FVectorToAKVector: Data truncation when converting from FVector to AkVector."));
  1535. #endif
  1536. return AkVector{ (float)in_vect.X, (float)in_vect.Y, (float)in_vect.Z };
  1537. }
  1538. static inline void FVectorToAKVector64( const FVector & in_vect, AkVector64 & out_vect )
  1539. {
  1540. out_vect.X = in_vect.X;
  1541. out_vect.Y = in_vect.Y;
  1542. out_vect.Z = in_vect.Z;
  1543. }
  1544. static inline AkVector64 FVectorToAKVector64(const FVector& in_vect)
  1545. {
  1546. return AkVector64{ in_vect.X, in_vect.Y, in_vect.Z };
  1547. }
  1548. static inline AkExtent FVectorToAkExtent(const FVector& in_vect)
  1549. {
  1550. #if UE_5_0_OR_LATER
  1551. checkf(in_vect.X <= FLT_MAX && in_vect.Y <= FLT_MAX && in_vect.Z <= FLT_MAX, TEXT("FVectorToAkExtent: Data truncation when converting from FVector to AkExtent."));
  1552. #endif
  1553. /* Unreal: right=y, up=z, front=x */
  1554. return AkExtent{ (float)in_vect.Y, (float)in_vect.Z, (float)in_vect.X };
  1555. }
  1556. static inline void FVectorsToAKWorldTransform(const FVector& in_Position, const FVector& in_Front, const FVector& in_Up, AkWorldTransform& out_AkTransform)
  1557. {
  1558. // Convert from the UE axis system to the Wwise axis system
  1559. out_AkTransform.Set(FVectorToAKVector64(in_Position), FVectorToAKVector(in_Front), FVectorToAKVector(in_Up));
  1560. }
  1561. static inline void AKVectorToFVector(const AkVector & in_vect, FVector & out_vect)
  1562. {
  1563. out_vect.X = in_vect.X;
  1564. out_vect.Y = in_vect.Y;
  1565. out_vect.Z = in_vect.Z;
  1566. }
  1567. static inline FVector AKVectorToFVector(const AkVector& in_vect)
  1568. {
  1569. return FVector(in_vect.X, in_vect.Y, in_vect.Z);
  1570. }
  1571. // Note that this is a loss of precision due to conversion from 64-bit to 32-bit
  1572. static inline void AKVector64ToFVector(const AkVector64 & in_vect, FVector & out_vect)
  1573. {
  1574. out_vect.X = (float)in_vect.X;
  1575. out_vect.Y = (float)in_vect.Y;
  1576. out_vect.Z = (float)in_vect.Z;
  1577. }
  1578. // Note that this is a loss of precision due to conversion from 64-bit to 32-bit
  1579. static inline FVector AKVector64ToFVector(const AkVector64& in_vect)
  1580. {
  1581. return FVector((float)in_vect.X, (float)in_vect.Y, (float)in_vect.Z);
  1582. }
  1583. FAkJobWorkerScheduler* GetAkJobWorkerScheduler() { return &AkJobWorkerScheduler; }
  1584. uint8 GetMaxAuxBus() const { return MaxAuxBus; }
  1585. AkCallbackInfoPool* GetAkCallbackInfoPool()
  1586. {
  1587. return CallbackInfoPool;
  1588. }
  1589. #if WITH_EDITOR
  1590. void SetMaxAuxBus(uint8 ValToSet) { MaxAuxBus = ValToSet; }
  1591. #endif
  1592. static const int32 FIND_COMPONENTS_DEPTH_INFINITE = -1;
  1593. /** Find UAkLateReverbComponents at a given location. */
  1594. TArray<class UAkLateReverbComponent*> FindLateReverbComponentsAtLocation(const FVector& Loc, const UWorld* in_World);
  1595. /** Add a UAkLateReverbComponent to the spatial index data structure. */
  1596. void IndexLateReverb(class UAkLateReverbComponent* ComponentToAdd);
  1597. /** Remove a UAkLateReverbComponent from the spatial index data structure. */
  1598. void UnindexLateReverb(class UAkLateReverbComponent* ComponentToRemove);
  1599. /** Update the bounds of a UAkLateReverbComponent in the spatial index data structure. Must be called if the component's transform changes.*/
  1600. void ReindexLateReverb(class UAkLateReverbComponent* ComponentToAdd);
  1601. /** Get whether the given world has room registered in it. */
  1602. bool WorldHasActiveRooms(UWorld* World);
  1603. /** Find UAkRoomComponents at a given location. */
  1604. TArray<class UAkRoomComponent*> FindRoomComponentsAtLocation(const FVector& Loc, const UWorld* World);
  1605. /** Return true if any UAkRoomComponents have been added to the prioritized list of rooms for the in_World**/
  1606. bool UsingSpatialAudioRooms(const UWorld* World);
  1607. /** Get the aux send values corresponding to a point in the world.**/
  1608. void GetAuxSendValuesAtLocation(FVector Loc, TArray<AkAuxSendValue>& AkAuxSendValues, const UWorld* in_World);
  1609. /** Update all portals. */
  1610. void UpdateAllSpatialAudioPortals(UWorld* InWorld);
  1611. /** Queue an update for all portals in a world to reconnect to their front and back rooms */
  1612. void PortalsNeedRoomUpdate(UWorld* World) { WorldsInNeedOfPortalRoomsUpdate.Add(World); }
  1613. /** Register a Portal in AK Spatial Audio. Can be called again to update the portal parameters. */
  1614. void SetSpatialAudioPortal(UAkPortalComponent* in_Portal);
  1615. /** Remove a Portal from AK Spatial Audio */
  1616. void RemoveSpatialAudioPortal(UAkPortalComponent* in_Portal);
  1617. void OnActorSpawned(AActor* SpawnedActor);
  1618. UAkComponentSet& GetDefaultListeners() { return m_defaultListeners; }
  1619. UAkComponentSet& GetDefaultEmitters() { return m_defaultEmitters; }
  1620. void SetListeners(UAkComponent* in_pEmitter, const TArray<UAkComponent*>& in_listenerSet);
  1621. void AddDefaultListener(UAkComponent* in_pListener);
  1622. void RemoveDefaultListener(UAkComponent* in_pListener);
  1623. void UpdateDefaultActiveListeners();
  1624. #if WITH_EDITORONLY_DATA
  1625. FTransform GetEditorListenerPosition(int32 ViewIndex) const;
  1626. #endif
  1627. /** Specifies which listener is used for Wwise Spatial Audio**/
  1628. bool SetSpatialAudioListener(UAkComponent* in_pListener);
  1629. /** Get the listener that has been choosen to be used for Wwise Spatial Audio**/
  1630. UAkComponent* GetSpatialAudioListener() const;
  1631. AKRESULT SetPosition(UAkComponent* in_akComponent, const AkSoundPosition& in_SoundPosition);
  1632. /** Add a UAkRoomComponent to the spatial index data structure. */
  1633. void IndexRoom(class UAkRoomComponent* ComponentToAdd);
  1634. /** Remove a UAkRoomComponent from the spatial index data structure. */
  1635. void UnindexRoom(class UAkRoomComponent* ComponentToRemove);
  1636. /** Update the bounds of a UAkRoomComponent in the spatial index data structure. Must be called if the component's transform changes.*/
  1637. void ReindexRoom(class UAkRoomComponent* ComponentToAdd);
  1638. AKRESULT AddRoom(UAkRoomComponent* in_pRoom, const AkRoomParams& in_RoomParams);
  1639. AKRESULT UpdateRoom(UAkRoomComponent* in_pRoom, const AkRoomParams& in_RoomParams);
  1640. AKRESULT RemoveRoom(UAkRoomComponent* in_pRoom);
  1641. AKRESULT SetGameObjectRadius(UAkComponent* in_akComponent, float in_outerRadius, float in_innerRadius);
  1642. AKRESULT SetImageSource(class AAkSpotReflector* in_pSpotReflector, const AkImageSourceSettings& in_ImageSourceInfo, AkUniqueID in_AuxBusID, UAkComponent* in_AkComponent);
  1643. AKRESULT RemoveImageSource(class AAkSpotReflector* in_pSpotReflector, AkUniqueID in_AuxBusID, UAkComponent* in_AkComponent);
  1644. AKRESULT ClearImageSources(AkUniqueID in_AuxBusID = AK_INVALID_AUX_ID, UAkComponent* in_AkComponent = NULL);
  1645. static void GetChannelConfig(AkChannelConfiguration ChannelConfiguration, AkChannelConfig& config);
  1646. static void GetChannelConfig(FAkChannelMask SpeakerConfiguration, AkChannelConfig& config);
  1647. FAkEnvironmentIndex& GetRoomIndex() { return RoomIndex; }
  1648. struct SetCurrentAudioCultureAsyncTask
  1649. {
  1650. enum CompletionType
  1651. {
  1652. LatentAction,
  1653. Callback
  1654. };
  1655. FWwiseLanguageCookedData Language;
  1656. FThreadSafeBool IsDone = false;
  1657. FThreadSafeBool Succeeded = false;
  1658. SetCurrentAudioCultureAsyncTask(FWwiseLanguageCookedData NewLanguage, FSetCurrentAudioCultureAction* LatentAction);
  1659. SetCurrentAudioCultureAsyncTask(FWwiseLanguageCookedData NewLanguage, const FOnSetCurrentAudioCultureCompleted& CompletedCallback);
  1660. bool Start();
  1661. void Update();
  1662. private:
  1663. TSharedPtr<FPendingLatentActionValidityToken, ESPMode::ThreadSafe> LatentActionValidityToken;
  1664. CompletionType CompletionActionType;
  1665. FSetCurrentAudioCultureAction* SetAudioCultureLatentAction;
  1666. FOnSetCurrentAudioCultureCompleted SetAudioCultureCompletedCallback;
  1667. };
  1668. void AddPlayingID(uint32 EventID, uint32 PlayingID, EAkAudioContext AudioContext);
  1669. bool IsPlayingIDActive(uint32 EventID, uint32 PlayingID);
  1670. bool IsEventIDActive(uint32 EventID);
  1671. void RemovePlayingID(uint32 EventID, uint32 PlayingID);
  1672. void StopEventID(uint32 EventID);
  1673. FOnSwitchValueLoaded& GetOnSwitchValueLoaded(uint32 SwitchID);
  1674. void BroadcastOnSwitchValueLoaded(UAkGroupValue* GroupValue);
  1675. void SetLocalOutput();
  1676. FAkComponentCallbackManager* GetCallbackManager() { return CallbackManager; }
  1677. AKRESULT RegisterGameObject(AkGameObjectID GameObjectID, const FString& Name);
  1678. static void LoadAudioObjectsAfterInitialization(TWeakObjectPtr<UAkAudioType>&& InAudioType);
  1679. void LoadDelayedObjects();
  1680. private:
  1681. bool EnsureInitialized();
  1682. /** Determine whether the Wwise sound engine should be updated for the given world type */
  1683. static bool ShouldNotifySoundEngine(EWorldType::Type WorldType);
  1684. void* AllocatePermanentMemory( int32 Size, /*OUT*/ bool& AllocatedInPool );
  1685. AKRESULT GetGameObjectID(AActor * in_pActor, AkGameObjectID& io_GameObject );
  1686. template<typename FCreateCallbackPackage>
  1687. AkPlayingID PostEventWithCallbackPackageOnGameObjectId(
  1688. const AkUInt32 EventShortID,
  1689. const AkGameObjectID GameObjectID,
  1690. const TArray<AkExternalSourceInfo>& ExternalSources,
  1691. FCreateCallbackPackage CreateCallbackPackage,
  1692. EAkAudioContext AudioContext
  1693. );
  1694. template<typename FCreateCallbackPackage>
  1695. AkPlayingID PostEventWithCallbackPackageOnAkGameObject(
  1696. const AkUInt32 EventShortID,
  1697. UAkGameObject* GameObject,
  1698. const TArray<AkExternalSourceInfo>& ExternalSources,
  1699. FCreateCallbackPackage CreateCallbackPackage,
  1700. EAkAudioContext AudioContext
  1701. );
  1702. template<typename ChannelConfig>
  1703. AKRESULT SetMultiplePositions(
  1704. UAkComponent* in_pGameObjectAkComponent,
  1705. const TArray<ChannelConfig>& in_aChannelConfigurations,
  1706. const TArray<FTransform>& in_aPositions,
  1707. AkMultiPositionType in_eMultiPositionType
  1708. );
  1709. // Overload allowing to modify StopWhenOwnerDestroyed after getting the AkComponent
  1710. AKRESULT GetGameObjectID(AActor * in_pActor, AkGameObjectID& io_GameObject, bool in_bStopWhenOwnerDestroyed );
  1711. /** Update the room connections for all portals */
  1712. void UpdateRoomsForPortals();
  1713. #if WITH_EDITORONLY_DATA
  1714. UAkComponent* CreateListener(UWorld* World, FEditorViewportClient* ViewportClient = nullptr);
  1715. TArray<FTransform> ListenerTransforms;
  1716. UAkComponent* EditorListener = nullptr;
  1717. /**
  1718. * Update Default Listeners when going in and out of Play mode in editor
  1719. */
  1720. void EndPIE(const bool bIsSimulating);
  1721. void BeginPIE(const bool bIsSimulating);
  1722. void PausePIE(const bool bIsSimulating);
  1723. void ResumePie(const bool bIsSimulating);
  1724. void OnSwitchBeginPIEAndSIE(const bool bIsSimulating);
  1725. #endif
  1726. /** Map to track whether new reverbs or rooms have been added to worlds in the previous frame.
  1727. * AkComponent checks this in its TickComponent function and updates its assigned room and/or reverb volumes.
  1728. */
  1729. TMap<UWorld*, bool> WorldVolumesUpdatedMap;
  1730. void SAComponentAddedRemoved(UWorld* World);
  1731. /** We keep a spatial index of UAkLateReverbComponents sorted by priority for faster finding of reverb volumes at a specific location.
  1732. */
  1733. FAkEnvironmentIndex LateReverbIndex;
  1734. /** We keep a spatial index of Spatial audio Rooms for faster finding of reverb volumes at a specific location.
  1735. */
  1736. FAkEnvironmentIndex RoomIndex;
  1737. /** We keep track of the portals in each world so their rooms can be updated when room and portal parameters change.
  1738. */
  1739. TMap<UWorld*, TArray<class UAkPortalComponent*>> WorldPortalsMap;
  1740. void CleanupComponentMapsForWorld(UWorld* World);
  1741. bool FindWwiseLanguage(const FString& NewAudioCulture, FString& FoundWwiseLanguage);
  1742. void UpdateSetCurrentAudioCultureAsyncTasks();
  1743. static bool m_bSoundEngineInitialized;
  1744. UAkComponentSet m_defaultListeners;
  1745. UAkComponentSet m_defaultEmitters;
  1746. UAkComponent* m_SpatialAudioListener;
  1747. bool m_isSuspended = false;
  1748. uint8 MaxAuxBus;
  1749. FAkComponentCallbackManager* CallbackManager;
  1750. AkCallbackInfoPool* CallbackInfoPool;
  1751. FAkJobWorkerScheduler AkJobWorkerScheduler;
  1752. FWwiseIOHook* IOHook = nullptr;
  1753. static bool m_EngineExiting;
  1754. /* WAAPI Callback handles. */
  1755. FDelegateHandle ProjectLoadedHandle;
  1756. FDelegateHandle ConnectionLostHandle;
  1757. FDelegateHandle ClientBeginDestroyHandle;
  1758. struct FWaapiSubscriptionIds
  1759. {
  1760. uint64 Renamed = 0;
  1761. uint64 PreDeleted = 0;
  1762. uint64 ChildRemoved = 0;
  1763. uint64 ChildAdded = 0;
  1764. uint64 Created = 0;
  1765. } WaapiSubscriptionIds;
  1766. TArray<SetCurrentAudioCultureAsyncTask*> AudioCultureAsyncTasks;
  1767. TSet<UWorld*> WorldsInNeedOfPortalRoomsUpdate;
  1768. #if !WITH_EDITOR
  1769. TMap<FCulturePtr, FString> CachedUnrealToWwiseCulture;
  1770. #endif
  1771. static FCriticalSection EventToPlayingIDMapCriticalSection;
  1772. static TMap<uint32, TArray<uint32>> EventToPlayingIDMap;
  1773. static TMap<uint32, EAkAudioContext> PlayingIDToAudioContextMap;
  1774. static void PostEventAtLocationEndOfEventCallback(AkCallbackType in_eType, AkCallbackInfo* in_pCallbackInfo);
  1775. static TMap<uint32, FOnSwitchValueLoaded> OnSwitchValueLoadedMap;
  1776. static TArray<TWeakObjectPtr<UAkAudioType>> AudioObjectsToLoadAfterInitialization;
  1777. #if WITH_EDITORONLY_DATA
  1778. #ifndef AK_OPTIMIZED
  1779. static AkErrorMessageTranslator* m_UnrealErrorTranslator;
  1780. #if AK_SUPPORT_WAAPI
  1781. static AkWAAPIErrorMessageTranslator m_waapiErrorMessageTranslator;
  1782. #endif //AK_SUPPORT_WAAPI
  1783. #endif //AK_OPTIMIZED
  1784. #endif //WITH_EDITORONLY_DATA
  1785. };