Version 4.2.0

This commit is contained in:
Gary Scavone
2009-03-24 23:02:14 -04:00
committed by Stephen Sinclair
parent cf06b7598b
commit a6381b9d38
281 changed files with 17152 additions and 12000 deletions

View File

@@ -4,99 +4,73 @@
This class implements a chorus effect.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#include "Chorus.h"
#include <iostream>
Chorus :: Chorus(MY_FLOAT baseDelay)
Chorus :: Chorus(StkFloat baseDelay)
{
delayLine[0] = new DelayL((long) baseDelay, (long) (baseDelay * 1.414) + 2);
delayLine[1] = new DelayL((long) (baseDelay), (long) baseDelay + 2);
baseLength = baseDelay;
delayLine_[0].setMaximumDelay( (unsigned long) (baseDelay * 1.414) + 2);
delayLine_[0].setDelay( baseDelay );
delayLine_[1].setMaximumDelay( (unsigned long) (baseDelay * 1.414) + 2);
delayLine_[1].setDelay( baseDelay );
baseLength_ = baseDelay;
// Concatenate the STK rawwave path to the rawwave file
mods[0] = new WaveLoop( (Stk::rawwavePath() + "sinewave.raw").c_str(), TRUE );
mods[1] = new WaveLoop( (Stk::rawwavePath() + "sinewave.raw").c_str(), TRUE );
mods[0]->setFrequency(0.2);
mods[1]->setFrequency(0.222222);
modDepth = 0.05;
effectMix = 0.5;
mods_[0] = new WaveLoop( (Stk::rawwavePath() + "sinewave.raw").c_str(), true );
mods_[1] = new WaveLoop( (Stk::rawwavePath() + "sinewave.raw").c_str(), true );
mods_[0]->setFrequency(0.2);
mods_[1]->setFrequency(0.222222);
modDepth_ = 0.05;
effectMix_ = 0.5;
this->clear();
}
Chorus :: ~Chorus()
{
delete delayLine[0];
delete delayLine[1];
delete mods[0];
delete mods[1];
delete mods_[0];
delete mods_[1];
}
void Chorus :: clear()
{
delayLine[0]->clear();
delayLine[1]->clear();
lastOutput[0] = 0.0;
lastOutput[1] = 0.0;
delayLine_[0].clear();
delayLine_[1].clear();
lastOutput_[0] = 0.0;
lastOutput_[1] = 0.0;
}
void Chorus :: setEffectMix(MY_FLOAT mix)
void Chorus :: setModDepth(StkFloat depth)
{
effectMix = mix;
if ( mix < 0.0 ) {
std::cerr << "Chorus: setEffectMix parameter is less than zero!" << std::endl;
effectMix = 0.0;
}
else if ( mix > 1.0 ) {
std::cerr << "Chorus: setEffectMix parameter is greater than 1.0!" << std::endl;
effectMix = 1.0;
}
modDepth_ = depth;
}
void Chorus :: setModDepth(MY_FLOAT depth)
void Chorus :: setModFrequency(StkFloat frequency)
{
modDepth = depth;
mods_[0]->setFrequency(frequency);
mods_[1]->setFrequency(frequency * 1.1111);
}
void Chorus :: setModFrequency(MY_FLOAT frequency)
StkFloat Chorus :: tick(StkFloat input)
{
mods[0]->setFrequency(frequency);
mods[1]->setFrequency(frequency * 1.1111);
delayLine_[0].setDelay( baseLength_ * 0.707 * (1.0 + mods_[0]->tick()) );
delayLine_[1].setDelay( baseLength_ * 0.5 * (1.0 - mods_[1]->tick()) );
lastOutput_[0] = input * (1.0 - effectMix_);
lastOutput_[0] += effectMix_ * delayLine_[0].tick(input);
lastOutput_[1] = input * (1.0 - effectMix_);
lastOutput_[1] += effectMix_ * delayLine_[1].tick(input);
return Effect::lastOut();
}
MY_FLOAT Chorus :: lastOut() const
StkFloat *Chorus :: tick(StkFloat *vector, unsigned int vectorSize)
{
return (lastOutput[0] + lastOutput[1]) * (MY_FLOAT) 0.5;
return Effect::tick( vector, vectorSize );
}
MY_FLOAT Chorus :: lastOutLeft() const
StkFrames& Chorus :: tick( StkFrames& frames, unsigned int channel )
{
return lastOutput[0];
}
MY_FLOAT Chorus :: lastOutRight() const
{
return lastOutput[1];
}
MY_FLOAT Chorus :: tick(MY_FLOAT input)
{
delayLine[0]->setDelay(baseLength * 0.707 * (1.0 + mods[0]->tick()));
delayLine[1]->setDelay(baseLength * 0.5 * (1.0 - mods[1]->tick()));
lastOutput[0] = input * (1.0 - effectMix);
lastOutput[0] += effectMix * delayLine[0]->tick(input);
lastOutput[1] = input * (1.0 - effectMix);
lastOutput[1] += effectMix * delayLine[1]->tick(input);
return (lastOutput[0] + lastOutput[1]) * (MY_FLOAT) 0.5;
}
MY_FLOAT *Chorus :: tick(MY_FLOAT *vector, unsigned int vectorSize)
{
for (unsigned int i=0; i<vectorSize; i++)
vector[i] = tick(vector[i]);
return vector;
return Effect::tick( frames, channel );
}