33 void setB0( StkFloat b0 ) { b_[0] = b0; };
36 void setB1( StkFloat b1 ) { b_[1] = b1; };
39 void setB2( StkFloat b2 ) { b_[2] = b2; };
42 void setCoefficients( StkFloat b0, StkFloat b1, StkFloat b2,
bool clearState =
false );
57 void setNotch( StkFloat frequency, StkFloat radius );
60 StkFloat
lastOut(
void )
const {
return lastFrame_[0]; };
63 StkFloat
tick( StkFloat input );
89 void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
94 inputs_[0] = gain_ * input;
95 lastFrame_[0] = b_[2] * inputs_[2] + b_[1] * inputs_[1] + b_[0] * inputs_[0];
96 inputs_[2] = inputs_[1];
97 inputs_[1] = inputs_[0];
104 #if defined(_STK_DEBUG_) 105 if ( channel >= frames.
channels() ) {
106 oStream_ <<
"TwoZero::tick(): channel and StkFrames arguments are incompatible!";
111 StkFloat *samples = &frames[channel];
112 unsigned int hop = frames.
channels();
113 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop ) {
114 inputs_[0] = gain_ * *samples;
115 *samples = b_[2] * inputs_[2] + b_[1] * inputs_[1] + b_[0] * inputs_[0];
116 inputs_[2] = inputs_[1];
117 inputs_[1] = inputs_[0];
120 lastFrame_[0] = *(samples-hop);
126 #if defined(_STK_DEBUG_) 128 oStream_ <<
"TwoZero::tick(): channel and StkFrames arguments are incompatible!";
133 StkFloat *iSamples = &iFrames[iChannel];
134 StkFloat *oSamples = &oFrames[oChannel];
136 for (
unsigned int i=0; i<iFrames.
frames(); i++, iSamples += iHop, oSamples += oHop ) {
137 inputs_[0] = gain_ * *iSamples;
138 *oSamples = b_[2] * inputs_[2] + b_[1] * inputs_[1] + b_[0] * inputs_[0];
139 inputs_[2] = inputs_[1];
140 inputs_[1] = inputs_[0];
143 lastFrame_[0] = *(oSamples-oHop);
static void handleError(const char *message, StkError::Type type)
Static function for error reporting and handling using c-strings.
void setNotch(StkFloat frequency, StkFloat radius)
Sets the filter coefficients for a "notch" at frequency (in Hz).
STK two-zero filter class.
Definition: TwoZero.h:20
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition: Stk.h:407
void setCoefficients(StkFloat b0, StkFloat b1, StkFloat b2, bool clearState=false)
Set all filter coefficients.
STK abstract filter class.
Definition: Filter.h:22
The STK namespace.
Definition: ADSR.h:6
StkFloat tick(StkFloat input)
Input one sample to the filter and return one output.
Definition: TwoZero.h:92
~TwoZero()
Class destructor.
TwoZero()
Default constructor creates a second-order pass-through filter.
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition: Stk.h:404
void ignoreSampleRateChange(bool ignore=true)
A function to enable/disable the automatic updating of class data when the STK sample rate changes...
Definition: TwoZero.h:30
void setB0(StkFloat b0)
Set the b[0] coefficient value.
Definition: TwoZero.h:33
An STK class to handle vectorized audio data.
Definition: Stk.h:275
StkFloat lastOut(void) const
Return the last computed output value.
Definition: TwoZero.h:60
void setB2(StkFloat b2)
Set the b[2] coefficient value.
Definition: TwoZero.h:39
void setB1(StkFloat b1)
Set the b[1] coefficient value.
Definition: TwoZero.h:36