The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# stk::Asymp Class Reference

STK asymptotic curve envelope class. More...

`#include <Asymp.h>`

Inheritance diagram for stk::Asymp:

List of all members.

## Public Member Functions
| Asymp (void)
| Default constructor.
| ~Asymp (void)
| Class destructor.
void | keyOn (void)
| Set target = 1.
void | keyOff (void)
| Set target = 0.
void | setTau (StkFloat tau)
| Set the asymptotic rate via the time factor tau (must be > 0).
void | setTime (StkFloat time)
| Set the asymptotic rate based on a time duration (must be > 0).
void | setT60 (StkFloat t60)
| Set the asymptotic rate such that the target value is perceptually reached (to within -60dB of the target) in t60 seconds.
void | setTarget (StkFloat target)
| Set the target value.
void | setValue (StkFloat value)
| Set current and target values to value.
int | getState (void) const
| Return the current envelope state (0 = at target, 1 otherwise).
StkFloat | lastOut (void) const
| Return the last computed output value.
StkFloat | tick (void)
| Compute and return one output sample.
StkFrames & | tick (StkFrames &frames, unsigned int channel=0)
| Fill a channel of the StkFrames object with computed outputs.

## Detailed Description

STK asymptotic curve envelope class.

This class implements a simple envelope generator which asymptotically approaches a target value. The algorithm used is of the form:

y[n] = a y[n-1] + (1-a) target,

where a = exp(-T/tau), T is the sample period, and tau is a time constant. The user can set the time constant (default value = 0.3) and target value. Theoretically, this recursion never reaches its target, though the calculations in this class are stopped when the current value gets within a small threshold value of the target (at which time the current value is set to the target). It responds to keyOn and keyOff messages by ramping to 1.0 on keyOn and to 0.0 on keyOff.

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

## Member Function Documentation

void stk::Asymp::setTau | ( | StkFloat | tau | ) |

Set the asymptotic rate via the time factor tau (must be > 0).

The rate is computed as described above. The value of tau must be greater than zero. Values of tau close to zero produce fast approach rates, while values greater than 1.0 produce rather slow rates.

StkFrames & stk::Asymp::tick | ( | StkFrames & | frames,
|  | unsigned int | channel = `0` |
| ) |  |  | `[inline, virtual]`

Fill a channel of the StkFrames object with computed outputs.

The `channel` argument must be less than the number of channels in the StkFrames argument (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an StkError exception.

Implements stk::Generator.

    00128 {
    00129 #if defined(_STK_DEBUG_)
    00130   if ( channel >= frames.channels() ) {
    00131     oStream_ << "Asymp::tick(): channel and StkFrames arguments are incompatible!";
    00132     handleError( StkError::FUNCTION_ARGUMENT );
    00133   }
    00134 #endif
    00135
    00136   StkFloat *samples = &frames[channel];
    00137   unsigned int hop = frames.channels();
    00138   for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
    00139     *samples = Asymp::tick();
    00140
    00141   return frames;
    00142 }

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

- Asymp.h

The Synthesis ToolKit in C++ (STK)
©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved.