Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


stk::Envelope Class Reference

STK linear line envelope class. More...

#include <Envelope.h>

Inheritance diagram for stk::Envelope:
stk::Generator stk::Stk

List of all members.

Public Member Functions

 Envelope (void)
 Default constructor.
 ~Envelope (void)
 Class destructor.
Envelopeoperator= (const Envelope &e)
 Assignment operator.
void keyOn (void)
 Set target = 1.
void keyOff (void)
 Set target = 0.
void setRate (StkFloat rate)
 Set the rate.
void setTime (StkFloat time)
 Set the rate based on a positive time duration (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.
StkFramestick (StkFrames &frames, unsigned int channel=0)
 Fill a channel of the StkFrames object with computed outputs.

Detailed Description

STK linear line envelope class.

This class implements a simple linear line envelope generator which is capable of ramping to an arbitrary target value by a specified rate. It also responds to simple keyOn and keyOff messages, 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::Envelope::setRate ( StkFloat  rate  ) 

Set the rate.

The rate must be positive (though a value of 0.0 is allowed).

void stk::Envelope::setTime ( StkFloat  time  ) 

Set the rate based on a positive time duration (seconds).

The rate is calculated such that the envelope will ramp from a value of 0.0 to 1.0 in the specified time duration.

StkFrames & stk::Envelope::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.

00112 {
00113 #if defined(_STK_DEBUG_)
00114   if ( channel >= frames.channels() ) {
00115     oStream_ << "Envelope::tick(): channel and StkFrames arguments are incompatible!";
00116     handleError( StkError::FUNCTION_ARGUMENT );
00117   }
00118 #endif
00119 
00120   StkFloat *samples = &frames[channel];
00121   unsigned int hop = frames.channels();
00122   for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
00123     *samples = tick();
00124 
00125   return frames;
00126 }


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

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