45 Iir( std::vector<StkFloat> &bCoefficients, std::vector<StkFloat> &aCoefficients );
58 void setCoefficients( std::vector<StkFloat> &bCoefficients, std::vector<StkFloat> &aCoefficients,
bool clearState =
false );
68 void setNumerator( std::vector<StkFloat> &bCoefficients,
bool clearState =
false );
80 void setDenominator( std::vector<StkFloat> &aCoefficients,
bool clearState =
false );
83 StkFloat
lastOut(
void )
const {
return lastFrame_[0]; };
86 StkFloat
tick( StkFloat input );
119 inputs_[0] = gain_ * input;
120 for ( i=b_.size()-1; i>0; i-- ) {
121 outputs_[0] += b_[i] * inputs_[i];
122 inputs_[i] = inputs_[i-1];
124 outputs_[0] += b_[0] * inputs_[0];
126 for ( i=a_.size()-1; i>0; i-- ) {
127 outputs_[0] += -a_[i] * outputs_[i];
128 outputs_[i] = outputs_[i-1];
131 lastFrame_[0] = outputs_[0];
132 return lastFrame_[0];
137 #if defined(_STK_DEBUG_)
138 if ( channel >= frames.
channels() ) {
139 oStream_ <<
"Iir::tick(): channel and StkFrames arguments are incompatible!";
144 StkFloat *samples = &frames[channel];
146 unsigned int hop = frames.
channels();
147 for (
unsigned int j=0; j<frames.
frames(); j++, samples += hop ) {
149 inputs_[0] = gain_ * *samples;
150 for ( i=b_.size()-1; i>0; i-- ) {
151 outputs_[0] += b_[i] * inputs_[i];
152 inputs_[i] = inputs_[i-1];
154 outputs_[0] += b_[0] * inputs_[0];
156 for ( i=a_.size()-1; i>0; i-- ) {
157 outputs_[0] += -a_[i] * outputs_[i];
158 outputs_[i] = outputs_[i-1];
161 *samples = outputs_[0];
164 lastFrame_[0] = *(samples-hop);
170 #if defined(_STK_DEBUG_)
172 oStream_ <<
"Iir::tick(): channel and StkFrames arguments are incompatible!";
177 StkFloat *iSamples = &iFrames[iChannel];
178 StkFloat *oSamples = &oFrames[oChannel];
181 for (
unsigned int j=0; j<iFrames.
frames(); j++, iSamples += iHop, oSamples += oHop ) {
183 inputs_[0] = gain_ * *iSamples;
184 for ( i=b_.size()-1; i>0; i-- ) {
185 outputs_[0] += b_[i] * inputs_[i];
186 inputs_[i] = inputs_[i-1];
188 outputs_[0] += b_[0] * inputs_[0];
190 for ( i=a_.size()-1; i>0; i-- ) {
191 outputs_[0] += -a_[i] * outputs_[i];
192 outputs_[i] = outputs_[i-1];
195 *oSamples = outputs_[0];
198 lastFrame_[0] = *(oSamples-oHop);
STK abstract filter class.
Definition: Filter.h:23
STK general infinite impulse response filter class.
Definition: Iir.h:35
StkFloat lastOut(void) const
Return the last computed output value.
Definition: Iir.h:83
Iir(void)
Default constructor creates a zero-order pass-through "filter".
void setNumerator(std::vector< StkFloat > &bCoefficients, bool clearState=false)
Set numerator coefficients.
StkFloat tick(StkFloat input)
Input one sample to the filter and return one output.
Definition: Iir.h:114
void setCoefficients(std::vector< StkFloat > &bCoefficients, std::vector< StkFloat > &aCoefficients, bool clearState=false)
Set filter coefficients.
Iir(std::vector< StkFloat > &bCoefficients, std::vector< StkFloat > &aCoefficients)
Overloaded constructor which takes filter coefficients.
~Iir(void)
Class destructor.
void setDenominator(std::vector< StkFloat > &aCoefficients, bool clearState=false)
Set denominator coefficients.
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