| 1 |
/***************************************************/ |
| 2 |
/*! \class Sitar |
| 3 |
\brief STK sitar string model class. |
| 4 |
|
| 5 |
This class implements a sitar plucked string |
| 6 |
physical model based on the Karplus-Strong |
| 7 |
algorithm. |
| 8 |
|
| 9 |
This is a digital waveguide model, making its |
| 10 |
use possibly subject to patents held by |
| 11 |
Stanford University, Yamaha, and others. |
| 12 |
There exist at least two patents, assigned to |
| 13 |
Stanford, bearing the names of Karplus and/or |
| 14 |
Strong. |
| 15 |
|
| 16 |
by Perry R. Cook and Gary P. Scavone, 1995 - 2005. |
| 17 |
*/ |
| 18 |
/***************************************************/ |
| 19 |
|
| 20 |
#ifndef STK_SITAR_H |
| 21 |
#define STK_SITAR_H |
| 22 |
|
| 23 |
#include "Instrmnt.h" |
| 24 |
#include "DelayA.h" |
| 25 |
#include "OneZero.h" |
| 26 |
#include "Noise.h" |
| 27 |
#include "ADSR.h" |
| 28 |
|
| 29 |
namespace Nyq |
| 30 |
{ |
| 31 |
|
| 32 |
class Sitar : public Instrmnt |
| 33 |
{ |
| 34 |
public: |
| 35 |
//! Class constructor, taking the lowest desired playing frequency. |
| 36 |
Sitar( StkFloat lowestFrequency = 20 ); |
| 37 |
|
| 38 |
//! Class destructor. |
| 39 |
~Sitar(); |
| 40 |
|
| 41 |
//! Reset and clear all internal state. |
| 42 |
void clear(); |
| 43 |
|
| 44 |
//! Set instrument parameters for a particular frequency. |
| 45 |
void setFrequency(StkFloat frequency); |
| 46 |
|
| 47 |
//! Pluck the string with the given amplitude using the current frequency. |
| 48 |
void pluck(StkFloat amplitude); |
| 49 |
|
| 50 |
//! Start a note with the given frequency and amplitude. |
| 51 |
void noteOn(StkFloat frequency, StkFloat amplitude); |
| 52 |
|
| 53 |
//! Stop a note with the given amplitude (speed of decay). |
| 54 |
void noteOff(StkFloat amplitude); |
| 55 |
|
| 56 |
protected: |
| 57 |
|
| 58 |
StkFloat computeSample( void ); |
| 59 |
|
| 60 |
DelayA delayLine_; |
| 61 |
OneZero loopFilter_; |
| 62 |
Noise noise_; |
| 63 |
ADSR envelope_; |
| 64 |
|
| 65 |
StkFloat loopGain_; |
| 66 |
StkFloat amGain_; |
| 67 |
StkFloat delay_; |
| 68 |
StkFloat targetDelay_; |
| 69 |
|
| 70 |
}; |
| 71 |
|
| 72 |
} // namespace Nyq |
| 73 |
|
| 74 |
#endif |
| 75 |
|