mirror of
https://github.com/thestk/stk
synced 2026-01-16 14:21:53 +00:00
Version 4.4.0
This commit is contained in:
committed by
Stephen Sinclair
parent
d199342e86
commit
eccd8c9981
@@ -2,53 +2,44 @@
|
||||
/*! \class PoleZero
|
||||
\brief STK one-pole, one-zero filter class.
|
||||
|
||||
This protected Filter subclass implements
|
||||
a one-pole, one-zero digital filter. A
|
||||
method is provided for creating an allpass
|
||||
filter with a given coefficient. Another
|
||||
method is provided to create a DC blocking filter.
|
||||
This class implements a one-pole, one-zero digital filter. A
|
||||
method is provided for creating an allpass filter with a given
|
||||
coefficient. Another method is provided to create a DC blocking
|
||||
filter.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "PoleZero.h"
|
||||
|
||||
PoleZero :: PoleZero() : Filter()
|
||||
namespace stk {
|
||||
|
||||
PoleZero :: PoleZero()
|
||||
{
|
||||
// Default setting for pass-through.
|
||||
std::vector<StkFloat> b(2, 0.0);
|
||||
std::vector<StkFloat> a(2, 0.0);
|
||||
b[0] = 1.0;
|
||||
a[0] = 1.0;
|
||||
Filter::setCoefficients( b, a );
|
||||
b_.resize( 2, 0.0 );
|
||||
a_.resize( 2, 0.0 );
|
||||
b_[0] = 1.0;
|
||||
a_[0] = 1.0;
|
||||
inputs_.resize( 2, 1, 0.0 );
|
||||
outputs_.resize( 2, 1, 0.0 );
|
||||
}
|
||||
|
||||
PoleZero :: ~PoleZero()
|
||||
{
|
||||
}
|
||||
|
||||
void PoleZero :: clear(void)
|
||||
{
|
||||
Filter::clear();
|
||||
}
|
||||
|
||||
void PoleZero :: setB0(StkFloat b0)
|
||||
void PoleZero :: setCoefficients( StkFloat b0, StkFloat b1, StkFloat a1, bool clearState )
|
||||
{
|
||||
b_[0] = b0;
|
||||
}
|
||||
|
||||
void PoleZero :: setB1(StkFloat b1)
|
||||
{
|
||||
b_[1] = b1;
|
||||
}
|
||||
|
||||
void PoleZero :: setA1(StkFloat a1)
|
||||
{
|
||||
a_[1] = a1;
|
||||
|
||||
if ( clearState ) this->clear();
|
||||
}
|
||||
|
||||
void PoleZero :: setAllpass(StkFloat coefficient)
|
||||
void PoleZero :: setAllpass( StkFloat coefficient )
|
||||
{
|
||||
b_[0] = coefficient;
|
||||
b_[1] = 1.0;
|
||||
@@ -56,7 +47,7 @@ void PoleZero :: setAllpass(StkFloat coefficient)
|
||||
a_[1] = coefficient;
|
||||
}
|
||||
|
||||
void PoleZero :: setBlockZero(StkFloat thePole)
|
||||
void PoleZero :: setBlockZero( StkFloat thePole )
|
||||
{
|
||||
b_[0] = 1.0;
|
||||
b_[1] = -1.0;
|
||||
@@ -64,32 +55,4 @@ void PoleZero :: setBlockZero(StkFloat thePole)
|
||||
a_[1] = -thePole;
|
||||
}
|
||||
|
||||
void PoleZero :: setGain(StkFloat gain)
|
||||
{
|
||||
Filter::setGain(gain);
|
||||
}
|
||||
|
||||
StkFloat PoleZero :: getGain(void) const
|
||||
{
|
||||
return Filter::getGain();
|
||||
}
|
||||
|
||||
StkFloat PoleZero :: lastOut(void) const
|
||||
{
|
||||
return Filter::lastOut();
|
||||
}
|
||||
|
||||
StkFloat PoleZero :: tick( StkFloat input )
|
||||
{
|
||||
inputs_[0] = gain_ * input;
|
||||
outputs_[0] = b_[0] * inputs_[0] + b_[1] * inputs_[1] - a_[1] * outputs_[1];
|
||||
inputs_[1] = inputs_[0];
|
||||
outputs_[1] = outputs_[0];
|
||||
|
||||
return outputs_[0];
|
||||
}
|
||||
|
||||
StkFrames& PoleZero :: tick( StkFrames& frames, unsigned int channel )
|
||||
{
|
||||
return Filter::tick( frames, channel );
|
||||
}
|
||||
} // stk namespace
|
||||
|
||||
Reference in New Issue
Block a user