1. From poles and zeros to sound
In python code, start by designing a filter with two complex conjugate pole pairs at 0.95 · e ±j0.1π and at 0.9 · e ±j0.3π , as well as zeros at z = 0.
Calculate the corresponding {b} and {a} filter coefficients — use numpy.poly() for this. Use lfilter if you like.
Draw the log-magnitude frequency response and phase response and show a pole-zeros plot for your filter. How does the magnitude spectrum change with (1) different angles of the poles and (2) different magnitude of the poles?
Then, construct an impulse train with N = 1000 points and periodicity T = 80 as input. Filter the input with the coefficients you derived. Plot the input and output in time-domain.
Finally, play the output file as audio sampled at 8 kHz, using the simpleaudio package.
How do the sounds change with (1) different angles of the poles and (2) different magnitude of the poles?

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import math
import matplotlib.pyplot as plt
import numpy as np
import scipy as sp
import scipy.signal as signal
import simpleaudio as sa

p1_mag = 0.95
p1_phase = 0.1*math.pi

p2_mag = 0.9
p2_phase = 0.3*math.pi

Construct complex poles
p1_root1 = p1_mag * complex(math.cos(p1_phase), math.sin(p1_phase))
p1_root2 = p1_mag * complex(math.cos(p1_phase), -1*math.sin(p1_phase))

p2_root1 = p2_mag * complex(math.cos(p2_phase), math.sin(p2_phase))
p2_root2 = p2_mag * complex(math.cos(p2_phase), -1*math.sin(p2_phase))

roots = [p1_root1, p1_root2, p2_root1, p2_root2]
zeros = [0, 0, 0, 0]

Construct filter coefficients
numerator = np.poly(zeros)
denominator = np.poly(roots)

Construct frequency response
w, mag, phase = signal.bode((numerator, denominator...

By purchasing this solution you'll be able to access the following files: and Solution.png.

50% discount

$60.00 $30.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Electrical Engineering Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats