45 Guitar(
unsigned int nStrings = 6, std::string bodyfile =
"" );
73 void setFrequency( StkFloat frequency,
unsigned int string = 0 );
80 void noteOn( StkFloat frequency, StkFloat amplitude,
unsigned int string = 0 );
83 void noteOff( StkFloat amplitude,
unsigned int string = 0 );
90 void controlChange(
int number, StkFloat value,
int string = -1 );
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_;
140 StkFloat temp, output = 0.0;
141 lastFrame_[0] = couplingGain_ * couplingFilter_.
tick( lastFrame_[0] ) / strings_.size();
142 for (
unsigned int i=0; i<strings_.size(); i++ ) {
143 if ( stringState_[i] ) {
146 if ( filePointer_[i] < excitation_.
frames() && pluckGains_[i] > 0.2 )
147 temp += pluckGains_[i] * excitation_[filePointer_[i]++];
148 temp += lastFrame_[0];
149 output += strings_[i].tick( temp );
151 if ( stringState_[i] == 1 ) {
152 if ( fabs( strings_[i].
lastOut() ) < 0.001 ) decayCounter_[i]++;
153 else decayCounter_[i] = 0;
154 if ( decayCounter_[i] > (
unsigned int) floor( 0.1 *
Stk::sampleRate() ) ) {
156 decayCounter_[i] = 0;
162 return lastFrame_[0] = output;
167 #if defined(_STK_DEBUG_)
168 if ( channel >= frames.
channels() ) {
169 oStream_ <<
"Guitar::tick(): channel and StkFrames arguments are incompatible!";
174 StkFloat *samples = &frames[channel];
175 unsigned int hop = frames.
channels();
176 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop )
177 *samples =
tick( *samples );
184 #if defined(_STK_DEBUG_)
186 oStream_ <<
"Guitar::tick(): channel and StkFrames arguments are incompatible!";
191 StkFloat *iSamples = &iFrames[iChannel];
192 StkFloat *oSamples = &oFrames[oChannel];
194 for (
unsigned int i=0; i<iFrames.
frames(); i++, iSamples += iHop, oSamples += oHop )
195 *oSamples =
tick( *iSamples );