Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   Tutorial


Filter Class Reference

#include <Filter.h>

Inheritance diagram for Filter:

Stk BiQuad Delay OnePole OneZero PoleZero TwoPole TwoZero FormSwep DelayA DelayL List of all members.

Detailed Description

STK filter class.

This class implements a generic structure which can be used to create a wide range of filters. It can function independently or be subclassed to provide more specific controls based on a particular filter type.

In particular, this class implements the standard difference equation:

a[0]*y[n] = b[0]*x[n] + ... + b[nb]*x[n-nb] - a[1]*y[n-1] - ... - a[na]*y[n-na]

If a[0] is not equal to 1, the filter coeffcients are normalized by a[0].

The gain parameter is applied at the filter input and does not affect the coefficient values. The default gain value is 1.0. This structure results in one extra multiply per computed sample, but allows easy control of the overall filter gain.

by Perry R. Cook and Gary P. Scavone, 1995 - 2004.

Definition at line 37 of file Filter.h.

Public Member Functions

 Filter (void)
 Default constructor creates a zero-order pass-through "filter".

 Filter (std::vector< StkFloat > &bCoefficients, std::vector< StkFloat > &aCoefficients)
 Overloaded constructor which takes filter coefficients.

virtual ~Filter (void)
 Class destructor.

void clear (void)
 Sets all internal states of the filter to zero.

void setCoefficients (std::vector< StkFloat > &bCoefficients, std::vector< StkFloat > &aCoefficients)
 Set filter coefficients.

void setNumerator (std::vector< StkFloat > &bCoefficients)
 Set numerator coefficients.

void setDenominator (std::vector< StkFloat > &aCoefficients)
 Set denominator coefficients.

virtual void setGain (StkFloat gain)
 Set the filter gain.

virtual StkFloat getGain (void) const
 Return the current filter gain.

virtual StkFloat lastOut (void) const
 Return the last computed output value.

virtual StkFloat tick (StkFloat sample)
 Input one sample to the filter and return one output.

virtual StkFloat * tick (StkFloat *vector, unsigned int vectorSize)
 Input vectorSize samples to the filter and return an equal number of outputs in vector.

virtual StkFramestick (StkFrames &frames, unsigned int channel=1)
 Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.


Constructor & Destructor Documentation

Filter::Filter std::vector< StkFloat > &  bCoefficients,
std::vector< StkFloat > &  aCoefficients
 

Overloaded constructor which takes filter coefficients.

An StkError can be thrown if either of the coefficient vector sizes is zero, or if the a[0] coefficient is equal to zero.


Member Function Documentation

void Filter::setCoefficients std::vector< StkFloat > &  bCoefficients,
std::vector< StkFloat > &  aCoefficients
 

Set filter coefficients.

An StkError can be thrown if either of the coefficient vector sizes is zero, or if the a[0] coefficient is equal to zero. If a[0] is not equal to 1, the filter coeffcients are normalized by a[0]. The internal state of the filter is cleared.

void Filter::setNumerator std::vector< StkFloat > &  bCoefficients  ) 
 

Set numerator coefficients.

An StkError can be thrown if coefficient vector is empty. Any previously set denominator coefficients are left unaffected. Note that the default constructor sets the single denominator coefficient a[0] to 1.0. The internal state of the filter is cleared.

void Filter::setDenominator std::vector< StkFloat > &  aCoefficients  ) 
 

Set denominator coefficients.

An StkError can be thrown if the coefficient vector is empty or if the a[0] coefficient is equal to zero. Previously set numerator coefficients are unaffected unless a[0] is not equal to 1, in which case all coeffcients are normalized by a[0]. Note that the default constructor sets the single numerator coefficient b[0] to 1.0. The internal state of the filter is cleared.

virtual void Filter::setGain StkFloat  gain  )  [virtual]
 

Set the filter gain.

The gain is applied at the filter input and does not affect the coefficient values. The default gain value is 1.0.

Reimplemented in BiQuad, OnePole, OneZero, PoleZero, TwoPole, and TwoZero.

virtual StkFrames& Filter::tick StkFrames frames,
unsigned int  channel = 1
[virtual]
 

Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.

The channel argument should be one or greater (the first channel is specified by 1). An StkError will be thrown if the channel argument is zero or it is greater than the number of channels in the StkFrames object.

Reimplemented in BiQuad, Delay, DelayA, DelayL, FormSwep, OnePole, OneZero, PoleZero, TwoPole, and TwoZero.


The documentation for this class was generated from the following file:
The Synthesis ToolKit in C++ (STK)
©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved.