MiniAudioPlaybackComponentConfig.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/Asset/AssetCommon.h>
  10. #include <AzCore/Component/ComponentBus.h>
  11. #include <AzCore/RTTI/RTTI.h>
  12. #include <AzCore/Serialization/EditContext.h>
  13. #include <MiniAudio/SoundAsset.h>
  14. namespace MiniAudio
  15. {
  16. // AttenuationModel hidden here to prevent needing to include miniaudio.h here.
  17. enum class AttenuationModel // must match ma_attenuation_model from miniaudio.
  18. {
  19. Inverse = 1, //ma_attenuation_model_inverse,
  20. Linear = 2, // ma_attenuation_model_linear,
  21. Exponential = 3, //= ma_attenuation_model_exponential
  22. };
  23. class MiniAudioPlaybackComponentConfig final
  24. : public AZ::ComponentConfig
  25. {
  26. public:
  27. AZ_RTTI(MiniAudioPlaybackComponentConfig, "{b829e7ae-690f-4cf4-a350-e39929f206c2}");
  28. static void Reflect(AZ::ReflectContext* context);
  29. AZ::Data::Asset<SoundAsset> m_sound;
  30. //! If true, automatically play when the entity activates, useful for
  31. //! environment audio.
  32. bool m_autoplayOnActivate = false;
  33. float m_volume = 1.f;
  34. //! If true, follow the position of the entity.
  35. bool m_autoFollowEntity = false;
  36. //! If true, loops the sound.
  37. bool m_loop = false;
  38. bool m_enableSpatialization = false;
  39. AttenuationModel m_attenuationModel = AttenuationModel::Inverse;
  40. float m_minimumDistance = 3.f;
  41. float m_maximumDistance = 30.f;
  42. };
  43. } // namespace MiniAudio