Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
Tapped Delay Line in O(1)

The class Tapped Delay Line is an implementation of the Tapped Delay Line (TDL) structure. A TDL is a discrete element in digital filter theory, that allows a signal to be delayed by a number of samples and provides an output signal for each delay. Here, a TDL is implemented as a circular buffer. This means that the complexity of the enqueue and dequeue operations is constant O(1), so integer delays can be computed very efficiently.

The delay by one sample is notated \(z^{-1}\) and delays of \(N\) samples is notated as \(z^{-N}\) motivated by the role the z-transform plays in describing digital filter structures.

To create a TDL, you just need to define an instance of type qlibs::tdl and then, configure it by using the constructor or qlibs::tdl::setup(), where you can define the number of lines to be delayed and the initial values for all of them. Then, you can start operating over this structure by inserting samples of the input signal by using qlibs::tdl::insertSample(). You can also get any specific delay from it by using:

  • qlibs::tdl::getOldest(), to get the oldest delay at tap \(z^{-N}\) You can also use the index at -1 as follows: "delay[ -1 ]"
  • qlibs::tdl::getAtIndex(), to get the delay at tap \(z^{-i}\). You can also use the index using an unsigned value as follows: "delay[ i ]"
  • Index operator

Given the applications of this structure, the qlibs::tdl class is used as the base component of some aspects of qlibs::smoother and qlibs::ltisys.

Example : Code snippet to instantiate a TDL to hold up to 256 delays.

real_t storage[ 256 ] = { 0.0f };
tdl delay( storage );
delay.insertSample( 2.5 );
delay.insertSample( -2.3 );
delay( 4.8 ); // same as delay.insertSample( 4.8 )
auto d3 = delay[ 3 ]; // get delay at t-3, same as delay.getAtIndex( 3 )
auto dOldest = delay[ -1 ]; // get delay at t-255 , same as delay.getOldest()