Logo Search packages:      
Sourcecode: csound version File versions  Download package

PoleZero.cpp

/***************************************************/
/*! \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.

    by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
*/
/***************************************************/

#include "PoleZero.h"

00017 PoleZero :: PoleZero() : Filter()
{
  // 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 );
}

00027 PoleZero :: ~PoleZero()
{
}

00031 void PoleZero :: clear(void)
{
  Filter::clear();
}

00036 void PoleZero :: setB0(StkFloat b0)
{
  b_[0] = b0;
}

00041 void PoleZero :: setB1(StkFloat b1)
{
  b_[1] = b1;
}

00046 void PoleZero :: setA1(StkFloat a1)
{
  a_[1] = a1;
}

00051 void PoleZero :: setAllpass(StkFloat coefficient)
{
  b_[0] = coefficient;
  b_[1] = 1.0;
  a_[0] = 1.0; // just in case
  a_[1] = coefficient;
}

00059 void PoleZero :: setBlockZero(StkFloat thePole)
{
  b_[0] = 1.0;
  b_[1] = -1.0;
  a_[0] = 1.0; // just in case
  a_[1] = -thePole;
}

00067 void PoleZero :: setGain(StkFloat gain)
{
  Filter::setGain(gain);
}

00072 StkFloat PoleZero :: getGain(void) const
{
  return Filter::getGain();
}

00077 StkFloat PoleZero :: lastOut(void) const
{
  return Filter::lastOut();
}

00082 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];
}

00092 StkFrames& PoleZero :: tick( StkFrames& frames, unsigned int channel )
{
  return Filter::tick( frames, channel );
}

Generated by  Doxygen 1.6.0   Back to index