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.

72 lines
2.0KB

  1. /*************************************************************************************
  2. * Original code copyright (C) 2012 Steve Folta
  3. * Converted to Juce module (C) 2016 Leo Olivers
  4. * Forked from https://github.com/stevefolta/SFZero
  5. * For license info please see the LICENSE file distributed with this source code
  6. *************************************************************************************/
  7. #ifndef SFZEG_H_INCLUDED
  8. #define SFZEG_H_INCLUDED
  9. #include "SFZRegion.h"
  10. #include "CarlaJuceUtils.hpp"
  11. namespace sfzero
  12. {
  13. class EG
  14. {
  15. public:
  16. EG();
  17. virtual ~EG() {}
  18. void setExponentialDecay(bool newExponentialDecay);
  19. void startNote(const EGParameters *parameters, float floatVelocity, double sampleRate, const EGParameters *velMod = nullptr);
  20. void nextSegment();
  21. void noteOff();
  22. void fastRelease();
  23. bool isDone() { return (segment_ == Done); }
  24. bool isReleasing() { return (segment_ == Release); }
  25. int segmentIndex() { return static_cast<int>(segment_); }
  26. float getLevel() const { return level_; }
  27. void setLevel(float v) { level_ = v; }
  28. float getSlope() const { return slope_; }
  29. void setSlope(float v) { slope_ = v; }
  30. int getSamplesUntilNextSegment() const { return samplesUntilNextSegment_; }
  31. void setSamplesUntilNextSegment(int v) { samplesUntilNextSegment_ = v; }
  32. bool getSegmentIsExponential() const { return segmentIsExponential_; }
  33. void setSegmentIsExponential(bool v) { segmentIsExponential_ = v; }
  34. private:
  35. enum Segment
  36. {
  37. Delay,
  38. Attack,
  39. Hold,
  40. Decay,
  41. Sustain,
  42. Release,
  43. Done
  44. };
  45. void startDelay();
  46. void startAttack();
  47. void startHold();
  48. void startDecay();
  49. void startSustain();
  50. void startRelease();
  51. Segment segment_;
  52. EGParameters parameters_;
  53. double sampleRate_;
  54. bool exponentialDecay_;
  55. float level_;
  56. float slope_;
  57. int samplesUntilNextSegment_;
  58. bool segmentIsExponential_;
  59. static const float BottomLevel;
  60. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EG)
  61. };
  62. }
  63. #endif // SFZEG_H_INCLUDED