Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search


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


Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

[How to cite this work]  [Order a printed hardcopy]  [Comment on this page via email]

``Physical Audio Signal Processing'', by Julius O. Smith III, W3K Publishing, 2010, ISBN 978-0-9745607-2-4
Copyright © 2024-06-28 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA