📄 onepole.cpp
字号:
/***************************************************//*! \class OnePole \brief STK one-pole filter class. This protected Filter subclass implements a one-pole digital filter. A method is provided for setting the pole position along the real axis of the z-plane while maintaining a constant peak filter gain. by Perry R. Cook and Gary P. Scavone, 1995 - 2005.*//***************************************************/#include "OnePole.h"OnePole :: OnePole() : Filter(){#if !defined(SYMBIAN) std::vector<StkFloat> b(1, 0.1); std::vector<StkFloat> a(2, 1.0);#else FloatVector b(1, 0.1); FloatVector a(2, 1.0);/* StkFloat *b= new (ELeave) TReal[1]; b[0] = 0.1; StkFloat *a= new (ELeave) TReal[2]; a[0] = 1.0;*/#endif a[1] = -0.9; Filter::setCoefficients( b, a );}OnePole :: OnePole(StkFloat thePole) : Filter(){#if !defined(SYMBIAN) std::vector<StkFloat> b(1); std::vector<StkFloat> a(2, 1.0);#else FloatVector b(1); FloatVector a(2, 1.0);/* StkFloat *b= new (ELeave) TReal[1]; StkFloat *a= new (ELeave) TReal[2]; a[0] = 1.0;*/#endif a[1] = -thePole; // Normalize coefficients for peak unity gain. if (thePole > 0.0) b[0] = (StkFloat) (1.0 - thePole); else b[0] = (StkFloat) (1.0 + thePole); Filter::setCoefficients( b, a );}OnePole :: ~OnePole() {}void OnePole :: clear(void){ Filter::clear();}void OnePole :: setB0(StkFloat b0){ b_[0] = b0;}void OnePole :: setA1(StkFloat a1){ a_[1] = a1;}void OnePole :: setPole(StkFloat thePole){ // Normalize coefficients for peak unity gain. if (thePole > 0.0) b_[0] = (StkFloat) (1.0 - thePole); else b_[0] = (StkFloat) (1.0 + thePole); a_[1] = -thePole;}void OnePole :: setGain(StkFloat gain){ Filter::setGain(gain);}StkFloat OnePole :: getGain(void) const{ return Filter::getGain();}StkFloat OnePole :: lastOut(void) // SYMBIAN const removed: const{ return Filter::lastOut();}StkFloat OnePole :: tick( StkFloat input ){ inputs_[0] = gain_ * input; outputs_[0] = b_[0] * inputs_[0] - a_[1] * outputs_[1]; outputs_[1] = outputs_[0]; return outputs_[0];}StkFrames& OnePole :: tick( StkFrames& frames, unsigned int channel ){ return Filter::tick( frames, channel );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -