mirror of
https://github.com/thestk/stk
synced 2026-01-15 22:11:52 +00:00
Version 4.4.3
This commit is contained in:
committed by
Stephen Sinclair
parent
baca57040b
commit
0aec39260a
@@ -2,14 +2,20 @@
|
||||
/*! \class JCRev
|
||||
\brief John Chowning's reverberator class.
|
||||
|
||||
This class takes a monophonic input signal and produces a stereo
|
||||
output signal. It is derived from the CLM JCRev function, which
|
||||
is based on the use of networks of simple allpass and comb delay
|
||||
filters. This class implements three series allpass units,
|
||||
followed by four parallel comb filters, and two decorrelation
|
||||
delay lines in parallel at the output.
|
||||
This class takes a monophonic input signal and
|
||||
produces a stereo output signal. It is derived
|
||||
from the CLM JCRev function, which is based on
|
||||
the use of networks of simple allpass and comb
|
||||
delay filters. This class implements three
|
||||
series allpass units, followed by four parallel
|
||||
comb filters, and two decorrelation delay lines
|
||||
in parallel at the output.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
|
||||
Although not in the original JC reverberator,
|
||||
one-pole lowpass filters have been added inside
|
||||
the feedback comb filters.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995-2011.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
@@ -20,10 +26,16 @@ namespace stk {
|
||||
|
||||
JCRev :: JCRev( StkFloat T60 )
|
||||
{
|
||||
if ( T60 <= 0.0 ) {
|
||||
oStream_ << "JCRev::JCRev: argument (" << T60 << ") must be positive!";
|
||||
handleError( StkError::FUNCTION_ARGUMENT );
|
||||
}
|
||||
|
||||
lastFrame_.resize( 1, 2, 0.0 ); // resize lastFrame_ for stereo output
|
||||
|
||||
// Delay lengths for 44100 Hz sample rate.
|
||||
int lengths[9] = {1777, 1847, 1993, 2137, 389, 127, 43, 211, 179};
|
||||
// {1116, 1188, 1356, 1277, 1422, 1491, 1617, 1557} // FreeVerb comb delays
|
||||
int lengths[9] = {1116, 1356, 1422, 1617, 225, 341, 441, 211, 179};
|
||||
double scaler = Stk::sampleRate() / 44100.0;
|
||||
|
||||
int delay, i;
|
||||
@@ -44,6 +56,7 @@ JCRev :: JCRev( StkFloat T60 )
|
||||
for ( i=0; i<4; i++ ) {
|
||||
combDelays_[i].setMaximumDelay( lengths[i] );
|
||||
combDelays_[i].setDelay( lengths[i] );
|
||||
combFilters_[i].setPole( 0.2 );
|
||||
}
|
||||
|
||||
this->setT60( T60 );
|
||||
@@ -73,6 +86,11 @@ void JCRev :: clear()
|
||||
|
||||
void JCRev :: setT60( StkFloat T60 )
|
||||
{
|
||||
if ( T60 <= 0.0 ) {
|
||||
oStream_ << "JCRev::setT60: argument (" << T60 << ") must be positive!";
|
||||
handleError( StkError::WARNING ); return;
|
||||
}
|
||||
|
||||
for ( int i=0; i<4; i++ )
|
||||
combCoefficient_[i] = pow(10.0, (-3.0 * combDelays_[i].getDelay() / (T60 * Stk::sampleRate())));
|
||||
}
|
||||
@@ -81,7 +99,7 @@ StkFrames& JCRev :: tick( StkFrames& frames, unsigned int channel )
|
||||
{
|
||||
#if defined(_STK_DEBUG_)
|
||||
if ( channel >= frames.channels() - 1 ) {
|
||||
errorString_ << "JCRev::tick(): channel and StkFrames arguments are incompatible!";
|
||||
oStream_ << "JCRev::tick(): channel and StkFrames arguments are incompatible!";
|
||||
handleError( StkError::FUNCTION_ARGUMENT );
|
||||
}
|
||||
#endif
|
||||
@@ -90,8 +108,7 @@ StkFrames& JCRev :: tick( StkFrames& frames, unsigned int channel )
|
||||
unsigned int hop = frames.channels();
|
||||
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
|
||||
*samples = tick( *samples );
|
||||
*samples++;
|
||||
*samples = lastFrame_[1];
|
||||
*(samples+1) = lastFrame_[1];
|
||||
}
|
||||
|
||||
return frames;
|
||||
@@ -101,7 +118,7 @@ StkFrames& JCRev :: tick( StkFrames& iFrames, StkFrames& oFrames, unsigned int i
|
||||
{
|
||||
#if defined(_STK_DEBUG_)
|
||||
if ( iChannel >= iFrames.channels() || oChannel >= oFrames.channels() - 1 ) {
|
||||
errorString_ << "JCRev::tick(): channel and StkFrames arguments are incompatible!";
|
||||
oStream_ << "JCRev::tick(): channel and StkFrames arguments are incompatible!";
|
||||
handleError( StkError::FUNCTION_ARGUMENT );
|
||||
}
|
||||
#endif
|
||||
@@ -110,8 +127,8 @@ StkFrames& JCRev :: tick( StkFrames& iFrames, StkFrames& oFrames, unsigned int i
|
||||
StkFloat *oSamples = &oFrames[oChannel];
|
||||
unsigned int iHop = iFrames.channels(), oHop = oFrames.channels();
|
||||
for ( unsigned int i=0; i<iFrames.frames(); i++, iSamples += iHop, oSamples += oHop ) {
|
||||
*oSamples++ = tick( *iSamples );
|
||||
*oSamples = lastFrame_[1];
|
||||
*oSamples = tick( *iSamples );
|
||||
*(oSamples+1) = lastFrame_[1];
|
||||
}
|
||||
|
||||
return iFrames;
|
||||
|
||||
Reference in New Issue
Block a user