41 Fir( std::vector<StkFloat> &coefficients );
52 void setCoefficients( std::vector<StkFloat> &coefficients,
bool clearState =
false );
55 StkFloat
lastOut(
void )
const {
return lastFrame_[0]; };
58 StkFloat
tick( StkFloat input );
89 inputs_[0] = gain_ * input;
91 for (
unsigned int i=(
unsigned int)(b_.size())-1; i>0; i-- ) {
92 lastFrame_[0] += b_[i] * inputs_[i];
93 inputs_[i] = inputs_[i-1];
95 lastFrame_[0] += b_[0] * inputs_[0];
102 #if defined(_STK_DEBUG_)
103 if ( channel >= frames.
channels() ) {
104 oStream_ <<
"Fir::tick(): channel and StkFrames arguments are incompatible!";
109 StkFloat *samples = &frames[channel];
110 unsigned int i, hop = frames.
channels();
111 for (
unsigned int j=0; j<frames.
frames(); j++, samples += hop ) {
112 inputs_[0] = gain_ * *samples;
115 for ( i=(
unsigned int)b_.size()-1; i>0; i-- ) {
116 *samples += b_[i] * inputs_[i];
117 inputs_[i] = inputs_[i-1];
119 *samples += b_[0] * inputs_[0];
122 lastFrame_[0] = *(samples-hop);
128 #if defined(_STK_DEBUG_)
130 oStream_ <<
"Fir::tick(): channel and StkFrames arguments are incompatible!";
135 StkFloat *iSamples = &iFrames[iChannel];
136 StkFloat *oSamples = &oFrames[oChannel];
138 for (
unsigned int j=0; j<iFrames.
frames(); j++, iSamples += iHop, oSamples += oHop ) {
139 inputs_[0] = gain_ * *iSamples;
142 for ( i=(
unsigned int)b_.size()-1; i>0; i-- ) {
143 *oSamples += b_[i] * inputs_[i];
144 inputs_[i] = inputs_[i-1];
146 *oSamples += b_[0] * inputs_[0];
149 lastFrame_[0] = *(oSamples-oHop);
STK abstract filter class.
Definition: Filter.h:23
STK general finite impulse response filter class.
Definition: Fir.h:31
StkFloat lastOut(void) const
Return the last computed output value.
Definition: Fir.h:55
~Fir(void)
Class destructor.
Fir(void)
Default constructor creates a zero-order pass-through "filter".
Fir(std::vector< StkFloat > &coefficients)
Overloaded constructor which takes filter coefficients.
void setCoefficients(std::vector< StkFloat > &coefficients, bool clearState=false)
Set filter coefficients.
StkFloat tick(StkFloat input)
Input one sample to the filter and return one output.
Definition: Fir.h:86
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