In Matlab, a digital delay line can be implemented as an FIR filter by specifying an appropriate feedforward coefficient vector to the filter() function. For a delay length of the coefficient vector would be b = [0, 0, 0, 0, 1] or more generally as b = [zeros(1, M) 1].
However, given that a digital delay line does not require any multiplies, it is significantly more efficient to implement a digital delay line by allocating a buffer of values in memory and using one or more pointers to specify incrementing input and output locations over time.
Memory allocation can be a relatively time consuming operation in a realtime synthesis environment. Thus, in situations where the delay length may change over time, a large buffer of some maximum size is usually created during initialization.
An example of this type of implementation is given by the Matlab script delay.m.
The Synthesis ToolKit in C++ (STK)
includes the class, Delay, which provides non-interpolating delay functionality. Delay is a protected subclass of the Filter class.
The Pd object delay~ implements a simple single-output delay line that takes arguments in samples. It cannot be used in a feedback loop.
The Pd object delwrite~ implements a digital delay line (a buffer of memory) with a given name and maximum length in milliseconds. The Pd object delread~ provides access to the contents of delwrite~ at arbitrary delay values (in milliseconds) up to the maximum delay length.