SPKitFBDelay


User's Guide

SPKitFBDelay is a delay line class specialized for use in a feedback loop. SPKitFBDelay is ment to be used in patches, where the output a delay line is fed back to its input. For other kinds of patches, see SPKitDelay.

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().

SPKitFBDelay stores the delayed samples in a buffer, which is initialized to contain sample values of 0.

The only difference from the regular delay line class SPKitDelay is that the delay buffer of SPKitFBDelay is one sample smaller.


Programmer's Reference

Defined in <spkit/delay.h>
Inherits from SPKitProcessor

SPKitFBDelay defines a setInputAndDelayTime() function for initialization and setting the delay time. SPKitFBDelay 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. The buffer is one sample shorter than in SPKitDelay.
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

Return to SPKit home

Kai Lassfolk / University of Helsinki / kpl@elisir.helsinki.fi

This class is based on an earlier Objective-C implementation by Janne Halmkrona.