Debian Codegraph @

lib-src/libnyquist/nyquist/nyqstk/src/Instrmnt.cpp

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 #include "Instrmnt.h"
13
14 using namespace Nyq;
15
16 Instrmnt :: Instrmnt()
17 {
18 }
19
20 Instrmnt :: ~Instrmnt()
21 {
22 }
23
24 void Instrmnt :: setFrequency(StkFloat frequency)
25 {
26 errorString_ << "Instrmnt::setFrequency: virtual setFrequency function call!";
27 handleError( StkError::WARNING );
28 }
29
30 StkFloat Instrmnt :: lastOut() const
31 {
32 return lastOutput_;
33 }
34
35 // Support for stereo output:
36 StkFloat Instrmnt :: lastOutLeft(void) const
37 {
38 return 0.5 * lastOutput_;
39 }
40
41 StkFloat Instrmnt :: lastOutRight(void) const
42 {
43 return 0.5 * lastOutput_;
44 }
45
46 StkFloat Instrmnt :: tick( void )
47 {
48 return computeSample();
49 }
50
51 StkFrames& Instrmnt :: tick( StkFrames& frames, unsigned int channel )
52 {
53 if ( channel >= frames.channels() ) {
54 errorString_ << "Instrmnt::tick(): channel and StkFrames arguments are incompatible!";
55 handleError( StkError::FUNCTION_ARGUMENT );
56 }
57
58 if ( frames.channels() == 1 ) {
59 for ( unsigned int i=0; i<frames.frames(); i++ )
60 frames[i] = tick();
61 }
62 else if ( frames.interleaved() ) {
63 unsigned int hop = frames.channels();
64 unsigned int index = channel;
65 for ( unsigned int i=0; i<frames.frames(); i++ ) {
66 frames[index] = tick();
67 index += hop;
68 }
69 }
70 else {
71 unsigned int iStart = channel * frames.frames();
72 for ( unsigned int i=0; i<frames.frames(); i++, iStart++ )
73 frames[iStart] = tick();
74 }
75
76 return frames;
77 }
78
79 void Instrmnt :: controlChange(int number, StkFloat value)
80 {
81 errorString_ << "Instrmnt::controlChange: virtual function call!";
82 handleError( StkError::WARNING );
83 }