3
0

MiniAudioPlaybackComponentConfig.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 "AzCore/Math/MathUtils.h"
  10. #include <AzCore/Asset/AssetCommon.h>
  11. #include <AzCore/Component/ComponentBus.h>
  12. #include <AzCore/RTTI/RTTI.h>
  13. #include <AzCore/Serialization/EditContext.h>
  14. #include <MiniAudio/SoundAsset.h>
  15. #include <AzCore/Math/Vector3.h>
  16. namespace MiniAudio
  17. {
  18. // AttenuationModel hidden here to prevent needing to include miniaudio.h here.
  19. enum class AttenuationModel // must match ma_attenuation_model from miniaudio.
  20. {
  21. Inverse = 1, //ma_attenuation_model_inverse,
  22. Linear = 2, // ma_attenuation_model_linear,
  23. Exponential = 3, //= ma_attenuation_model_exponential
  24. };
  25. class MiniAudioPlaybackComponentConfig final
  26. : public AZ::ComponentConfig
  27. {
  28. public:
  29. AZ_RTTI(MiniAudioPlaybackComponentConfig, "{b829e7ae-690f-4cf4-a350-e39929f206c2}");
  30. static void Reflect(AZ::ReflectContext* context);
  31. AZ::Data::Asset<SoundAsset> m_sound;
  32. //! If true, automatically play when the entity activates, useful for
  33. //! environment audio.
  34. bool m_autoplayOnActivate = false;
  35. //! Playback volume represented as a percentage
  36. float m_volume = 100.f;
  37. //! If true, follow the position of the entity.
  38. bool m_autoFollowEntity = false;
  39. //! If true, loops the sound.
  40. bool m_loop = false;
  41. bool m_enableSpatialization = false;
  42. AttenuationModel m_attenuationModel = AttenuationModel::Inverse;
  43. float m_minimumDistance = 3.f;
  44. float m_maximumDistance = 30.f;
  45. //! Inner cone angle
  46. float m_innerAngleInRadians = AZ::Constants::TwoPi;
  47. float m_innerAngleInDegrees = AZ::RadToDeg(m_innerAngleInRadians);
  48. //! Outer cone angle
  49. float m_outerAngleInRadians = AZ::Constants::TwoPi;
  50. float m_outerAngleInDegrees = AZ::RadToDeg(m_outerAngleInRadians);
  51. //! Volume outside of outer cone
  52. float m_outerVolume = 0.f;
  53. //! Directional controls
  54. float m_directionalAttenuationFactor = 1.f;
  55. bool m_fixedDirection = false;
  56. AZ::Vector3 m_direction = AZ::Vector3::CreateAxisY(1.f);
  57. };
  58. } // namespace MiniAudio