 
    
   
Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial
   45   Guitar( 
unsigned int nStrings = 6, std::string bodyfile = 
"" );
 
   80   void noteOn( StkFloat frequency, StkFloat amplitude, 
unsigned int string = 0 );
 
   83   void noteOff( StkFloat amplitude, 
unsigned int string = 0 );
 
   93   StkFloat 
lastOut( 
void ) { 
return lastFrame_[0]; };
 
   96   StkFloat 
tick( StkFloat input = 0.0 );
 
  122   std::vector< stk::Twang > strings_;
 
  123   std::vector< int > stringState_; 
 
  124   std::vector< unsigned int > decayCounter_;
 
  125   std::vector< unsigned int > filePointer_;
 
  126   std::vector< StkFloat > pluckGains_;
 
  130   StkFloat  couplingGain_;
 
  137   StkFloat temp, output = 0.0;
 
  138   lastFrame_[0] /= strings_.size(); 
 
  139   for ( 
unsigned int i=0; i<strings_.size(); i++ ) {
 
  140     if ( stringState_[i] ) {
 
  143       if ( filePointer_[i] < excitation_.
frames() && pluckGains_[i] > 0.2 )
 
  144         temp += pluckGains_[i] * excitation_[filePointer_[i]++];
 
  145       temp += couplingGain_ * couplingFilter_.
tick( lastFrame_[0] ); 
 
  146       output += strings_[i].tick( temp );
 
  148       if ( stringState_[i] == 1 ) {
 
  149         if ( fabs( strings_[i].
lastOut() ) < 0.001 ) decayCounter_[i]++;
 
  150         else decayCounter_[i] = 0;
 
  151         if ( decayCounter_[i] > (
unsigned int) floor( 0.1 * 
Stk::sampleRate() ) ) {
 
  153           decayCounter_[i] = 0;
 
  159   return lastFrame_[0] = output;
 
  164 #if defined(_STK_DEBUG_) 
  165   if ( channel >= frames.
channels() ) {
 
  166     oStream_ << 
"Guitar::tick(): channel and StkFrames arguments are incompatible!";
 
  171   StkFloat *samples = &frames[channel];
 
  172   unsigned int hop = frames.
channels();
 
  173   for ( 
unsigned int i=0; i<frames.
frames(); i++, samples += hop )
 
  174     *samples = 
tick( *samples );
 
  181 #if defined(_STK_DEBUG_) 
  183     oStream_ << 
"Guitar::tick(): channel and StkFrames arguments are incompatible!";
 
  188   StkFloat *iSamples = &iFrames[iChannel];
 
  189   StkFloat *oSamples = &oFrames[oChannel];
 
  191   for ( 
unsigned int i=0; i<iFrames.
frames(); i++, iSamples += iHop, oSamples += oHop )
 
  192     *oSamples = 
tick( *iSamples );
 
  
STK one-pole filter class.
Definition: OnePole.h:21
void noteOff(StkFloat amplitude, unsigned int string=0)
Stop a note with the given amplitude (speed of decay).
void controlChange(int number, StkFloat value, int string=-1)
Perform the control change specified by number and value (0.0 - 128.0).
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition: Stk.h:407
void noteOn(StkFloat frequency, StkFloat amplitude, unsigned int string=0)
Start a note with the given frequency and amplitude.
StkFloat tick(StkFloat input)
Input one sample to the filter and return one output.
Definition: OnePole.h:80
void setPluckPosition(StkFloat position, int string=-1)
Set the pluck position for one or all strings.
static StkFloat sampleRate(void)
Static method that returns the current STK sample rate.
Definition: Stk.h:145
void clear(void)
Reset and clear all internal state.
StkFloat tick(StkFloat input=0.0)
Take an optional input sample and compute one output sample.
Definition: Guitar.h:135
StkFloat lastOut(void)
Return the last computed output value.
Definition: Guitar.h:93
An STK class to handle vectorized audio data.
Definition: Stk.h:276
void setBodyFile(std::string bodyfile="")
Set the string excitation, using either a soundfile or computed noise.
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition: Stk.h:404
static void handleError(const char *message, StkError::Type type)
Static function for error reporting and handling using c-strings.
void setLoopGain(StkFloat gain, int string=-1)
Set the loop gain for one or all strings.
Guitar(unsigned int nStrings=6, std::string bodyfile="")
Class constructor, specifying an arbitrary number of strings (default = 6).
void setFrequency(StkFloat frequency, unsigned int string=0)
Set instrument parameters for a particular frequency.
The STK namespace.
Definition: ADSR.h:6
STK guitar model class.
Definition: Guitar.h:42
STK base class.
Definition: Stk.h:133