/usr/include/stk/TapDelay.h is in libstk0-dev 4.4.4-5+deb8u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | #ifndef STK_TAPDELAY_H
#define STK_TAPDELAY_H
#include "Filter.h"
namespace stk {
/***************************************************/
/*! \class TapDelay
\brief 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.
*/
/***************************************************/
class TapDelay : public Filter
{
public:
//! 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.
*/
TapDelay( std::vector<unsigned long> taps = std::vector<unsigned long>( 1, 0 ), unsigned long maxDelay = 4095 );
//! Class destructor.
~TapDelay();
//! 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 setMaximumDelay( unsigned long delay );
//! Set the delay-line tap lengths.
/*!
The valid range for each tap length is from 0 to the maximum delay-line length.
*/
void setTapDelays( std::vector<unsigned long> taps );
//! Return the current delay-line length.
std::vector<unsigned long> getTapDelays( void ) const { return delays_; };
//! 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 \c 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.
*/
StkFloat lastOut( unsigned int tap = 0 ) const;
//! 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.
*/
StkFrames& tick( StkFloat input, StkFrames& outputs );
//! 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.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
//! Take a channel of the \c iFrames object as inputs to the filter and write outputs to the \c oFrames object.
/*!
The \c 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 \c
iChannel argument must be less than the number of channels in
the \c iFrames argument (the first channel is specified by 0).
The \c 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.
*/
StkFrames& tick( StkFrames& iFrames, StkFrames &oFrames, unsigned int iChannel = 0 );
protected:
unsigned long inPoint_;
std::vector<unsigned long> outPoint_;
std::vector<unsigned long> delays_;
};
inline StkFloat TapDelay :: lastOut( unsigned int tap ) const
{
#if defined(_STK_DEBUG_)
if ( tap >= lastFrame_.size() ) ) {
oStream_ << "TapDelay::lastOut(): tap argument and number of taps are incompatible!";
handleError( StkError::FUNCTION_ARGUMENT );
}
#endif
return lastFrame_[tap];
}
inline StkFrames& TapDelay :: tick( StkFloat input, StkFrames& outputs )
{
#if defined(_STK_DEBUG_)
if ( outputs.channels() < outPoint_.size() ) {
oStream_ << "TapDelay::tick(): number of taps > channels in StkFrames argument!";
handleError( StkError::FUNCTION_ARGUMENT );
}
#endif
inputs_[inPoint_++] = input * gain_;
// Check for end condition
if ( inPoint_ == inputs_.size() )
inPoint_ = 0;
// Read out next values
StkFloat *outs = &outputs[0];
for ( unsigned int i=0; i<outPoint_.size(); i++ ) {
*outs++ = inputs_[outPoint_[i]];
lastFrame_[i] = *outs;
if ( ++outPoint_[i] == inputs_.size() )
outPoint_[i] = 0;
}
return outputs;
}
inline StkFrames& TapDelay :: tick( StkFrames& frames, unsigned int channel )
{
#if defined(_STK_DEBUG_)
if ( channel >= frames.channels() ) {
oStream_ << "TapDelay::tick(): channel and StkFrames arguments are incompatible!";
handleError( StkError::FUNCTION_ARGUMENT );
}
if ( frames.channels() < outPoint_.size() ) {
oStream_ << "TapDelay::tick(): number of taps > channels in StkFrames argument!";
handleError( StkError::FUNCTION_ARGUMENT );
}
#endif
StkFloat *iSamples = &frames[channel];
StkFloat *oSamples = &frames[0];
unsigned int j, iHop = frames.channels(), oHop = frames.channels() - outPoint_.size();
for ( unsigned int i=0; i<frames.frames(); i++, iSamples += iHop, oSamples += oHop ) {
inputs_[inPoint_++] = *iSamples * gain_;
if ( inPoint_ == inputs_.size() ) inPoint_ = 0;
for ( j=0; j<outPoint_.size(); j++ ) {
*oSamples++ = inputs_[outPoint_[j]];
if ( ++outPoint_[j] == inputs_.size() ) outPoint_[j] = 0;
}
}
oSamples -= frames.channels();
for ( j=0; j<outPoint_.size(); j++ ) lastFrame_[j] = *oSamples++;
return frames;
}
inline StkFrames& TapDelay :: tick( StkFrames& iFrames, StkFrames& oFrames, unsigned int iChannel )
{
#if defined(_STK_DEBUG_)
if ( iChannel >= iFrames.channels() ) {
oStream_ << "TapDelay::tick(): channel and StkFrames arguments are incompatible!";
handleError( StkError::FUNCTION_ARGUMENT );
}
if ( oFrames.channels() < outPoint_.size() ) {
oStream_ << "TapDelay::tick(): number of taps > channels in output StkFrames argument!";
handleError( StkError::FUNCTION_ARGUMENT );
}
#endif
StkFloat *iSamples = &iFrames[iChannel];
StkFloat *oSamples = &oFrames[0];
unsigned int j, iHop = iFrames.channels(), oHop = oFrames.channels() - outPoint_.size();
for ( unsigned int i=0; i<iFrames.frames(); i++, iSamples += iHop, oSamples += oHop ) {
inputs_[inPoint_++] = *iSamples * gain_;
if ( inPoint_ == inputs_.size() ) inPoint_ = 0;
for ( j=0; j<outPoint_.size(); j++ ) {
*oSamples++ = inputs_[outPoint_[j]];
if ( ++outPoint_[j] == inputs_.size() ) outPoint_[j] = 0;
}
}
oSamples -= oFrames.channels();
for ( j=0; j<outPoint_.size(); j++ ) lastFrame_[j] = *oSamples++;
return iFrames;
}
#endif
} // stk namespace
|