AudioEnvironmentComponent.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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/std/string/string.h>
  10. #include <AzCore/Component/Component.h>
  11. #include <LmbrCentral/Audio/AudioEnvironmentComponentBus.h>
  12. #include <IAudioInterfacesCommonData.h>
  13. namespace LmbrCentral
  14. {
  15. /*!
  16. * AudioEnvironmentComponent
  17. * Allows "sending" an amount of sound signal through effects.
  18. * Typically this is done via auxillary effects bus sends.
  19. * The signal goes through the bus and comes out 'wet' and is
  20. * mixed into the original 'dry' sound.
  21. * Only 1 AudioEnvironmentComponent is allowed on an Entity,
  22. * but the api supports multiple Environment sends.
  23. */
  24. class AudioEnvironmentComponent
  25. : public AZ::Component
  26. , public AudioEnvironmentComponentRequestBus::Handler
  27. {
  28. public:
  29. /*!
  30. * AZ::Component
  31. */
  32. AZ_COMPONENT(AudioEnvironmentComponent, "{D5085D04-2522-4585-9E65-D337C5BBB8A7}");
  33. void Activate() override;
  34. void Deactivate() override;
  35. AudioEnvironmentComponent() = default;
  36. AudioEnvironmentComponent(const AZStd::string& environmentName);
  37. /*!
  38. * AudioEnvironmentComponentRequestBus::Handler Interface
  39. */
  40. void SetAmount(float amount) override;
  41. void SetEnvironmentAmount(const char* environmentName, float amount) override;
  42. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  43. {
  44. provided.push_back(AZ_CRC_CE("AudioEnvironmentService"));
  45. }
  46. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  47. {
  48. dependent.push_back(AZ_CRC_CE("AudioPreloadService"));
  49. }
  50. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  51. {
  52. required.push_back(AZ_CRC_CE("AudioProxyService"));
  53. }
  54. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  55. {
  56. incompatible.push_back(AZ_CRC_CE("AudioEnvironmentService"));
  57. }
  58. static void Reflect(AZ::ReflectContext* context);
  59. private:
  60. //! Editor callbacks
  61. void OnDefaultEnvironmentChanged();
  62. //! Transient data
  63. Audio::TAudioEnvironmentID m_defaultEnvironmentID;
  64. //! Serialized data
  65. AZStd::string m_defaultEnvironmentName;
  66. };
  67. } // namespace LmbrCentral