ModulatorReader.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 ModulatorReader.h
  19. * @ingroup fx
  20. * The ModulatorReader class.
  21. */
  22. #include "IReader.h"
  23. #include "util/Buffer.h"
  24. #include <memory>
  25. AUD_NAMESPACE_BEGIN
  26. /**
  27. * This reader plays two readers with the same specs in parallel multiplying their samples.
  28. */
  29. class AUD_API ModulatorReader : public IReader
  30. {
  31. private:
  32. /**
  33. * The first reader.
  34. */
  35. std::shared_ptr<IReader> m_reader1;
  36. /**
  37. * The second reader.
  38. */
  39. std::shared_ptr<IReader> m_reader2;
  40. /**
  41. * Buffer used for mixing.
  42. */
  43. Buffer m_buffer;
  44. // delete copy constructor and operator=
  45. ModulatorReader(const ModulatorReader&) = delete;
  46. ModulatorReader& operator=(const ModulatorReader&) = delete;
  47. public:
  48. /**
  49. * Creates a new modulator reader.
  50. * \param reader1 The first reader to read from.
  51. * \param reader2 The second reader to read from.
  52. * \exception Exception Thrown if the specs from the readers differ.
  53. */
  54. ModulatorReader(std::shared_ptr<IReader> reader1, std::shared_ptr<IReader> reader2);
  55. /**
  56. * Destroys the reader.
  57. */
  58. virtual ~ModulatorReader();
  59. virtual bool isSeekable() const;
  60. virtual void seek(int position);
  61. virtual int getLength() const;
  62. virtual int getPosition() const;
  63. virtual Specs getSpecs() const;
  64. virtual void read(int& length, bool& eos, sample_t* buffer);
  65. };
  66. AUD_NAMESPACE_END