The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

Public Member Functions | List of all members
stk::FormSwep Class Reference

STK sweepable formant filter class. More...

`#include <FormSwep.h>`

Inheritance diagram for stk::FormSwep:

## 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). More...
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). More...
void | setSweepTime (StkFloat time)
| Set the sweep rate in terms of a time value in seconds. More...
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. More...
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. More...
Public Member Functions inherited from stk::Filter
| Filter (void)
| Class constructor.
unsigned int | channelsIn (void) const
| Return the number of input channels for the class.
unsigned int | channelsOut (void) const
| Return the number of output channels for the class.
virtual void | clear (void)
| Clears all internal states of the filter.
void | setGain (StkFloat gain)
| Set the filter gain. More...
StkFloat | getGain (void) const
| Return the current filter gain.
StkFloat | phaseDelay (StkFloat frequency)
| Return the filter phase delay at the specified frequency. More...
const StkFrames & | lastFrame (void) const
| Return an StkFrames reference to the last output sample frame.
Public Member Functions inherited from stk::Stk
void | ignoreSampleRateChange (bool ignore=true)
| A function to enable/disable the automatic updating of class data when the STK sample rate changes. More...

## Additional Inherited Members
Static Public Member Functions inherited from stk::Stk
static StkFloat | sampleRate (void)
| Static method that returns the current STK sample rate.
static void | setSampleRate (StkFloat rate)
| Static method that sets the STK sample rate. More...
static void | clear_alertList ()
| Static method that frees memory from alertList_.
static std::string | rawwavePath (void)
| Static method that returns the current rawwave path.
static void | setRawwavePath (std::string path)
| Static method that sets the STK rawwave path.
static void | swap16 (unsigned char *ptr)
| Static method that byte-swaps a 16-bit data type.
static void | swap32 (unsigned char *ptr)
| Static method that byte-swaps a 32-bit data type.
static void | swap64 (unsigned char *ptr)
| Static method that byte-swaps a 64-bit data type.
static void | sleep (unsigned long milliseconds)
| Static cross-platform method to sleep for a number of milliseconds.
static bool | inRange (StkFloat value, StkFloat min, StkFloat max)
| Static method to check whether a value is within a specified range.
static void | handleError (const char *message, StkError::Type type)
| Static function for error reporting and handling using c-strings.
static void | handleError (std::string message, StkError::Type type)
| Static function for error reporting and handling using c++ strings.
static void | showWarnings (bool status)
| Toggle display of WARNING and STATUS messages.
static void | printErrors (bool status)
| Toggle display of error messages before throwing exceptions.
Static Public Attributes inherited from stk::Stk
static const StkFormat | STK_SINT8
static const StkFormat | STK_SINT16
static const StkFormat | STK_SINT24
static const StkFormat | STK_SINT32
static const StkFormat | STK_FLOAT32
static const StkFormat | STK_FLOAT64
Protected Member Functions inherited from stk::Stk
| Stk (void)
| Default constructor.
virtual | ~Stk (void)
| Class destructor.
void | addSampleRateAlert (Stk *ptr)
| Add class pointer to list for sample rate change notification.
void | removeSampleRateAlert (Stk *ptr)
| Remove class pointer from list for sample rate change notification.
void | handleError (StkError::Type type) const
| Internal function for error reporting that assumes message in `oStream_` variable.

## 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–2017.

## 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`
| ) |  |
| inlinevirtual

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.

154 {
155 #if defined(_STK_DEBUG_)
156 if ( channel >= frames.channels() ) {
157 oStream_ << "FormSwep::tick(): channel and StkFrames arguments are incompatible!";
158 handleError( StkError::FUNCTION_ARGUMENT );
159 }
160 #endif
161
162 StkFloat *samples = &frames[channel];
163 unsigned int hop = frames.channels();
164 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
165 *samples = tick( *samples );
166
167 return frames;
168 }

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.

171 {
172 #if defined(_STK_DEBUG_)
173 if ( iChannel >= iFrames.channels() || oChannel >= oFrames.channels() ) {
174 oStream_ << "FormSwep::tick(): channel and StkFrames arguments are incompatible!";
175 handleError( StkError::FUNCTION_ARGUMENT );
176 }
177 #endif
178
179 StkFloat *iSamples = &iFrames[iChannel];
180 StkFloat *oSamples = &oFrames[oChannel];
181 unsigned int iHop = iFrames.channels(), oHop = oFrames.channels();
182 for ( unsigned int i=0; i<iFrames.frames(); i++, iSamples += iHop, oSamples += oHop )
183 *oSamples = tick( *iSamples );
184
185 return iFrames;
186 }

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

- FormSwep.h

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