SequenceEntry.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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 SequenceEntry.h
  19. * @ingroup sequence
  20. * The SequenceEntry class.
  21. */
  22. #include "sequence/AnimateableProperty.h"
  23. #include "util/ILockable.h"
  24. #include <mutex>
  25. #include <memory>
  26. AUD_NAMESPACE_BEGIN
  27. class ISound;
  28. /**
  29. * This class represents a sequenced entry in a sequencer sound.
  30. */
  31. class AUD_API SequenceEntry : public ILockable
  32. {
  33. friend class SequenceHandle;
  34. private:
  35. /// The status of the entry. Changes every time a non-animated parameter changes.
  36. int m_status;
  37. /// The positional status of the entry. Changes every time the entry is moved.
  38. int m_pos_status;
  39. /// The sound status, changed when the sound is changed.
  40. int m_sound_status;
  41. /// The unique (regarding the sound) ID of the entry.
  42. int m_id;
  43. /// The sound this entry plays.
  44. std::shared_ptr<ISound> m_sound;
  45. /// The begin time.
  46. float m_begin;
  47. /// The end time.
  48. float m_end;
  49. /// How many seconds are skipped at the beginning.
  50. float m_skip;
  51. /// Whether the entry is muted.
  52. bool m_muted;
  53. /// Whether the position to the listener is relative or absolute
  54. bool m_relative;
  55. /// Maximum volume.
  56. float m_volume_max;
  57. /// Minimum volume.
  58. float m_volume_min;
  59. /// Maximum distance.
  60. float m_distance_max;
  61. /// Reference distance;
  62. float m_distance_reference;
  63. /// Attenuation
  64. float m_attenuation;
  65. /// Cone outer angle.
  66. float m_cone_angle_outer;
  67. /// Cone inner angle.
  68. float m_cone_angle_inner;
  69. /// Cone outer volume.
  70. float m_cone_volume_outer;
  71. /// The mutex for locking.
  72. std::recursive_mutex m_mutex;
  73. /// The animated volume.
  74. AnimateableProperty m_volume;
  75. /// The animated panning.
  76. AnimateableProperty m_panning;
  77. /// The animated pitch.
  78. AnimateableProperty m_pitch;
  79. /// The animated location.
  80. AnimateableProperty m_location;
  81. /// The animated orientation.
  82. AnimateableProperty m_orientation;
  83. // delete copy constructor and operator=
  84. SequenceEntry(const SequenceEntry&) = delete;
  85. SequenceEntry& operator=(const SequenceEntry&) = delete;
  86. public:
  87. /**
  88. * Creates a new sequenced entry.
  89. * \param sound The sound this entry should play.
  90. * \param begin The start time.
  91. * \param end The end time or a negative value if determined by the sound.
  92. * \param skip How much seconds should be skipped at the beginning.
  93. * \param id The ID of the entry.
  94. */
  95. SequenceEntry(std::shared_ptr<ISound> sound, float begin, float end, float skip, int id);
  96. virtual ~SequenceEntry();
  97. /**
  98. * Locks the entry.
  99. */
  100. virtual void lock();
  101. /**
  102. * Unlocks the previously locked entry.
  103. */
  104. virtual void unlock();
  105. /**
  106. * Retrieves the sound of the entry.
  107. * \return The sound.
  108. */
  109. std::shared_ptr<ISound> getSound();
  110. /**
  111. * Sets the sound of the entry.
  112. * \param sound The new sound.
  113. */
  114. void setSound(std::shared_ptr<ISound> sound);
  115. /**
  116. * Moves the entry.
  117. * \param begin The new start time.
  118. * \param end The new end time or a negative value if unknown.
  119. * \param skip How many seconds to skip at the beginning.
  120. */
  121. void move(float begin, float end, float skip);
  122. /**
  123. * Retrieves the muting state of the entry.
  124. * \return Whether the entry should is muted or not.
  125. */
  126. bool isMuted();
  127. /**
  128. * Sets the muting state of the entry.
  129. * \param mute Whether the entry should be muted or not.
  130. */
  131. void mute(bool mute);
  132. /**
  133. * Retrieves the ID of the entry.
  134. * \return The ID of the entry.
  135. */
  136. int getID() const;
  137. /**
  138. * Retrieves one of the animated properties of the entry.
  139. * \param type Which animated property to retrieve.
  140. * \return A pointer to the animated property, valid as long as the
  141. * entry is.
  142. */
  143. AnimateableProperty* getAnimProperty(AnimateablePropertyType type);
  144. /**
  145. * Checks whether the source location, velocity and orientation are relative
  146. * to the listener.
  147. * \return Whether the source is relative.
  148. */
  149. bool isRelative();
  150. /**
  151. * Sets whether the source location, velocity and orientation are relative
  152. * to the listener.
  153. * \param relative Whether the source is relative.
  154. * \return Whether the action succeeded.
  155. */
  156. void setRelative(bool relative);
  157. /**
  158. * Retrieves the maximum volume of a source.
  159. * \return The maximum volume.
  160. */
  161. float getVolumeMaximum();
  162. /**
  163. * Sets the maximum volume of a source.
  164. * \param volume The new maximum volume.
  165. * \return Whether the action succeeded.
  166. */
  167. void setVolumeMaximum(float volume);
  168. /**
  169. * Retrieves the minimum volume of a source.
  170. * \return The minimum volume.
  171. */
  172. float getVolumeMinimum();
  173. /**
  174. * Sets the minimum volume of a source.
  175. * \param volume The new minimum volume.
  176. * \return Whether the action succeeded.
  177. */
  178. void setVolumeMinimum(float volume);
  179. /**
  180. * Retrieves the maximum distance of a source.
  181. * If a source is further away from the reader than this distance, the
  182. * volume will automatically be set to 0.
  183. * \return The maximum distance.
  184. */
  185. float getDistanceMaximum();
  186. /**
  187. * Sets the maximum distance of a source.
  188. * If a source is further away from the reader than this distance, the
  189. * volume will automatically be set to 0.
  190. * \param distance The new maximum distance.
  191. * \return Whether the action succeeded.
  192. */
  193. void setDistanceMaximum(float distance);
  194. /**
  195. * Retrieves the reference distance of a source.
  196. * \return The reference distance.
  197. */
  198. float getDistanceReference();
  199. /**
  200. * Sets the reference distance of a source.
  201. * \param distance The new reference distance.
  202. * \return Whether the action succeeded.
  203. */
  204. void setDistanceReference(float distance);
  205. /**
  206. * Retrieves the attenuation of a source.
  207. * \return The attenuation.
  208. */
  209. float getAttenuation();
  210. /**
  211. * Sets the attenuation of a source.
  212. * This value is used for distance calculation.
  213. * \param factor The new attenuation.
  214. * \return Whether the action succeeded.
  215. */
  216. void setAttenuation(float factor);
  217. /**
  218. * Retrieves the outer angle of the cone of a source.
  219. * \return The outer angle of the cone.
  220. */
  221. float getConeAngleOuter();
  222. /**
  223. * Sets the outer angle of the cone of a source.
  224. * \param angle The new outer angle of the cone.
  225. * \return Whether the action succeeded.
  226. */
  227. void setConeAngleOuter(float angle);
  228. /**
  229. * Retrieves the inner angle of the cone of a source.
  230. * \return The inner angle of the cone.
  231. */
  232. float getConeAngleInner();
  233. /**
  234. * Sets the inner angle of the cone of a source.
  235. * \param angle The new inner angle of the cone.
  236. * \return Whether the action succeeded.
  237. */
  238. void setConeAngleInner(float angle);
  239. /**
  240. * Retrieves the outer volume of the cone of a source.
  241. * The volume between inner and outer angle is interpolated between inner
  242. * volume and this value.
  243. * \return The outer volume of the cone.
  244. */
  245. float getConeVolumeOuter();
  246. /**
  247. * Sets the outer volume of the cone of a source.
  248. * The volume between inner and outer angle is interpolated between inner
  249. * volume and this value.
  250. * \param volume The new outer volume of the cone.
  251. * \return Whether the action succeeded.
  252. */
  253. void setConeVolumeOuter(float volume);
  254. };
  255. AUD_NAMESPACE_END