I3DDevice.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*******************************************************************************
  2. * Copyright 2009-2016 Jörg Müller
  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 I3DDevice.h
  19. * @ingroup devices
  20. * Defines the I3DDevice interface as well as the different distance models.
  21. */
  22. #include "util/Math3D.h"
  23. AUD_NAMESPACE_BEGIN
  24. /**
  25. * Possible distance models for the 3D device.
  26. *
  27. * The distance models supported are the same as documented in the [OpenAL Specification](http://openal.org/).
  28. */
  29. enum DistanceModel
  30. {
  31. DISTANCE_MODEL_INVALID = 0,
  32. DISTANCE_MODEL_INVERSE,
  33. DISTANCE_MODEL_INVERSE_CLAMPED,
  34. DISTANCE_MODEL_LINEAR,
  35. DISTANCE_MODEL_LINEAR_CLAMPED,
  36. DISTANCE_MODEL_EXPONENT,
  37. DISTANCE_MODEL_EXPONENT_CLAMPED
  38. };
  39. /**
  40. * @interface I3DDevice
  41. * The I3DDevice interface represents an output device for 3D sound.
  42. *
  43. * The interface has been modelled after the OpenAL 1.1 API,
  44. * see the [OpenAL Specification](http://openal.org/) for lots of details.
  45. */
  46. class AUD_API I3DDevice
  47. {
  48. public:
  49. /**
  50. * Retrieves the listener location.
  51. * \return The listener location.
  52. */
  53. virtual Vector3 getListenerLocation() const=0;
  54. /**
  55. * Sets the listener location.
  56. * \param location The new location.
  57. * \note The location is not updated with the velocity and
  58. * remains constant until the next call of this method.
  59. */
  60. virtual void setListenerLocation(const Vector3& location)=0;
  61. /**
  62. * Retrieves the listener velocity.
  63. * \return The listener velocity.
  64. */
  65. virtual Vector3 getListenerVelocity() const=0;
  66. /**
  67. * Sets the listener velocity.
  68. * \param velocity The new velocity.
  69. * \note This velocity does not change the position of the listener
  70. * over time, it is simply used for the calculation of the doppler effect.
  71. */
  72. virtual void setListenerVelocity(const Vector3& velocity)=0;
  73. /**
  74. * Retrieves the listener orientation.
  75. * \return The listener orientation as quaternion.
  76. */
  77. virtual Quaternion getListenerOrientation() const=0;
  78. /**
  79. * Sets the listener orientation.
  80. * \param orientation The new orientation as quaternion.
  81. * \note The coordinate system used is right handed and the listener
  82. * by default is oriented looking in the negative z direction with the
  83. * positive y axis as up direction.
  84. */
  85. virtual void setListenerOrientation(const Quaternion& orientation)=0;
  86. /**
  87. * Retrieves the speed of sound.
  88. * This value is needed for doppler effect calculation.
  89. * \return The speed of sound.
  90. */
  91. virtual float getSpeedOfSound() const=0;
  92. /**
  93. * Sets the speed of sound.
  94. * This value is needed for doppler effect calculation.
  95. * \param speed The new speed of sound.
  96. */
  97. virtual void setSpeedOfSound(float speed)=0;
  98. /**
  99. * Retrieves the doppler factor.
  100. * This value is a scaling factor for the velocity vectors of sources and
  101. * listener which is used while calculating the doppler effect.
  102. * \return The doppler factor.
  103. */
  104. virtual float getDopplerFactor() const=0;
  105. /**
  106. * Sets the doppler factor.
  107. * This value is a scaling factor for the velocity vectors of sources and
  108. * listener which is used while calculating the doppler effect.
  109. * \param factor The new doppler factor.
  110. */
  111. virtual void setDopplerFactor(float factor)=0;
  112. /**
  113. * Retrieves the distance model.
  114. * \return The distance model.
  115. */
  116. virtual DistanceModel getDistanceModel() const=0;
  117. /**
  118. * Sets the distance model.
  119. * \param model distance model.
  120. */
  121. virtual void setDistanceModel(DistanceModel model)=0;
  122. };
  123. AUD_NAMESPACE_END