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.

Envelope.h 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #include "../Params/EnvelopeParams.h"
  21. /**Implementation of a general Envelope*/
  22. class Envelope
  23. {
  24. public:
  25. /**Constructor*/
  26. Envelope(class EnvelopeParams *envpars, float basefreq);
  27. /**Destructor*/
  28. ~Envelope();
  29. void relasekey();
  30. float envout();
  31. float envout_dB();
  32. /**Determines the status of the Envelope
  33. * @return returns 1 if the envelope is finished*/
  34. bool finished() const;
  35. private:
  36. float env_rap2dB(float rap);
  37. float env_dB2rap(float db);
  38. int envpoints;
  39. int envsustain; //"-1" means disabled
  40. float envdt[MAX_ENVELOPE_POINTS]; //millisecons
  41. float envval[MAX_ENVELOPE_POINTS]; // [0.0f .. 1.0f]
  42. float envstretch;
  43. int linearenvelope;
  44. int currentpoint; //current envelope point (starts from 1)
  45. int forcedrelase;
  46. bool keyreleased; //if the key was released
  47. bool envfinish;
  48. float t; // the time from the last point
  49. float inct; // the time increment
  50. float envoutval; //used to do the forced release
  51. };
  52. #endif