CSL  5.2
KarplusString.h
Go to the documentation of this file.
1 //
2 // KarplusString.h -- the simplest possible "physical model" string class
3 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
4 //
5 
6 /* TODO:
7  Jorge . . . November 2005
8  1) Add a dump() function.
9  2) implement exceptions
10  3) add DEBUG print code.
11  4) make it scalable . . .
12  5) allow for dynamic frequency . . . ? do we want that?
13  6) add a trigger function . . . (do we need an envelope?)
14 */
15 
16 
17 #ifndef CSL_KARPLUSSTRING_H
18 #define CSL_KARPLUSSTRING_H
19 
20 #include "CSL_Core.h" // my superclass
21 //#include "RingBuffer.h"
22 //#include "Filters.h"
23 #include "Noise.h"
24 
25 namespace csl { // my namespace
26 
27 ///
28 /// KarplusString -- string model class
29 ///
30 
31 class KarplusString : public UnitGenerator, public Scalable, public Phased {
32 
33 public:
34  KarplusString();
35  KarplusString(float frequency);
36  void setFrequency(float frequency);
37  void trigger(); ///< reset internal buffers to re-pluck the string.
38  void dump(); ///< print debugging info.
39 
40  void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw (CException);
41  virtual bool isActive() { return (mEnergy > 0); };
42 
43  Buffer mDelayLine; ///< the delay line (just a buffer, not a RingBuffer)
44 
45 protected:
46  void initDelayLine(); ///< function to initialize the delay line
47  unsigned mIndex; ///< current index in the delay line
48  unsigned mDelayLength; ///< allocated size of the delay line
49  unsigned mEnergy; ///< energy left in buffer
50  float mFrequency;
51 
52 }; // end of class
53 
54 } // end of namespace
55 
56 #endif
57