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

@@ -10,14 +10,14 @@
filters, and two decorrelation delay lines in
parallel at the output.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#include "JCRev.h"
#include <math.h>
JCRev :: JCRev(MY_FLOAT T60)
JCRev :: JCRev(StkFloat T60)
{
// Delay lengths for 44100 Hz sample rate.
int lengths[9] = {1777, 1847, 1993, 2137, 389, 127, 43, 211, 179};
@@ -33,89 +33,101 @@ JCRev :: JCRev(MY_FLOAT T60)
}
}
for (i=0; i<3; i++)
allpassDelays[i] = new Delay(lengths[i+4], lengths[i+4]);
for (i=0; i<4; i++) {
combDelays[i] = new Delay(lengths[i], lengths[i]);
combCoefficient[i] = pow(10.0,(-3 * lengths[i] / (T60 * Stk::sampleRate())));
for (i=0; i<3; i++) {
allpassDelays_[i].setMaximumDelay( lengths[i+4] );
allpassDelays_[i].setDelay( lengths[i+4] );
}
outLeftDelay = new Delay(lengths[7], lengths[7]);
outRightDelay = new Delay(lengths[8], lengths[8]);
allpassCoefficient = 0.7;
effectMix = 0.3;
for ( i=0; i<4; i++ ) {
combDelays_[i].setMaximumDelay( lengths[i] );
combDelays_[i].setDelay( lengths[i] );
}
this->setT60( T60 );
outLeftDelay_.setMaximumDelay( lengths[7] );
outLeftDelay_.setDelay( lengths[7] );
outRightDelay_.setMaximumDelay( lengths[8] );
outRightDelay_.setDelay( lengths[8] );
allpassCoefficient_ = 0.7;
effectMix_ = 0.3;
this->clear();
}
JCRev :: ~JCRev()
{
delete allpassDelays[0];
delete allpassDelays[1];
delete allpassDelays[2];
delete combDelays[0];
delete combDelays[1];
delete combDelays[2];
delete combDelays[3];
delete outLeftDelay;
delete outRightDelay;
}
void JCRev :: clear()
{
allpassDelays[0]->clear();
allpassDelays[1]->clear();
allpassDelays[2]->clear();
combDelays[0]->clear();
combDelays[1]->clear();
combDelays[2]->clear();
combDelays[3]->clear();
outRightDelay->clear();
outLeftDelay->clear();
lastOutput[0] = 0.0;
lastOutput[1] = 0.0;
allpassDelays_[0].clear();
allpassDelays_[1].clear();
allpassDelays_[2].clear();
combDelays_[0].clear();
combDelays_[1].clear();
combDelays_[2].clear();
combDelays_[3].clear();
outRightDelay_.clear();
outLeftDelay_.clear();
lastOutput_[0] = 0.0;
lastOutput_[1] = 0.0;
}
MY_FLOAT JCRev :: tick(MY_FLOAT input)
void JCRev :: setT60( StkFloat T60 )
{
MY_FLOAT temp, temp0, temp1, temp2, temp3, temp4, temp5, temp6;
MY_FLOAT filtout;
for ( int i=0; i<4; i++ )
combCoefficient_[i] = pow(10.0, (-3.0 * combDelays_[i].getDelay() / (T60 * Stk::sampleRate())));
}
temp = allpassDelays[0]->lastOut();
temp0 = allpassCoefficient * temp;
StkFloat JCRev :: tick(StkFloat input)
{
StkFloat temp, temp0, temp1, temp2, temp3, temp4, temp5, temp6;
StkFloat filtout;
temp = allpassDelays_[0].lastOut();
temp0 = allpassCoefficient_ * temp;
temp0 += input;
allpassDelays[0]->tick(temp0);
temp0 = -(allpassCoefficient * temp0) + temp;
allpassDelays_[0].tick(temp0);
temp0 = -(allpassCoefficient_ * temp0) + temp;
temp = allpassDelays[1]->lastOut();
temp1 = allpassCoefficient * temp;
temp = allpassDelays_[1].lastOut();
temp1 = allpassCoefficient_ * temp;
temp1 += temp0;
allpassDelays[1]->tick(temp1);
temp1 = -(allpassCoefficient * temp1) + temp;
allpassDelays_[1].tick(temp1);
temp1 = -(allpassCoefficient_ * temp1) + temp;
temp = allpassDelays[2]->lastOut();
temp2 = allpassCoefficient * temp;
temp = allpassDelays_[2].lastOut();
temp2 = allpassCoefficient_ * temp;
temp2 += temp1;
allpassDelays[2]->tick(temp2);
temp2 = -(allpassCoefficient * temp2) + temp;
allpassDelays_[2].tick(temp2);
temp2 = -(allpassCoefficient_ * temp2) + temp;
temp3 = temp2 + (combCoefficient[0] * combDelays[0]->lastOut());
temp4 = temp2 + (combCoefficient[1] * combDelays[1]->lastOut());
temp5 = temp2 + (combCoefficient[2] * combDelays[2]->lastOut());
temp6 = temp2 + (combCoefficient[3] * combDelays[3]->lastOut());
temp3 = temp2 + (combCoefficient_[0] * combDelays_[0].lastOut());
temp4 = temp2 + (combCoefficient_[1] * combDelays_[1].lastOut());
temp5 = temp2 + (combCoefficient_[2] * combDelays_[2].lastOut());
temp6 = temp2 + (combCoefficient_[3] * combDelays_[3].lastOut());
combDelays[0]->tick(temp3);
combDelays[1]->tick(temp4);
combDelays[2]->tick(temp5);
combDelays[3]->tick(temp6);
combDelays_[0].tick(temp3);
combDelays_[1].tick(temp4);
combDelays_[2].tick(temp5);
combDelays_[3].tick(temp6);
filtout = temp3 + temp4 + temp5 + temp6;
lastOutput[0] = effectMix * (outLeftDelay->tick(filtout));
lastOutput[1] = effectMix * (outRightDelay->tick(filtout));
temp = (1.0 - effectMix) * input;
lastOutput[0] += temp;
lastOutput[1] += temp;
lastOutput_[0] = effectMix_ * (outLeftDelay_.tick(filtout));
lastOutput_[1] = effectMix_ * (outRightDelay_.tick(filtout));
temp = (1.0 - effectMix_) * input;
lastOutput_[0] += temp;
lastOutput_[1] += temp;
return (lastOutput[0] + lastOutput[1]) * 0.5;
return Effect::lastOut();
}
StkFloat *JCRev :: tick(StkFloat *vector, unsigned int vectorSize)
{
return Effect::tick( vector, vectorSize );
}
StkFrames& JCRev :: tick( StkFrames& frames, unsigned int channel )
{
return Effect::tick( frames, channel );
}