WwiseRefPluginShareSet.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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/Ref/WwiseRefPluginShareSet.h"
  16. #include "Wwise/WwiseProjectDatabaseModule.h"
  17. #include "Wwise/Metadata/WwiseMetadataPlugin.h"
  18. #include "Wwise/Metadata/WwiseMetadataPluginGroup.h"
  19. #include "Wwise/Metadata/WwiseMetadataSoundBank.h"
  20. #include "Wwise/Ref/WwiseRefAudioDevice.h"
  21. #include "Wwise/Ref/WwiseRefCustomPlugin.h"
  22. #include "Wwise/Ref/WwiseRefMedia.h"
  23. #include "Wwise/Stats/ProjectDatabase.h"
  24. const TCHAR* const FWwiseRefPluginShareSet::NAME = TEXT("PluginShareSet");
  25. const FWwiseMetadataPlugin* FWwiseRefPluginShareSet::GetPlugin() const
  26. {
  27. const auto* SoundBank = GetSoundBank();
  28. if (UNLIKELY(!SoundBank || !SoundBank->Plugins))
  29. {
  30. return nullptr;
  31. }
  32. const auto& Plugins = SoundBank->Plugins->ShareSets;
  33. if (Plugins.IsValidIndex(PluginShareSetIndex))
  34. {
  35. return &Plugins[PluginShareSetIndex];
  36. }
  37. else
  38. {
  39. UE_LOG(LogWwiseProjectDatabase, Error, TEXT("Could not get Plugin ShareSet index #%zu"), PluginShareSetIndex);
  40. return nullptr;
  41. }
  42. }
  43. WwiseMediaIdsMap FWwiseRefPluginShareSet::GetPluginMedia(const WwiseMediaGlobalIdsMap& GlobalMap) const
  44. {
  45. const auto* PluginShareSet = GetPlugin();
  46. const auto* SoundBank = GetSoundBank();
  47. if (UNLIKELY(!PluginShareSet || !SoundBank))
  48. {
  49. return {};
  50. }
  51. const auto& Media = PluginShareSet->MediaRefs;
  52. WwiseMediaIdsMap Result;
  53. Result.Empty(Media.Num());
  54. for (const auto& Elem : Media)
  55. {
  56. FWwiseDatabaseMediaIdKey Id(Elem.Id, SoundBank->Id);
  57. const auto* MediaInGlobalMap = GlobalMap.Find(Id);
  58. if (MediaInGlobalMap)
  59. {
  60. Result.Add(Elem.Id, *MediaInGlobalMap);
  61. }
  62. }
  63. return Result;
  64. }
  65. WwiseCustomPluginIdsMap FWwiseRefPluginShareSet::GetPluginCustomPlugins(const WwiseCustomPluginGlobalIdsMap& GlobalMap) const
  66. {
  67. const auto* Plugin = GetPlugin();
  68. if (!Plugin || !Plugin->PluginRefs)
  69. {
  70. return {};
  71. }
  72. const auto& Plugins = Plugin->PluginRefs->Custom;
  73. WwiseCustomPluginIdsMap Result;
  74. Result.Empty(Plugins.Num());
  75. for (const auto& Elem : Plugins)
  76. {
  77. FWwiseDatabaseLocalizableIdKey Id(Elem.Id, LanguageId);
  78. const auto* GlobalRef = GlobalMap.Find(Id);
  79. if (GlobalRef)
  80. {
  81. Result.Add(Elem.Id, *GlobalRef);
  82. }
  83. }
  84. return Result;
  85. }
  86. WwisePluginShareSetIdsMap FWwiseRefPluginShareSet::GetPluginPluginShareSets(const WwisePluginShareSetGlobalIdsMap& GlobalMap) const
  87. {
  88. const auto* Plugin = GetPlugin();
  89. if (!Plugin || !Plugin->PluginRefs)
  90. {
  91. return {};
  92. }
  93. const auto& Plugins = Plugin->PluginRefs->ShareSets;
  94. WwisePluginShareSetIdsMap Result;
  95. Result.Empty(Plugins.Num());
  96. for (const auto& Elem : Plugins)
  97. {
  98. FWwiseDatabaseLocalizableIdKey Id(Elem.Id, LanguageId);
  99. const auto* GlobalRef = GlobalMap.Find(Id);
  100. if (GlobalRef)
  101. {
  102. Result.Add(Elem.Id, *GlobalRef);
  103. }
  104. }
  105. return Result;
  106. }
  107. WwiseAudioDeviceIdsMap FWwiseRefPluginShareSet::GetPluginAudioDevices(const WwiseAudioDeviceGlobalIdsMap& GlobalMap) const
  108. {
  109. const auto* Plugin = GetPlugin();
  110. if (!Plugin || !Plugin->PluginRefs)
  111. {
  112. return {};
  113. }
  114. const auto& Plugins = Plugin->PluginRefs->AudioDevices;
  115. WwiseAudioDeviceIdsMap Result;
  116. Result.Empty(Plugins.Num());
  117. for (const auto& Elem : Plugins)
  118. {
  119. FWwiseDatabaseLocalizableIdKey Id(Elem.Id, LanguageId);
  120. const auto* GlobalRef = GlobalMap.Find(Id);
  121. if (GlobalRef)
  122. {
  123. Result.Add(Elem.Id, *GlobalRef);
  124. }
  125. }
  126. return Result;
  127. }
  128. uint32 FWwiseRefPluginShareSet::PluginShareSetId() const
  129. {
  130. const auto* PluginShareSet = GetPlugin();
  131. if (UNLIKELY(!PluginShareSet))
  132. {
  133. return 0;
  134. }
  135. return PluginShareSet->Id;
  136. }
  137. FGuid FWwiseRefPluginShareSet::PluginShareSetGuid() const
  138. {
  139. const auto* PluginShareSet = GetPlugin();
  140. if (UNLIKELY(!PluginShareSet))
  141. {
  142. return {};
  143. }
  144. return PluginShareSet->GUID;
  145. }
  146. FName FWwiseRefPluginShareSet::PluginShareSetName() const
  147. {
  148. const auto* PluginShareSet = GetPlugin();
  149. if (UNLIKELY(!PluginShareSet))
  150. {
  151. return {};
  152. }
  153. return PluginShareSet->Name;
  154. }
  155. FName FWwiseRefPluginShareSet::PluginShareSetObjectPath() const
  156. {
  157. const auto* PluginShareSet = GetPlugin();
  158. if (UNLIKELY(!PluginShareSet))
  159. {
  160. return {};
  161. }
  162. return PluginShareSet->ObjectPath;
  163. }
  164. uint32 FWwiseRefPluginShareSet::Hash() const
  165. {
  166. auto Result = FWwiseRefSoundBank::Hash();
  167. Result = HashCombine(Result, GetTypeHash(PluginShareSetIndex));
  168. return Result;
  169. }