mirror of
https://github.com/thestk/stk
synced 2026-01-19 07:31:52 +00:00
Version 4.0
This commit is contained in:
committed by
Stephen Sinclair
parent
3f126af4e5
commit
81475b04c5
@@ -1,41 +1,68 @@
|
||||
/*******************************************/
|
||||
/* Envelope Class, Perry R. Cook, 1995-96 */
|
||||
/* This is the base class for envelopes. */
|
||||
/* This one is capable of ramping state */
|
||||
/* from where it is to a target value by */
|
||||
/* a rate. It also responds to simple */
|
||||
/* KeyOn and KeyOff messages, ramping to */
|
||||
/* 1.0 on keyon and to 0.0 on keyoff. */
|
||||
/* There are two tick (update value) */
|
||||
/* methods, one returns the value, and */
|
||||
/* other returns 0 if the envelope is at */
|
||||
/* the target value (the state bit). */
|
||||
/*******************************************/
|
||||
|
||||
#if !defined(__Envelope_h)
|
||||
#define __Envelope_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class Envelope : public Object
|
||||
{
|
||||
protected:
|
||||
MY_FLOAT value;
|
||||
MY_FLOAT target;
|
||||
MY_FLOAT rate;
|
||||
int state;
|
||||
public:
|
||||
Envelope();
|
||||
virtual ~Envelope();
|
||||
void keyOn();
|
||||
void keyOff();
|
||||
void setRate(MY_FLOAT aRate);
|
||||
void setTime(MY_FLOAT aTime);
|
||||
void setTarget(MY_FLOAT aTarget);
|
||||
void setValue(MY_FLOAT aValue);
|
||||
MY_FLOAT tick();
|
||||
int informTick();
|
||||
MY_FLOAT lastOut();
|
||||
};
|
||||
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class Envelope
|
||||
\brief STK envelope base class.
|
||||
|
||||
This class implements a simple envelope
|
||||
generator which is capable of ramping to
|
||||
a target value by a specified \e rate.
|
||||
It also responds to simple \e keyOn and
|
||||
\e keyOff messages, ramping to 1.0 on
|
||||
keyOn and to 0.0 on keyOff.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ENVELOPE_H)
|
||||
#define __ENVELOPE_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class Envelope : public Stk
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
Envelope(void);
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Envelope(void);
|
||||
|
||||
//! Set target = 1.
|
||||
virtual void keyOn(void);
|
||||
|
||||
//! Set target = 0.
|
||||
virtual void keyOff(void);
|
||||
|
||||
//! Set the \e rate.
|
||||
void setRate(MY_FLOAT aRate);
|
||||
|
||||
//! Set the \e rate based on a time duration.
|
||||
void setTime(MY_FLOAT aTime);
|
||||
|
||||
//! Set the target value.
|
||||
virtual void setTarget(MY_FLOAT aTarget);
|
||||
|
||||
//! Set current and target values to \e aValue.
|
||||
virtual void setValue(MY_FLOAT aValue);
|
||||
|
||||
//! Return the current envelope \e state (0 = at target, 1 otherwise).
|
||||
virtual int getState(void) const;
|
||||
|
||||
//! Return one envelope output value.
|
||||
virtual MY_FLOAT tick(void);
|
||||
|
||||
//! Return \e vectorSize envelope outputs in \e vector.
|
||||
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
|
||||
protected:
|
||||
MY_FLOAT value;
|
||||
MY_FLOAT target;
|
||||
MY_FLOAT rate;
|
||||
int state;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user