Home Information Classes Download Usage Mail List Requirements Links Tutorial

# Filter Class Reference

STK filter class. More...

`#include <Filter.h>`

Inheritance diagram for Filter:

List of all members.

## Public Member Functions

| Filter (void)
| Default constructor creates a zero-order pass-through "filter".
| Filter (int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients)
| Overloaded constructor which takes filter coefficients.
virtual | ~Filter (void)
| Class destructor.
void | clear (void)
| Clears all internal states of the filter.
void | setCoefficients (int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients)
| Set filter coefficients.
void | setNumerator (int nb, MY_FLOAT *bCoefficients)
| Set numerator coefficients.
void | setDenominator (int na, MY_FLOAT *aCoefficients)
| Set denominator coefficients.
virtual void | setGain (MY_FLOAT theGain)
| Set the filter gain.
virtual MY_FLOAT | getGain (void) const
| Return the current filter gain.
virtual MY_FLOAT | lastOut (void) const
| Return the last computed output value.
virtual MY_FLOAT | tick (MY_FLOAT sample)
| Input one sample to the filter and return one output.
virtual MY_FLOAT * | tick (MY_FLOAT *vector, unsigned int vectorSize)
| Input vectorSize samples to the filter and return an equal number of outputs in vector.

## 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 - 2002.

Definition at line 35 of file Filter.h.

## Constructor & Destructor Documentation

Filter::Filter | ( | int | nb,
|  | MY_FLOAT * | bCoefficients,
|  | int | na,
|  | MY_FLOAT * | aCoefficients
| ) |

| Overloaded constructor which takes filter coefficients. An StkError can be thrown if either nb or na is less than one, or if the a[0] coefficient is equal to zero.

## Member Function Documentation

void Filter::setCoefficients | ( | int | nb,
|  | MY_FLOAT * | bCoefficients,
|  | int | na,
|  | MY_FLOAT * | aCoefficients
| ) |

| Set filter coefficients. An StkError can be thrown if either nb or na is less than one, 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].

void Filter::setNumerator | ( | int | nb,
|  | MY_FLOAT * | bCoefficients
| ) |

| Set numerator coefficients. An StkError can be thrown if nb is less than one. Any previously set denominator coefficients are left unaffected. Note that the default constructor sets the single denominator coefficient a[0] to 1.0.

void Filter::setDenominator | ( | int | na,
|  | MY_FLOAT * | aCoefficients
| ) |

| Set denominator coefficients. An StkError can be thrown if na is less than one 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.

virtual void Filter::setGain | ( | MY_FLOAT | theGain | ) | `[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.

The documentation for this class was generated from the following file:

- Filter.h

The Synthesis ToolKit in C++ (STK)
©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved.