Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
STK abstract filter class. More...
#include <Filter.h>
Public Member Functions | |
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. | |
StkFloat | getGain (void) const |
Return the current filter gain. | |
StkFloat | phaseDelay (StkFloat frequency) |
Return the filter phase delay at the specified frequency. | |
const StkFrames & | lastFrame (void) const |
Return an StkFrames reference to the last output sample frame. | |
virtual StkFrames & | tick (StkFrames &frames, unsigned int channel=0)=0 |
Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs. |
STK abstract filter class.
This class provides limited common functionality for STK digital filter subclasses. It is general enough to support both monophonic and polyphonic input/output classes.
by Perry R. Cook and Gary P. Scavone, 1995-2011.
void stk::Filter::setGain | ( | StkFloat | gain | ) | [inline] |
StkFloat stk::Filter::phaseDelay | ( | StkFloat | frequency | ) | [inline] |
Return the filter phase delay at the specified frequency.
Note that the phase delay calculation accounts for the filter gain. The frequency value should be greater than 0.0 and less than or equal to one-half the sample rate.
00094 { 00095 if ( frequency <= 0.0 || frequency > 0.5 * Stk::sampleRate() ) { 00096 oStream_ << "Filter::phaseDelay: argument (" << frequency << ") is out of range!"; 00097 handleError( StkError::WARNING ); return 0.0; 00098 } 00099 00100 StkFloat omegaT = 2 * M_PI * frequency / Stk::sampleRate(); 00101 StkFloat real = 0.0, imag = 0.0; 00102 for ( unsigned int i=0; i<b_.size(); i++ ) { 00103 real += b_[i] * std::cos( i * omegaT ); 00104 imag -= b_[i] * std::sin( i * omegaT ); 00105 } 00106 real *= gain_; 00107 imag *= gain_; 00108 00109 StkFloat phase = atan2( imag, real ); 00110 00111 real = 0.0, imag = 0.0; 00112 for ( unsigned int i=0; i<a_.size(); i++ ) { 00113 real += a_[i] * std::cos( i * omegaT ); 00114 imag -= a_[i] * std::sin( i * omegaT ); 00115 } 00116 00117 phase -= std::atan2( imag, real ); 00118 phase = std::fmod( -phase, 2 * M_PI ); 00119 return phase / omegaT; 00120 }
virtual StkFrames& stk::Filter::tick | ( | StkFrames & | frames, | |
unsigned int | channel = 0 | |||
) | [pure 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.
Implemented in stk::BiQuad, stk::Delay, stk::DelayA, stk::DelayL, stk::Fir, stk::FormSwep, stk::Iir, stk::OnePole, stk::OneZero, stk::PoleZero, stk::TapDelay, stk::TwoPole, and stk::TwoZero.
The Synthesis ToolKit in C++ (STK) |
©1995-2011 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |