FaderReader.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 FaderReader.h
  19. * @ingroup fx
  20. * Defines the FaderReader class as well as the two fading types.
  21. */
  22. #include "fx/EffectReader.h"
  23. AUD_NAMESPACE_BEGIN
  24. /// Fading types.
  25. enum FadeType
  26. {
  27. FADE_IN,
  28. FADE_OUT
  29. };
  30. /**
  31. * This class fades another reader.
  32. * If the fading type is FADE_IN, everything before the fading start will be
  33. * silenced, for FADE_OUT that's true for everything after fading ends.
  34. */
  35. class AUD_API FaderReader : public EffectReader
  36. {
  37. private:
  38. /**
  39. * The fading type.
  40. */
  41. const FadeType m_type;
  42. /**
  43. * The fading start.
  44. */
  45. const float m_start;
  46. /**
  47. * The fading length.
  48. */
  49. const float m_length;
  50. // delete copy constructor and operator=
  51. FaderReader(const FaderReader&) = delete;
  52. FaderReader& operator=(const FaderReader&) = delete;
  53. public:
  54. /**
  55. * Creates a new fader reader.
  56. * \param reader The reader that this effect is applied on.
  57. * \param type The fading type.
  58. * \param start The time where fading should start in seconds.
  59. * \param length How long fading should last in seconds.
  60. */
  61. FaderReader(std::shared_ptr<IReader> reader, FadeType type,
  62. float start,float length);
  63. virtual void read(int& length, bool& eos, sample_t* buffer);
  64. };
  65. AUD_NAMESPACE_END