Back to main

Audio Programming Lab 6


Exercise 15: Complex Arithmetic


Polar coordinate vectors. See wikipedia or your first-year maths textbook.

Maths homework

To be able to calculate frequency responses and design filters easily, it is important to be fluent at vector arithmetic, so the the prep for this section contains a bit of practice at that.

Work out the following equations, expressing the results in polar form:

  1. (4∠π/3) + (3∠π/2)
  2. (4∠π/3) + (-3∠π/2)
  3. (3∠π/2) - (4∠π/3)
  4. (3∠π/2) + (0∠π/3)
  5. (3∠0) + (4∠π/3)
  6. (-4∠π/3) + (-3∠π/2)

You should also be familiar with multiplication and division.

  1. (4∠π/3)(3∠π/2)
  2. (-2∠π/3)³
  3. (2+j3)(1.5∠-3π/2)
  4. j(1+j)
  5. (3∠-π/4)(-2∠-3π/2)
  6. (3∠π/2)÷(4∠π/3)

You must express all results in polar coordinates.

You must show one of these problems done by hand (with a calculator, writing out intermediate steps); the others can be solved with either a computer program, or by hand.

If you write a computer program, you can just write down the answers, but show us the program so we know you didn't just use maple or the google calculator.

Your task...

Write python functions to do addition, multiplication, and division of polar coordinates. Functions can return two values by doing

def add(a, b, c, d):
    return magnitude, angle

magnitude, angle = add(0, 1, 2, 3)
print magnitude, angle

If you use global variables for this, you will make the next 4 exercises a lot harder for yourself. Also, Graham will mock you for the rest of the year.

... show your work to a demonstrator

Exercise 16: frequency response


A few labs ago, we constructed oscillators by placing poles on the unit circle in the z-plane. This concept can be extended by providing the objects we build with an input, and implementing them with poles (and zeros) inside the unit circle.

To calculate the frequency response of such a system, we can follow the procedure described in the "Subtractive Synthesis" chapter of mcm.pdf. This describes an easily-rememered graphical method to calculate the magnitude and phase of a system's transfer function given the position of the poles and zeros. In summary:

  1. Take a position on the unit-circle corresponding to the frequency of the input signal.
  2. Construct vectors from each pole to that position.
  3. Calculate the vector product of these vectors, producing the result P
  4. Repeat the procedure for for the zeros yeilding Z. Remember that to make a causal system, you probably ended up with zeros at the origin.
  5. The frequency response is the result of the vector division of Z by P

Maths homework

Consider a system is running at a sample rate of 44100Hz, having two poles at z = 0.995∠±π/10, and two zeros at z = 0.9∠±π/10.

What is the frequency response at alpha = 0.25 ?

At what frequency does it have maximum gain? And what is that gain?

Your task...

Make some plots of the magnitude frequency response for the following systems of poles and zeros. This requires you to write a function to figure out the frequency response at a particular point, then call that function a bunch of times so you have your data to plot.

You should have a single frequency_response(poles, zeros) function.

Back to main

Creative Commons LicenseUnless otherwise noted, all materials on these pages are licenced under a Creative Commons Licence.