SPKitDelay
User's Guide
SPKitDelay is a delay line class.
Delay time is set with the initialization function
setInputAndDelayTime(SPKitProcessor* input, SPKitFloat dt),
where input is the object's signal input
and dt is delay time in seconds.
setInputAndDelayTime() should be used instead of the standard
initialization function setInput().
SPKitDelay stores the delayed samples in a buffer,
which is initialized to contain sample values of 0.
SPKitDelay produces incorrect results when used in a feedback loop.
For that purpose, SPKit includes a special delay line:
SPKitFBDelay.
Programmer's Reference
Defined in <spkit/delay.h>
Inherits from SPKitProcessor
SPKitDelay
defines a setInputAndDelayTime() function
for initialization and setting the delay time.
SPKitDelay also overrides
getSample().
Public Members
- SPKitError
setInputAndDelayTime(SPKitProcessor* ip, SPKitFloat dt)
- connect an input to the object and initialize it.
Sets delayTime to dt.
The function allocates
dt * inputChannelCount * inputSamplingRate
samples for buffer.
Calls
SPKitProcessor::setInput().
- int getSample(SPKitSample& outputSample)
- retrieve a delayed audio sample
On each call, getSample() reads one sample from
buffer and stores it to outputSample.
Then the function reads a new sample from input
and stores it to buffer.
Increments oldestSampleIndex.
The function returns 0 on end of signal, 1 otherwise.
Protected Members
- SPKitFloat delayTime
- delay time
- SPKitSample* buffer
- buffer for the delayed samples
- SPKitInt bufSize
- size of buffer in samples
- SPKitInt oldestSampleIndex
- the position in buffer,
where getSample()
retrives the delayed sample and stores
the new input sample.
- SPKitInt lastSampleIndex
- index of the last sample retrived from input
before end of signal
- SPKitInt haveInput
- initially 0, set to 1 when input returns the first sample
- SPKitInt endOfInput
- initially 0, set to 1 when input runs out of samples