The Doppler effect occurs when a sound source and listener are moving relative to one another. When the source and listener move toward each other, the sound is perceived to increase in frequency. When the source and listener move away from each other, the sound is heard to decrease in frequency.
The Doppler effect can be used to enhance the realism of simulated moving sound sources.
The amount of frequency shift is given by:
where is the frequency of the source at rest, is the frequency perceived by the listener, is the speed of the listener toward the source (zero if not moving), is the speed of the source toward the listener (zero is not moving), and is the sound speed.
We can simulate time-varying source and listener velocities using a time-varying digital delay line with separate read and write pointers. The write pointer corresponds to the source signal and the read pointer corresponds to the listener. If the source position is moving toward the listener, the write pointer increment should be changed from 1 to . Likewise, if the listener is moving toward the source, the read pointer increment should be changed from 1 to .
Interpolated reads from a delay line (fractional delay lengths) were previously discussed. Interpolated writes are referred to as de-interpolation.
Because Doppler shift is dependent only on the relative motion of a source and listener and because the de-interpolation process is generally more complicated to implement than interpolation, it is best to change only the read pointer increment when possible.
A continuously varying delay can be implemented with a “growth parameter” such that the read pointer is incremented by at each time step.