Version 4.4.0

This commit is contained in:
Gary Scavone
2013-09-29 23:11:39 +02:00
committed by Stephen Sinclair
parent d199342e86
commit eccd8c9981
287 changed files with 11712 additions and 7676 deletions

View File

@@ -12,7 +12,7 @@
- Blowing Frequency Modulation = 2
- Volume = 128
by Perry R. Cook 1996 - 2004.
by Perry R. Cook 1996 - 2009.
*/
/***************************************************/
@@ -20,6 +20,8 @@
#include "SKINI.msg"
#include <cmath>
namespace stk {
const int CAN_RADIUS = 100;
const int PEA_RADIUS = 30;
const int BUMP_RADIUS = 5;
@@ -33,7 +35,7 @@ const StkFloat SLOW_TICK_SIZE = 0.0001;
const StkFloat ENV_RATE = 0.001;
Whistle :: Whistle()
Whistle :: Whistle( void )
{
sine_.setFrequency( 2800.0 );
@@ -54,31 +56,31 @@ Whistle :: Whistle()
envelope_.setRate( ENV_RATE );
envelope_.keyOn();
fippleFreqMod_ = 0.5;
fippleGainMod_ = 0.5;
blowFreqMod_ = 0.25;
noiseGain_ = 0.125;
baseFrequency_ = 2000;
fippleFreqMod_ = 0.5;
fippleGainMod_ = 0.5;
blowFreqMod_ = 0.25;
noiseGain_ = 0.125;
baseFrequency_ = 2000;
tickSize_ = NORM_TICK_SIZE;
canLoss_ = NORM_CAN_LOSS;
tickSize_ = NORM_TICK_SIZE;
canLoss_ = NORM_CAN_LOSS;
subSample_ = 1;
subSampCount_ = subSample_;
subSample_ = 1;
subSampCount_ = subSample_;
}
Whistle :: ~Whistle()
Whistle :: ~Whistle( void )
{
#ifdef WHISTLE_ANIMATION
printf("Exit, Whistle bye bye!!\n");
#endif
}
void Whistle :: clear()
void Whistle :: clear( void )
{
}
void Whistle :: setFrequency(StkFloat frequency)
void Whistle :: setFrequency( StkFloat frequency )
{
StkFloat freakency = frequency * 4; // the whistle is a transposing instrument
if ( frequency <= 0.0 ) {
@@ -90,19 +92,19 @@ void Whistle :: setFrequency(StkFloat frequency)
baseFrequency_ = freakency;
}
void Whistle :: startBlowing(StkFloat amplitude, StkFloat rate)
void Whistle :: startBlowing( StkFloat amplitude, StkFloat rate )
{
envelope_.setRate( ENV_RATE );
envelope_.setTarget( amplitude );
envelope_.setRate( ENV_RATE );
envelope_.setTarget( amplitude );
}
void Whistle :: stopBlowing(StkFloat rate)
void Whistle :: stopBlowing( StkFloat rate )
{
envelope_.setRate( rate );
envelope_.keyOff();
}
void Whistle :: noteOn(StkFloat frequency, StkFloat amplitude)
void Whistle :: noteOn( StkFloat frequency, StkFloat amplitude )
{
this->setFrequency( frequency );
this->startBlowing( amplitude*2.0 ,amplitude * 0.2 );
@@ -112,7 +114,7 @@ void Whistle :: noteOn(StkFloat frequency, StkFloat amplitude)
#endif
}
void Whistle :: noteOff(StkFloat amplitude)
void Whistle :: noteOff( StkFloat amplitude )
{
this->stopBlowing( amplitude * 0.02 );
@@ -124,17 +126,17 @@ void Whistle :: noteOff(StkFloat amplitude)
int frameCount = 0;
StkFloat Whistle :: computeSample()
StkFloat Whistle :: tick( unsigned int )
{
StkFloat soundMix, tempFreq;
StkFloat envOut = 0, temp, temp1, temp2, tempX, tempY;
double phi, cosphi, sinphi;
double gain = 0.5, mod = 0.0;
if ( --subSampCount_ <= 0 ) {
tempVectorP_ = pea_.getPosition();
subSampCount_ = subSample_;
temp = bumper_.isInside( tempVectorP_ );
if ( --subSampCount_ <= 0 ) {
tempVectorP_ = pea_.getPosition();
subSampCount_ = subSample_;
temp = bumper_.isInside( tempVectorP_ );
#ifdef WHISTLE_ANIMATION
frameCount += 1;
if ( frameCount >= (1470 / subSample_) ) {
@@ -151,7 +153,7 @@ StkFloat Whistle :: computeSample()
pea_.addVelocity( tempX, tempY, 0 );
pea_.tick( tickSize_ );
}
mod = exp(-temp * 0.01); // exp. distance falloff of fipple/pea effect
temp = onepole_.tick(mod); // smooth it a little
gain = (1.0 - (fippleGainMod_*0.5)) + (2.0 * fippleGainMod_ * temp);
@@ -164,7 +166,7 @@ StkFloat Whistle :: computeSample()
tempFreq *= baseFrequency_;
sine_.setFrequency(tempFreq);
tempVectorP_ = pea_.getPosition();
temp = can_.isInside(tempVectorP_);
temp = -temp; // We know (hope) it's inside, just how much??
@@ -202,22 +204,22 @@ StkFloat Whistle :: computeSample()
tempX = 0.0;
tempY = 0.0;
}
temp = (0.9 + 0.1*subSample_*noise_.tick()) * envOut * 0.6 * tickSize_;
pea_.addVelocity( temp * tempX, (temp*tempY) - (GRAVITY*tickSize_), 0 );
pea_.tick( tickSize_ );
// bumper_.tick(0.0);
}
}
temp = envOut * envOut * gain / 2;
soundMix = temp * ( sine_.tick() + ( noiseGain_*noise_.tick() ) );
lastOutput_ = 0.25 * soundMix; // should probably do one-zero filter here
temp = envOut * envOut * gain / 2;
soundMix = temp * ( sine_.tick() + ( noiseGain_*noise_.tick() ) );
lastFrame_[0] = 0.20 * soundMix; // should probably do one-zero filter here
return lastOutput_;
return lastFrame_[0];
}
void Whistle :: controlChange(int number, StkFloat value)
void Whistle :: controlChange( int number, StkFloat value )
{
StkFloat norm = value * ONE_OVER_128;
if ( norm < 0 ) {
@@ -252,8 +254,9 @@ void Whistle :: controlChange(int number, StkFloat value)
}
#if defined(_STK_DEBUG_)
errorString_ << "Whistle::controlChange: number = " << number << ", value = " << value << '.';
handleError( StkError::DEBUG_WARNING );
errorString_ << "Whistle::controlChange: number = " << number << ", value = " << value << '.';
handleError( StkError::DEBUG_WARNING );
#endif
}
} // stk namespace