Logo Search packages:      
Sourcecode: csound version File versions  Download package

ADSR Class Reference

#include <ADSR.h>

Inheritance diagram for ADSR:

Envelope Generator Stk

List of all members.


Detailed Description

STK ADSR envelope class.

This Envelope subclass implements a traditional ADSR (Attack, Decay, Sustain, Release) envelope. It responds to simple keyOn and keyOff messages, keeping track of its state. The state = ADSR::DONE after the envelope value reaches 0.0 in the ADSR::RELEASE state.

by Perry R. Cook and Gary P. Scavone, 1995 - 2005.

Definition at line 171 of file physutil.h.


Public Types

enum  {
  ATTACK, DECAY, SUSTAIN, RELEASE,
  DONE
}
 Envelope states.
typedef unsigned long StkFormat

Public Member Functions

 ADSR (void)
 Default constructor.
int getState (void) const
 Return the current envelope state (ATTACK, DECAY, SUSTAIN, RELEASE, DONE).
void keyOff (void)
 Set target = 0, state = ADSR::RELEASE.
void keyOn (void)
 Set target = 1, state = ADSR::ATTACK.
virtual StkFloat lastOut (void) const
 Return the last output value.
void setAllTimes (StkFloat aTime, StkFloat dTime, StkFloat sLevel, StkFloat rTime)
 Set sustain level and attack, decay, and release time durations.
void setAttackRate (StkFloat rate)
 Set the attack rate.
void setAttackTime (StkFloat time)
 Set the attack rate based on a time duration.
void setDecayRate (StkFloat rate)
 Set the decay rate.
void setDecayTime (StkFloat time)
 Set the decay rate based on a time duration.
void setRate (StkFloat rate)
 Set the rate.
void setReleaseRate (StkFloat rate)
 Set the release rate.
void setReleaseTime (StkFloat time)
 Set the release rate based on a time duration.
void setSustainLevel (StkFloat level)
 Set the sustain level.
void setTarget (StkFloat target)
 Set the target value.
void setTime (StkFloat time)
 Set the rate based on a time duration.
void setValue (StkFloat value)
 Set to state = ADSR::SUSTAIN with current and target values of aValue.
StkFramestick (StkFrames &frames, unsigned int channel=0)
 Fill a channel of the StkFrames object with computed outputs.
StkFloat tick (void)
 Compute one sample and output.
 ~ADSR (void)
 Class destructor.

Static Public Member Functions

static void handleError (std::string message, StkError::Type type)
 Static function for error reporting and handling using c++ strings.
static void handleError (const char *message, StkError::Type type)
 Static function for error reporting and handling using c-strings.
static void printErrors (bool status)
 Toggle display of error messages before throwing exceptions.
static std::string rawwavePath (void)
 Static method which returns the current rawwave path.
static StkFloat sampleRate (void)
 Static method which returns the current STK sample rate.
static void setRawwavePath (std::string path)
 Static method which sets the STK rawwave path.
static void setSampleRate (StkFloat rate)
 Static method which sets the STK sample rate.
static void showWarnings (bool status)
 Toggle display of WARNING and STATUS messages.
static void sleep (unsigned long milliseconds)
 Static cross-platform method to sleep for a number of milliseconds.
static void swap16 (unsigned char *ptr)
 Static method which byte-swaps a 16-bit data type.
static void swap32 (unsigned char *ptr)
 Static method which byte-swaps a 32-bit data type.
static void swap64 (unsigned char *ptr)
 Static method which byte-swaps a 64-bit data type.

Public Attributes

MYFLT attackRate
MYFLT decayRate
MYFLT rate
MYFLT releaseRate
int state
MYFLT sustainLevel
MYFLT target
MYFLT value

Static Public Attributes

static const StkFormat STK_FLOAT32 = 0x10
static const StkFormat STK_FLOAT64 = 0x20
static const StkFormat STK_SINT16 = 0x2
static const StkFormat STK_SINT24 = 0x4
static const StkFormat STK_SINT32 = 0x8
static const StkFormat STK_SINT8 = 0x1

Protected Member Functions

StkFloat computeSample (void)
void handleError (StkError::Type type)
 Internal function for error reporting which assumes message in errorString_ variable.

Protected Attributes

StkFloat attackRate_
StkFloat decayRate_
std::ostringstream errorString_
StkFloat lastOutput_
StkFloat rate_
StkFloat releaseRate_
int state_
StkFloat sustainLevel_
StkFloat target_
StkFloat value_

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

Generated by  Doxygen 1.6.0   Back to index