OpenWareLaboratory
AdsrEnvelope< linear > Class Template Reference

ADSR Envelope, either linear or exponential. More...

Inheritance diagram for AdsrEnvelope< linear >:
Collaboration diagram for AdsrEnvelope< linear >:

Public Member Functions

 AdsrEnvelope (float sampleRate)
 
void attenuate (FloatArray buf)
 
void gate (bool state)
 
void gate (bool state, int delay)
 
virtual float generate ()
 Produce the next consecutive sample. More...
 
float generate ()
 Produce the next envelope sample. More...
 
virtual void generate (FloatArray output)
 Produce a block of samples. More...
 
virtual void generate (FloatArray output)
 Produce a block of samples. More...
 
void getEnvelope (FloatArray output)
 
float getLevel ()
 
float getNextSample ()
 
virtual float process (float input)
 
virtual float process (float input)
 
virtual void process (FloatArray input, FloatArray output)
 Attenuate samples in. More...
 
virtual void process (FloatArray input, FloatArray output)
 Attenuate samples in. More...
 
void setAttack (float value)
 
void setDecay (float value)
 
void setLevel (float newLevel)
 
void setRelease (float value)
 
void setRetrigger (bool state)
 
void setSampleRate (float value)
 
void setSustain (float newSustain)
 
virtual void trigger ()
 
virtual void trigger (bool state)
 
virtual void trigger (bool state)
 
void trigger (bool state, int delay)
 
virtual void trigger (bool state, int triggerDelay)=0
 

Static Public Member Functions

static AdsrEnvelope< linear > * create (float sampleRate)
 
static void destroy (AdsrEnvelope< linear > *env)
 

Protected Types

enum  EnvelopeStage {
  kAttack , kDecay , kSustain , kRelease ,
  kIdle
}
 
enum  EnvelopeTrigger { kGate , kTrigger }
 

Protected Member Functions

float calculateIncrement (float startValue, float endValue, float time)
 
float calculateIncrement (float startValue, float endValue, float time)
 
float calculateIncrement (float startValue, float endValue, float time)
 
float decrement (float level, float amount)
 
float decrement (float level, float amount)
 
float decrement (float level, float amount)
 
float increment (float level, float amount)
 
float increment (float level, float amount)
 
float increment (float level, float amount)
 
const float MINLEVEL
 
const float MINLEVEL
 

Protected Attributes

float attackIncrement
 
float decayIncrement
 
bool gateState
 
int gateTime
 
float level
 
float releaseIncrement
 
bool retrigger
 
float sampleRate
 
EnvelopeStage stage
 
float sustain
 
EnvelopeTrigger trig
 

Static Protected Attributes

static const float MINLEVEL
 

Detailed Description

template<bool linear>
class AdsrEnvelope< linear >

ADSR Envelope, either linear or exponential.

Definition at line 10 of file AdsrEnvelope.h.

Member Enumeration Documentation

◆ EnvelopeStage

template<bool linear>
enum AdsrEnvelope::EnvelopeStage
protected
Enumerator
kAttack 
kDecay 
kSustain 
kRelease 
kIdle 

Definition at line 13 of file AdsrEnvelope.h.

◆ EnvelopeTrigger

template<bool linear>
enum AdsrEnvelope::EnvelopeTrigger
protected
Enumerator
kGate 
kTrigger 

Definition at line 14 of file AdsrEnvelope.h.

Constructor & Destructor Documentation

◆ AdsrEnvelope()

Member Function Documentation

◆ attenuate()

template<bool linear>
void AdsrEnvelope< linear >::attenuate ( FloatArray  buf)
inline

Definition at line 148 of file AdsrEnvelope.h.

References AdsrEnvelope< linear >::process().

◆ calculateIncrement() [1/3]

template<bool linear>
float AdsrEnvelope< linear >::calculateIncrement ( float  startValue,
float  endValue,
float  time 
)
protected

◆ calculateIncrement() [2/3]

float AdsrEnvelope< true >::calculateIncrement ( float  startValue,
float  endValue,
float  time 
)
protected

Definition at line 192 of file AdsrEnvelope.h.

◆ calculateIncrement() [3/3]

float AdsrEnvelope< false >::calculateIncrement ( float  startValue,
float  endValue,
float  time 
)
protected

Definition at line 197 of file AdsrEnvelope.h.

◆ create()

template<bool linear>
static AdsrEnvelope<linear>* AdsrEnvelope< linear >::create ( float  sampleRate)
inlinestatic

Definition at line 151 of file AdsrEnvelope.h.

References AdsrEnvelope< linear >::sampleRate.

◆ decrement() [1/3]

template<bool linear>
float AdsrEnvelope< linear >::decrement ( float  level,
float  amount 
)
protected

◆ decrement() [2/3]

float AdsrEnvelope< true >::decrement ( float  level,
float  amount 
)
protected

Definition at line 177 of file AdsrEnvelope.h.

◆ decrement() [3/3]

float AdsrEnvelope< false >::decrement ( float  level,
float  amount 
)
protected

Definition at line 187 of file AdsrEnvelope.h.

◆ destroy()

template<bool linear>
static void AdsrEnvelope< linear >::destroy ( AdsrEnvelope< linear > *  env)
inlinestatic

Definition at line 154 of file AdsrEnvelope.h.

◆ gate() [1/2]

template<bool linear>
void AdsrEnvelope< linear >::gate ( bool  state)
inlinevirtual

Reimplemented from Envelope.

Definition at line 58 of file AdsrEnvelope.h.

Referenced by AdsrEnvelope< linear >::trigger().

◆ gate() [2/2]

template<bool linear>
void AdsrEnvelope< linear >::gate ( bool  state,
int  delay 
)
inlinevirtual

◆ generate() [1/4]

template<bool linear>
virtual float SignalGenerator::generate
inlinevirtual

Produce the next consecutive sample.

Reimplemented from SignalGenerator.

Definition at line 19 of file SignalGenerator.h.

◆ generate() [2/4]

◆ generate() [3/4]

template<bool linear>
virtual void SignalGenerator::generate
inlinevirtual

Produce a block of samples.

Reimplemented from SignalGenerator.

Definition at line 25 of file SignalGenerator.h.

◆ generate() [4/4]

◆ getEnvelope()

template<bool linear>
void AdsrEnvelope< linear >::getEnvelope ( FloatArray  output)
inline

Definition at line 144 of file AdsrEnvelope.h.

References AdsrEnvelope< linear >::generate().

◆ getLevel()

template<bool linear>
float AdsrEnvelope< linear >::getLevel ( )
inline

Definition at line 68 of file AdsrEnvelope.h.

References AdsrEnvelope< linear >::level.

◆ getNextSample()

template<bool linear>
float AdsrEnvelope< linear >::getNextSample ( )
inline

Definition at line 140 of file AdsrEnvelope.h.

References AdsrEnvelope< linear >::generate().

◆ increment() [1/3]

template<bool linear>
float AdsrEnvelope< linear >::increment ( float  level,
float  amount 
)
protected

◆ increment() [2/3]

float AdsrEnvelope< true >::increment ( float  level,
float  amount 
)
protected

Definition at line 172 of file AdsrEnvelope.h.

◆ increment() [3/3]

float AdsrEnvelope< false >::increment ( float  level,
float  amount 
)
protected

Definition at line 182 of file AdsrEnvelope.h.

◆ MINLEVEL() [1/2]

const float AdsrEnvelope< true >::MINLEVEL
protected

Definition at line 203 of file AdsrEnvelope.h.

◆ MINLEVEL() [2/2]

const float AdsrEnvelope< false >::MINLEVEL
protected

Definition at line 206 of file AdsrEnvelope.h.

◆ process() [1/4]

template<bool linear>
virtual float Envelope::process
inline

Definition at line 22 of file Envelope.h.

Referenced by AdsrEnvelope< linear >::attenuate().

◆ process() [2/4]

virtual float Envelope::process ( float  input)
inlinevirtualinherited

Reimplemented from SignalProcessor.

Definition at line 22 of file Envelope.h.

References Envelope::generate().

◆ process() [3/4]

template<bool linear>
virtual void Envelope::process
inline

Attenuate samples in.

Parameters
inputby envelope and place results in
output

Definition at line 28 of file Envelope.h.

◆ process() [4/4]

virtual void Envelope::process ( FloatArray  input,
FloatArray  output 
)
inlinevirtualinherited

Attenuate samples in.

Parameters
inputby envelope and place results in
output

Reimplemented from SignalProcessor.

Definition at line 28 of file Envelope.h.

References Envelope::generate(), and SimpleArray< T >::getSize().

◆ setAttack()

template<bool linear>
void AdsrEnvelope< linear >::setAttack ( float  value)
inline

◆ setDecay()

template<bool linear>
void AdsrEnvelope< linear >::setDecay ( float  value)
inline

◆ setLevel()

template<bool linear>
void AdsrEnvelope< linear >::setLevel ( float  newLevel)
inline

Definition at line 71 of file AdsrEnvelope.h.

References AdsrEnvelope< linear >::level.

◆ setRelease()

template<bool linear>
void AdsrEnvelope< linear >::setRelease ( float  value)
inline

◆ setRetrigger()

template<bool linear>
void AdsrEnvelope< linear >::setRetrigger ( bool  state)
inline

Definition at line 55 of file AdsrEnvelope.h.

References AdsrEnvelope< linear >::retrigger.

Referenced by AdsrEnvelope< linear >::AdsrEnvelope().

◆ setSampleRate()

template<bool linear>
void AdsrEnvelope< linear >::setSampleRate ( float  value)
inline

Definition at line 36 of file AdsrEnvelope.h.

References AdsrEnvelope< linear >::sampleRate.

◆ setSustain()

template<bool linear>
void AdsrEnvelope< linear >::setSustain ( float  newSustain)
inline

Definition at line 48 of file AdsrEnvelope.h.

References AdsrEnvelope< linear >::sustain.

Referenced by AdsrEnvelope< linear >::AdsrEnvelope().

◆ trigger() [1/5]

template<bool linear>
virtual void Envelope::trigger
inlinevirtual

Reimplemented from Envelope.

Definition at line 11 of file Envelope.h.

Referenced by AdsrEnvelope< linear >::generate().

◆ trigger() [2/5]

template<bool linear>
virtual void Envelope::trigger
inlinevirtual

Reimplemented from Envelope.

Definition at line 14 of file Envelope.h.

◆ trigger() [3/5]

virtual void Envelope::trigger ( bool  state)
inlinevirtualinherited

Definition at line 14 of file Envelope.h.

References Envelope::trigger().

◆ trigger() [4/5]

template<bool linear>
void AdsrEnvelope< linear >::trigger ( bool  state,
int  delay 
)
inlinevirtual

◆ trigger() [5/5]

template<bool linear>
virtual void Envelope::trigger
virtual

Reimplemented from Envelope.

Field Documentation

◆ attackIncrement

template<bool linear>
float AdsrEnvelope< linear >::attackIncrement
protected

◆ decayIncrement

template<bool linear>
float AdsrEnvelope< linear >::decayIncrement
protected

◆ gateState

template<bool linear>
bool AdsrEnvelope< linear >::gateState
protected

◆ gateTime

template<bool linear>
int AdsrEnvelope< linear >::gateTime
protected

◆ level

template<bool linear>
float AdsrEnvelope< linear >::level
protected

◆ MINLEVEL

template<bool linear>
const float AdsrEnvelope< linear >::MINLEVEL
staticprotected

◆ releaseIncrement

template<bool linear>
float AdsrEnvelope< linear >::releaseIncrement
protected

◆ retrigger

template<bool linear>
bool AdsrEnvelope< linear >::retrigger
protected

◆ sampleRate

template<bool linear>
float AdsrEnvelope< linear >::sampleRate
protected

◆ stage

template<bool linear>
EnvelopeStage AdsrEnvelope< linear >::stage
protected

Definition at line 159 of file AdsrEnvelope.h.

Referenced by AdsrEnvelope< linear >::generate().

◆ sustain

template<bool linear>
float AdsrEnvelope< linear >::sustain
protected

◆ trig

template<bool linear>
EnvelopeTrigger AdsrEnvelope< linear >::trig
protected

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