Debian Codegraph @

lib-src/libnyquist/nyquist/nyqstk/include/Envelope.h

raw
1 /***************************************************/
2 /*! \class Envelope
3 \brief STK envelope base class.
4
5 This class implements a simple envelope
6 generator which is capable of ramping to
7 a target value by a specified \e rate.
8 It also responds to simple \e keyOn and
9 \e keyOff messages, ramping to 1.0 on
10 keyOn and to 0.0 on keyOff.
11
12 by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
13 */
14 /***************************************************/
15
16 #ifndef STK_ENVELOPE_H
17 #define STK_ENVELOPE_H
18
19 #include "Generator.h"
20
21 namespace Nyq
22 {
23
24 class Envelope : public Generator
25 {
26 public:
27
28 //! Default constructor.
29 Envelope(void);
30
31 //! Copy constructor.
32 Envelope( const Envelope& e );
33
34 //! Class destructor.
35 virtual ~Envelope(void);
36
37 //! Assignment operator.
38 Envelope& operator= ( const Envelope& e );
39
40 //! Set target = 1.
41 virtual void keyOn(void);
42
43 //! Set target = 0.
44 virtual void keyOff(void);
45
46 //! Set the \e rate.
47 void setRate(StkFloat rate);
48
49 //! Set the \e rate based on a time duration.
50 void setTime(StkFloat time);
51
52 //! Set the target value.
53 virtual void setTarget(StkFloat target);
54
55 //! Set current and target values to \e aValue.
56 virtual void setValue(StkFloat value);
57
58 //! Return the current envelope \e state (0 = at target, 1 otherwise).
59 virtual int getState(void) const;
60
61 protected:
62
63 virtual StkFloat computeSample( void );
64
65 StkFloat value_;
66 StkFloat target_;
67 StkFloat rate_;
68 int state_;
69 };
70
71 } // namespace Nyq
72
73 #endif