Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.0KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Envelope.h - Envelope implementation
  4. Copyright (C) 2002-2005 Nasca Octavian Paul
  5. Author: Nasca Octavian Paul
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of version 2 of the GNU General Public License
  8. as published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License (version 2 or later) for more details.
  13. You should have received a copy of the GNU General Public License (version 2)
  14. along with this program; if not, write to the Free Software Foundation,
  15. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #ifndef ENVELOPE_H
  18. #define ENVELOPE_H
  19. #include "../globals.h"
  20. /**Implementation of a general Envelope*/
  21. class Envelope
  22. {
  23. public:
  24. /**Constructor*/
  25. Envelope(class EnvelopeParams &pars, float basefreq, float dt);
  26. /**Destructor*/
  27. ~Envelope();
  28. void releasekey();
  29. float envout();
  30. float envout_dB();
  31. /**Determines the status of the Envelope
  32. * @return returns 1 if the envelope is finished*/
  33. bool finished() const;
  34. private:
  35. float env_rap2dB(float rap);
  36. float env_dB2rap(float db);
  37. int envpoints;
  38. int envsustain; //"-1" means disabled
  39. float envdt[MAX_ENVELOPE_POINTS]; //millisecons
  40. float envval[MAX_ENVELOPE_POINTS]; // [0.0f .. 1.0f]
  41. float envstretch;
  42. int linearenvelope;
  43. int currentpoint; //current envelope point (starts from 1)
  44. int forcedrelease;
  45. bool keyreleased; //if the key was released
  46. bool envfinish;
  47. float t; // the time from the last point
  48. float inct; // the time increment
  49. float envoutval; //used to do the forced release
  50. };
  51. #endif