Gamma  0.9.5
Generic Synthesis Library
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
ADSR< Tv, Tp, Ts > Class Template Reference

ADSR (Attack, Decay, Sustain, Release) envelope. More...

#include <Envelope.h>

Inheritance diagram for ADSR< Tv, Tp, Ts >:
Env< 3, Tv, Tp, Ts >

List of all members.

Public Member Functions

 ADSR (Tp att=Tp(0.01), Tp dec=Tp(0.1), Tv sus=Tv(0.7), Tp rel=Tp(1.), Tv amp=Tv(1), Tp crv=Tp(-4))
ADSRattack (Tp len)
 Set attack length.
ADSRdecay (Tp len)
 Set decay length.
ADSRsustain (Tv val)
 Set sustain level.
ADSRrelease (Tp len)
 Set release length.
ADSRamp (Tv v)
 Set amplitude.
int size () const
 Get the number of segments.
int position () const
 Get the position, in samples, within the current segment.
int sustainPoint () const
 Get the sustain break-point.
EnvsustainPoint (int v)
 Sets the point at which the envelope holds its value until released.
int stage () const
 Get the envelope's current segment.
Tv value () const
 Get the current envelope value.
bool done () const
 Returns whether the envelope is done.
bool released () const
 Returns whether the envelope is released.
bool sustained () const
 Returns whether the envelope is currently sustained.
Tv operator() ()
 Generate next value.
void release ()
 Release the envelope.
Envloop (bool v)
 Set whether envelope loops.
EnvsustainDisable ()
 Disable sustain.
void reset ()
 Reset envelope to starting point.
Tp * lengths ()
 Get segment lengths array.
Envlengths (const V *vals, int len)
 Set break-point values.
Envlengths (Tp a, Tp b)
 Set first two segment lengths.
Envlengths (Tp a, Tp b, Tp c)
 Set first three segment lengths.
Envlengths (Tp a, Tp b, Tp c, Tp d)
 Set first four segment lengths.
Envlengths (Tp a, Tp b, Tp c, Tp d, Tp e)
 Set first five segment lengths.
Tp totalLength () const
 Get total length of all envelope segments.
EnvtotalLength (Tp length, int modSegment)
 Set total length of envelope by adjusting one segment length.
EnvtotalLength (Tp length)
 Set total length of envelope by scaling all segment lengths.
Tp * curves ()
 Get segment curvature array.
Envcurve (Tp v)
 Set curvature of all segments.
Envsegment (int i, Tp len, Tp crv)
 Set length and curvature of a segment.
Envsegments (const V *lens, const V *crvs, int len, int begin=0)
 Set length and curvature of many segments.
Envsegments (Tp la, Tp ca, Tp lb, Tp cb)
 Set length and curvature of first two segments.
Envsegments (Tp la, Tp ca, Tp lb, Tp cb, Tp lc, Tp cc)
 Set length and curvature of first three segments.
Envsegments (Tp la, Tp ca, Tp lb, Tp cb, Tp lc, Tp cc, Tp ld, Tp cd)
 Set length and curvature of first four segments.
Tv * levels ()
 Get break-point levels array.
Envlevels (const V *vals, int len)
 Set break-point values.
Envlevels (Tv a, Tv b)
 Set first two break-point levels.
Envlevels (Tv a, Tv b, Tv c)
 Set first three break-point levels.
Envlevels (Tv a, Tv b, Tv c, Tv d)
 Set first four break-point levels.
Envlevels (Tv a, Tv b, Tv c, Tv d, Tv e)
 Set first five break-point levels.

Detailed Description

template<class Tv = real, class Tp = real, class Ts = Synced>
class gam::ADSR< Tv, Tp, Ts >

ADSR (Attack, Decay, Sustain, Release) envelope.

This is a three segment envelope that rises to one and then falls back to zero. The attack is the rise length, the decay is the length until hitting the sustain level, and the release is the length until hitting zero again. This envelope is most useful when the duration of the envelope is not known in advance. However, it can be easily converted into a fixed length ADR by calling the sustainDisable() method. The decay segment then acts as a pseudo steady state portion.

Template Parameters:
Tvvalue (sample) type
Tpparameter type
Tssync type

Constructor & Destructor Documentation

ADSR ( Tp  att = Tp(0.01),
Tp  dec = Tp(0.1),
Tv  sus = Tv(0.7),
Tp  rel = Tp(1.),
Tv  amp = Tv( 1),
Tp  crv = Tp(-4) 
)
Parameters:
[in]attAttack length
[in]decDecay length
[in]susSustain level (as factor of amplitude)
[in]relRelease length
[in]ampAmplitude
[in]crvCurvature of all segments

Member Function Documentation

Env& totalLength ( Tp  length,
int  modSegment 
) [inherited]

Set total length of envelope by adjusting one segment length.

Parameters:
[in]lengthdesired length
[in]modSegmentsegment whose length is modified to match desired length

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