In software, a delay line is often implemented using a circular buffer. Let D denote an array of length . Then we can implement the -sample delay line in the C programming language as shown in Fig.2.2.
/* delayline.c */ static double D[M]; // initialized to zero static long ptr=0; // read-write offset double delayline(double x) { double y = D[ptr]; // read operation D[ptr++] = x; // write operation if (ptr >= M) { ptr -= M; } // wrap ptr if needed // ptr %= M; // modulo-operator syntax return y; } |
Delay lines of this type are typically used in digital reverberators and other acoustic simulators involving fixed propagation delays. Later, in Chapter 5, we will consider time-varying delay lengths.