Load on Python the file “1234567890_py.wav”, which contains the dual tone code for a touchtone telephone keypad corresponding to the numbers 1,2,3,4,5,6,7,8,9,0, sampled at 44.1 kHz.
a) Plot the signal. Then plot the zoomed-in signal corresponding to the first tone (‘1’) and explain if the signal is periodic and justify your answer.
b) Calculate and plot the spectrogram of the signal, using a Hann window of 100ms in length and an overlap of 50%. By visual inspection of the spectrogram, determine the frequencies of each of the ten tones in this signal and explain how you obtained the answer.
c) Now change the window-length for calculating the spectrogram to a. 50 ms b. 200 ms
Plot the spectrograms. What is the major advantage of using shorter windows compared to the longer ones and what is the major disadvantage of using a shorter window? Justify your answer based on observation of the plotted spectrograms and on theory.
d) Explain how you can ensure that a spectrogram has a frequency resolution of 50Hz and plot the corresponding spectrogram, showing any calculations made to find input parameters for the spectrogram function.
e) Based on the result of part b) and visual analysis of the spectrogram, determine the telephone number (7 numbers) in the file 'Phone_number_py.wav'.
Consider the system represented in Figure 1. It includes two omnidirectional microphones arranged at distance d=2 m and a sound source located at an angle θ from the axis of the microphone array. The signals measured by the microphones are contaminated by identical noise n(t). The two microphone signals y1(t) and y2(t) have been sampled and stored and are given in file “y1.wav” and “y2.wav”, respectively (note: the sampling frequency is not the same as in the previous question). The last second of the recording may be considered as only containing the noise.
a) Power spectral density: i. Compute and plot the power spectral density (PSD) of the two microphone signals using Welch’s method. Use a block (window) size of 10.7 milliseconds (use the closest corresponding integer number of samples for the length of the fft and give that number), a 50% overlap and a Hann window. You may use Python’s built-in psd functions (e.g. scipy.signal.welch or scipy.signal.csd). Include the relevant part of your commented code as part of your answer in this section. ii. Plot the PSDs of the two microphone signals on a linear and dB scale, and with a linear and logarithmic frequency axis (4 plots).
b) Average power: i. Report the relevant formula and calculate the average power of the two signals from the time domain. ii. Report the relevant formula and calculate the average power of the two signals from the spectrum you computed in part a). iii. Compare and comment the results.
c) Filtering to remove noise: By considering the properties of the signals, estimate the bandwidth of the noise. Referring to Appendix 2 of this document, set the cut-off frequencies f1 and f2 of the digital filter and apply the filter to the two microphone signals y1 and y2 to reduce the noise as much as possible. Include the relevant part of your commented code as part of your answer in this section. Explain your approach and plot the spectrum of the filtered signals and explain how this shows that your approach has been successful.. [hint: the last second of signals y1 and y2 contains only noise]
d) Delay estimation: i. After having removed the noise, write a Python function that estimates the delay between the two signals from their cross-correlation function (see Appendix 3). Include the relevant part of your commented code as part of your answer in this section and explain it. ii. Plot the cross-correlation function between the two signals and explain your result. iii. What is the delay between the two signals? Explain how you got to this result.
e) Sound source localisation: i. State the formula to determine the angular location θ of the source. Assume that the source generates a planar wave front and given a speed of sound propagation of 344 m/s. ii. Calculate the source angular location using your formula. iii. Critically discuss the methods used and their limitations.
The digital cross-over network of a loudspeaker reported in Figure 2 is a Single-Input Multiple-Output (SIMO) system. The 2-channel output of the system has been measured for various input files, as shown in the table below: Signal type
Input file name
White noise 100 Hz sinusoid 3 kHz sinusoid 7 kHz sinusoid
x_noise.wav x_sin100.wav x_sin3k.wav x_sin7k.wav
Output file name Output file name Low-pass High-pass y_l_noise.wav y_h _noise.wav y_l _sin100.wav y_h _sin100.wav y_l _sin3k.wav y_h _sin3k.wav y_l _sin7k.wav y_h _sin7k.wav
The sampling frequency of all files is fs=48000. The objective of this exercise is to calculate and analyse the two complex frequency response function (FRFs) and the two Impulse Responses (IRs) of this SIMO system.
a) Coherence: i. Write a function to calculate and plot the coherence function ?? 2 (f) between two signals. You may not use any built-in Python function to calculate coherence. You may use Python’s built-in fft function and/or the scipy.signal.csd function, but you can also write your own code to compute the cross-spectrum of the signals (same mark as long as the results and explanation are correct). Include the relevant part of your commented code as part of your answer in this section. ii. Write the code to create the correct frequency vector (do not use that provided by the csd function) and report it in your answer. Calculate the number of FFT points (nfft) as the closest integer number that gives a frequency resolution of 46.875 Hz. iii. What is the relation between the number of FFT points and the length of the coherence vector? Why? iv. Using your code and number of fft points computed above, compute and plot the two coherence functions for the white noise signal (i.e. coherence between x_noise.wav and y_l_noise.wav and between x_noise.wav and y_h_noise.wav). v. Comment your results. What can you tell about the noise w[n]? (you can assume that the system is linear and time invariant). Remember that the input signal is white noise. 10%
b) Frequency response: i. Using the H1 estimator and the white noise files, calculate the two frequency response functions (FRFs) of the SIMO digital system. Use the same number of FFT points as in point a) above. Include the relevant part of your commented code as part of your answer in this section. ii. Plot the two FRFs (magnitude and phase) you computed. iii. Comment on the FRFs you obtained. iv. What is the cross-over frequency of the system? The cross-over frequency is defined as the frequency. at which the magnitude of both FRFs is -6dB.
c) Sum of responses: i. Sum the two complex FRFs of the low-pass and high-pass filter and plot the result (magnitude and phase). ii. What are the magnitude and phase at the cross-over frequency and at low and high frequencies? iii. Comment on the practical significance of this result.
d) Impulse responses: i. Compute the impulse responses (IRs) of the system and comment them. Include the relevant part of your commented code as part of your answer in this section. Explain how you obtained the impulse responses. ii. Check if the impulse response is a real-valued or complex-valued signal (you can use the numpy.isreal or numpy.iscomplex Python functions). If the IR is complex valued, what is the amplitude of the imaginary part compared to the real part? Comment if this is in line with your expectations. iii. Calculate the length of the impulse response you obtained and discuss how this relates to the length of your frequency vector and of your filter frequency response vector. iv. Plot the IRs you computed. Include a close-up plot of the first 200 samples of the IRs. v. How is the IR of the low-pass filter different from the IR of the high-pass filter?
e) Response to sinusoidal signals: i. Compute the output/input rms ratios of the three sinusoidal signals (100 Hz, 3 kHz, 7 kHz), for both the low-pass and high-pass section. Note that any noise has been removed from these measurements. Convert the results into dB and report them in a table, together with the magnitude of the FRFs of the system computed in point b) above and evaluated at the same frequencies (for both high-pass and low-pass). ii. Plot these ratios on top of the plot of the magnitude FRF computed at point b). iii. Does the plot show what you expected? Comment on your results.