AkWaapiUtils.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. includes.
  17. ------------------------------------------------------------------------------------*/
  18. #include "AkWaapiUtils.h"
  19. #include "AkAudioDevice.h"
  20. #include "AkWaapiClient.h"
  21. /*------------------------------------------------------------------------------------
  22. Defines
  23. ------------------------------------------------------------------------------------*/
  24. #define LOCTEXT_NAMESPACE "AkAudio"
  25. /*------------------------------------------------------------------------------------
  26. Statics and Globals
  27. ------------------------------------------------------------------------------------*/
  28. const FString WwiseWaapiHelper::ACTION = TEXT("action");
  29. const FString WwiseWaapiHelper::ANCESTORS = TEXT("ancestors");
  30. const FString WwiseWaapiHelper::AT = TEXT("@");
  31. const FString WwiseWaapiHelper::AUX_BUSSES = TEXT("auxBusses");
  32. const FString WwiseWaapiHelper::BACK_SLASH = TEXT("\\");
  33. const FString WwiseWaapiHelper::BANK_DATA = TEXT("bankData");
  34. const FString WwiseWaapiHelper::BANK_INFO = TEXT("bankInfo");
  35. const FString WwiseWaapiHelper::CHILD = TEXT("child");
  36. const FString WwiseWaapiHelper::CHILDREN = TEXT("children");
  37. const FString WwiseWaapiHelper::CHILDREN_COUNT = TEXT("childrenCount");
  38. const FString WwiseWaapiHelper::CLASSID = TEXT("classId");
  39. const FString WwiseWaapiHelper::COMMAND = TEXT("command");
  40. const FString WwiseWaapiHelper::DATA = TEXT("data");
  41. const FString WwiseWaapiHelper::DELETE_ITEMS = TEXT("Delete Items");
  42. const FString WwiseWaapiHelper::DESCENDANTS = TEXT("descendants");
  43. const FString WwiseWaapiHelper::DISPLAY_NAME = TEXT("displayName");
  44. const FString WwiseWaapiHelper::DRAG_DROP_ITEMS = TEXT("Drag Drop Items");
  45. const FString WwiseWaapiHelper::EVENT = TEXT("event");
  46. const FString WwiseWaapiHelper::EVENTS = TEXT("events");
  47. const FString WwiseWaapiHelper::FILEPATH = TEXT("filePath");
  48. const FString WwiseWaapiHelper::FILTER = TEXT("filter");
  49. const FString WwiseWaapiHelper::FIND_IN_PROJECT_EXPLORER = TEXT("FindInProjectExplorerSelectionChannel1");
  50. const FString WwiseWaapiHelper::FOLDER = TEXT("Folder");
  51. const FString WwiseWaapiHelper::FROM = TEXT("from");
  52. const FString WwiseWaapiHelper::ID = TEXT("id");
  53. const FString WwiseWaapiHelper::INCLUSIONS = TEXT("inclusions");
  54. const FString WwiseWaapiHelper::INFO_FILE = TEXT("infoFile");
  55. const FString WwiseWaapiHelper::IS_CONNECTED = TEXT("isConnected");
  56. const FString WwiseWaapiHelper::LANGUAGE = TEXT("language");
  57. const FString WwiseWaapiHelper::LANGUAGES = TEXT("languages");
  58. const FString WwiseWaapiHelper::MAX = TEXT("max");
  59. const FString WwiseWaapiHelper::MAX_RADIUS_ATTENUATION = TEXT("audioSource:maxRadiusAttenuation");
  60. const FString WwiseWaapiHelper::MESSSAGE = TEXT("message");
  61. const FString WwiseWaapiHelper::MIN = TEXT("min");
  62. const FString WwiseWaapiHelper::NAME = TEXT("name");
  63. const FString WwiseWaapiHelper::NAMECONTAINS = TEXT("name:contains");
  64. const FString WwiseWaapiHelper::NEW = TEXT("new");
  65. const FString WwiseWaapiHelper::NEW_NAME = TEXT("newName");
  66. const FString WwiseWaapiHelper::NOTES = TEXT("notes");
  67. const FString WwiseWaapiHelper::OBJECT = TEXT("object");
  68. const FString WwiseWaapiHelper::OBJECTS = TEXT("objects");
  69. const FString WwiseWaapiHelper::OF_TYPE = TEXT("ofType");
  70. const FString WwiseWaapiHelper::OLD_NAME = TEXT("oldName");
  71. const FString WwiseWaapiHelper::ON_NAME_CONFLICT = TEXT("onNameConflict");
  72. const FString WwiseWaapiHelper::OPERATION = TEXT("operation");
  73. const FString WwiseWaapiHelper::PARENT = TEXT("parent");
  74. const FString WwiseWaapiHelper::PATH = TEXT("path");
  75. const FString WwiseWaapiHelper::PHYSICAL_FOLDER = TEXT("PhysicalFolder");
  76. const FString WwiseWaapiHelper::PLATFORM = TEXT("platform");
  77. const FString WwiseWaapiHelper::PLATFORMS = TEXT("platforms");
  78. const FString WwiseWaapiHelper::PLAY = TEXT("play");
  79. const FString WwiseWaapiHelper::PLAYING = TEXT("playing");
  80. const FString WwiseWaapiHelper::PLAYSTOP = TEXT("playStop");
  81. const FString WwiseWaapiHelper::PLUGININFO_OPTIONS = TEXT("pluginInfo");
  82. const FString WwiseWaapiHelper::PLUGININFO_RESPONSE = TEXT("PluginInfo");
  83. const FString WwiseWaapiHelper::PROJECT = TEXT("Project");
  84. const FString WwiseWaapiHelper::PROPERTY = TEXT("property");
  85. const FString WwiseWaapiHelper::RADIUS = TEXT("radius");
  86. const FString WwiseWaapiHelper::RANGE = TEXT("range");
  87. const FString WwiseWaapiHelper::REBUILD = TEXT("rebuild");
  88. const FString WwiseWaapiHelper::REBUILD_INIT_BANK = TEXT("rebuildInitBank");
  89. const FString WwiseWaapiHelper::REDO = TEXT("Redo");
  90. const FString WwiseWaapiHelper::RENAME = TEXT("rename");
  91. const FString WwiseWaapiHelper::RESTRICTION = TEXT("restriction");
  92. const FString WwiseWaapiHelper::RETURN = TEXT("return");
  93. const FString WwiseWaapiHelper::SEARCH = TEXT("search");
  94. const FString WwiseWaapiHelper::SELECT = TEXT("select");
  95. const FString WwiseWaapiHelper::SIZE = TEXT("size");
  96. const FString WwiseWaapiHelper::SKIP_LANGUAGES = TEXT("skipLanguages");
  97. const FString WwiseWaapiHelper::SOUNDBANK_TYPE = TEXT("SoundBank");
  98. const FString WwiseWaapiHelper::SOUNDBANK_FIELD = TEXT("soundbank");
  99. const FString WwiseWaapiHelper::SOUNDBANKS = TEXT("soundbanks");
  100. const FString WwiseWaapiHelper::STATE = TEXT("state");
  101. const FString WwiseWaapiHelper::STOP = TEXT("stop");
  102. const FString WwiseWaapiHelper::STOPPED = TEXT("stopped");
  103. const FString WwiseWaapiHelper::STRUCTURE = TEXT("structure");
  104. const FString WwiseWaapiHelper::TRANSFORM = TEXT("transform");
  105. const FString WwiseWaapiHelper::TRANSPORT = TEXT("transport");
  106. const FString WwiseWaapiHelper::TYPE = TEXT("type");
  107. const FString WwiseWaapiHelper::UI = TEXT("ui");
  108. const FString WwiseWaapiHelper::UNDO = TEXT("Undo");
  109. const FString WwiseWaapiHelper::VALUE = TEXT("value");
  110. const FString WwiseWaapiHelper::VOLUME = TEXT("Volume");
  111. const FString WwiseWaapiHelper::WHERE = TEXT("where");
  112. const FString WwiseWaapiHelper::WORKUNIT_TYPE = TEXT("workunit:type");
  113. const FString WwiseWaapiHelper::WRITE_TO_DISK = TEXT("writeToDisk");
  114. /*------------------------------------------------------------------------------------
  115. Methods
  116. ------------------------------------------------------------------------------------*/
  117. bool CallWappiGetPropertySate(const FString& ItemID, const FString& ItemProperty, TSharedPtr<FJsonObject>& ItemInfoResult)
  118. {
  119. auto* waapiClient = FAkWaapiClient::Get();
  120. if (!waapiClient)
  121. return false;
  122. TSharedRef<FJsonObject> args = MakeShareable(new FJsonObject());
  123. {
  124. TSharedPtr<FJsonObject> from = MakeShareable(new FJsonObject());
  125. from->SetArrayField(WwiseWaapiHelper::ID, TArray<TSharedPtr<FJsonValue>> { MakeShareable(new FJsonValueString(ItemID)) });
  126. args->SetObjectField(WwiseWaapiHelper::FROM, from);
  127. }
  128. TSharedRef<FJsonObject> options = MakeShareable(new FJsonObject());
  129. options->SetArrayField(WwiseWaapiHelper::RETURN, TArray<TSharedPtr<FJsonValue>> { MakeShareable(new FJsonValueString(WwiseWaapiHelper::AT + ItemProperty)) });
  130. #if AK_SUPPORT_WAAPI
  131. TSharedPtr<FJsonObject> outJsonResult;
  132. if (!waapiClient->Call(ak::wwise::core::object::get, args, options, outJsonResult))
  133. return false;
  134. ItemInfoResult = outJsonResult->GetArrayField(WwiseWaapiHelper::RETURN)[0]->AsObject();
  135. #endif
  136. return true;
  137. }
  138. bool SubscribeToPropertyStateChange(const FString& ItemID, const FString& ItemProperty, WampEventCallback CallBack, uint64& SubscriptionId, TSharedPtr<FJsonObject>& outJsonResult)
  139. {
  140. auto* waapiClient = FAkWaapiClient::Get();
  141. if (!waapiClient)
  142. return false;
  143. #if AK_SUPPORT_WAAPI
  144. TSharedRef<FJsonObject> options = MakeShareable(new FJsonObject());
  145. options->SetStringField(WwiseWaapiHelper::OBJECT, ItemID);
  146. options->SetStringField(WwiseWaapiHelper::PROPERTY, ItemProperty);
  147. return waapiClient->Subscribe(ak::wwise::core::object::propertyChanged, options, CallBack, SubscriptionId, outJsonResult);
  148. #endif
  149. return false;
  150. }
  151. #undef LOCTEXT_NAMESPACE