Common_wwise.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. * its licensors.
  4. *
  5. * For complete copyright and license terms please see the LICENSE at the root of this
  6. * distribution (the "License"). All use of this software is governed by the License,
  7. * or, if provided, by the license below or the license accompanying this file. Do not
  8. * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. *
  11. */
  12. // Original file Copyright Crytek GMBH or its affiliates, used under license.
  13. #pragma once
  14. #include <AK/SoundEngine/Common/AkMemoryMgr.h>
  15. #include <AK/SoundEngine/Common/AkTypes.h>
  16. #include <AK/AkWwiseSDKVersion.h>
  17. #include <IAudioSystem.h>
  18. #include <AudioEngineWwise_Traits_Platform.h>
  19. #define WWISE_IMPL_VERSION_STRING "Wwise " AK_WWISESDK_VERSIONNAME
  20. #define ASSERT_WWISE_OK(x) (AKASSERT((x) == AK_Success))
  21. #define IS_WWISE_OK(x) ((x) == AK_Success)
  22. namespace Audio
  23. {
  24. ///////////////////////////////////////////////////////////////////////////////////////////////////
  25. // Wwise Xml Element Names
  26. namespace WwiseXmlTags
  27. {
  28. static constexpr const char* WwiseEventTag = "WwiseEvent";
  29. static constexpr const char* WwiseRtpcTag = "WwiseRtpc";
  30. static constexpr const char* WwiseSwitchTag = "WwiseSwitch";
  31. static constexpr const char* WwiseStateTag = "WwiseState";
  32. static constexpr const char* WwiseRtpcSwitchTag = "WwiseRtpc";
  33. static constexpr const char* WwiseFileTag = "WwiseFile";
  34. static constexpr const char* WwiseAuxBusTag = "WwiseAuxBus";
  35. static constexpr const char* WwiseValueTag = "WwiseValue";
  36. static constexpr const char* WwiseNameAttribute = "wwise_name";
  37. static constexpr const char* WwiseValueAttribute = "wwise_value";
  38. static constexpr const char* WwiseMutiplierAttribute = "atl_mult";
  39. static constexpr const char* WwiseShiftAttribute = "atl_shift";
  40. static constexpr const char* WwiseLocalizedAttribute = "wwise_localized";
  41. namespace Legacy
  42. {
  43. static constexpr const char* WwiseLocalizedAttribute = "wwise_localised";
  44. }
  45. } // namespace WwiseXmlTags
  46. ///////////////////////////////////////////////////////////////////////////////////////////////////
  47. // Wwise-specific helper functions
  48. ///////////////////////////////////////////////////////////////////////////////////////////////////
  49. inline AkVector AZVec3ToAkVector(const AZ::Vector3& vec3)
  50. {
  51. // swizzle Y <--> Z
  52. AkVector akVec;
  53. akVec.X = vec3.GetX();
  54. akVec.Y = vec3.GetZ();
  55. akVec.Z = vec3.GetY();
  56. return akVec;
  57. }
  58. ///////////////////////////////////////////////////////////////////////////////////////////////////
  59. inline AkTransform AZVec3ToAkTransform(const AZ::Vector3& position)
  60. {
  61. AkTransform akTransform;
  62. akTransform.SetOrientation(0.0, 0.0, 1.0, 0.0, 1.0, 0.0); // May add orientation support later.
  63. akTransform.SetPosition(AZVec3ToAkVector(position));
  64. return akTransform;
  65. }
  66. ///////////////////////////////////////////////////////////////////////////////////////////////////
  67. inline void ATLTransformToAkTransform(const SATLWorldPosition& atlTransform, AkTransform& akTransform)
  68. {
  69. akTransform.Set(
  70. AZVec3ToAkVector(atlTransform.GetPositionVec()),
  71. AZVec3ToAkVector(atlTransform.GetForwardVec().GetNormalized()), // Wwise SDK requires that the Orientation vectors
  72. AZVec3ToAkVector(atlTransform.GetUpVec().GetNormalized()) // are normalized prior to sending to the apis.
  73. );
  74. }
  75. ///////////////////////////////////////////////////////////////////////////////////////////////////
  76. namespace Wwise
  77. {
  78. // See AkMemoryMgr.h
  79. inline static const char* MemoryManagerCategories[]
  80. {
  81. "Object", "Event", "Structure", "Media", "GameObject", "Processing", "ProcessingPlugin", "Streaming", "StreamingIO",
  82. "SpatialAudio", "SpatialAudioGeometry", "SpatialAudioPaths", "GameSim", "MonitorQueue", "Profiler", "FilePackage",
  83. "SoundEngine", "Integration"
  84. };
  85. static_assert(AZ_ARRAY_SIZE(MemoryManagerCategories) == AkMemID_NUM,
  86. "Wwise memory categories have changed, the list of display names needs to be updated.");
  87. } // namespace Wwise
  88. } // namespace Audio