LMMS
Loading...
Searching...
No Matches
dsp::adsr Class Reference

#include <envelope.h>

Public Types

enum  env_state {
  STOP , ATTACK , DECAY , SUSTAIN ,
  RELEASE , LOCKDECAY
}

Public Member Functions

 adsr ()
void reset ()
 Stop (reset) the envelope.
void set (float a, float d, float s, float r, float er, float f=0.f)
bool released () const
bool stopped () const
void note_on ()
 Start the envelope.
void note_off ()
 Release the envelope.
void advance ()
 Calculate next envelope value.
double interpolate (double pos)
float get_amp_value ()

Public Attributes

env_state state
 Current envelope stage.
double attack
double decay
double sustain
double release
double fade
double release_time
 Requested release time (not the rate!) in frames, used for recalculating the rate if sustain is changed.
double value
 Current envelope (output) level.
double thisrelease
double thiss
double old_value
 Value from the time before advance() was called last time.

Detailed Description

Rate-based ADSFR envelope class. Note that if release rate is slower than decay rate, this envelope won't use release rate until output level falls below sustain level it's different to what certain hardware synth companies did, but it prevents the very un-musical (IMHO) behaviour known from (for example) SoundFont 2.

Member Enumeration Documentation

◆ env_state

Enumerator
STOP 

envelope is stopped

ATTACK 

attack - rise from 0 to 1

DECAY 

decay - fall from 1 to sustain level

SUSTAIN 

sustain - remain at sustain level (unless sustain is 0 - then it gets stopped); with fade != 0 it goes towards 0% (positive fade) or 100% (negative fade)

RELEASE 

release - fall from sustain (or pre-sustain) level to 0

LOCKDECAY 

locked decay

Constructor & Destructor Documentation

◆ adsr()

dsp::adsr::adsr ( )
inline

Member Function Documentation

◆ advance()

void dsp::adsr::advance ( )
inline

Calculate next envelope value.

◆ get_amp_value()

float dsp::adsr::get_amp_value ( )
inline

◆ interpolate()

double dsp::adsr::interpolate ( double pos)
inline

Return a value between old_value (previous step) and value (current step)

Parameters
posbetween 0 and 1

◆ note_off()

void dsp::adsr::note_off ( )
inline

Release the envelope.

◆ note_on()

void dsp::adsr::note_on ( )
inline

Start the envelope.

◆ released()

bool dsp::adsr::released ( ) const
inline
Return values
trueif envelope is in released state (forced decay, release or stopped)

◆ reset()

void dsp::adsr::reset ( )
inline

Stop (reset) the envelope.

◆ set()

void dsp::adsr::set ( float a,
float d,
float s,
float r,
float er,
float f = 0.f )
inline

Set the envelope parameters (updates rate member variables based on values passed)

Parameters
aattack time
ddecay time
ssustain level
rrelease time
erEnvelope (update) rate
ffade time (if applicable)

◆ stopped()

bool dsp::adsr::stopped ( ) const
inline
Return values
trueif envelope is stopped (has not been started or has run till its end)

Member Data Documentation

◆ attack

double dsp::adsr::attack
Note
these are rates, not times

◆ decay

double dsp::adsr::decay

◆ fade

double dsp::adsr::fade

◆ old_value

double dsp::adsr::old_value

Value from the time before advance() was called last time.

◆ release

double dsp::adsr::release

◆ release_time

double dsp::adsr::release_time

Requested release time (not the rate!) in frames, used for recalculating the rate if sustain is changed.

◆ state

env_state dsp::adsr::state

Current envelope stage.

◆ sustain

double dsp::adsr::sustain

◆ thisrelease

double dsp::adsr::thisrelease

Release rate used for the current note (calculated from this note's sustain level, and not the current sustain level, which may have changed after note has been released)

◆ thiss

double dsp::adsr::thiss

Sustain level used for the current note (used to calculate release rate if sustain changed during release stage of the current note)

◆ value

double dsp::adsr::value

Current envelope (output) level.


The documentation for this class was generated from the following file: