A Software Delay Line

In software, a delay line is often implemented using a circular buffer. Let D denote an array of length $ M$. Then we can implement the $ M$-sample delay line in the C programming language as shown in Fig.2.2.

Figure 2.2: The $ M$-sample delay line.

    /* 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
//    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.

Next Section:
Traveling Waves
Previous Section:
A Simplified Starting Theory