Common_wwise.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AK/SoundEngine/Common/AkMemoryMgr.h>
  10. #include <AK/SoundEngine/Common/AkTypes.h>
  11. #include <AK/AkWwiseSDKVersion.h>
  12. #include <IAudioSystem.h>
  13. #include <AudioEngineWwise_Traits_Platform.h>
  14. #define WWISE_IMPL_VERSION_STRING "Wwise " AK_WWISESDK_VERSIONNAME
  15. #define ASSERT_WWISE_OK(x) (AKASSERT((x) == AK_Success))
  16. #define IS_WWISE_OK(x) ((x) == AK_Success)
  17. namespace Audio
  18. {
  19. ///////////////////////////////////////////////////////////////////////////////////////////////////
  20. // Wwise Xml Element Names
  21. namespace WwiseXmlTags
  22. {
  23. static constexpr const char* WwiseEventTag = "WwiseEvent";
  24. static constexpr const char* WwiseRtpcTag = "WwiseRtpc";
  25. static constexpr const char* WwiseSwitchTag = "WwiseSwitch";
  26. static constexpr const char* WwiseStateTag = "WwiseState";
  27. static constexpr const char* WwiseRtpcSwitchTag = "WwiseRtpc";
  28. static constexpr const char* WwiseFileTag = "WwiseFile";
  29. static constexpr const char* WwiseAuxBusTag = "WwiseAuxBus";
  30. static constexpr const char* WwiseValueTag = "WwiseValue";
  31. static constexpr const char* WwiseNameAttribute = "wwise_name";
  32. static constexpr const char* WwiseValueAttribute = "wwise_value";
  33. static constexpr const char* WwiseMutiplierAttribute = "atl_mult";
  34. static constexpr const char* WwiseShiftAttribute = "atl_shift";
  35. static constexpr const char* WwiseLocalizedAttribute = "wwise_localized";
  36. namespace Legacy
  37. {
  38. static constexpr const char* WwiseLocalizedAttribute = "wwise_localised";
  39. }
  40. } // namespace WwiseXmlTags
  41. ///////////////////////////////////////////////////////////////////////////////////////////////////
  42. // Wwise-specific helper functions
  43. ///////////////////////////////////////////////////////////////////////////////////////////////////
  44. inline AkVector AZVec3ToAkVector(const AZ::Vector3& vec3)
  45. {
  46. // swizzle Y <--> Z
  47. AkVector akVec;
  48. akVec.X = vec3.GetX();
  49. akVec.Y = vec3.GetZ();
  50. akVec.Z = vec3.GetY();
  51. return akVec;
  52. }
  53. ///////////////////////////////////////////////////////////////////////////////////////////////////
  54. inline AkTransform AZVec3ToAkTransform(const AZ::Vector3& position)
  55. {
  56. AkTransform akTransform;
  57. akTransform.SetOrientation(0.0, 0.0, 1.0, 0.0, 1.0, 0.0); // May add orientation support later.
  58. akTransform.SetPosition(AZVec3ToAkVector(position));
  59. return akTransform;
  60. }
  61. #if AK_WWISESDK_VERSION_MAJOR >= 2022
  62. inline void ATLTransformToAkTransform(const SATLWorldPosition& atlTransform, AkWorldTransform& akWorldTransform)
  63. {
  64. akWorldTransform.Set(
  65. AZVec3ToAkVector(atlTransform.GetPositionVec()),
  66. AZVec3ToAkVector(atlTransform.GetForwardVec().GetNormalized()), // Wwise SDK requires that the Orientation vectors
  67. AZVec3ToAkVector(atlTransform.GetUpVec().GetNormalized()) // are normalized prior to sending to the apis.
  68. );
  69. }
  70. #endif // AK_WWISESDK_VERSION_MAJOR >= 2022
  71. ///////////////////////////////////////////////////////////////////////////////////////////////////
  72. inline void ATLTransformToAkTransform(const SATLWorldPosition& atlTransform, AkTransform& akTransform)
  73. {
  74. akTransform.Set(
  75. AZVec3ToAkVector(atlTransform.GetPositionVec()),
  76. AZVec3ToAkVector(atlTransform.GetForwardVec().GetNormalized()), // Wwise SDK requires that the Orientation vectors
  77. AZVec3ToAkVector(atlTransform.GetUpVec().GetNormalized()) // are normalized prior to sending to the apis.
  78. );
  79. }
  80. ///////////////////////////////////////////////////////////////////////////////////////////////////
  81. namespace Wwise
  82. {
  83. // See AkMemoryMgr.h
  84. inline static const char* MemoryManagerCategories[]
  85. {
  86. "Object", "Event", "Structure", "Media", "GameObject", "Processing", "ProcessingPlugin", "Streaming", "StreamingIO",
  87. "SpatialAudio", "SpatialAudioGeometry", "SpatialAudioPaths", "GameSim", "MonitorQueue", "Profiler", "FilePackage",
  88. "SoundEngine", "Integration"
  89. #if AK_WWISESDK_VERSION_MAJOR >= 2022
  90. , "JobMgr"
  91. #endif // AK_WWISESDK_VERSION_MAJOR >= 2022
  92. };
  93. static_assert(AZ_ARRAY_SIZE(MemoryManagerCategories) == AkMemID_NUM,
  94. "Wwise memory categories have changed, the list of display names needs to be updated.");
  95. } // namespace Wwise
  96. } // namespace Audio