WwiseDataStructure.cpp 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  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. #include "Wwise/WwiseDataStructure.h"
  16. #include "Wwise/WwiseDirectoryVisitor.h"
  17. #include "Wwise/Metadata/WwiseMetadataAcousticTexture.h"
  18. #include "Wwise/Metadata/WwiseMetadataBus.h"
  19. #include "Wwise/Metadata/WwiseMetadataDialogue.h"
  20. #include "Wwise/Metadata/WwiseMetadataEvent.h"
  21. #include "Wwise/Metadata/WwiseMetadataExternalSource.h"
  22. #include "Wwise/Metadata/WwiseMetadataGameParameter.h"
  23. #include "Wwise/Metadata/WwiseMetadataLanguage.h"
  24. #include "Wwise/Metadata/WwiseMetadataMedia.h"
  25. #include "Wwise/Metadata/WwiseMetadataPlatformInfo.h"
  26. #include "Wwise/Metadata/WwiseMetadataPlugin.h"
  27. #include "Wwise/Metadata/WwiseMetadataPluginGroup.h"
  28. #include "Wwise/Metadata/WwiseMetadataPluginInfo.h"
  29. #include "Wwise/Metadata/WwiseMetadataPluginLib.h"
  30. #include "Wwise/Metadata/WwiseMetadataProjectInfo.h"
  31. #include "Wwise/Metadata/WwiseMetadataRootFile.h"
  32. #include "Wwise/Metadata/WwiseMetadataSoundBank.h"
  33. #include "Wwise/Metadata/WwiseMetadataSoundBanksInfo.h"
  34. #include "Wwise/Metadata/WwiseMetadataState.h"
  35. #include "Wwise/Metadata/WwiseMetadataStateGroup.h"
  36. #include "Wwise/Metadata/WwiseMetadataSwitch.h"
  37. #include "Wwise/Metadata/WwiseMetadataSwitchContainer.h"
  38. #include "Wwise/Metadata/WwiseMetadataSwitchGroup.h"
  39. #include "Wwise/Metadata/WwiseMetadataTrigger.h"
  40. #include "WwiseDefines.h"
  41. #include "WwiseUnrealDefines.h"
  42. #include "Async/Async.h"
  43. #if UE_5_0_OR_LATER
  44. #include "HAL/PlatformFileManager.h"
  45. #else
  46. #include "HAL/PlatformFilemanager.h"
  47. #endif
  48. #include "Misc/LocalTimestampDirectoryVisitor.h"
  49. #include "Misc/Paths.h"
  50. FWwiseDataStructure::FWwiseDataStructure(const FDirectoryPath& InDirectoryPath, const FName* InPlatform, const FGuid* InBasePlatformGuid)
  51. {
  52. if (InDirectoryPath.Path.IsEmpty())
  53. {
  54. return;
  55. }
  56. IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
  57. FWwiseDirectoryVisitor Visitor(PlatformFile, InPlatform, InBasePlatformGuid);
  58. PlatformFile.IterateDirectory(*InDirectoryPath.Path, Visitor);
  59. auto Directory = Visitor.Get();
  60. if (!Directory.IsValid())
  61. {
  62. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Invalid Generated Directory %s"), *InDirectoryPath.Path);
  63. return;
  64. }
  65. FString RequestedPlatformPath;
  66. if (InPlatform)
  67. {
  68. const auto& ProjectInfoPlatforms = Directory.ProjectInfo->ProjectInfo->Platforms;
  69. for (const auto& Platform : ProjectInfoPlatforms)
  70. {
  71. if (Platform.Name == *InPlatform)
  72. {
  73. RequestedPlatformPath = InDirectoryPath.Path / Platform.Path.ToString();
  74. FPaths::CollapseRelativeDirectories(RequestedPlatformPath);
  75. }
  76. }
  77. }
  78. if (InPlatform)
  79. {
  80. if (Directory.Platforms.Num() == 0)
  81. {
  82. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Could not find platform %s in Generated Directory %s"), *InPlatform->ToString(), *RequestedPlatformPath);
  83. return;
  84. }
  85. UE_LOG(LogWwiseProjectDatabase, Verbose, TEXT("Parsing Wwise data structure for platform %s at: %s..."), *InPlatform->ToString(), *RequestedPlatformPath);
  86. }
  87. else
  88. {
  89. UE_LOG(LogWwiseProjectDatabase, Verbose, TEXT("Parsing Wwise data structure at: %s..."), *InDirectoryPath.Path);
  90. }
  91. LoadDataStructure(MoveTemp(Directory));
  92. }
  93. FWwiseDataStructure::~FWwiseDataStructure()
  94. {
  95. FWriteScopeLock ScopeLock(Lock);
  96. }
  97. void FWwiseDataStructure::LoadDataStructure(FWwiseGeneratedFiles&& Directory)
  98. {
  99. SCOPED_WWISEPROJECTDATABASE_EVENT_2(TEXT("FWwiseDataStructure::LoadDataStructure"));
  100. UE_LOG(LogWwiseProjectDatabase, VeryVerbose, TEXT("Starting load task"));
  101. // Create the file lists to be used in loading root files
  102. TArray<FString> FileListForRoot;
  103. {
  104. const FString ProjectInfoPath = Directory.GeneratedRootFiles.ProjectInfoFile.Get<0>();
  105. if (ProjectInfoPath.IsEmpty())
  106. {
  107. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("- Could not find project info"));
  108. }
  109. else
  110. {
  111. UE_LOG(LogWwiseProjectDatabase, VeryVerbose, TEXT("- Adding project info: %s"), *ProjectInfoPath);
  112. FileListForRoot.Add(ProjectInfoPath);
  113. }
  114. }
  115. TSharedFuture<FWwiseRootDataStructure*> RootFuture = Async(EAsyncExecution::TaskGraph, [this, &FileListForRoot, &Directory] {
  116. UE_LOG(LogWwiseProjectDatabase, Verbose, TEXT("Loading Generated file contents for root"));
  117. auto JsonFiles = FWwiseMetadataRootFile::LoadFiles(FileListForRoot);
  118. UE_LOG(LogWwiseProjectDatabase, Verbose, TEXT("Parsing Generated file contents for root"));
  119. auto RootDataStructure = new FWwiseRootDataStructure(MoveTemp(JsonFiles));
  120. RootDataStructure->GeneratedRootFiles = MoveTemp(Directory.GeneratedRootFiles);
  121. return RootDataStructure;
  122. }).Share();
  123. // Create the file lists to be used in loading files per platform
  124. TMap<FWwiseSharedPlatformId, TFuture<FWwisePlatformDataStructure*>> Futures;
  125. for (const auto& Platform : Directory.Platforms)
  126. {
  127. UE_LOG(LogWwiseProjectDatabase, VeryVerbose, TEXT("Loading platform files: %s"), *Platform.Key.GetPlatformName().ToString());
  128. TArray<FString> FileList;
  129. const FWwiseSharedPlatformId& PlatformRef = Platform.Key;
  130. const FWwiseGeneratedFiles::FPlatformFiles& Files = Platform.Value;
  131. // Add Platform and Plug-in files
  132. const FString PlatformInfoPath = Files.PlatformInfoFile.Get<0>();
  133. {
  134. if (UNLIKELY(PlatformInfoPath.IsEmpty()))
  135. {
  136. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("No PlatformInfo file for platform %s"), *PlatformRef.GetPlatformName().ToString());
  137. continue;
  138. }
  139. UE_LOG(LogWwiseProjectDatabase, VeryVerbose, TEXT("- Adding platform info: %s"), *PlatformInfoPath);
  140. FileList.Add(PlatformInfoPath);
  141. }
  142. {
  143. const FString PluginInfoPath = Files.PluginInfoFile.Get<0>();
  144. if (UNLIKELY(PluginInfoPath.IsEmpty()))
  145. {
  146. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("No PluginInfo file for platform %s"), *PlatformRef.GetPlatformName().ToString());
  147. continue;
  148. }
  149. UE_LOG(LogWwiseProjectDatabase, VeryVerbose, TEXT("- Adding plugin info: %s"), *PluginInfoPath);
  150. FileList.Add(PluginInfoPath);
  151. }
  152. // Parse PlatformInfo file to detect settings
  153. // (will be parsed twice. Now once, and officially later - since the file is small, it's not a big worry)
  154. UE_LOG(LogWwiseProjectDatabase, VeryVerbose, TEXT("Pre-parsing platform info file for settings"));
  155. auto PlatformInfoFile = FWwiseMetadataRootFile::LoadFile(PlatformInfoPath);
  156. if (!PlatformInfoFile || !PlatformInfoFile->PlatformInfo)
  157. {
  158. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Could not read PlatformInfo for platform %s."), *PlatformRef.GetPlatformName().ToString());
  159. continue;
  160. }
  161. const auto& Settings = PlatformInfoFile->PlatformInfo->Settings;
  162. bool bIsValid = true;
  163. if (!Settings.bCopyLooseStreamedMediaFiles)
  164. {
  165. bIsValid = false;
  166. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Platform %s: Requires \"Copy Loose/Streamed Media\"."), *PlatformRef.GetPlatformName().ToString());
  167. }
  168. if (!Settings.bGenerateMetadataJSON)
  169. {
  170. bIsValid = false;
  171. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Platform %s: Requires \"Generate JSON Metadata\"."), *PlatformRef.GetPlatformName().ToString());
  172. }
  173. if (Settings.bGenerateAllBanksMetadata && Settings.bGeneratePerBankMetadata)
  174. {
  175. UE_LOG(LogWwiseProjectDatabase, Log, TEXT("Platform %s: Having both \"Generate All Banks Metadata file\" and \"Generate Per Bank Metadata file\" will use the latter."), *PlatformRef.GetPlatformName().ToString());
  176. }
  177. else if (Settings.bGenerateAllBanksMetadata)
  178. {
  179. UE_LOG(LogWwiseProjectDatabase, Log, TEXT("Platform %s: Using \"Generate All Banks Metadata file\" is less efficient than Per Bank."), *PlatformRef.GetPlatformName().ToString());
  180. }
  181. else if (!Settings.bGeneratePerBankMetadata)
  182. {
  183. bIsValid = false;
  184. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Platform %s: No metadata generated. Requires one of the \"Generate Metadata file\" option set."), *PlatformRef.GetPlatformName().ToString());
  185. }
  186. if (!Settings.bPrintObjectGuid)
  187. {
  188. bIsValid = false;
  189. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Platform %s: Requires \"Object GUID\" Metadata."), *PlatformRef.GetPlatformName().ToString());
  190. }
  191. if (!Settings.bPrintObjectPath)
  192. {
  193. bIsValid = false;
  194. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Platform %s: Requires \"Object Path\" Metadata."), *PlatformRef.GetPlatformName().ToString());
  195. }
  196. if (!Settings.bMaxAttenuationInfo)
  197. {
  198. bIsValid = false;
  199. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Platform %s: Requires \"Max Attenuation\" Metadata."), *PlatformRef.GetPlatformName().ToString());
  200. }
  201. if (!Settings.bEstimatedDurationInfo)
  202. {
  203. bIsValid = false;
  204. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Platform %s: Requires \"Estimated Duration\" Metadata."), *PlatformRef.GetPlatformName().ToString());
  205. }
  206. if (!bIsValid)
  207. {
  208. UE_LOG(LogWwiseProjectDatabase, Verbose, TEXT("Skipping platform"));
  209. continue;
  210. }
  211. // Monolithic SoundBanksInfo or split files
  212. if (Settings.bGeneratePerBankMetadata)
  213. {
  214. if (UNLIKELY(Files.MetadataFiles.Num() == 0))
  215. {
  216. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Platform %s: Generated Per Bank metadata, but no metadata file found."), *PlatformRef.GetPlatformName().ToString());
  217. continue;
  218. }
  219. FileList.Reserve(FileList.Num() + Files.MetadataFiles.Num());
  220. for (const auto& MetadataFile : Files.MetadataFiles)
  221. {
  222. UE_LOG(LogWwiseProjectDatabase, VeryVerbose, TEXT("- Adding metadata file: %s"), *MetadataFile.Key);
  223. FileList.Add(MetadataFile.Key);
  224. }
  225. }
  226. else if (!Files.SoundbanksInfoFile.Get<0>().IsEmpty())
  227. {
  228. UE_LOG(LogWwiseProjectDatabase, VeryVerbose, TEXT("- Adding monolithic SoundBanks info file: %s"), *Files.SoundbanksInfoFile.Get<0>());
  229. FileList.Add(Files.SoundbanksInfoFile.Get<0>());
  230. }
  231. else
  232. {
  233. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Platform %s: Generated All Banks metadata, but SoundBanksInfo.json file not found."), *PlatformRef.GetPlatformName().ToString());
  234. continue;
  235. }
  236. Futures.Add(Platform.Key, Async(EAsyncExecution::TaskGraph, [this, PlatformRef, RootFuture, FileList, &Directory] {
  237. UE_LOG(LogWwiseProjectDatabase, Verbose, TEXT("Loading Generated file contents for platform %s"), *PlatformRef.GetPlatformName().ToString());
  238. auto JsonFiles = FWwiseMetadataRootFile::LoadFiles(FileList);
  239. auto PlatformData = new FWwisePlatformDataStructure(PlatformRef, *RootFuture.Get(), MoveTemp(JsonFiles));
  240. PlatformData->GeneratedPlatformFiles = MoveTemp(Directory.Platforms[PlatformRef]);
  241. return PlatformData;
  242. }));
  243. }
  244. UE_LOG(LogWwiseProjectDatabase, VeryVerbose, TEXT("Finalizing parsing %d files"), Futures.Num());
  245. for (const auto& Future : Futures)
  246. {
  247. auto* Result = Future.Value.Get();
  248. if (UNLIKELY(!Result))
  249. {
  250. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("File parsing failed"));
  251. }
  252. else
  253. {
  254. Platforms.Add(Future.Key, MoveTemp(*Result));
  255. delete Result;
  256. }
  257. }
  258. Futures.Empty();
  259. UE_LOG(LogWwiseProjectDatabase, VeryVerbose, TEXT("Finalizing parsing root"));
  260. if (auto* Result = RootFuture.Get())
  261. {
  262. // Will move result. Must have all other Futures done
  263. RootData = MoveTemp(*Result);
  264. delete Result;
  265. }
  266. }
  267. FWwiseRootDataStructure::FWwiseRootDataStructure(WwiseMetadataFileMap&& InJsonFiles) :
  268. JsonFiles(MoveTemp(InJsonFiles))
  269. {
  270. SCOPED_WWISEPROJECTDATABASE_EVENT_2(TEXT("FWwiseRootDataStructure::FWwiseRootDataStructure"));
  271. for (const auto& JsonFileKV : JsonFiles)
  272. {
  273. const auto JsonFilePath = FName(JsonFileKV.Key);
  274. if (JsonFileKV.Value)
  275. {
  276. const WwiseMetadataSharedRootFileConstPtr SharedRootFile = JsonFileKV.Value;
  277. const FWwiseMetadataRootFile& RootFile = *SharedRootFile;
  278. if (RootFile.ProjectInfo)
  279. {
  280. const FWwiseMetadataProjectInfo& ProjectInfo = *RootFile.ProjectInfo;
  281. // PlatformReferenceNames + PlatformReferenceGuids;
  282. for (WwiseRefIndexType PlatformIndex = 0; PlatformIndex < ProjectInfo.Platforms.Num(); ++PlatformIndex)
  283. {
  284. const FWwiseMetadataPlatformReference& PlatformReference = ProjectInfo.Platforms[PlatformIndex];
  285. PlatformNames.Add(PlatformReference.Name, FWwiseRefPlatform(SharedRootFile, JsonFilePath, PlatformIndex));
  286. PlatformGuids.Add(PlatformReference.GUID, FWwiseRefPlatform(SharedRootFile, JsonFilePath, PlatformIndex));
  287. Platforms.Emplace(FWwiseSharedPlatformId(PlatformReference.GUID, PlatformReference.Name, PlatformReference.Path), nullptr);
  288. }
  289. // LanguageNames, LanguageIds, LanguageRefs
  290. for (WwiseRefIndexType LanguageIndex = 0; LanguageIndex < ProjectInfo.Languages.Num(); ++LanguageIndex)
  291. {
  292. const FWwiseMetadataLanguage& Language = ProjectInfo.Languages[LanguageIndex];
  293. LanguageNames.Add(Language.Name, FWwiseRefLanguage(SharedRootFile, JsonFilePath, LanguageIndex));
  294. LanguageIds.Add(Language.Id, FWwiseRefLanguage(SharedRootFile, JsonFilePath, LanguageIndex));
  295. Languages.Emplace(FWwiseSharedLanguageId(Language.Id, Language.Name, Language.bDefault ? EWwiseLanguageRequirement::IsDefault : EWwiseLanguageRequirement::IsOptional), nullptr);
  296. }
  297. }
  298. }
  299. }
  300. }
  301. FWwisePlatformDataStructure::FWwisePlatformDataStructure() :
  302. AcousticTextures(FWwiseRefAcousticTexture::FGlobalIdsMap::GlobalIdsMap),
  303. AudioDevices(FWwiseRefAudioDevice::FGlobalIdsMap::GlobalIdsMap),
  304. AuxBusses(FWwiseRefAuxBus::FGlobalIdsMap::GlobalIdsMap),
  305. Busses(FWwiseRefBus::FGlobalIdsMap::GlobalIdsMap),
  306. CustomPlugins(FWwiseRefCustomPlugin::FGlobalIdsMap::GlobalIdsMap),
  307. DialogueArguments(FWwiseRefDialogueArgument::FGlobalIdsMap::GlobalIdsMap),
  308. DialogueEvents(FWwiseRefDialogueEvent::FGlobalIdsMap::GlobalIdsMap),
  309. Events(FWwiseRefEvent::FGlobalIdsMap::GlobalIdsMap),
  310. ExternalSources(FWwiseRefExternalSource::FGlobalIdsMap::GlobalIdsMap),
  311. GameParameters(FWwiseRefGameParameter::FGlobalIdsMap::GlobalIdsMap),
  312. MediaFiles(FWwiseRefMedia::FGlobalIdsMap::GlobalIdsMap),
  313. PluginLibs(FWwiseRefPluginLib::FGlobalIdsMap::GlobalIdsMap),
  314. PluginShareSets(FWwiseRefPluginShareSet::FGlobalIdsMap::GlobalIdsMap),
  315. SoundBanks(FWwiseRefSoundBank::FGlobalIdsMap::GlobalIdsMap),
  316. States(FWwiseRefState::FGlobalIdsMap::GlobalIdsMap),
  317. StateGroups(FWwiseRefStateGroup::FGlobalIdsMap::GlobalIdsMap),
  318. Switches(FWwiseRefSwitch::FGlobalIdsMap::GlobalIdsMap),
  319. SwitchGroups(FWwiseRefSwitchGroup::FGlobalIdsMap::GlobalIdsMap),
  320. Triggers(FWwiseRefTrigger::FGlobalIdsMap::GlobalIdsMap)
  321. {}
  322. FWwisePlatformDataStructure::FWwisePlatformDataStructure(const FWwiseSharedPlatformId& InPlatform, FWwiseRootDataStructure& InRootData, WwiseMetadataFileMap&& InJsonFiles) :
  323. Platform(InPlatform),
  324. JsonFiles(MoveTemp(InJsonFiles)),
  325. AcousticTextures(FWwiseRefAcousticTexture::FGlobalIdsMap::GlobalIdsMap),
  326. AudioDevices(FWwiseRefAudioDevice::FGlobalIdsMap::GlobalIdsMap),
  327. AuxBusses(FWwiseRefAuxBus::FGlobalIdsMap::GlobalIdsMap),
  328. Busses(FWwiseRefBus::FGlobalIdsMap::GlobalIdsMap),
  329. CustomPlugins(FWwiseRefCustomPlugin::FGlobalIdsMap::GlobalIdsMap),
  330. DialogueArguments(FWwiseRefDialogueArgument::FGlobalIdsMap::GlobalIdsMap),
  331. DialogueEvents(FWwiseRefDialogueEvent::FGlobalIdsMap::GlobalIdsMap),
  332. Events(FWwiseRefEvent::FGlobalIdsMap::GlobalIdsMap),
  333. ExternalSources(FWwiseRefExternalSource::FGlobalIdsMap::GlobalIdsMap),
  334. GameParameters(FWwiseRefGameParameter::FGlobalIdsMap::GlobalIdsMap),
  335. MediaFiles(FWwiseRefMedia::FGlobalIdsMap::GlobalIdsMap),
  336. PluginLibs(FWwiseRefPluginLib::FGlobalIdsMap::GlobalIdsMap),
  337. PluginShareSets(FWwiseRefPluginShareSet::FGlobalIdsMap::GlobalIdsMap),
  338. SoundBanks(FWwiseRefSoundBank::FGlobalIdsMap::GlobalIdsMap),
  339. States(FWwiseRefState::FGlobalIdsMap::GlobalIdsMap),
  340. StateGroups(FWwiseRefStateGroup::FGlobalIdsMap::GlobalIdsMap),
  341. Switches(FWwiseRefSwitch::FGlobalIdsMap::GlobalIdsMap),
  342. SwitchGroups(FWwiseRefSwitchGroup::FGlobalIdsMap::GlobalIdsMap),
  343. Triggers(FWwiseRefTrigger::FGlobalIdsMap::GlobalIdsMap)
  344. {
  345. SCOPED_WWISEPROJECTDATABASE_EVENT_2(TEXT("FWwisePlatformDataStructure::FWwisePlatformDataStructure"));
  346. for (const auto& JsonFileKV : JsonFiles)
  347. {
  348. const auto JsonFilePath = FName(JsonFileKV.Key);
  349. if (JsonFileKV.Value)
  350. {
  351. const WwiseMetadataSharedRootFileConstPtr SharedRootFile = JsonFileKV.Value;
  352. const FWwiseMetadataRootFile& RootFile = *SharedRootFile;
  353. if (RootFile.PlatformInfo)
  354. {
  355. // Platform have different information depending on its location.
  356. // Project's Platform contains the Path, generator version, and Guid.
  357. // PlatformInfo contains all the other information, including generation data.
  358. // So we must merge one into the other.
  359. const FWwiseMetadataPlatformInfo& PlatformInfo = *RootFile.PlatformInfo;
  360. FWwiseRefPlatform NewPlatformRef(SharedRootFile, JsonFilePath);
  361. const auto& PlatformName = PlatformInfo.Platform.Name;
  362. // Update PlatformNames
  363. FWwiseRefPlatform* RootPlatformByName = InRootData.PlatformNames.Find(PlatformName);
  364. if (UNLIKELY(!RootPlatformByName))
  365. {
  366. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Could not find platform %s in ProjectInfo"), *PlatformName.ToString());
  367. continue;
  368. }
  369. RootPlatformByName->Merge(MoveTemp(NewPlatformRef));
  370. // Update PlatformGUID
  371. const auto* PlatformReference = RootPlatformByName->GetPlatformReference();
  372. check(PlatformReference);
  373. const auto& Guid = PlatformReference->GUID;
  374. FWwiseRefPlatform* RootPlatformByGuid = InRootData.PlatformGuids.Find(Guid);
  375. if (UNLIKELY(!RootPlatformByGuid))
  376. {
  377. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Could not find platform %s guid %s in ProjectInfo"), *PlatformName.ToString(), *Guid.ToString());
  378. continue;
  379. }
  380. *RootPlatformByGuid = *RootPlatformByName;
  381. PlatformRef = *RootPlatformByName;
  382. }
  383. if (RootFile.PluginInfo)
  384. {
  385. const FWwiseMetadataPluginInfo& PluginInfo = *RootFile.PluginInfo;
  386. // PluginLibNames + PluginLibIDs
  387. for (WwiseRefIndexType PluginLibIndex = 0; PluginLibIndex < PluginInfo.PluginLibs.Num(); ++PluginLibIndex)
  388. {
  389. const FWwiseMetadataPluginLib& PluginLib = PluginInfo.PluginLibs[PluginLibIndex];
  390. const auto& PluginRef = FWwiseRefPluginLib(SharedRootFile, JsonFilePath, PluginLibIndex);
  391. AddRefToMap(PluginLibs, PluginRef, PluginLib.LibId, &PluginLib.LibName, nullptr, nullptr);
  392. PluginLibNames.Add(PluginLib.LibName, PluginRef);
  393. }
  394. }
  395. if (RootFile.ProjectInfo)
  396. {
  397. const FWwiseMetadataProjectInfo& ProjectInfo = *RootFile.ProjectInfo;
  398. // Should be loaded in FWwiseRootDataStructure
  399. }
  400. if (RootFile.SoundBanksInfo)
  401. {
  402. const FWwiseMetadataSoundBanksInfo& SoundBanksInfo = *RootFile.SoundBanksInfo;
  403. // SoundBanks
  404. for (WwiseRefIndexType SoundBankIndex = 0; SoundBankIndex < SoundBanksInfo.SoundBanks.Num(); ++SoundBankIndex)
  405. {
  406. const FWwiseMetadataSoundBank& SoundBank = SoundBanksInfo.SoundBanks[SoundBankIndex];
  407. const uint32 LanguageId = InRootData.GetLanguageId(SoundBank.Language);
  408. AddRefToMap(SoundBanks, FWwiseRefSoundBank(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId), SoundBank.Id, &SoundBank.ShortName, &SoundBank.ObjectPath, &SoundBank.GUID);
  409. // Media
  410. for (WwiseRefIndexType MediaIndex = 0; MediaIndex < SoundBank.Media.Num(); ++MediaIndex)
  411. {
  412. const FWwiseMetadataMedia& File = SoundBank.Media[MediaIndex];
  413. MediaFiles.Add(FWwiseDatabaseMediaIdKey(File.Id, SoundBank.Id),
  414. FWwiseRefMedia(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, MediaIndex));
  415. }
  416. // DialogueEvents
  417. for (WwiseRefIndexType DialogueEventIndex = 0; DialogueEventIndex < SoundBank.DialogueEvents.Num(); ++DialogueEventIndex)
  418. {
  419. const FWwiseMetadataDialogueEvent& DialogueEvent = SoundBank.DialogueEvents[DialogueEventIndex];
  420. AddBasicRefToMap(DialogueEvents, FWwiseRefDialogueEvent(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, DialogueEventIndex), DialogueEvent);
  421. // DialogueArguments
  422. for (WwiseRefIndexType DialogueArgumentIndex = 0; DialogueArgumentIndex < DialogueEvent.Arguments.Num(); ++DialogueArgumentIndex)
  423. {
  424. const FWwiseMetadataDialogueArgument& DialogueArgument = DialogueEvent.Arguments[DialogueArgumentIndex];
  425. AddBasicRefToMap(DialogueArguments, FWwiseRefDialogueArgument(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, DialogueEventIndex, DialogueArgumentIndex), DialogueArgument);
  426. }
  427. }
  428. // We have multiple copies of the Busses. We currently want the Init Bank version.
  429. if (SoundBank.IsInitBank())
  430. {
  431. // Busses
  432. for (WwiseRefIndexType BusIndex = 0; BusIndex < SoundBank.Busses.Num(); ++BusIndex)
  433. {
  434. const FWwiseMetadataBus& Bus = SoundBank.Busses[BusIndex];
  435. AddBasicRefToMap(Busses, FWwiseRefBus(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, BusIndex), Bus);
  436. }
  437. // AuxBusses
  438. for (WwiseRefIndexType AuxBusIndex = 0; AuxBusIndex < SoundBank.AuxBusses.Num(); ++AuxBusIndex)
  439. {
  440. const FWwiseMetadataBus& AuxBus = SoundBank.AuxBusses[AuxBusIndex];
  441. AddBasicRefToMap(AuxBusses, FWwiseRefAuxBus(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, AuxBusIndex), AuxBus);
  442. }
  443. }
  444. // Plugins
  445. if (SoundBank.Plugins)
  446. {
  447. const auto& Plugins = *SoundBank.Plugins;
  448. // CustomPlugins
  449. for (WwiseRefIndexType CustomPluginIndex = 0; CustomPluginIndex < Plugins.Custom.Num(); ++CustomPluginIndex)
  450. {
  451. const FWwiseMetadataPlugin& CustomPlugin = Plugins.Custom[CustomPluginIndex];
  452. AddBasicRefToMap(CustomPlugins, FWwiseRefCustomPlugin(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, CustomPluginIndex), CustomPlugin);
  453. }
  454. // PluginShareSets
  455. for (WwiseRefIndexType PluginShareSetIndex = 0; PluginShareSetIndex < Plugins.ShareSets.Num(); ++PluginShareSetIndex)
  456. {
  457. const FWwiseMetadataPlugin& PluginShareSet = Plugins.ShareSets[PluginShareSetIndex];
  458. AddBasicRefToMap(PluginShareSets, FWwiseRefPluginShareSet(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, PluginShareSetIndex), PluginShareSet);
  459. }
  460. // AudioDevices
  461. for (WwiseRefIndexType AudioDeviceIndex = 0; AudioDeviceIndex < Plugins.AudioDevices.Num(); ++AudioDeviceIndex)
  462. {
  463. const FWwiseMetadataPlugin& AudioDevice = Plugins.AudioDevices[AudioDeviceIndex];
  464. AddBasicRefToMap(AudioDevices, FWwiseRefAudioDevice(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, AudioDeviceIndex), AudioDevice);
  465. }
  466. }
  467. // Events
  468. for (WwiseRefIndexType EventIndex = 0; EventIndex < SoundBank.Events.Num(); ++EventIndex)
  469. {
  470. const FWwiseMetadataEvent& Event = SoundBank.Events[EventIndex];
  471. AddEventRefToMap(Events, FWwiseRefEvent(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, EventIndex), Event);
  472. // Switch Containers
  473. TArray<WwiseRefIndexType> ContainerIndex;
  474. ContainerIndex.Add(0);
  475. while (true)
  476. {
  477. if (ContainerIndex.Num() == 0)
  478. {
  479. // Fully done
  480. break;
  481. }
  482. // Retrieve Container
  483. const FWwiseMetadataSwitchContainer* Container = nullptr;
  484. const auto* ContainerArray = &Event.SwitchContainers;
  485. for (WwiseRefIndexType ContainerLevel = 0; ContainerLevel < ContainerIndex.Num() && ContainerArray; ++ContainerLevel)
  486. {
  487. WwiseRefIndexType CurrentIndex = ContainerIndex[ContainerLevel];
  488. if (!ContainerArray->IsValidIndex(CurrentIndex))
  489. {
  490. // Done last level
  491. ContainerArray = nullptr;
  492. Container = nullptr;
  493. break;
  494. }
  495. Container = &(*ContainerArray)[CurrentIndex];
  496. ContainerArray = &Container->Children;
  497. }
  498. if (Container == nullptr)
  499. {
  500. // Done this level
  501. ContainerIndex.Pop();
  502. if (ContainerIndex.Num() > 0)
  503. {
  504. ++ContainerIndex[ContainerIndex.Num() - 1];
  505. }
  506. continue;
  507. }
  508. if (Container->MediaRefs.Num() > 0 || Container->ExternalSourceRefs.Num() >0 || Container->PluginRefs != nullptr)
  509. {
  510. const auto& Ref = FWwiseRefSwitchContainer(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, EventIndex, ContainerIndex);
  511. SwitchContainersByEvent.Add(FWwiseDatabaseLocalizableIdKey(Event.Id, LanguageId), Ref);
  512. }
  513. if (ContainerArray->Num() > 0)
  514. {
  515. // There are children. Add one sublevel
  516. ContainerIndex.Add(0);
  517. }
  518. else
  519. {
  520. // No children. Next.
  521. ++ContainerIndex[ContainerIndex.Num() - 1];
  522. }
  523. }
  524. }
  525. // ExternalSources
  526. for (WwiseRefIndexType ExternalSourceIndex = 0; ExternalSourceIndex < SoundBank.ExternalSources.Num(); ++ExternalSourceIndex)
  527. {
  528. const FWwiseMetadataExternalSource& ExternalSource = SoundBank.ExternalSources[ExternalSourceIndex];
  529. AddRefToMap(ExternalSources, FWwiseRefExternalSource(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, ExternalSourceIndex), ExternalSource.Cookie, &ExternalSource.Name, &ExternalSource.ObjectPath, &ExternalSource.GUID);
  530. }
  531. // AcousticTextures
  532. for (WwiseRefIndexType AcousticTextureIndex = 0; AcousticTextureIndex < SoundBank.AcousticTextures.Num(); ++AcousticTextureIndex)
  533. {
  534. const FWwiseMetadataAcousticTexture& AcousticTexture = SoundBank.AcousticTextures[AcousticTextureIndex];
  535. AddBasicRefToMap(AcousticTextures, FWwiseRefAcousticTexture(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, AcousticTextureIndex), AcousticTexture);
  536. }
  537. // GameParameters
  538. for (WwiseRefIndexType GameParameterIndex = 0; GameParameterIndex < SoundBank.GameParameters.Num(); ++GameParameterIndex)
  539. {
  540. const FWwiseMetadataGameParameter& GameParameter = SoundBank.GameParameters[GameParameterIndex];
  541. AddBasicRefToMap(GameParameters, FWwiseRefGameParameter(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, GameParameterIndex), GameParameter);
  542. }
  543. // StateGroups
  544. for (WwiseRefIndexType StateGroupIndex = 0; StateGroupIndex < SoundBank.StateGroups.Num(); ++StateGroupIndex)
  545. {
  546. const FWwiseMetadataStateGroup& StateGroup = SoundBank.StateGroups[StateGroupIndex];
  547. AddBasicRefToMap(StateGroups, FWwiseRefStateGroup(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, StateGroupIndex), StateGroup);
  548. // States
  549. for (WwiseRefIndexType StateIndex = 0; StateIndex < StateGroup.States.Num(); ++StateIndex)
  550. {
  551. const FWwiseMetadataState& State = StateGroup.States[StateIndex];
  552. const FWwiseRefState StateRef(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, StateGroupIndex, StateIndex);
  553. const FWwiseAnyRef AnyRef = FWwiseAnyRef::Create(StateRef);
  554. States.Add(FWwiseDatabaseLocalizableGroupValueKey(StateGroup.Id, State.Id, LanguageId), StateRef);
  555. if (State.GUID != FGuid()) Guids.Add(FWwiseDatabaseLocalizableGuidKey(State.GUID, LanguageId), AnyRef);
  556. if (!State.Name.IsNone()) Names.Add(FWwiseDatabaseLocalizableNameKey(State.Name, LanguageId), AnyRef);
  557. if (!State.ObjectPath.IsNone()) Names.Add(FWwiseDatabaseLocalizableNameKey(State.ObjectPath, LanguageId), AnyRef);
  558. }
  559. }
  560. // SwitchGroups
  561. for (WwiseRefIndexType SwitchGroupIndex = 0; SwitchGroupIndex < SoundBank.SwitchGroups.Num(); ++SwitchGroupIndex)
  562. {
  563. const FWwiseMetadataSwitchGroup& SwitchGroup = SoundBank.SwitchGroups[SwitchGroupIndex];
  564. AddBasicRefToMap(SwitchGroups, FWwiseRefSwitchGroup(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, SwitchGroupIndex), SwitchGroup);
  565. // Switches
  566. for (WwiseRefIndexType SwitchIndex = 0; SwitchIndex < SwitchGroup.Switches.Num(); ++SwitchIndex)
  567. {
  568. const FWwiseMetadataSwitch& Switch = SwitchGroup.Switches[SwitchIndex];
  569. const FWwiseRefSwitch SwitchRef(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, SwitchGroupIndex, SwitchIndex);
  570. const FWwiseAnyRef AnyRef = FWwiseAnyRef::Create(SwitchRef);
  571. Switches.Add(FWwiseDatabaseLocalizableGroupValueKey(SwitchGroup.Id, Switch.Id, LanguageId), SwitchRef);
  572. if (Switch.GUID != FGuid()) Guids.Add(FWwiseDatabaseLocalizableGuidKey(Switch.GUID, LanguageId), AnyRef);
  573. if (!Switch.Name.IsNone()) Names.Add(FWwiseDatabaseLocalizableNameKey(Switch.Name, LanguageId), AnyRef);
  574. if (!Switch.ObjectPath.IsNone()) Names.Add(FWwiseDatabaseLocalizableNameKey(Switch.ObjectPath, LanguageId), AnyRef);
  575. }
  576. }
  577. // Triggers
  578. for (WwiseRefIndexType TriggerIndex = 0; TriggerIndex < SoundBank.Triggers.Num(); ++TriggerIndex)
  579. {
  580. const FWwiseMetadataTrigger& Trigger = SoundBank.Triggers[TriggerIndex];
  581. AddBasicRefToMap(Triggers, FWwiseRefTrigger(SharedRootFile, JsonFilePath, SoundBankIndex, LanguageId, TriggerIndex), Trigger);
  582. }
  583. }
  584. }
  585. }
  586. }
  587. }
  588. FWwisePlatformDataStructure::FWwisePlatformDataStructure(const FWwisePlatformDataStructure& Rhs) :
  589. FWwiseRefAcousticTexture::FGlobalIdsMap(Rhs),
  590. FWwiseRefAudioDevice::FGlobalIdsMap(Rhs),
  591. FWwiseRefAuxBus::FGlobalIdsMap(Rhs),
  592. FWwiseRefBus::FGlobalIdsMap(Rhs),
  593. FWwiseRefCustomPlugin::FGlobalIdsMap(Rhs),
  594. FWwiseRefDialogueArgument::FGlobalIdsMap(Rhs),
  595. FWwiseRefDialogueEvent::FGlobalIdsMap(Rhs),
  596. FWwiseRefEvent::FGlobalIdsMap(Rhs),
  597. FWwiseRefExternalSource::FGlobalIdsMap(Rhs),
  598. FWwiseRefGameParameter::FGlobalIdsMap(Rhs),
  599. FWwiseRefMedia::FGlobalIdsMap(Rhs),
  600. FWwiseRefPluginLib::FGlobalIdsMap(Rhs),
  601. FWwiseRefPluginShareSet::FGlobalIdsMap(Rhs),
  602. FWwiseRefSoundBank::FGlobalIdsMap(Rhs),
  603. FWwiseRefState::FGlobalIdsMap(Rhs),
  604. FWwiseRefStateGroup::FGlobalIdsMap(Rhs),
  605. FWwiseRefSwitch::FGlobalIdsMap(Rhs),
  606. FWwiseRefSwitchGroup::FGlobalIdsMap(Rhs),
  607. FWwiseRefTrigger::FGlobalIdsMap(Rhs),
  608. Platform(Rhs.Platform),
  609. PlatformRef(Rhs.PlatformRef),
  610. GeneratedPlatformFiles(Rhs.GeneratedPlatformFiles),
  611. JsonFiles(Rhs.JsonFiles),
  612. AcousticTextures(FWwiseRefAcousticTexture::FGlobalIdsMap::GlobalIdsMap),
  613. AudioDevices(FWwiseRefAudioDevice::FGlobalIdsMap::GlobalIdsMap),
  614. AuxBusses(FWwiseRefAuxBus::FGlobalIdsMap::GlobalIdsMap),
  615. Busses(FWwiseRefBus::FGlobalIdsMap::GlobalIdsMap),
  616. CustomPlugins(FWwiseRefCustomPlugin::FGlobalIdsMap::GlobalIdsMap),
  617. DialogueArguments(FWwiseRefDialogueArgument::FGlobalIdsMap::GlobalIdsMap),
  618. DialogueEvents(FWwiseRefDialogueEvent::FGlobalIdsMap::GlobalIdsMap),
  619. Events(FWwiseRefEvent::FGlobalIdsMap::GlobalIdsMap),
  620. ExternalSources(FWwiseRefExternalSource::FGlobalIdsMap::GlobalIdsMap),
  621. GameParameters(FWwiseRefGameParameter::FGlobalIdsMap::GlobalIdsMap),
  622. MediaFiles(FWwiseRefMedia::FGlobalIdsMap::GlobalIdsMap),
  623. PluginLibs(FWwiseRefPluginLib::FGlobalIdsMap::GlobalIdsMap),
  624. PluginShareSets(FWwiseRefPluginShareSet::FGlobalIdsMap::GlobalIdsMap),
  625. SoundBanks(FWwiseRefSoundBank::FGlobalIdsMap::GlobalIdsMap),
  626. States(FWwiseRefState::FGlobalIdsMap::GlobalIdsMap),
  627. StateGroups(FWwiseRefStateGroup::FGlobalIdsMap::GlobalIdsMap),
  628. Switches(FWwiseRefSwitch::FGlobalIdsMap::GlobalIdsMap),
  629. SwitchGroups(FWwiseRefSwitchGroup::FGlobalIdsMap::GlobalIdsMap),
  630. Triggers(FWwiseRefTrigger::FGlobalIdsMap::GlobalIdsMap),
  631. PluginLibNames(Rhs.PluginLibNames),
  632. SwitchContainersByEvent(Rhs.SwitchContainersByEvent),
  633. Guids(Rhs.Guids),
  634. Names(Rhs.Names)
  635. {}
  636. FWwisePlatformDataStructure::FWwisePlatformDataStructure(FWwisePlatformDataStructure&& Rhs) :
  637. FWwiseRefAcousticTexture::FGlobalIdsMap(MoveTemp(Rhs)),
  638. FWwiseRefAudioDevice::FGlobalIdsMap(MoveTemp(Rhs)),
  639. FWwiseRefAuxBus::FGlobalIdsMap(MoveTemp(Rhs)),
  640. FWwiseRefBus::FGlobalIdsMap(MoveTemp(Rhs)),
  641. FWwiseRefCustomPlugin::FGlobalIdsMap(MoveTemp(Rhs)),
  642. FWwiseRefDialogueArgument::FGlobalIdsMap(MoveTemp(Rhs)),
  643. FWwiseRefDialogueEvent::FGlobalIdsMap(MoveTemp(Rhs)),
  644. FWwiseRefEvent::FGlobalIdsMap(MoveTemp(Rhs)),
  645. FWwiseRefExternalSource::FGlobalIdsMap(MoveTemp(Rhs)),
  646. FWwiseRefGameParameter::FGlobalIdsMap(MoveTemp(Rhs)),
  647. FWwiseRefMedia::FGlobalIdsMap(MoveTemp(Rhs)),
  648. FWwiseRefPluginLib::FGlobalIdsMap(MoveTemp(Rhs)),
  649. FWwiseRefPluginShareSet::FGlobalIdsMap(MoveTemp(Rhs)),
  650. FWwiseRefSoundBank::FGlobalIdsMap(MoveTemp(Rhs)),
  651. FWwiseRefState::FGlobalIdsMap(MoveTemp(Rhs)),
  652. FWwiseRefStateGroup::FGlobalIdsMap(MoveTemp(Rhs)),
  653. FWwiseRefSwitch::FGlobalIdsMap(MoveTemp(Rhs)),
  654. FWwiseRefSwitchGroup::FGlobalIdsMap(MoveTemp(Rhs)),
  655. FWwiseRefTrigger::FGlobalIdsMap(MoveTemp(Rhs)),
  656. Platform(MoveTemp(Rhs.Platform)),
  657. PlatformRef(MoveTemp(Rhs.PlatformRef)),
  658. GeneratedPlatformFiles(MoveTemp(Rhs.GeneratedPlatformFiles)),
  659. JsonFiles(MoveTemp(Rhs.JsonFiles)),
  660. AcousticTextures(FWwiseRefAcousticTexture::FGlobalIdsMap::GlobalIdsMap),
  661. AudioDevices(FWwiseRefAudioDevice::FGlobalIdsMap::GlobalIdsMap),
  662. AuxBusses(FWwiseRefAuxBus::FGlobalIdsMap::GlobalIdsMap),
  663. Busses(FWwiseRefBus::FGlobalIdsMap::GlobalIdsMap),
  664. CustomPlugins(FWwiseRefCustomPlugin::FGlobalIdsMap::GlobalIdsMap),
  665. DialogueArguments(FWwiseRefDialogueArgument::FGlobalIdsMap::GlobalIdsMap),
  666. DialogueEvents(FWwiseRefDialogueEvent::FGlobalIdsMap::GlobalIdsMap),
  667. Events(FWwiseRefEvent::FGlobalIdsMap::GlobalIdsMap),
  668. ExternalSources(FWwiseRefExternalSource::FGlobalIdsMap::GlobalIdsMap),
  669. GameParameters(FWwiseRefGameParameter::FGlobalIdsMap::GlobalIdsMap),
  670. MediaFiles(FWwiseRefMedia::FGlobalIdsMap::GlobalIdsMap),
  671. PluginLibs(FWwiseRefPluginLib::FGlobalIdsMap::GlobalIdsMap),
  672. PluginShareSets(FWwiseRefPluginShareSet::FGlobalIdsMap::GlobalIdsMap),
  673. SoundBanks(FWwiseRefSoundBank::FGlobalIdsMap::GlobalIdsMap),
  674. States(FWwiseRefState::FGlobalIdsMap::GlobalIdsMap),
  675. StateGroups(FWwiseRefStateGroup::FGlobalIdsMap::GlobalIdsMap),
  676. Switches(FWwiseRefSwitch::FGlobalIdsMap::GlobalIdsMap),
  677. SwitchGroups(FWwiseRefSwitchGroup::FGlobalIdsMap::GlobalIdsMap),
  678. Triggers(FWwiseRefTrigger::FGlobalIdsMap::GlobalIdsMap),
  679. PluginLibNames(MoveTemp(Rhs.PluginLibNames)),
  680. SwitchContainersByEvent(MoveTemp(Rhs.SwitchContainersByEvent)),
  681. Guids(MoveTemp(Rhs.Guids)),
  682. Names(MoveTemp(Rhs.Names))
  683. {}
  684. FWwiseRootDataStructure& FWwiseRootDataStructure::operator+=(FWwiseRootDataStructure&& Rhs)
  685. {
  686. // GeneratedRootFiles += MoveTemp(Rhs.GeneratedRootFiles);
  687. JsonFiles.Append(MoveTemp(Rhs.JsonFiles));
  688. LanguageNames.Append(MoveTemp(Rhs.LanguageNames));
  689. LanguageIds.Append(MoveTemp(Rhs.LanguageIds));
  690. PlatformNames.Append(MoveTemp(Rhs.PlatformNames));
  691. PlatformGuids.Append(MoveTemp(Rhs.PlatformGuids));
  692. return *this;
  693. }
  694. FWwisePlatformDataStructure& FWwisePlatformDataStructure::operator+=(FWwisePlatformDataStructure&& Rhs)
  695. {
  696. // GeneratedPlatformFiles += MoveTemp(Rhs.GeneratedPlatformFiles);
  697. JsonFiles.Append(MoveTemp(Rhs.JsonFiles));
  698. MediaFiles.Append(MoveTemp(Rhs.MediaFiles));
  699. PluginLibNames.Append(MoveTemp(Rhs.PluginLibNames));
  700. PluginLibs.Append(MoveTemp(Rhs.PluginLibs));
  701. SoundBanks.Append(MoveTemp(Rhs.SoundBanks));
  702. DialogueEvents.Append(MoveTemp(Rhs.DialogueEvents));
  703. DialogueArguments.Append(MoveTemp(Rhs.DialogueArguments));
  704. Busses.Append(MoveTemp(Rhs.Busses));
  705. AuxBusses.Append(MoveTemp(Rhs.AuxBusses));
  706. Events.Append(MoveTemp(Rhs.Events));
  707. ExternalSources.Append(MoveTemp(Rhs.ExternalSources));
  708. AcousticTextures.Append(MoveTemp(Rhs.AcousticTextures));
  709. GameParameters.Append(MoveTemp(Rhs.GameParameters));
  710. StateGroups.Append(MoveTemp(Rhs.StateGroups));
  711. SwitchGroups.Append(MoveTemp(Rhs.SwitchGroups));
  712. Triggers.Append(MoveTemp(Rhs.Triggers));
  713. States.Append(MoveTemp(Rhs.States));
  714. Switches.Append(MoveTemp(Rhs.Switches));
  715. SwitchContainersByEvent.Append(MoveTemp(Rhs.SwitchContainersByEvent));
  716. return *this;
  717. }
  718. bool FWwisePlatformDataStructure::GetFromId(FWwiseRefMedia& OutRef, uint32 InShortId, uint32 InLanguageId, uint32 InSoundBankId) const
  719. {
  720. const FWwiseRefMedia* Result = nullptr;
  721. if (LIKELY(InSoundBankId != 0))
  722. {
  723. FWwiseDatabaseMediaIdKey MediaId(InShortId, InSoundBankId);
  724. Result = MediaFiles.Find(MediaId);
  725. }
  726. else
  727. {
  728. for (const auto& MediaFile : MediaFiles)
  729. {
  730. if (MediaFile.Key.MediaId == InShortId)
  731. {
  732. Result = &MediaFile.Value;
  733. break;
  734. }
  735. }
  736. }
  737. if (UNLIKELY(!Result))
  738. {
  739. UE_LOG(LogWwiseProjectDatabase, Warning, TEXT("Could not find Media %" PRIu32 " (Lang=%" PRIu32 "; SB=%" PRIu32 ")"), InShortId, InLanguageId, InSoundBankId);
  740. return false;
  741. }
  742. OutRef = *Result;
  743. return true;
  744. }
  745. FWwiseDataStructure& FWwiseDataStructure::operator+=(FWwiseDataStructure&& Rhs)
  746. {
  747. FWriteScopeLock ScopeLockLhs(Lock);
  748. FWriteScopeLock ScopeLockRhs(Rhs.Lock);
  749. Platforms.Append(MoveTemp(Rhs.Platforms));
  750. return *this;
  751. }