Sequence.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 Sequence.h
  19. * @ingroup sequence
  20. * The Sequence class.
  21. */
  22. #include "ISound.h"
  23. #include "respec/Specification.h"
  24. #include "devices/I3DDevice.h"
  25. #include "sequence/AnimateableProperty.h"
  26. #include <list>
  27. AUD_NAMESPACE_BEGIN
  28. class SequenceEntry;
  29. class SequenceData;
  30. /**
  31. * This sound represents sequenced entries to play a sound scene.
  32. */
  33. class AUD_API Sequence : public ISound
  34. {
  35. friend class SequenceReader;
  36. private:
  37. /// The sequence.
  38. std::shared_ptr<SequenceData> m_sequence;
  39. // delete copy constructor and operator=
  40. Sequence(const Sequence&) = delete;
  41. Sequence& operator=(const Sequence&) = delete;
  42. public:
  43. /**
  44. * Creates a new sound scene.
  45. * \param specs The output audio data specification.
  46. * \param fps The FPS of the scene.
  47. * \param muted Whether the whole scene is muted.
  48. */
  49. Sequence(Specs specs, float fps, bool muted);
  50. /**
  51. * Retrieves the audio output specification.
  52. * \return The specification.
  53. */
  54. Specs getSpecs();
  55. /**
  56. * Sets the audio output specification.
  57. * \param specs The new specification.
  58. */
  59. void setSpecs(Specs specs);
  60. /**
  61. * Retrieves the scene's FPS.
  62. * \return The scene's FPS.
  63. */
  64. float getFPS() const;
  65. /**
  66. * Sets the scene's FPS.
  67. * \param fps The new FPS.
  68. */
  69. void setFPS(float fps);
  70. /**
  71. * Sets the muting state of the scene.
  72. * \param muted Whether the scene is muted.
  73. */
  74. void mute(bool muted);
  75. /**
  76. * Retrieves the muting state of the scene.
  77. * \return Whether the scene is muted.
  78. */
  79. bool isMuted() const;
  80. /**
  81. * Retrieves the speed of sound.
  82. * This value is needed for doppler effect calculation.
  83. * \return The speed of sound.
  84. */
  85. float getSpeedOfSound() const;
  86. /**
  87. * Sets the speed of sound.
  88. * This value is needed for doppler effect calculation.
  89. * \param speed The new speed of sound.
  90. */
  91. void setSpeedOfSound(float speed);
  92. /**
  93. * Retrieves the doppler factor.
  94. * This value is a scaling factor for the velocity vectors of sources and
  95. * listener which is used while calculating the doppler effect.
  96. * \return The doppler factor.
  97. */
  98. float getDopplerFactor() const;
  99. /**
  100. * Sets the doppler factor.
  101. * This value is a scaling factor for the velocity vectors of sources and
  102. * listener which is used while calculating the doppler effect.
  103. * \param factor The new doppler factor.
  104. */
  105. void setDopplerFactor(float factor);
  106. /**
  107. * Retrieves the distance model.
  108. * \return The distance model.
  109. */
  110. DistanceModel getDistanceModel() const;
  111. /**
  112. * Sets the distance model.
  113. * \param model distance model.
  114. */
  115. void setDistanceModel(DistanceModel model);
  116. /**
  117. * Retrieves one of the animated properties of the sound.
  118. * \param type Which animated property to retrieve.
  119. * \return A pointer to the animated property, valid as long as the
  120. * sound is.
  121. */
  122. AnimateableProperty* getAnimProperty(AnimateablePropertyType type);
  123. /**
  124. * Adds a new entry to the scene.
  125. * \param sound The sound this entry should play.
  126. * \param begin The start time.
  127. * \param end The end time or a negative value if determined by the sound.
  128. * \param skip How much seconds should be skipped at the beginning.
  129. * \return The entry added.
  130. */
  131. std::shared_ptr<SequenceEntry> add(std::shared_ptr<ISound> sound, float begin, float end, float skip);
  132. /**
  133. * Removes an entry from the scene.
  134. * \param entry The entry to remove.
  135. */
  136. void remove(std::shared_ptr<SequenceEntry> entry);
  137. /**
  138. * Creates a new reader with high quality resampling.
  139. * \return The new reader.
  140. */
  141. std::shared_ptr<IReader> createQualityReader();
  142. virtual std::shared_ptr<IReader> createReader();
  143. };
  144. AUD_NAMESPACE_END