No Description
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 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef ENVELOPE_H_
  2. #define ENVELOPE_H_
  3. #include <stdint.h>
  4. // Code converted to C from http://www.earlevel.com/main/2013/06/01/envelope-generators/
  5. struct Envelope {
  6. // private
  7. enum {
  8. EnvNone,
  9. EnvAttack,
  10. EnvDecay,
  11. EnvSustain,
  12. EnvRelease
  13. } state;
  14. float output,
  15. attack_rate,
  16. decay_rate,
  17. release_rate,
  18. attack_coef,
  19. decay_coef,
  20. release_coef,
  21. sustain_level,
  22. target_ratio_a,
  23. target_ratio_dr,
  24. attack_base,
  25. decay_base,
  26. release_base;
  27. };
  28. void envelope_init(struct Envelope *env);
  29. void envelope_reset(struct Envelope *env);
  30. void envelope_start(struct Envelope *env);
  31. void envelope_stop(struct Envelope *env);
  32. void envelope_set_attack_rate(struct Envelope *env, float rate);
  33. void envelope_set_decay_rate(struct Envelope *env, float rate);
  34. void envelope_set_release_rate(struct Envelope *env, float rate);
  35. void envelope_set_sustain_level(struct Envelope *env, float level);
  36. void envelope_set_target_ratio_a(struct Envelope *env, float target_ratio);
  37. void envelope_set_target_ratio_dr(struct Envelope *env, float target_ratio);
  38. float envelope_sample(struct Envelope *env);
  39. #endif /* ENVELOPE_H_ */