Next |
Prev |
Up |
Top
|
Index |
JOS Index |
JOS Pubs |
JOS Home |
Search
Time varying delay lines are fundamental building blocks for delay
effects, synthesis algorithms, and computational acoustic models of
musical instruments.
Let A denote an array of length
. Then we can implement an
-sample variable delay line in the C programming language
as shown in Fig.5.1. We require, of course,
.
Figure 5.1:
The
-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.5.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.5.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
, the delay grows
samples per sample,
which we may also interpret as seconds per second, i.e.,
. In §5.7.2, this will be applied to
simulation of the Doppler effect.
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]