The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# stk::FormSwep Class Reference

STK sweepable formant filter class. More...

`#include <FormSwep.h>`

Inheritance diagram for stk::FormSwep:

List of all members.

## Public Member Functions
| FormSwep (void)
| Default constructor creates a second-order pass-through filter.
| ~FormSwep ()
| Class destructor.
void | ignoreSampleRateChange (bool ignore=true)
| A function to enable/disable the automatic updating of class data when the STK sample rate changes.
void | setResonance (StkFloat frequency, StkFloat radius)
| Sets the filter coefficients for a resonance at frequency (in Hz).
void | setStates (StkFloat frequency, StkFloat radius, StkFloat gain=1.0)
| Set both the current and target resonance parameters.
void | setTargets (StkFloat frequency, StkFloat radius, StkFloat gain=1.0)
| Set target resonance parameters.
void | setSweepRate (StkFloat rate)
| Set the sweep rate (between 0.0 - 1.0).
void | setSweepTime (StkFloat time)
| Set the sweep rate in terms of a time value in seconds.
StkFloat | lastOut (void) const
| Return the last computed output value.
StkFloat | tick (StkFloat input)
| Input one sample to the filter and return a reference to one output.
StkFrames & | tick (StkFrames &frames, unsigned int channel=0)
| Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
StkFrames & | tick (StkFrames &iFrames, StkFrames &oFrames, unsigned int iChannel=0, unsigned int oChannel=0)
| Take a channel of the `iFrames` object as inputs to the filter and write outputs to the `oFrames` object.

## Detailed Description

STK sweepable formant filter class.

This class implements a formant (resonance) which can be "swept" over time from one frequency setting to another. It provides methods for controlling the sweep rate and target frequency.

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

## Member Function Documentation

void stk::FormSwep::setResonance | ( | StkFloat | frequency,
|  | StkFloat | radius |
| ) |  |  |

Sets the filter coefficients for a resonance at frequency (in Hz).

This method determines the filter coefficients corresponding to two complex-conjugate poles with the given frequency (in Hz) and radius from the z-plane origin. The filter zeros are placed at z = 1, z = -1, and the coefficients are then normalized to produce a constant unity gain (independent of the filter gain parameter). The resulting filter frequency response has a resonance at the given frequency. The closer the poles are to the unit-circle (radius close to one), the narrower the resulting resonance width. An unstable filter will result for radius >= 1.0. The frequency value should be between zero and half the sample rate.

void stk::FormSwep::setSweepRate | ( | StkFloat | rate | ) |

Set the sweep rate (between 0.0 - 1.0).

The formant parameters are varied in increments of the sweep rate between their current and target values. A sweep rate of 1.0 will produce an immediate change in resonance parameters from their current values to the target values. A sweep rate of 0.0 will produce no change in resonance parameters.

void stk::FormSwep::setSweepTime | ( | StkFloat | time | ) |

Set the sweep rate in terms of a time value in seconds.

This method adjusts the sweep rate based on a given time for the formant parameters to reach their target values.

StkFrames & stk::FormSwep::tick | ( | StkFrames & | frames,
|  | unsigned int | channel = `0` |
| ) |  |  | `[inline, virtual]`

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

The StkFrames argument reference is returned. The `channel` argument must be less than the number of channels in the StkFrames argument (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an StkError exception.

Implements stk::Filter.

    00154 {
    00155 #if defined(_STK_DEBUG_)
    00156   if ( channel >= frames.channels() ) {
    00157     oStream_ << "FormSwep::tick(): channel and StkFrames arguments are incompatible!";
    00158     handleError( StkError::FUNCTION_ARGUMENT );
    00159   }
    00160 #endif
    00161
    00162   StkFloat *samples = &frames[channel];
    00163   unsigned int hop = frames.channels();
    00164   for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
    00165     *samples = tick( *samples );
    00166
    00167   return frames;
    00168 }

StkFrames & stk::FormSwep::tick | ( | StkFrames & | iFrames,
|  | StkFrames & | oFrames,
|  | unsigned int | iChannel = `0`,
|  | unsigned int | oChannel = `0` |
| ) |  |  | `[inline]`

Take a channel of the `iFrames` object as inputs to the filter and write outputs to the `oFrames` object.

The `iFrames` object reference is returned. Each channel argument must be less than the number of channels in the corresponding StkFrames argument (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an StkError exception.

    00171 {
    00172 #if defined(_STK_DEBUG_)
    00173   if ( iChannel >= iFrames.channels() || oChannel >= oFrames.channels() ) {
    00174     oStream_ << "FormSwep::tick(): channel and StkFrames arguments are incompatible!";
    00175     handleError( StkError::FUNCTION_ARGUMENT );
    00176   }
    00177 #endif
    00178
    00179   StkFloat *iSamples = &iFrames[iChannel];
    00180   StkFloat *oSamples = &oFrames[oChannel];
    00181   unsigned int iHop = iFrames.channels(), oHop = oFrames.channels();
    00182   for ( unsigned int i=0; i<iFrames.frames(); i++, iSamples += iHop, oSamples += oHop )
    00183     *oSamples = tick( *iSamples );
    00184
    00185   return iFrames;
    00186 }

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

- FormSwep.h

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