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,63 +2,34 @@
/*! \class OneZero
\brief STK one-zero filter class.
This protected Filter subclass implements
a one-zero digital filter. A method is
provided for setting the zero position
along the real axis of the z-plane while
maintaining a constant filter gain.
This class implements a one-zero digital filter. A method is
provided for setting the zero position along the real axis of the
z-plane while maintaining a constant filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
*/
/***************************************************/
#include "OneZero.h"
OneZero :: OneZero() : Filter()
namespace stk {
OneZero :: OneZero( StkFloat theZero )
{
std::vector<StkFloat> b(2, 0.5);
std::vector<StkFloat> a(1, 1.0);
Filter::setCoefficients( b, a );
b_.resize( 2 );
inputs_.resize( 2, 1, 0.0 );
this->setZero( theZero );
}
OneZero :: OneZero(StkFloat theZero) : Filter()
{
std::vector<StkFloat> b(2);
std::vector<StkFloat> a(1, 1.0);
// Normalize coefficients for unity gain.
if (theZero > 0.0)
b[0] = 1.0 / ((StkFloat) 1.0 + theZero);
else
b[0] = 1.0 / ((StkFloat) 1.0 - theZero);
b[1] = -theZero * b[0];
Filter::setCoefficients( b, a );
}
OneZero :: ~OneZero(void)
OneZero :: ~OneZero( void )
{
}
void OneZero :: clear(void)
{
Filter::clear();
}
void OneZero :: setB0(StkFloat b0)
{
b_[0] = b0;
}
void OneZero :: setB1(StkFloat b1)
{
b_[1] = b1;
}
void OneZero :: setZero(StkFloat theZero)
void OneZero :: setZero( StkFloat theZero )
{
// Normalize coefficients for unity gain.
if (theZero > 0.0)
if ( theZero > 0.0 )
b_[0] = 1.0 / ((StkFloat) 1.0 + theZero);
else
b_[0] = 1.0 / ((StkFloat) 1.0 - theZero);
@@ -66,31 +37,12 @@ void OneZero :: setZero(StkFloat theZero)
b_[1] = -theZero * b_[0];
}
void OneZero :: setGain(StkFloat gain)
void OneZero :: setCoefficients( StkFloat b0, StkFloat b1, bool clearState )
{
Filter::setGain(gain);
b_[0] = b0;
b_[1] = b1;
if ( clearState ) this->clear();
}
StkFloat OneZero :: getGain(void) const
{
return Filter::getGain();
}
StkFloat OneZero :: lastOut(void) const
{
return Filter::lastOut();
}
StkFloat OneZero :: tick( StkFloat input )
{
inputs_[0] = gain_ * input;
outputs_[0] = b_[1] * inputs_[1] + b_[0] * inputs_[0];
inputs_[1] = inputs_[0];
return outputs_[0];
}
StkFrames& OneZero :: tick( StkFrames& frames, unsigned int channel )
{
return Filter::tick( frames, channel );
}
} // stk namespace