AudioRtpcComponent.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/AudioRtpcComponentBus.h>
  12. #include <IAudioInterfacesCommonData.h>
  13. namespace LmbrCentral
  14. {
  15. /*!
  16. * AudioRtpcComponent
  17. * Allows settings values on ATL Rtpcs (Real-Time Parameter Controls).
  18. * An Rtpc name can be serialized with the component, or it can be manually specified
  19. * at runtime for use in scripting.
  20. */
  21. class AudioRtpcComponent
  22. : public AZ::Component
  23. , public AudioRtpcComponentRequestBus::Handler
  24. {
  25. public:
  26. /*!
  27. * AZ::Component
  28. */
  29. AZ_COMPONENT(AudioRtpcComponent, "{C54C7AE6-08AA-49E0-B6CD-E1BBB4950DAF}");
  30. void Activate() override;
  31. void Deactivate() override;
  32. AudioRtpcComponent() = default;
  33. AudioRtpcComponent(const AZStd::string& rtpcName);
  34. /*!
  35. * AudioRtpcComponentRequestBus::Handler Required Interface
  36. */
  37. void SetValue(float value) override;
  38. void SetRtpcValue(const char* rtpcName, float value) override;
  39. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  40. {
  41. provided.push_back(AZ_CRC_CE("AudioRtpcService"));
  42. }
  43. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  44. {
  45. required.push_back(AZ_CRC_CE("AudioProxyService"));
  46. }
  47. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  48. {
  49. dependent.push_back(AZ_CRC_CE("AudioPreloadService"));
  50. }
  51. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  52. {
  53. incompatible.push_back(AZ_CRC_CE("AudioRtpcService"));
  54. }
  55. static void Reflect(AZ::ReflectContext* context);
  56. private:
  57. //! Editor callback
  58. void OnRtpcNameChanged();
  59. //! Transient data
  60. Audio::TAudioControlID m_defaultRtpcID = INVALID_AUDIO_CONTROL_ID;
  61. //! Serialized data
  62. AZStd::string m_defaultRtpcName;
  63. };
  64. } // namespace LmbrCentral