Debian Codegraph @

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

raw
1 /***************************************************/
2 /*! \class Instrmnt
3 \brief STK instrument abstract base class.
4
5 This class provides a common interface for
6 all STK instruments.
7
8 by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
9 */
10 /***************************************************/
11
12 #ifndef STK_INSTRMNT_H
13 #define STK_INSTRMNT_H
14
15 #include "Stk.h"
16
17 namespace Nyq
18 {
19
20 class Instrmnt : public Stk
21 {
22 public:
23 //! Default constructor.
24 Instrmnt();
25
26 //! Class destructor.
27 virtual ~Instrmnt();
28
29 //! Start a note with the given frequency and amplitude.
30 virtual void noteOn(StkFloat frequency, StkFloat amplitude) = 0;
31
32 //! Stop a note with the given amplitude (speed of decay).
33 virtual void noteOff(StkFloat amplitude) = 0;
34
35 //! Set instrument parameters for a particular frequency.
36 virtual void setFrequency(StkFloat frequency);
37
38 //! Return the last output value.
39 StkFloat lastOut() const;
40
41 //! Return the last left output value.
42 StkFloat lastOutLeft() const;
43
44 //! Return the last right output value.
45 StkFloat lastOutRight() const;
46
47 //! Compute one sample and output.
48 StkFloat tick( void );
49
50 //! Fill a channel of the StkFrames object with computed outputs.
51 /*!
52 The \c channel argument should be zero or greater (the first
53 channel is specified by 0). An StkError will be thrown if the \c
54 channel argument is equal to or greater than the number of
55 channels in the StkFrames object.
56 */
57 StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
58
59 //! Perform the control change specified by \e number and \e value (0.0 - 128.0).
60 virtual void controlChange(int number, StkFloat value);
61
62 protected:
63
64 // This abstract function must be implemented in all subclasses.
65 // It is used to get around a C++ problem with overloaded virtual
66 // functions.
67 virtual StkFloat computeSample( void ) = 0;
68
69 StkFloat lastOutput_;
70
71 };
72
73 } // namespace Nyq
74
75 #endif