question archive In this exercise, we consider the implementation of a filter as a cascade (series) of two filters
Subject:Electrical EngineeringPrice: Bought3
In this exercise, we consider the implementation of a filter as a cascade (series) of two filters. If two LTI systems with transfer functions H1(z) and H2(z) are connected in cascade (series), then the total system is also an LTI system and it has transfer function H(z) = H1(z)H2(z).
In this exercise, we let H1(z) be the system implemented as the difference equation as: lfilter(b1, a1, x, zi = ...) Similarly, let H2(z) be implemented as lfilter(b2, a2, x, zi = ...) Let the filter coefficients be as follows. a1 = [1.0000, -0.0000, 0.1716] b1 = [0.2929, 0.5858, 0.2929] a2 = [1.0000, -1.5610, 0.6414] b2 = [0.8006, -1.6012, 0.8006]
Give a Python program using Pyaudio and the lfilter function to implement the filter H(z) = H1(z)H2(z). Your program should read the wave file author.wav one block at a time, using a block length of 128 samples. Use the lfilter function twice for each block to implement the filter in cascade form as indicated. Set the states in the lfilter functon so that no erroneous artifacts arise. Your program should play the output signal to the loudspeaker and write the output signal to a wave file. Give a brief explanation of (1) how it works and (2) how you checked its correctness. Submit your Python program, your output wave file, and your brief explanation. The program demo_filter_blocks_corrected.py will be a good starting point.