Sign in

username:

password:



Not a member?

Search Online Books



Search tips

Free Online Books



Chapters

Chapter Contents:

Search Physical Audio Signal Processing

  

Book Index | Global Index


Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?

  

Variable Delay Lines

Let A denote an array of length $ N$. Then we can implement an $ M$-sample variable delay line in the C programming language as shown in Fig.3.1. We require, of course, $ M\leq N$.

Figure 3.1: The $ M$-sample variable delay line using separate read- and write-pointers.

 
   static double A[N];
   static double *rptr = A; // read ptr
   static double *wptr = A; // write ptr

   double setdelay(int M) {
       rptr = wptr - M;
       while (rptr < A) { rptr += N }
   }

   double delayline(double x)
   {
     double y;
     A[wptr++] = x; 
     y = A[rptr++];
     if ((wptr-A) >= N) { wptr -= N }
     if ((rptr-A) >= N) { rptr -= N }
     return y;
   }

The Synthesis Tool Kit, Version 4 [86] contains the C++ class ``Delay'' which implements this type of variable (but non-interpolating) delay line. There are additional subclasses which provide interpolating reads by various methods. In particular, the class DelayL implements continuously variable delay lengths using linear interpolation. The code listing in Fig.3.1 can be modified to use linear interpolation by replacing the line

  y = A[rptr++];
with
  long rpi = (long)floor(rptr);
  double a = rptr - (double)rpi;
  y = a * A[rpi] + (1-a) * A[rpi+1];
  rptr += 1;

To implement a continuously varying delay, we add a ``delay growth parameter'' g to the delayline function in Fig.3.1, and change the line

  rptr += 1; // pointer update
above to
  rptr += 1 - g; // pointer update
When g is 0, we have a fixed delay line. When $ \texttt{g}>0$, the delay grows $ \texttt{g}$ samples per sample, which we may also interpret as seconds per second, i.e., $ {\dot D_t}=\texttt{g}$. In §3.4.5, this will be applied to simulation of the Doppler effect.

Order a Hardcopy of Physical Audio Signal Processing

Previous: Time-Varying Delay Effects
Next: Delay-Line Interpolation

written by Julius Orion Smith III
Julius Smith's background is in electrical engineering (BS Rice 1975, PhD Stanford 1983). He is presently Professor of Music and Associate Professor (by courtesy) of Electrical Engineering at Stanford's Center for Computer Research in Music and Acoustics (CCRMA), teaching courses and pursuing research related to signal processing applied to music and audio systems. See http://ccrma.stanford.edu/~jos/ for details.


Comments


No comments yet for this page


Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )