Mozzi  version v1.1.0
sound synthesis library for Arduino
Ead Class Reference

Exponential attack decay envelope. More...

#include <Ead.h>

Public Member Functions

 Ead (unsigned int update_rate)
 Constructor. More...
 
void setAttack (unsigned int attack_ms)
 Set the attack time in milliseconds. More...
 
void setDecay (unsigned int decay_ms)
 Set the decay time in milliseconds. More...
 
void set (unsigned int attack_ms, unsigned int decay_ms)
 Set attack and decay times in milliseconds. More...
 
void start ()
 Start the envelope from the beginning. More...
 
void start (unsigned int attack_ms, unsigned int decay_ms)
 Set attack and decay times in milliseconds, and start the envelope from the beginning. More...
 
uint8_t next ()
 Calculate and return the next envelope value, in the range -128 to 127. More...
 

Detailed Description

Exponential attack decay envelope.

This produces a natural sounding envelope. It calculates a new value each time next() is called, which can be mapped to other parameters to change the amplitude or timbre of a sound.

Note
Currently doesn't work at audio rate... may need larger number types for Q8n8attack and Q8n8decay ?

Definition at line 29 of file Ead.h.

Constructor & Destructor Documentation

◆ Ead()

Ead::Ead ( unsigned int  update_rate)
inline

Constructor.

Parameters
update_rateUsually this will be CONTROL_RATE or AUDIO_RATE, unless you design another scheme for updating. One such alternative scheme could take turns for various control changes in a rotating schedule to spread out calculations made in successive updateControl() routines.

Definition at line 41 of file Ead.h.

Member Function Documentation

◆ next()

uint8_t Ead::next ( )
inline

Calculate and return the next envelope value, in the range -128 to 127.

Note
Timing: 5us

Definition at line 114 of file Ead.h.

◆ set()

void Ead::set ( unsigned int  attack_ms,
unsigned int  decay_ms 
)
inline

Set attack and decay times in milliseconds.

Parameters
attack_msThe time taken for values returned by successive calls of the next() method to change from 0 to 255.
decay_msThe time taken for values returned by successive calls of the next() method to change from 255 to 0.

Definition at line 75 of file Ead.h.

◆ setAttack()

void Ead::setAttack ( unsigned int  attack_ms)
inline

Set the attack time in milliseconds.

Parameters
attack_msThe time taken for values returned by successive calls of the next() method to change from 0 to 255.

Definition at line 51 of file Ead.h.

◆ setDecay()

void Ead::setDecay ( unsigned int  decay_ms)
inline

Set the decay time in milliseconds.

Parameters
decay_msThe time taken for values returned by successive calls of the next() method to change from 255 to 0.

Definition at line 62 of file Ead.h.

◆ start() [1/2]

void Ead::start ( )
inline

Start the envelope from the beginning.

This can be used at any time, even if the previous envelope is not finished.

Definition at line 86 of file Ead.h.

◆ start() [2/2]

void Ead::start ( unsigned int  attack_ms,
unsigned int  decay_ms 
)
inline

Set attack and decay times in milliseconds, and start the envelope from the beginning.

This can be used at any time, even if the previous envelope is not finished.

Parameters
attack_msThe time taken for values returned by successive calls of the next() method to change from 0 to 255.
decay_msThe time taken for values returned by successive calls of the next() method to change from 255 to 0.

Definition at line 101 of file Ead.h.