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_;
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 );