|
enum | EStage {
kReleasedToEndEarly = -3
, kReleasedToRetrigger = -2
, kIdle = -1
, kAttack
,
kDecay
, kSustain
, kRelease
} |
|
|
| ADSREnvelope (const char *name="", std::function< void()> resetFunc=nullptr, bool sustainEnabled=true) |
| Constructs an ADSREnvelope object. More...
|
|
void | SetStageTime (int stage, T timeMS) |
| Sets the time for a particular envelope stage. More...
|
|
bool | GetBusy () const |
|
bool | GetReleased () const |
|
T | GetPrevOutput () const |
|
void | Start (T level, T timeScalar=1.) |
| Trigger/Start the envelope. More...
|
|
void | Release () |
| Release the envelope. More...
|
|
void | Retrigger (T newStartLevel, T timeScalar=1.) |
| Retrigger the envelope. More...
|
|
void | Kill (bool hard) |
| Kill the envelope. More...
|
|
void | SetSampleRate (T sr) |
| Set the sample rate for processing, with updates the early release time and retrigger release time coefficents. More...
|
|
void | SetResetFunc (std::function< void()> func) |
| Sets a function to call when the envelope gets retriggered, called when the fade out ramp is at zero, useful for example to reset an oscillator's phase WARNING: don't call this on the audio thread, std::function can malloc. More...
|
|
void | SetEndReleaseFunc (std::function< void()> func) |
| Sets a function to call when the envelope gets released, called when the ramp is at zero WARNING: don't call this on the audio thread, std::function can malloc. More...
|
|
T | Process (T sustainLevel=0.) |
| Process the envelope, returning the value according to the current envelope stage. More...
|
|
template<typename T>
class ADSREnvelope< T >
Definition at line 22 of file ADSREnvelope.h.
◆ EStage
template<typename T >
enum ADSREnvelope::EStage |
◆ ADSREnvelope()
template<typename T >
ADSREnvelope< T >::ADSREnvelope |
( |
const char * |
name = "" , |
|
|
std::function< void()> |
resetFunc = nullptr , |
|
|
bool |
sustainEnabled = true |
|
) |
| |
|
inline |
Constructs an ADSREnvelope object.
- Parameters
-
name | CString to identify the envelope in debug mode, when DEBUG_ENV=1 is set as a global preprocessor macro |
resetFunc | A function to call when the envelope gets retriggered, called when the fade out ramp is at zero, useful for example to reset an oscillator's phase |
sustainEnabled | if true the envelope is an ADSR envelope. If false, it's is an AD envelope (suitable for drums). |
Definition at line 74 of file ADSREnvelope.h.
References ADSREnvelope< T >::SetSampleRate().
◆ GetBusy()
- Returns
- /c true if the envelope is not idle
Definition at line 105 of file ADSREnvelope.h.
◆ GetPrevOutput()
◆ GetReleased()
- Returns
- /c true if the envelope is released
Definition at line 111 of file ADSREnvelope.h.
◆ Kill()
Kill the envelope.
- Parameters
-
hard | If true, the envelope will get reset automatically, probably causing an audible glitch. If false, it's a "soft kill", which will fade out in EARLY_RELEASE_TIME |
Definition at line 162 of file ADSREnvelope.h.
◆ Process()
Process the envelope, returning the value according to the current envelope stage.
- Parameters
-
sustainLevel | Since the sustain level could be changed during processing, it is supplied as an argument, so that it can be smoothed extenally if nessecary, to avoid discontinuities |
Definition at line 214 of file ADSREnvelope.h.
References ADSREnvelope< T >::Release().
◆ Release()
◆ Retrigger()
template<typename T >
void ADSREnvelope< T >::Retrigger |
( |
T |
newStartLevel, |
|
|
T |
timeScalar = 1. |
|
) |
| |
|
inline |
Retrigger the envelope.
This method will cause the envelope to move to a "releasedToRetrigger" stage, which is a fast ramp to zero in RETRIGGER_RELEASE_TIME, used when voices are stolen to avoid clicks.
- Parameters
-
newStartLevel | the overall level when the envelope restarts (usually linked to MIDI velocity) |
timeScalar | Factor to scale the envelope's rates. Use this, for example to adjust the envelope stage rates based on the key pressed |
Definition at line 146 of file ADSREnvelope.h.
◆ SetEndReleaseFunc()
template<typename T >
void ADSREnvelope< T >::SetEndReleaseFunc |
( |
std::function< void()> |
func | ) |
|
|
inline |
Sets a function to call when the envelope gets released, called when the ramp is at zero WARNING: don't call this on the audio thread, std::function can malloc.
- Parameters
-
func | the release function, or nullptr for none |
Definition at line 210 of file ADSREnvelope.h.
◆ SetResetFunc()
template<typename T >
void ADSREnvelope< T >::SetResetFunc |
( |
std::function< void()> |
func | ) |
|
|
inline |
Sets a function to call when the envelope gets retriggered, called when the fade out ramp is at zero, useful for example to reset an oscillator's phase WARNING: don't call this on the audio thread, std::function can malloc.
- Parameters
-
func | the reset function, or nullptr for none |
Definition at line 205 of file ADSREnvelope.h.
◆ SetSampleRate()
Set the sample rate for processing, with updates the early release time and retrigger release time coefficents.
NOTE: you also need to think about updating the Attack, Decay and Release times when the sample rate changes
- Parameters
-
sr | SampleRate in samples per second |
Definition at line 195 of file ADSREnvelope.h.
Referenced by ADSREnvelope< T >::ADSREnvelope().
◆ SetStageTime()
template<typename T >
void ADSREnvelope< T >::SetStageTime |
( |
int |
stage, |
|
|
T |
timeMS |
|
) |
| |
|
inline |
Sets the time for a particular envelope stage.
- Parameters
-
stage | The stage to set the time for /see EStage |
timeMS | The time in milliseconds for that stage |
Definition at line 85 of file ADSREnvelope.h.
References Clip().
◆ Start()
template<typename T >
void ADSREnvelope< T >::Start |
( |
T |
level, |
|
|
T |
timeScalar = 1. |
|
) |
| |
|
inline |
Trigger/Start the envelope.
- Parameters
-
level | The overall depth of the envelope (usually linked to MIDI velocity)
|
timeScalar | Factor to scale the envelope's rates. Use this, for example to adjust the envelope stage rates based on the key pressed |
Definition at line 125 of file ADSREnvelope.h.
◆ EARLY_RELEASE_TIME
◆ ENV_VALUE_HIGH
◆ ENV_VALUE_LOW
◆ MAX_ENV_TIME_MS
◆ MIN_ENV_TIME_MS
template<typename T >
constexpr T ADSREnvelope< T >::MIN_ENV_TIME_MS = 0.022675736961451 |
|
staticconstexpr |
◆ RETRIGGER_RELEASE_TIME
The documentation for this class was generated from the following file: