⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 onezero.cpp

📁 Mobile STK for Symbian OS V0.1
💻 CPP
字号:
/***************************************************//*! \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.    by Perry R. Cook and Gary P. Scavone, 1995 - 2005.*//***************************************************/#include "OneZero.h"#include "Debug.h"#define DEBUGOneZero :: OneZero() : Filter(){#ifdef DEBUG	dcnt=0;#endif#if !defined(SYMBIAN)  std::vector<StkFloat> b(2, 0.5);  std::vector<StkFloat> a(1, 1.0);#else  FloatVector b(2, 0.5);  FloatVector a(1, 1.0);/*  StkFloat *b= new (ELeave) TReal[2];  b[0] = 0.5;  b[1] = 0.5;  StkFloat *a= new (ELeave) TReal[1];  a[0] = 1.0;*/#endif  Filter::setCoefficients( b, a );}OneZero :: OneZero(StkFloat theZero) : Filter(){#if !defined(SYMBIAN)  std::vector<StkFloat> b(2);  std::vector<StkFloat> a(1, 1.0);#else  FloatVector b(2);  FloatVector a(1, 1.0);/*  StkFloat *b= new (ELeave) TReal[2];  StkFloat *a= new (ELeave) TReal[1];  a[0] = 1.0;*/#endif  // 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){}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){  // 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];}void OneZero :: setGain(StkFloat gain){  Filter::setGain(gain);}StkFloat OneZero :: getGain(void) const{  return Filter::getGain();}StkFloat OneZero :: lastOut(void) // SYMBIAN const removed: const{  return Filter::lastOut();}StkFloat OneZero :: tick( StkFloat input ){#ifdef DEBUG	if(dcnt<20)	{	CStaticDebug::WriteInt(inputs_.size());	CStaticDebug::WriteInt(outputs_.size());	CStaticDebug::WriteInt(b_.size());	CStaticDebug::WriteIntN(a_.size());	dcnt++;	}#endif  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 );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -