Accumulator.h 2.5 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 Accumulator.h
  19. * @ingroup fx
  20. * The Accumulator class.
  21. */
  22. #include "fx/Effect.h"
  23. AUD_NAMESPACE_BEGIN
  24. class CallbackIIRFilterReader;
  25. /**
  26. * This sound creates an accumulator reader.
  27. *
  28. * The accumulator adds the difference at the input to the last output in case
  29. * it's positive. In additive mode it additionaly adds the difference always.
  30. * So in case the difference is positive, it's added twice.
  31. */
  32. class AUD_API Accumulator : public Effect
  33. {
  34. private:
  35. /**
  36. * Whether the accumulator is additive.
  37. */
  38. const bool m_additive;
  39. // delete copy constructor and operator=
  40. Accumulator(const Accumulator&) = delete;
  41. Accumulator& operator=(const Accumulator&) = delete;
  42. public:
  43. /**
  44. * Creates a new accumulator sound.
  45. * \param sound The input sound.
  46. * \param additive Whether the accumulator is additive.
  47. */
  48. Accumulator(std::shared_ptr<ISound> sound, bool additive = false);
  49. virtual std::shared_ptr<IReader> createReader();
  50. /**
  51. * The accumulatorFilterAdditive function implements the doFilterIIR callback
  52. * for the additive accumulator filter.
  53. * @param reader The CallbackIIRFilterReader that executes the callback.
  54. * @param useless A user defined pointer that is not needed for this filter.
  55. * @return The filtered sample.
  56. */
  57. static sample_t AUD_LOCAL accumulatorFilterAdditive(CallbackIIRFilterReader* reader, void* useless);
  58. /**
  59. * The accumulatorFilter function implements the doFilterIIR callback
  60. * for the non-additive accumulator filter.
  61. * @param reader The CallbackIIRFilterReader that executes the callback.
  62. * @param useless A user defined pointer that is not needed for this filter.
  63. * @return The filtered sample.
  64. */
  65. static sample_t AUD_LOCAL accumulatorFilter(CallbackIIRFilterReader* reader, void* useless);
  66. };
  67. AUD_NAMESPACE_END