Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
STK non-interpolating tapped delay line class. More...
#include <TapDelay.h>
Public Member Functions | |
TapDelay (std::vector< unsigned long > taps=std::vector< unsigned long >(1, 0), unsigned long maxDelay=4095) | |
The default constructor creates a delay-line with maximum length of 4095 samples and a single tap at delay = 0. | |
~TapDelay () | |
Class destructor. | |
void | setMaximumDelay (unsigned long delay) |
Set the maximum delay-line length. | |
void | setTapDelays (std::vector< unsigned long > taps) |
Set the delay-line tap lengths. | |
std::vector< unsigned long > | getTapDelays (void) const |
Return the current delay-line length. | |
StkFloat | lastOut (unsigned int tap=0) const |
Return the specified tap value of the last computed frame. | |
StkFrames & | tick (StkFloat input, StkFrames &outputs) |
Input one sample to the delayline and return outputs at all tap positions. | |
StkFrames & | tick (StkFrames &frames, unsigned int channel=0) |
Take a channel of the StkFrames object as inputs to the filter and write outputs back to the same object. | |
StkFrames & | tick (StkFrames &iFrames, StkFrames &oFrames, unsigned int iChannel=0) |
Take a channel of the iFrames object as inputs to the filter and write outputs to the oFrames object. |
STK non-interpolating tapped delay line class.
This class implements a non-interpolating digital delay-line with an arbitrary number of output "taps". If the maximum length and tap delays are not specified during instantiation, a fixed maximum length of 4095 and a single tap delay of zero is set.
A non-interpolating delay line is typically used in fixed delay-length applications, such as for reverberation.
by Perry R. Cook and Gary P. Scavone, 1995-2012.
stk::TapDelay::TapDelay | ( | std::vector< unsigned long > | taps = std::vector< unsigned long >(1, 0) , |
|
unsigned long | maxDelay = 4095 | |||
) |
The default constructor creates a delay-line with maximum length of 4095 samples and a single tap at delay = 0.
An StkError will be thrown if any tap delay parameter is less than zero, the maximum delay parameter is less than one, or any tap delay parameter is greater than the maxDelay value.
void stk::TapDelay::setMaximumDelay | ( | unsigned long | delay | ) |
Set the maximum delay-line length.
This method should generally only be used during initial setup of the delay line. If it is used between calls to the tick() function, without a call to clear(), a signal discontinuity will likely occur. If the current maximum length is greater than the new length, no change will be made.
void stk::TapDelay::setTapDelays | ( | std::vector< unsigned long > | taps | ) |
Set the delay-line tap lengths.
The valid range for each tap length is from 0 to the maximum delay-line length.
StkFloat stk::TapDelay::lastOut | ( | unsigned int | tap = 0 |
) | const [inline] |
Return the specified tap value of the last computed frame.
Use the lastFrame() function to get all tap values from the last computed frame. The tap
argument must be less than the number of delayline taps (the first tap 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.
00116 { 00117 #if defined(_STK_DEBUG_) 00118 if ( tap >= lastFrame_.size() ) ) { 00119 oStream_ << "TapDelay::lastOut(): tap argument and number of taps are incompatible!"; 00120 handleError( StkError::FUNCTION_ARGUMENT ); 00121 } 00122 #endif 00123 00124 return lastFrame_[tap]; 00125 }
Input one sample to the delayline and return outputs at all tap positions.
The StkFrames argument reference is returned. The output values are ordered according to the tap positions set using the setTapDelays() function (no sorting is performed). The StkFrames argument must contain at least as many channels as the number of taps. 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.
00128 { 00129 #if defined(_STK_DEBUG_) 00130 if ( outputs.channels() < outPoint_.size() ) { 00131 oStream_ << "TapDelay::tick(): number of taps > channels in StkFrames argument!"; 00132 handleError( StkError::FUNCTION_ARGUMENT ); 00133 } 00134 #endif 00135 00136 inputs_[inPoint_++] = input * gain_; 00137 00138 // Check for end condition 00139 if ( inPoint_ == inputs_.size() ) 00140 inPoint_ = 0; 00141 00142 // Read out next values 00143 StkFloat *outs = &outputs[0]; 00144 for ( unsigned int i=0; i<outPoint_.size(); i++ ) { 00145 *outs++ = inputs_[outPoint_[i]]; 00146 lastFrame_[i] = *outs; 00147 if ( ++outPoint_[i] == inputs_.size() ) 00148 outPoint_[i] = 0; 00149 } 00150 00151 return outputs; 00152 }
Take a channel of the StkFrames object as inputs to the filter and write outputs back to the same object.
The StkFrames argument reference is returned. The output values are ordered according to the tap positions set using the setTapDelays() function (no sorting is performed). The StkFrames argument must contain at least as many channels as the number of taps. 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.
00155 { 00156 #if defined(_STK_DEBUG_) 00157 if ( channel >= frames.channels() ) { 00158 oStream_ << "TapDelay::tick(): channel and StkFrames arguments are incompatible!"; 00159 handleError( StkError::FUNCTION_ARGUMENT ); 00160 } 00161 if ( frames.channels() < outPoint_.size() ) { 00162 oStream_ << "TapDelay::tick(): number of taps > channels in StkFrames argument!"; 00163 handleError( StkError::FUNCTION_ARGUMENT ); 00164 } 00165 #endif 00166 00167 StkFloat *iSamples = &frames[channel]; 00168 StkFloat *oSamples = &frames[0]; 00169 unsigned int j, iHop = frames.channels(), oHop = frames.channels() - outPoint_.size(); 00170 for ( unsigned int i=0; i<frames.frames(); i++, iSamples += iHop, oSamples += oHop ) { 00171 inputs_[inPoint_++] = *iSamples * gain_; 00172 if ( inPoint_ == inputs_.size() ) inPoint_ = 0; 00173 for ( j=0; j<outPoint_.size(); j++ ) { 00174 *oSamples++ = inputs_[outPoint_[j]]; 00175 if ( ++outPoint_[j] == inputs_.size() ) outPoint_[j] = 0; 00176 } 00177 } 00178 00179 oSamples -= frames.channels(); 00180 for ( j=0; j<outPoint_.size(); j++ ) lastFrame_[j] = *oSamples++; 00181 return frames; 00182 }
StkFrames & stk::TapDelay::tick | ( | StkFrames & | iFrames, | |
StkFrames & | oFrames, | |||
unsigned int | iChannel = 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. The output values are ordered according to the tap positions set using the setTapDelays() function (no sorting is performed). The iChannel
argument must be less than the number of channels in the iFrames
argument (the first channel is specified by 0). The oFrames
argument must contain at least as many channels as the number of taps. 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.
00185 { 00186 #if defined(_STK_DEBUG_) 00187 if ( iChannel >= iFrames.channels() ) { 00188 oStream_ << "TapDelay::tick(): channel and StkFrames arguments are incompatible!"; 00189 handleError( StkError::FUNCTION_ARGUMENT ); 00190 } 00191 if ( oFrames.channels() < outPoint_.size() ) { 00192 oStream_ << "TapDelay::tick(): number of taps > channels in output StkFrames argument!"; 00193 handleError( StkError::FUNCTION_ARGUMENT ); 00194 } 00195 #endif 00196 00197 StkFloat *iSamples = &iFrames[iChannel]; 00198 StkFloat *oSamples = &oFrames[0]; 00199 unsigned int j, iHop = iFrames.channels(), oHop = oFrames.channels() - outPoint_.size(); 00200 for ( unsigned int i=0; i<iFrames.frames(); i++, iSamples += iHop, oSamples += oHop ) { 00201 inputs_[inPoint_++] = *iSamples * gain_; 00202 if ( inPoint_ == inputs_.size() ) inPoint_ = 0; 00203 for ( j=0; j<outPoint_.size(); j++ ) { 00204 *oSamples++ = inputs_[outPoint_[j]]; 00205 if ( ++outPoint_[j] == inputs_.size() ) outPoint_[j] = 0; 00206 } 00207 } 00208 00209 oSamples -= oFrames.channels(); 00210 for ( j=0; j<outPoint_.size(); j++ ) lastFrame_[j] = *oSamples++; 00211 return iFrames; 00212 }
The Synthesis ToolKit in C++ (STK) |
©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |