update to a new version of STK reverb (inserting comb filters for more realistic reverberation effect)
This commit is contained in:
parent
7da3489350
commit
2980c195a4
2 changed files with 39 additions and 4 deletions
28
src/util.cpp
28
src/util.cpp
|
@ -198,6 +198,7 @@ void CAudioReverb::Init ( const int iSampleRate,
|
|||
for ( i = 0; i < 4; i++ )
|
||||
{
|
||||
combDelays[i].Init ( lengths[i] );
|
||||
combFilters[i].setPole ( 0.2 );
|
||||
}
|
||||
|
||||
setT60 ( rT60, iSampleRate );
|
||||
|
@ -246,6 +247,10 @@ void CAudioReverb::Clear()
|
|||
combDelays[1].Reset ( 0 );
|
||||
combDelays[2].Reset ( 0 );
|
||||
combDelays[3].Reset ( 0 );
|
||||
combFilters[0].Reset();
|
||||
combFilters[1].Reset();
|
||||
combFilters[2].Reset();
|
||||
combFilters[3].Reset();
|
||||
outRightDelay.Reset ( 0 );
|
||||
outLeftDelay.Reset ( 0 );
|
||||
}
|
||||
|
@ -261,6 +266,21 @@ void CAudioReverb::setT60 ( const double rT60,
|
|||
}
|
||||
}
|
||||
|
||||
void CAudioReverb::COnePole::setPole ( const double dPole )
|
||||
{
|
||||
// calculate IIR filter coefficients based on the pole value
|
||||
dA = -dPole;
|
||||
dB = 1.0 - dPole;
|
||||
}
|
||||
|
||||
double CAudioReverb::COnePole::Calc ( const double dIn )
|
||||
{
|
||||
// calculate IIR filter
|
||||
dLastSample = dB * dIn - dA * dLastSample;
|
||||
|
||||
return dLastSample;
|
||||
}
|
||||
|
||||
void CAudioReverb::ProcessSample ( int16_t& iInputOutputLeft,
|
||||
int16_t& iInputOutputRight,
|
||||
const double dAttenuation )
|
||||
|
@ -290,10 +310,10 @@ void CAudioReverb::ProcessSample ( int16_t& iInputOutputLeft,
|
|||
allpassDelays[2].Add ( temp2 );
|
||||
temp2 = - ( allpassCoefficient * temp2 ) + temp;
|
||||
|
||||
const double temp3 = temp2 + ( combCoefficient[0] * combDelays[0].Get() );
|
||||
const double temp4 = temp2 + ( combCoefficient[1] * combDelays[1].Get() );
|
||||
const double temp5 = temp2 + ( combCoefficient[2] * combDelays[2].Get() );
|
||||
const double temp6 = temp2 + ( combCoefficient[3] * combDelays[3].Get() );
|
||||
const double temp3 = temp2 + combFilters[0].Calc ( combCoefficient[0] * combDelays[0].Get() );
|
||||
const double temp4 = temp2 + combFilters[1].Calc ( combCoefficient[1] * combDelays[1].Get() );
|
||||
const double temp5 = temp2 + combFilters[2].Calc ( combCoefficient[2] * combDelays[2].Get() );
|
||||
const double temp6 = temp2 + combFilters[3].Calc ( combCoefficient[3] * combDelays[3].Get() );
|
||||
|
||||
combDelays[0].Add ( temp3 );
|
||||
combDelays[1].Add ( temp4 );
|
||||
|
|
15
src/util.h
15
src/util.h
|
@ -877,8 +877,23 @@ protected:
|
|||
void setT60 ( const double rT60, const int iSampleRate );
|
||||
bool isPrime ( const int number );
|
||||
|
||||
class COnePole
|
||||
{
|
||||
public:
|
||||
COnePole() : dA ( 0 ), dB ( 0 ) { Reset(); }
|
||||
void setPole ( const double dPole );
|
||||
double Calc ( const double dIn );
|
||||
void Reset() { dLastSample = 0; }
|
||||
|
||||
protected:
|
||||
double dA;
|
||||
double dB;
|
||||
double dLastSample;
|
||||
};
|
||||
|
||||
CFIFO<double> allpassDelays[3];
|
||||
CFIFO<double> combDelays[4];
|
||||
COnePole combFilters[4];
|
||||
CFIFO<double> outLeftDelay;
|
||||
CFIFO<double> outRightDelay;
|
||||
double allpassCoefficient;
|
||||
|
|
Loading…
Reference in a new issue