Digital Music Programming 2: Homework 4: allpass filters




The goal of this homework is to implement an allpass filter, which has a difference equation of:
   y[n] = -g x[n] + x[n-1] + g y[n-1]

where y is the output signal, x is the input signal, and g is the feedback gain.

This is called a first-order allpass filter, because it only uses a one sample delay. It is possible to create second order allpass filters using up to a two-sample delay. Any-order allpass filters can be created by using an arbitrary amount of maximum delay.

The interesting thing about the allpass filter (of any order) is that the amplitudes of the frequencies are not changed as the sound travels through the filter. This may seem like a boring filter, but what does change is the time that it takes for different frequencies to get through the filter. Here is a plot of the group delay for the filter which describes how the sound is delays at various frequences and values of g, the gain.

Interesting note: water behaves as an allpass filter. Over long distances, the high frequencies will arrive sooner than lower frequencies. So you can hear thunder underwater from hundreds of miles away which sounds like a sinewave falling in pitch.

This is called dispersion. Here are some soundfiles which magnify the effect of the first order allpass several hundred times to make the frequency delays noticeable: [ dispersion of whitenoise | dispersion of whitenoise | dispersion of voice | dispersion of voice ]

Assignment:

  1. Draw the flowgraph for the first-order allpass filter.

  2. Calculate the z-transform of the first-order allpass filter.

  3. Calculate the transfer-function for the first-order allpass filter.

  4. Implement as a Max/MSP object a first-order allpass filter using difference equation given above.

  5. Test your implementation of the allpass filter in Max/MSP with a patch that starts with loading a sound sample such as whitenoise, a spoken word, or a instrument note in to memory. Send this sound through your allpass filter with your choice of g feedback gain -- 0.5 to 1.0 is a good range to choose from. Send the sound again and again though the filter. Come back after an hour and listen to the output sound. How does it sound different from the original sound?

    Email me the original sound and the final output sound, as well as the g value which you choose. Also, it would be nice to count how many times the sound goes through the filter. Starting around 1000 times, you should be able to start hearing a difference from the original sound.

  6. Extra Credit: implement a second-order allpass filter as a Max/MSP object:
       y[n] = -g x[n] + x[n-2] + g y[n-2]
    
  7. Extra Extra Credit: implement a Nth-order allpass filter:
       y[n] = -g x[n] + x[n-N] + g y[n-N]
    
    Where N is any (reasonably) positive integer which represents a delay amount in samples.