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

@@ -2,64 +2,36 @@
/*! \class OnePole
\brief STK one-pole filter class.
This protected Filter subclass implements
a one-pole digital filter. A method is
provided for setting the pole position along
the real axis of the z-plane while maintaining
a constant peak filter gain.
This class implements a one-pole digital filter. A method is
provided for setting the pole position along the real axis of the
z-plane while maintaining a constant peak filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
*/
/***************************************************/
#include "OnePole.h"
OnePole :: OnePole() : Filter()
namespace stk {
OnePole :: OnePole( StkFloat thePole )
{
std::vector<StkFloat> b(1, 0.1);
std::vector<StkFloat> a(2, 1.0);
a[1] = -0.9;
Filter::setCoefficients( b, a );
}
b_.resize( 1 );
a_.resize( 2 );
inputs_.resize( 1, 1, 0.0 );
outputs_.resize( 2, 1, 0.0 );
OnePole :: OnePole(StkFloat thePole) : Filter()
{
std::vector<StkFloat> b(1);
std::vector<StkFloat> a(2, 1.0);
a[1] = -thePole;
// Normalize coefficients for peak unity gain.
if (thePole > 0.0)
b[0] = (StkFloat) (1.0 - thePole);
else
b[0] = (StkFloat) (1.0 + thePole);
Filter::setCoefficients( b, a );
this->setPole( thePole );
}
OnePole :: ~OnePole()
{
}
void OnePole :: clear(void)
{
Filter::clear();
}
void OnePole :: setB0(StkFloat b0)
{
b_[0] = b0;
}
void OnePole :: setA1(StkFloat a1)
{
a_[1] = a1;
}
void OnePole :: setPole(StkFloat thePole)
void OnePole :: setPole( StkFloat thePole )
{
// Normalize coefficients for peak unity gain.
if (thePole > 0.0)
if ( thePole > 0.0 )
b_[0] = (StkFloat) (1.0 - thePole);
else
b_[0] = (StkFloat) (1.0 + thePole);
@@ -67,31 +39,12 @@ void OnePole :: setPole(StkFloat thePole)
a_[1] = -thePole;
}
void OnePole :: setGain(StkFloat gain)
void OnePole :: setCoefficients( StkFloat b0, StkFloat a1, bool clearState )
{
Filter::setGain(gain);
b_[0] = b0;
a_[1] = a1;
if ( clearState ) this->clear();
}
StkFloat OnePole :: getGain(void) const
{
return Filter::getGain();
}
StkFloat OnePole :: lastOut(void) const
{
return Filter::lastOut();
}
StkFloat OnePole :: tick( StkFloat input )
{
inputs_[0] = gain_ * input;
outputs_[0] = b_[0] * inputs_[0] - a_[1] * outputs_[1];
outputs_[1] = outputs_[0];
return outputs_[0];
}
StkFrames& OnePole :: tick( StkFrames& frames, unsigned int channel )
{
return Filter::tick( frames, channel );
}
} // stk namespace