34 TapDelay( std::vector<unsigned long> taps = std::vector<unsigned long>( 1, 0 ),
unsigned long maxDelay = 4095 );
56 std::vector<unsigned long>
getTapDelays(
void )
const {
return delays_; };
67 StkFloat
lastOut(
unsigned int tap = 0 )
const;
109 unsigned long inPoint_;
110 std::vector<unsigned long> outPoint_;
111 std::vector<unsigned long> delays_;
115inline StkFloat TapDelay :: lastOut(
unsigned int tap )
const
117#if defined(_STK_DEBUG_)
118 if ( tap >= lastFrame_.size() ) {
119 oStream_ <<
"TapDelay::lastOut(): tap argument and number of taps are incompatible!";
120 handleError( StkError::FUNCTION_ARGUMENT );
124 return lastFrame_[tap];
129#if defined(_STK_DEBUG_)
130 if ( outputs.
channels() < outPoint_.size() ) {
131 oStream_ <<
"TapDelay::tick(): number of taps > channels in StkFrames argument!";
132 handleError( StkError::FUNCTION_ARGUMENT );
136 inputs_[inPoint_++] = input * gain_;
139 if ( inPoint_ == inputs_.size() )
143 StkFloat *outs = &outputs[0];
144 for (
unsigned int i=0; i<outPoint_.size(); i++ ) {
145 *outs++ = inputs_[outPoint_[i]];
146 lastFrame_[i] = *outs;
147 if ( ++outPoint_[i] == inputs_.size() )
156#if defined(_STK_DEBUG_)
157 if ( channel >= frames.
channels() ) {
158 oStream_ <<
"TapDelay::tick(): channel and StkFrames arguments are incompatible!";
159 handleError( StkError::FUNCTION_ARGUMENT );
161 if ( frames.
channels() < outPoint_.size() ) {
162 oStream_ <<
"TapDelay::tick(): number of taps > channels in StkFrames argument!";
163 handleError( StkError::FUNCTION_ARGUMENT );
167 StkFloat *iSamples = &frames[channel];
168 StkFloat *oSamples = &frames[0];
170 unsigned int iHop = frames.
channels();
171 std::size_t oHop = frames.
channels() - outPoint_.size();
172 for (
unsigned long i=0; i<frames.
frames(); i++, iSamples += iHop, oSamples += oHop ) {
173 inputs_[inPoint_++] = *iSamples * gain_;
174 if ( inPoint_ == inputs_.size() ) inPoint_ = 0;
175 for ( j=0; j<outPoint_.size(); j++ ) {
176 *oSamples++ = inputs_[outPoint_[j]];
177 if ( ++outPoint_[j] == inputs_.size() ) outPoint_[j] = 0;
182 for ( j=0; j<outPoint_.size(); j++ ) lastFrame_[j] = *oSamples++;
188#if defined(_STK_DEBUG_)
189 if ( iChannel >= iFrames.
channels() ) {
190 oStream_ <<
"TapDelay::tick(): channel and StkFrames arguments are incompatible!";
191 handleError( StkError::FUNCTION_ARGUMENT );
193 if ( oFrames.
channels() < outPoint_.size() ) {
194 oStream_ <<
"TapDelay::tick(): number of taps > channels in output StkFrames argument!";
195 handleError( StkError::FUNCTION_ARGUMENT );
199 StkFloat *iSamples = &iFrames[iChannel];
200 StkFloat *oSamples = &oFrames[0];
202 unsigned int iHop = iFrames.
channels();
203 std::size_t oHop = oFrames.
channels() - outPoint_.size();
204 for (
unsigned long i=0; i<iFrames.
frames(); i++, iSamples += iHop, oSamples += oHop ) {
205 inputs_[inPoint_++] = *iSamples * gain_;
206 if ( inPoint_ == inputs_.size() ) inPoint_ = 0;
207 for ( j=0; j<outPoint_.size(); j++ ) {
208 *oSamples++ = inputs_[outPoint_[j]];
209 if ( ++outPoint_[j] == inputs_.size() ) outPoint_[j] = 0;
214 for ( j=0; j<outPoint_.size(); j++ ) lastFrame_[j] = *oSamples++;
STK abstract filter class.
Definition Filter.h:23
An STK class to handle vectorized audio data.
Definition Stk.h:279
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition Stk.h:416
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition Stk.h:419
STK non-interpolating tapped delay line class.
Definition TapDelay.h:25
void setMaximumDelay(unsigned long delay)
Set the maximum delay-line length.
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 ...
StkFloat lastOut(unsigned int tap=0) const
Return the specified tap value of the last computed frame.
Definition TapDelay.h:115
std::vector< unsigned long > getTapDelays(void) const
Return the current delay-line length.
Definition TapDelay.h:56
~TapDelay()
Class destructor.
void setTapDelays(std::vector< unsigned long > taps)
Set the delay-line tap lengths.
StkFrames & tick(StkFloat input, StkFrames &outputs)
Input one sample to the delayline and return outputs at all tap positions.
Definition TapDelay.h:127
The STK namespace.
Definition ADSR.h:6