Calculating Doppler shift for moving virtual sound sources

A stereo spatialization effect can be achieved using x,y coordinates to determine intensity and delay for the sound at each speaker at each moment. The hypothetical listener is placed at a point equidistant from the two speakers. The speakers are each assumed to be at some angle from the listener between 0 and pi radians, with 0 radians being straight to the right, pi/2 radians being directly in front of the listener, and pi radians being to the left.

Constant power panning using square root of intensity

The intensity of sound is proportional to the square of its amplitude. So if we want to have a linear change in intensity as we go from 0 to 1 or 1 to 0, we need to use the square root of that linear change to calculate the amplitude. This example patch is exactly like "Linear amplitude panning", except that we consider the linearly changing signal from line~ to be the intensity rather than the amplitude, and we take the square root of that value to obtain the actual amplitude for each speaker.

Linear interpolation of audio

For linear interpolation of a MSP signal, the line~ object sends out a signal that progress to some new value over a certain amount of time interpolating sample-by-sample along the way. The input to line~ is a pair of numbers representing a destination value (where it should eventually arrive) and a transition time (how long it should take to get there). It can receive multiple pairs of numbers in a single message, and it will use the pairs in order, starting each new pair when the previous transition has finished.