34 void setCoefficients( StkFloat b0, StkFloat b1, StkFloat b2, StkFloat a1, StkFloat a2,
bool clearState =
false );
37 void setB0( StkFloat b0 ) { b_[0] = b0; };
40 void setB1( StkFloat b1 ) { b_[1] = b1; };
43 void setB2( StkFloat b2 ) { b_[2] = b2; };
46 void setA1( StkFloat a1 ) { a_[1] = a1; };
49 void setA2( StkFloat a2 ) { a_[2] = a2; };
65 void setResonance( StkFloat frequency, StkFloat radius,
bool normalize =
false );
75 void setNotch( StkFloat frequency, StkFloat radius );
87 StkFloat
lastOut(
void )
const {
return lastFrame_[0]; };
90 StkFloat
tick( StkFloat input );
116 virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
121 inputs_[0] = gain_ * input;
122 lastFrame_[0] = b_[0] * inputs_[0] + b_[1] * inputs_[1] + b_[2] * inputs_[2];
123 lastFrame_[0] -= a_[2] * outputs_[2] + a_[1] * outputs_[1];
124 inputs_[2] = inputs_[1];
125 inputs_[1] = inputs_[0];
126 outputs_[2] = outputs_[1];
127 outputs_[1] = lastFrame_[0];
129 return lastFrame_[0];
134 #if defined(_STK_DEBUG_)
135 if ( channel >= frames.
channels() ) {
136 oStream_ <<
"BiQuad::tick(): channel and StkFrames arguments are incompatible!";
141 StkFloat *samples = &frames[channel];
142 unsigned int hop = frames.
channels();
143 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop ) {
144 inputs_[0] = gain_ * *samples;
145 *samples = b_[0] * inputs_[0] + b_[1] * inputs_[1] + b_[2] * inputs_[2];
146 *samples -= a_[2] * outputs_[2] + a_[1] * outputs_[1];
147 inputs_[2] = inputs_[1];
148 inputs_[1] = inputs_[0];
149 outputs_[2] = outputs_[1];
150 outputs_[1] = *samples;
153 lastFrame_[0] = outputs_[1];
159 #if defined(_STK_DEBUG_)
161 oStream_ <<
"BiQuad::tick(): channel and StkFrames arguments are incompatible!";
166 StkFloat *iSamples = &iFrames[iChannel];
167 StkFloat *oSamples = &oFrames[oChannel];
169 for (
unsigned int i=0; i<iFrames.
frames(); i++, iSamples += iHop, oSamples += oHop ) {
170 inputs_[0] = gain_ * *iSamples;
171 *oSamples = b_[0] * inputs_[0] + b_[1] * inputs_[1] + b_[2] * inputs_[2];
172 *oSamples -= a_[2] * outputs_[2] + a_[1] * outputs_[1];
173 inputs_[2] = inputs_[1];
174 inputs_[1] = inputs_[0];
175 outputs_[2] = outputs_[1];
176 outputs_[1] = *oSamples;
179 lastFrame_[0] = outputs_[1];
STK biquad (two-pole, two-zero) filter class.
Definition: BiQuad.h:21
void setA1(StkFloat a1)
Set the a[1] coefficient value.
Definition: BiQuad.h:46
void setB2(StkFloat b2)
Set the b[2] coefficient value.
Definition: BiQuad.h:43
void setB0(StkFloat b0)
Set the b[0] coefficient value.
Definition: BiQuad.h:37
void setEqualGainZeroes(void)
Sets the filter zeroes for equal resonance gain.
void setResonance(StkFloat frequency, StkFloat radius, bool normalize=false)
Sets the filter coefficients for a resonance at frequency (in Hz).
StkFloat tick(StkFloat input)
Input one sample to the filter and return a reference to one output.
Definition: BiQuad.h:119
BiQuad()
Default constructor creates a second-order pass-through filter.
void ignoreSampleRateChange(bool ignore=true)
A function to enable/disable the automatic updating of class data when the STK sample rate changes.
Definition: BiQuad.h:31
StkFloat lastOut(void) const
Return the last computed output value.
Definition: BiQuad.h:87
~BiQuad()
Class destructor.
void setB1(StkFloat b1)
Set the b[1] coefficient value.
Definition: BiQuad.h:40
void setNotch(StkFloat frequency, StkFloat radius)
Set the filter coefficients for a notch at frequency (in Hz).
void setA2(StkFloat a2)
Set the a[2] coefficient value.
Definition: BiQuad.h:49
void setCoefficients(StkFloat b0, StkFloat b1, StkFloat b2, StkFloat a1, StkFloat a2, bool clearState=false)
Set all filter coefficients.
STK abstract filter class.
Definition: Filter.h:23
An STK class to handle vectorized audio data.
Definition: Stk.h:287
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition: Stk.h:415
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition: Stk.h:418
static void handleError(const char *message, StkError::Type type)
Static function for error reporting and handling using c-strings.
The STK namespace.
Definition: ADSR.h:8