You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.0KB

  1. /***************************************************/
  2. /*! \class OneZero
  3. \brief STK one-zero filter class.
  4. This class implements a one-zero digital filter. A method is
  5. provided for setting the zero position along the real axis of the
  6. z-plane while maintaining a constant filter gain.
  7. by Perry R. Cook and Gary P. Scavone, 1995--2017.
  8. */
  9. /***************************************************/
  10. #include "OneZero.h"
  11. #include <cmath>
  12. namespace stk {
  13. OneZero :: OneZero( StkFloat theZero )
  14. {
  15. b_.resize( 2 );
  16. inputs_.resize( 2, 1, 0.0 );
  17. this->setZero( theZero );
  18. }
  19. OneZero :: ~OneZero( void )
  20. {
  21. }
  22. void OneZero :: setZero( StkFloat theZero )
  23. {
  24. // Normalize coefficients for unity gain.
  25. if ( theZero > 0.0 )
  26. b_[0] = 1.0 / ((StkFloat) 1.0 + theZero);
  27. else
  28. b_[0] = 1.0 / ((StkFloat) 1.0 - theZero);
  29. b_[1] = -theZero * b_[0];
  30. }
  31. void OneZero :: setCoefficients( StkFloat b0, StkFloat b1, bool clearState )
  32. {
  33. b_[0] = b0;
  34. b_[1] = b1;
  35. if ( clearState ) this->clear();
  36. }
  37. } // stk namespace