34 void setB0( StkFloat b0 ) { b_[0] = b0; };
37 void setA1( StkFloat a1 ) { a_[1] = a1; };
40 void setA2( StkFloat a2 ) { a_[2] = a2; };
43 void setCoefficients( StkFloat b0, StkFloat a1, StkFloat a2,
bool clearState =
false );
61 void setResonance(StkFloat frequency, StkFloat radius,
bool normalize =
false);
64 StkFloat
lastOut(
void )
const {
return lastFrame_[0]; };
67 StkFloat
tick( StkFloat input );
93 virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
96inline StkFloat TwoPole :: tick( StkFloat input )
98 inputs_[0] = gain_ * input;
99 lastFrame_[0] = b_[0] * inputs_[0] - a_[1] * outputs_[1] - a_[2] * outputs_[2];
100 outputs_[2] = outputs_[1];
101 outputs_[1] = lastFrame_[0];
103 return lastFrame_[0];
108#if defined(_STK_DEBUG_)
109 if ( channel >= frames.
channels() ) {
110 oStream_ <<
"TwoPole::tick(): channel and StkFrames arguments are incompatible!";
111 handleError( StkError::FUNCTION_ARGUMENT );
115 StkFloat *samples = &frames[channel];
116 unsigned int hop = frames.
channels();
117 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop ) {
118 inputs_[0] = gain_ * *samples;
119 *samples = b_[0] * inputs_[0] - a_[1] * outputs_[1] - a_[2] * outputs_[2];
120 outputs_[2] = outputs_[1];
121 outputs_[1] = *samples;
124 lastFrame_[0] = outputs_[1];
130#if defined(_STK_DEBUG_)
132 oStream_ <<
"TwoPole::tick(): channel and StkFrames arguments are incompatible!";
133 handleError( StkError::FUNCTION_ARGUMENT );
137 StkFloat *iSamples = &iFrames[iChannel];
138 StkFloat *oSamples = &oFrames[oChannel];
140 for (
unsigned int i=0; i<iFrames.
frames(); i++, iSamples += iHop, oSamples += oHop ) {
141 inputs_[0] = gain_ * *iSamples;
142 *oSamples = b_[0] * inputs_[0] - a_[1] * outputs_[1] - a_[2] * outputs_[2];
143 outputs_[2] = outputs_[1];
144 outputs_[1] = *oSamples;
147 lastFrame_[0] = outputs_[1];
STK abstract filter class.
Definition Filter.h:23
An STK class to handle vectorized audio data.
Definition Stk.h:279
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition Stk.h:416
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition Stk.h:419
STK two-pole filter class.
Definition TwoPole.h:21
void setResonance(StkFloat frequency, StkFloat radius, bool normalize=false)
Sets the filter coefficients for a resonance at frequency (in Hz).
TwoPole(void)
Default constructor creates a second-order pass-through filter.
void setB0(StkFloat b0)
Set the b[0] coefficient value.
Definition TwoPole.h:34
void setA2(StkFloat a2)
Set the a[2] coefficient value.
Definition TwoPole.h:40
~TwoPole()
Class destructor.
void ignoreSampleRateChange(bool ignore=true)
A function to enable/disable the automatic updating of class data when the STK sample rate changes.
Definition TwoPole.h:31
void setA1(StkFloat a1)
Set the a[1] coefficient value.
Definition TwoPole.h:37
StkFloat tick(StkFloat input)
Input one sample to the filter and return one output.
Definition TwoPole.h:96
StkFloat lastOut(void) const
Return the last computed output value.
Definition TwoPole.h:64
void setCoefficients(StkFloat b0, StkFloat a1, StkFloat a2, bool clearState=false)
Set all filter coefficients.
The STK namespace.
Definition ADSR.h:6