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.

57 lines
1.6KB

  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
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. */
  11. #ifndef ENVELOPE_H
  12. #define ENVELOPE_H
  13. #include "../globals.h"
  14. /**Implementation of a general Envelope*/
  15. class Envelope
  16. {
  17. public:
  18. /**Constructor*/
  19. Envelope(class EnvelopeParams &pars, float basefreq, float dt);
  20. /**Destructor*/
  21. ~Envelope();
  22. void releasekey();
  23. /**Push Envelope to finishing state*/
  24. void forceFinish(void);
  25. float envout();
  26. float envout_dB();
  27. /**Determines the status of the Envelope
  28. * @return returns 1 if the envelope is finished*/
  29. bool finished() const;
  30. private:
  31. float env_rap2dB(float rap);
  32. float env_dB2rap(float db);
  33. int envpoints;
  34. int envsustain; //"-1" means disabled
  35. float envdt[MAX_ENVELOPE_POINTS]; //millisecons
  36. float envval[MAX_ENVELOPE_POINTS]; // [0.0f .. 1.0f]
  37. float envstretch;
  38. int linearenvelope;
  39. int currentpoint; //current envelope point (starts from 1)
  40. int forcedrelease;
  41. bool keyreleased; //if the key was released
  42. bool envfinish;
  43. float t; // the time from the last point
  44. float inct; // the time increment
  45. float envoutval; //used to do the forced release
  46. };
  47. #endif