Envelope.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 Envelope.h
  19. * @ingroup fx
  20. * The Envelope class.
  21. */
  22. #include "fx/Effect.h"
  23. AUD_NAMESPACE_BEGIN
  24. class CallbackIIRFilterReader;
  25. struct EnvelopeParameters;
  26. /**
  27. * This sound creates an envelope follower reader.
  28. */
  29. class AUD_API Envelope : public Effect
  30. {
  31. private:
  32. /**
  33. * The attack value in seconds.
  34. */
  35. const float m_attack;
  36. /**
  37. * The release value in seconds.
  38. */
  39. const float m_release;
  40. /**
  41. * The threshold value.
  42. */
  43. const float m_threshold;
  44. /**
  45. * The attack/release threshold value.
  46. */
  47. const float m_arthreshold;
  48. // delete copy constructor and operator=
  49. Envelope(const Envelope&) = delete;
  50. Envelope& operator=(const Envelope&) = delete;
  51. public:
  52. /**
  53. * Creates a new envelope sound.
  54. * \param sound The input sound.
  55. * \param attack The attack value in seconds.
  56. * \param release The release value in seconds.
  57. * \param threshold The threshold value.
  58. * \param arthreshold The attack/release threshold value.
  59. */
  60. Envelope(std::shared_ptr<ISound> sound, float attack, float release,
  61. float threshold, float arthreshold);
  62. virtual std::shared_ptr<IReader> createReader();
  63. /**
  64. * The envelopeFilter function implements the doFilterIIR callback
  65. * for the callback IIR filter.
  66. * @param reader The CallbackIIRFilterReader that executes the callback.
  67. * @param param The envelope parameters.
  68. * @return The filtered sample.
  69. */
  70. static sample_t AUD_LOCAL envelopeFilter(CallbackIIRFilterReader* reader, EnvelopeParameters* param);
  71. /**
  72. * The endEnvelopeFilter function implements the endFilterIIR callback
  73. * for the callback IIR filter.
  74. * @param param The envelope parameters.
  75. */
  76. static void AUD_LOCAL endEnvelopeFilter(EnvelopeParameters* param);
  77. };
  78. AUD_NAMESPACE_END