Fader.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 Fader.h
  19. * @ingroup fx
  20. * The Fader class.
  21. */
  22. #include "fx/Effect.h"
  23. #include "fx/FaderReader.h"
  24. AUD_NAMESPACE_BEGIN
  25. /**
  26. * This sound fades another sound.
  27. * If the fading type is FADE_IN, everything before the fading start will be
  28. * silenced, for FADE_OUT that's true for everything after fading ends.
  29. */
  30. class AUD_API Fader : public Effect
  31. {
  32. private:
  33. /**
  34. * The fading type.
  35. */
  36. const FadeType m_type;
  37. /**
  38. * The fading start.
  39. */
  40. const float m_start;
  41. /**
  42. * The fading length.
  43. */
  44. const float m_length;
  45. // delete copy constructor and operator=
  46. Fader(const Fader&) = delete;
  47. Fader& operator=(const Fader&) = delete;
  48. public:
  49. /**
  50. * Creates a new fader sound.
  51. * \param sound The input sound.
  52. * \param type The fading type.
  53. * \param start The time where fading should start in seconds.
  54. * \param length How long fading should last in seconds.
  55. */
  56. Fader(std::shared_ptr<ISound> sound,
  57. FadeType type = FADE_IN,
  58. float start = 0.0f, float length = 1.0f);
  59. /**
  60. * Returns the fading type.
  61. */
  62. FadeType getType() const;
  63. /**
  64. * Returns the fading start.
  65. */
  66. float getStart() const;
  67. /**
  68. * Returns the fading length.
  69. */
  70. float getLength() const;
  71. virtual std::shared_ptr<IReader> createReader();
  72. };
  73. AUD_NAMESPACE_END