Newer
Older
music / app / src / main / cpp / effects / Envelope.h
  1. #ifndef MUSIC_ENVELOPE_H
  2. #define MUSIC_ENVELOPE_H
  3.  
  4. class Envelope;
  5.  
  6. #include <cstdint>
  7. #include "../AudioHost.h"
  8. #include "Processable.h"
  9.  
  10. enum EnvelopePhase {
  11. NONE, ATTACK, DELAY, SUSTAIN, RELEASE,
  12. };
  13.  
  14. class Envelope : public Processable {
  15. private:
  16. EnvelopePhase phase;
  17. float attackIncrement, delayIncrement, releaseIncrement;
  18. float value = 0;
  19. AudioHost *host;
  20. public:
  21. float attack = 0.05, delay = 0.05, sustain = 0.7, release = 0.1;
  22.  
  23. void initialize(AudioHost *host);
  24.  
  25. void update();
  26.  
  27. void startNote();
  28. void endNote();
  29. void doRender(uint32_t sampleCount);
  30. };
  31.  
  32.  
  33. #endif