Version 4.4.3

This commit is contained in:
Gary Scavone
2013-09-29 23:21:29 +02:00
committed by Stephen Sinclair
parent baca57040b
commit 0aec39260a
223 changed files with 26190 additions and 11130 deletions

View File

@@ -13,7 +13,7 @@
Stanford, bearing the names of Karplus and/or
Strong.
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
by Perry R. Cook and Gary P. Scavone, 1995-2011.
*/
/***************************************************/
@@ -23,16 +23,21 @@ namespace stk {
Sitar :: Sitar( StkFloat lowestFrequency )
{
if ( lowestFrequency <= 0.0 ) {
oStream_ << "Sitar::Sitar: argument is less than or equal to zero!";
handleError( StkError::FUNCTION_ARGUMENT );
}
unsigned long length = (unsigned long) ( Stk::sampleRate() / lowestFrequency + 1 );
delayLine_.setMaximumDelay( length );
delay_ = 0.5 * length;
delayLine_.setDelay( delay_ );
targetDelay_ = delay_;
loopFilter_.setZero(0.01);
loopFilter_.setZero( 0.01 );
loopGain_ = 0.999;
envelope_.setAllTimes(0.001, 0.04, 0.0, 0.5);
envelope_.setAllTimes( 0.001, 0.04, 0.0, 0.5 );
this->clear();
}
@@ -48,17 +53,17 @@ void Sitar :: clear( void )
void Sitar :: setFrequency( StkFloat frequency )
{
StkFloat freakency = frequency;
#if defined(_STK_DEBUG_)
if ( frequency <= 0.0 ) {
errorString_ << "Sitar::setFrequency: parameter is less than or equal to zero!";
handleError( StkError::WARNING );
freakency = 220.0;
oStream_ << "Sitar::setFrequency: parameter is less than or equal to zero!";
handleError( StkError::WARNING ); return;
}
#endif
targetDelay_ = (Stk::sampleRate() / freakency);
targetDelay_ = (Stk::sampleRate() / frequency);
delay_ = targetDelay_ * (1.0 + (0.05 * noise_.tick()));
delayLine_.setDelay( delay_ );
loopGain_ = 0.995 + (freakency * 0.0000005);
loopGain_ = 0.995 + (frequency * 0.0000005);
if ( loopGain_ > 0.9995 ) loopGain_ = 0.9995;
}
@@ -72,31 +77,16 @@ void Sitar :: noteOn( StkFloat frequency, StkFloat amplitude )
this->setFrequency( frequency );
this->pluck( amplitude );
amGain_ = 0.1 * amplitude;
#if defined(_STK_DEBUG_)
errorString_ << "Sitar::NoteOn: frequency = " << frequency << ", amplitude = " << amplitude << ".";
handleError( StkError::DEBUG_WARNING );
#endif
}
void Sitar :: noteOff( StkFloat amplitude )
{
loopGain_ = (StkFloat) 1.0 - amplitude;
if ( loopGain_ < 0.0 ) {
errorString_ << "Sitar::noteOff: amplitude is greater than 1.0 ... setting to 1.0!";
handleError( StkError::WARNING );
loopGain_ = 0.0;
}
else if ( loopGain_ > 1.0 ) {
errorString_ << "Sitar::noteOff: amplitude is < 0.0 ... setting to 0.0!";
handleError( StkError::WARNING );
loopGain_ = 0.99999;
if ( amplitude < 0.0 || amplitude > 1.0 ) {
oStream_ << "Sitar::noteOff: amplitude is out of range!";
handleError( StkError::WARNING ); return;
}
#if defined(_STK_DEBUG_)
errorString_ << "Sitar::NoteOff: amplitude = " << amplitude << ".";
handleError( StkError::DEBUG_WARNING );
#endif
loopGain_ = (StkFloat) 1.0 - amplitude;
}
} // stk namespace