If we consider our digital audio samples to correspond to successive moments in time, then time shifting the signal by samples corresponds to a delay of time units, where is the sample rate. (If is negative, then we are saying that the output predicts the input; this isn't practical in systems, such as Pd, that schedule computations in order of time.)
Figure 7.3 shows one example of a linear delay network: an assembly of delay units, possibly with amplitude scaling operations, combined using addition and subtraction. The output is a linear function of the input, in the sense that adding two signals at the input is the same as processing each one separately and adding the results. Moreover, they are time invariant, i.e., they create no new frequencies in the output that weren't present in the input.
In general there are two ways of thinking about delay networks. We can think in the time domain, in which we draw waveforms as functions of time (or of the index ), and consider delays as time shifts. Alternatively we may think in the frequency domain, in which we dose the input with a sinusoid (so that its output is a sinusoid at the same frequency) and report the amplitude and/or phase change brought by the network, as a function of the frequency (encoded in the complex number ). We'll now look at the delay network of Figure 7.3 in each of the two ways in turn.
Figure 7.4 shows the network's behavior in the time domain. We invent some sort of suitable test function as input (it's a rectangular pulse eight samples wide in this example) and graph the input and output as functions of the sample number . This particular delay network adds the input to a delayed copy of itself.
A frequently used test function is an impulse, which is a pulse lasting only one sample. The utility of this is that, if we know the output of the network for an impulse, we can find the output for any other digital audio signal--because any signal is a sum of impulses, one of height , the next one occurring one sample later and having height , and so on. Later, when the networks get more complicated, we will move to using impulses as input signals to show their time-domain behavior.
On the other hand, we can analyze the same network in the frequency domain
by considering a (complex-valued) test signal,
Figure 7.5 is a graph, in the complex plane, showing how the quantities and combine additively. To add complex numbers we add their real and complex parts separately. So the complex number (real part , imaginary part ) is added coordinate-wise to the complex number (real part , imaginary part ). This is shown graphically by making a parallelogram, with corners at the origin and at the two points to be added, and whose fourth corner is the sum .
As the figure shows, the result can be understood by symmetrizing it about
the real axis: instead of and , it's easier to sum the
quantities and , because they are symmetric about
the real (horizontal) axis. (Strictly speaking, we haven't defined the
quantities and ; we use those expressions
to denote unit
complex numbers whose arguments are half those of and .)
We rewrite the gain as:
Since the network has greater gain at some frequencies than at others, it may be considered as a filter, that can be used to separate certain components of a sound from others. Because of the shape of this particular gain expression as a function of , this kind of delay network is called a (non-recirculating) comb filter.
The output of the network is a sum of two sinusoids of equal amplitude, and whose phases differ by . The resulting output amplitude can therefore be checked against the prediction of Section 1.6--and they agree. The result also agrees with common sense: if the angular frequency is set so that an integer number of periods fit into samples, i.e., if is a multiple of , the output of the delay is exactly the same as the original signal, and so the two combine to make an output with twice the original amplitude. If the delay is half the period, on the other hand (so that ) the delay output is out of phase and cancels the input exactly.
This particular delay network has an interesting application: if we have a periodic (or nearly periodic) incoming signal, whose fundamental frequency is radians per sample, we can tune the comb filter so that the peaks in the gain are aligned at even harmonics and the odd ones fall where the gain is zero. To do this we choose , i.e., set the delay time to exactly one half period of the incoming signal. In this way we get a new signal whose harmonics are , and so it now has a new fundamental frequency at twice the original one. Except for a factor of two, the amplitudes of the remaining harmonics still follow the spectral envelope of the original sound. So we have a tool now for raising the pitch of an incoming sound by an octave without changing its spectral envelope. This octave doubler is the reverse of the octave divider introduced back in Chapter 5.
The time domain and frequency domain pictures are complementary ways of looking at the same delay network. When the delays inside the network are smaller than the ear's ability to resolve events in time--less than about 20 milliseconds--the time domain picture becomes less relevant to our understanding of the delay network, and we turn mostly to the frequency-domain picture. On the other hand, when delays are greater than about 50 milliseconds, the peaks and valleys of plots showing gain versus frequency (such as that of Figure 7.6) become crowded so closely together that the frequency-domain view becomes less important. Both are nonetheless valid over the entire range of possible delay times.