41 Ead(
unsigned int update_rate) : UPDATE_RATE(update_rate)
75 void set(
unsigned int attack_ms,
unsigned int decay_ms)
101 void start(
unsigned int attack_ms,
unsigned int decay_ms)
123 attack_phase =
false;
126 Q8n24state -= (Q8n24state * Q8n8decay)>>8;
138 const unsigned int UPDATE_RATE;
143 float millisToOneMinusRealPole(
unsigned int milliseconds)
145 static const float NUMERATOR = 1000.0f * log(0.001f);
146 return -expm1(NUMERATOR / ((
float)UPDATE_RATE * milliseconds));
uint16_t Q8n8
unsigned fractional number using 8 integer bits and 8 fractional bits, represents 0 to 255...
void start(unsigned int attack_ms, unsigned int decay_ms)
Set attack and decay times in milliseconds, and start the envelope from the beginning.
void set(unsigned int attack_ms, unsigned int decay_ms)
Set attack and decay times in milliseconds.
Exponential attack decay envelope.
Ead(unsigned int update_rate)
Constructor.
void start()
Start the envelope from the beginning.
Q8n8 float_to_Q8n8(float a)
Convert float to Q8n8 fix.
void setAttack(unsigned int attack_ms)
Set the attack time in milliseconds.
void setDecay(unsigned int decay_ms)
Set the decay time in milliseconds.
uint8_t next()
Calculate and return the next envelope value, in the range -128 to 127.
uint32_t Q8n24
signed fractional number using 8 integer bits and 24 fractional bits, represents 0 to 255...
#define Q8n24_FIX1
1 in Q8n24 format
Q0n8 Q8n24_to_Q0n8(Q8n24 a)
Convert Q8n24 fixed to Q0n8 uint8_t.