CSL  6.0
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 
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
unsigned mIndex
current index in the delay line
Definition: KarplusString.h:47
Phased – a mix-in for objects with phase accumulators (local float) and frequency controls (an input...
Definition: CSL_Core.h:497
void initDelayLine()
function to initialize the delay line
void dump()
print debugging info.
void setFrequency(float frequency)
Scalable – mix-in class with scale and offset control inputs (may be constants or generators)...
Definition: CSL_Core.h:403
unsigned mDelayLength
allocated size of the delay line
Definition: KarplusString.h:48
void trigger()
reset internal buffers to re-pluck the string.
unsigned mEnergy
energy left in buffer
Definition: KarplusString.h:49
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Definition: CSL_Core.h:106
void nextBuffer(Buffer &outputBuffer, unsigned outBufNum)
The mono_next_buffer method does all the work.
forward declaration
Definition: CSL_Core.h:241
Buffer mDelayLine
the delay line (just a buffer, not a RingBuffer)
Definition: KarplusString.h:41
virtual bool isActive()
query whether I'm currently active (Envelopes can go inactive)
Definition: KarplusString.h:41
KarplusString – string model class.
Definition: KarplusString.h:31
Base class of CSL exceptions (written upper-case). Has a string message.