AudioSystemEditor_wwise.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 <IAudioSystemEditor.h>
  10. #include <IAudioConnection.h>
  11. #include <IAudioSystemControl.h>
  12. #include <AudioWwiseLoader.h>
  13. namespace AudioControls
  14. {
  15. //-------------------------------------------------------------------------------------------//
  16. class CRtpcConnection
  17. : public IAudioConnection
  18. {
  19. public:
  20. explicit CRtpcConnection(CID id)
  21. : IAudioConnection(id)
  22. , m_mult(1.0f)
  23. , m_shift(0.0f)
  24. {}
  25. ~CRtpcConnection() override = default;
  26. bool HasProperties() override { return true; }
  27. float m_mult;
  28. float m_shift;
  29. };
  30. using TRtpcConnectionPtr = AZStd::shared_ptr<CRtpcConnection>;
  31. //-------------------------------------------------------------------------------------------//
  32. class CStateToRtpcConnection
  33. : public IAudioConnection
  34. {
  35. public:
  36. explicit CStateToRtpcConnection(CID id)
  37. : IAudioConnection(id)
  38. , m_value(0.0f)
  39. {}
  40. ~CStateToRtpcConnection() override = default;
  41. bool HasProperties() override { return true; }
  42. float m_value;
  43. };
  44. using TStateConnectionPtr = AZStd::shared_ptr<CStateToRtpcConnection>;
  45. //-------------------------------------------------------------------------------------------//
  46. class CAudioSystemEditor_wwise
  47. : public IAudioSystemEditor
  48. {
  49. friend class CAudioWwiseLoader;
  50. public:
  51. CAudioSystemEditor_wwise();
  52. ~CAudioSystemEditor_wwise() override = default;
  53. //////////////////////////////////////////////////////////
  54. // IAudioSystemEditor implementation
  55. /////////////////////////////////////////////////////////
  56. void Reload() override;
  57. IAudioSystemControl* CreateControl(const SControlDef& controlDefinition) override;
  58. IAudioSystemControl* GetRoot() override { return &m_rootControl; }
  59. IAudioSystemControl* GetControl(CID id) const override;
  60. EACEControlType ImplTypeToATLType(TImplControlType type) const override;
  61. TImplControlTypeMask GetCompatibleTypes(EACEControlType atlControlType) const override;
  62. TConnectionPtr CreateConnectionToControl(EACEControlType atlControlType, IAudioSystemControl* middlewareControl) override;
  63. TConnectionPtr CreateConnectionFromXMLNode(AZ::rapidxml::xml_node<char>* node, EACEControlType atlControlType) override;
  64. AZ::rapidxml::xml_node<char>* CreateXMLNodeFromConnection(const TConnectionPtr connection, const EACEControlType atlControlType) override;
  65. const AZStd::string_view GetTypeIcon(TImplControlType type) const override;
  66. const AZStd::string_view GetTypeIconSelected(TImplControlType type) const override;
  67. AZStd::string GetName() const override;
  68. AZ::IO::FixedMaxPath GetDataPath() const override;
  69. void DataSaved() override {}
  70. void ConnectionRemoved(IAudioSystemControl* control) override;
  71. //////////////////////////////////////////////////////////
  72. private:
  73. IAudioSystemControl* GetControlByName(AZStd::string name, bool isLocalized = false, IAudioSystemControl* parent = nullptr) const;
  74. // Gets the ID of the control given its name. As controls can have the same name
  75. // if they're under different parents, the name of the parent is also needed (if there is one)
  76. CID GetID(const AZStd::string_view name) const;
  77. void UpdateConnectedStatus();
  78. IAudioSystemControl m_rootControl;
  79. using TControlPtr = AZStd::shared_ptr<IAudioSystemControl>;
  80. using TControlMap = AZStd::unordered_map<CID, TControlPtr>;
  81. TControlMap m_controls;
  82. using TConnectionsMap = AZStd::unordered_map<CID, int>;
  83. TConnectionsMap m_connectionsByID;
  84. CAudioWwiseLoader m_loader;
  85. };
  86. } // namespace AudioControls