AkReverbDescriptor.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #pragma once
  16. #include "AkGameplayTypes.h"
  17. #include "AkReverbDescriptor.generated.h"
  18. class UAkAcousticTextureSetComponent;
  19. class UAkLateReverbComponent;
  20. class UAkRoomComponent;
  21. #define PARAM_ESTIMATION_UPDATE_PERIOD 0.1f
  22. /**
  23. * FAkReverbDescriptor is used to estimate the reverb parameters of a primitive component, by calculating its volume and surface area, and using the 'sabine equation' to estimate the reverb tail.
  24. * It also estimates the Time to First Reflection and the HFDamping.
  25. */
  26. USTRUCT()
  27. struct AKAUDIO_API FAkReverbDescriptor
  28. {
  29. GENERATED_BODY()
  30. public:
  31. static double TriangleArea(const FVector& v1, const FVector& v2, const FVector& v3);
  32. static float SignedVolumeOfTriangle(const FVector& p1, const FVector& p2, const FVector& p3);
  33. float PrimitiveVolume = 0.0f;
  34. float PrimitiveSurfaceArea = 0.0f;
  35. float T60Decay = 0.0f;
  36. float HFDamping = 0.0f;
  37. float TimeToFirstReflection = 0.0f;
  38. bool ShouldEstimateDecay() const;
  39. bool ShouldEstimateDamping() const;
  40. bool ShouldEstimatePredelay() const;
  41. bool RequiresUpdates() const;
  42. void CalculateT60(UAkLateReverbComponent* reverbComp);
  43. void CalculateTimeToFirstReflection();
  44. void CalculateHFDamping(const UAkAcousticTextureSetComponent* textureSetComponent);
  45. void SetPrimitive(UPrimitiveComponent* primitive);
  46. void SetReverbComponent(UAkLateReverbComponent* reverbComp);
  47. void UpdateAllRTPCs(const UAkRoomComponent* room) const;
  48. private:
  49. UPROPERTY(Transient)
  50. UPrimitiveComponent* Primitive = nullptr;
  51. UAkLateReverbComponent* ReverbComponent = nullptr;
  52. /* Looks for a room component attached to Primitive, whose room ID has been registered with wwise, and whose world is Game or PIE.
  53. room will be null if no such room is found, or if there is no valid AkAudioDevice.
  54. return true if a room is found (and there is a valid AkAudioDevice). */
  55. bool GetRTPCRoom(UAkRoomComponent*& room) const;
  56. bool CanSetRTPCOnRoom(const UAkRoomComponent* room) const;
  57. void UpdateDecayRTPC() const;
  58. void UpdateDampingRTPC() const;
  59. void UpdatePredelaytRTPC() const;
  60. };