Source.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*******************************************************************************
  2. * Copyright 2015-2016 Juan Francisco Crespo Galán
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. ******************************************************************************/
  16. #pragma once
  17. /**
  18. * @file Source.h
  19. * @ingroup fx
  20. * The Source class.
  21. */
  22. #include "Audaspace.h"
  23. #include <atomic>
  24. AUD_NAMESPACE_BEGIN
  25. /**
  26. * This class stores the azimuth and elevation angles of a sound and allows to change them dynamically.
  27. * The azimuth angle goes clockwise. For a sound source situated at the right of the listener the azimuth angle is 90.
  28. */
  29. class AUD_API Source
  30. {
  31. private:
  32. /**
  33. * Azimuth value.
  34. */
  35. std::atomic<float> m_azimuth;
  36. /**
  37. * Elevation value.
  38. */
  39. std::atomic<float> m_elevation;
  40. /**
  41. * Distance value. Between 0 and 1.
  42. */
  43. std::atomic<float> m_distance;
  44. // delete copy constructor and operator=
  45. Source(const Source&) = delete;
  46. Source& operator=(const Source&) = delete;
  47. public:
  48. /**
  49. * Creates a Source instance with an initial value.
  50. * \param azimuth The value of the azimuth.
  51. * \param elevation The value of the elevation.
  52. * \param distance The distance from the listener. Max distance is 1, min distance is 0.
  53. */
  54. Source(float azimuth, float elevation, float distance = 0.0);
  55. /**
  56. * Retrieves the current azimuth value.
  57. * \return The current azimuth.
  58. */
  59. float getAzimuth();
  60. /**
  61. * Retrieves the current elevation value.
  62. * \return The current elevation.
  63. */
  64. float getElevation();
  65. /**
  66. * Retrieves the current distance value.
  67. * \return The current distance.
  68. */
  69. float getDistance();
  70. /**
  71. * Retrieves the current volume value based on the distance.
  72. * \return The current volume based on the Distance.
  73. */
  74. float getVolume();
  75. /**
  76. * Changes the azimuth value.
  77. * \param azimuth The new value for the azimuth.
  78. */
  79. void setAzimuth(float azimuth);
  80. /**
  81. * Changes the elevation value.
  82. * \param elevation The new value for the elevation.
  83. */
  84. void setElevation(float elevation);
  85. /**
  86. * Changes the distance value.
  87. * \param distance The new value for the distance. Max distance is 1, min distance is 0.
  88. */
  89. void setDistance(float distance);
  90. };
  91. AUD_NAMESPACE_END