Envelope.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. 
  2. #ifndef MODULE_SOUND_ENVELOPE
  3. #define MODULE_SOUND_ENVELOPE
  4. #include "../../DFPSR/api/soundAPI.h"
  5. #include "../../DFPSR/api/imageAPI.h"
  6. namespace dsr {
  7. struct EnvelopeSettings {
  8. // Basic ADSR
  9. double attack, decay, sustain, release;
  10. // Extended
  11. double hold, rise, sustainedSmooth, releasedSmooth;
  12. bool used;
  13. EnvelopeSettings();
  14. EnvelopeSettings(double attack, double decay, double sustain, double release, double hold = 0.0, double rise = 0.0, double sustainedSmooth = 0.0, double releasedSmooth = 0.0);
  15. };
  16. struct Envelope {
  17. // Settings
  18. EnvelopeSettings envelopeSettings;
  19. // Dynamic
  20. int state = 0;
  21. double currentVolume = 0.0, currentGoal = 0.0, releaseVolume = 0.0, timeSinceChange = 0.0;
  22. bool lastSustained = true;
  23. Envelope(const EnvelopeSettings &envelopeSettings);
  24. double getVolume(bool sustained, double seconds);
  25. bool done();
  26. };
  27. // Visualization
  28. void soundEngine_drawEnvelope(ImageRgbaU8 target, const IRect &region, const EnvelopeSettings &envelopeSettings, double releaseTime, double viewTime);
  29. }
  30. #endif