37 DelayL( StkFloat delay = 0.0,
unsigned long maxDelay = 4095 );
62 StkFloat
getDelay(
void )
const {
return delay_; };
70 StkFloat
tapOut(
unsigned long tapDelay );
73 void tapIn( StkFloat value,
unsigned long tapDelay );
76 StkFloat
lastOut(
void )
const {
return lastFrame_[0]; };
85 StkFloat
tick( StkFloat input );
111 unsigned long inPoint_;
112 unsigned long outPoint_;
116 StkFloat nextOutput_;
120inline StkFloat DelayL :: nextOut(
void )
124 nextOutput_ = inputs_[outPoint_] * omAlpha_;
126 if (outPoint_+1 < inputs_.size())
127 nextOutput_ += inputs_[outPoint_+1] * alpha_;
129 nextOutput_ += inputs_[0] * alpha_;
136inline void DelayL :: setDelay( StkFloat delay )
138 if ( delay + 1 > inputs_.size() ) {
139 oStream_ <<
"DelayL::setDelay: argument (" << delay <<
") greater than maximum!";
140 handleError( StkError::WARNING );
return;
144 oStream_ <<
"DelayL::setDelay: argument (" << delay <<
") less than zero!";
145 handleError( StkError::WARNING );
return;
148 StkFloat outPointer = inPoint_ - delay;
151 while ( outPointer < 0 )
152 outPointer += inputs_.size();
154 outPoint_ = (long) outPointer;
156 alpha_ = outPointer - outPoint_;
157 omAlpha_ = (StkFloat) 1.0 - alpha_;
159 if ( outPoint_ == inputs_.size() ) outPoint_ = 0;
163inline StkFloat DelayL :: tick( StkFloat input )
165 inputs_[inPoint_++] = input * gain_;
168 if ( inPoint_ == inputs_.size() )
171 lastFrame_[0] = nextOut();
175 if ( ++outPoint_ == inputs_.size() )
178 return lastFrame_[0];
183#if defined(_STK_DEBUG_)
184 if ( channel >= frames.
channels() ) {
185 oStream_ <<
"DelayL::tick(): channel and StkFrames arguments are incompatible!";
186 handleError( StkError::FUNCTION_ARGUMENT );
190 StkFloat *samples = &frames[channel];
191 unsigned int hop = frames.
channels();
192 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop ) {
193 inputs_[inPoint_++] = *samples * gain_;
194 if ( inPoint_ == inputs_.size() ) inPoint_ = 0;
195 *samples = nextOut();
197 if ( ++outPoint_ == inputs_.size() ) outPoint_ = 0;
200 lastFrame_[0] = *(samples-hop);
206#if defined(_STK_DEBUG_)
208 oStream_ <<
"DelayL::tick(): channel and StkFrames arguments are incompatible!";
209 handleError( StkError::FUNCTION_ARGUMENT );
213 StkFloat *iSamples = &iFrames[iChannel];
214 StkFloat *oSamples = &oFrames[oChannel];
216 for (
unsigned int i=0; i<iFrames.
frames(); i++, iSamples += iHop, oSamples += oHop ) {
217 inputs_[inPoint_++] = *iSamples * gain_;
218 if ( inPoint_ == inputs_.size() ) inPoint_ = 0;
219 *oSamples = nextOut();
221 if ( ++outPoint_ == inputs_.size() ) outPoint_ = 0;
224 lastFrame_[0] = *(oSamples-oHop);
STK linear interpolating delay line class.
Definition DelayL.h:28
StkFloat lastOut(void) const
Return the last computed output value.
Definition DelayL.h:76
void setMaximumDelay(unsigned long delay)
Set the maximum delay-line length.
StkFloat tick(StkFloat input)
Input one sample to the filter and return one output.
Definition DelayL.h:163
void setDelay(StkFloat delay)
Set the delay-line length.
Definition DelayL.h:136
~DelayL()
Class destructor.
void tapIn(StkFloat value, unsigned long tapDelay)
Set the value at tapDelay samples from the delay-line input.
StkFloat nextOut(void)
Return the value which will be output by the next call to tick().
Definition DelayL.h:120
unsigned long getMaximumDelay(void)
Get the maximum delay-line length.
Definition DelayL.h:43
StkFloat tapOut(unsigned long tapDelay)
Return the value at tapDelay samples from the delay-line input.
DelayL(StkFloat delay=0.0, unsigned long maxDelay=4095)
Default constructor creates a delay-line with maximum length of 4095 samples and zero delay.
StkFloat getDelay(void) const
Return the current delay-line length.
Definition DelayL.h:62
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
size_t size() const
Returns the total number of audio samples represented by the object.
Definition Stk.h:374
The STK namespace.
Definition ADSR.h:6