Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

JEIA2002: Audio and Signal Processing Assignment

What the assignment assesses

The assignment assesses your ability to :

-      connect different relevant disciplines, including acoustics, mathematics, signal processing and computing, and to integrate and synthesize this knowledge and understanding;

-      understand the fundamental principles of signal processing covered in this module;

-      apply appropriate signal processing techniques to analyse and process audio signals to achieve desired outcomes and to identify systems;

-      argue the advantages and limitations of different signal processing techniques in a given context;

-      critically evaluate the results;

-      study independently.

What is expected of a good submission

High marks will only be awarded if you

-     can demonstrate that you do understand the fundamental concepts behind the signal processing techniques involved;

-     are able to implement the techniques;

-      present the results using the appropriate plots, with correct axis labels, units, etc.;

-     demonstrate the ability to critically evaluate your results;

-     show an appreciation for the advantages, disadvantages and limits of different signal; analysis techniques;

-      produce a document with appropriate format, structure, and demonstrate a rigorous use of technical language.

It is important for each of you to work on this assignment individually. Do not share code or answers to questions with fellow students! Do not quote or paraphrase other sources, unless appropriately   acknowledged. Make sure all your answers demonstrate your understanding of the concepts involved.

INSTRUCTIONS

This assignment counts as 50% of the module mark.

Please respond to all questions.

You can find all relevant files on Blackboard in the Assignments folder.

Provide  your  answers,  together  with  results  and  relevant  comments,  observations  as  well  as justifications for methods used and indicate how your results answer the questions (for example, don’t just submit the plots you obtained without an explanation of their relevance). You must include any calculations and also listings of Python programs you may have used in your scripts. Please document the scripts (using # or """) and remember that we wish to follow your thought processes in arriving at your conclusions. Please provide all results (numbers and graphs) in your answer sheet.

Appendix 1 of this documents contains a list of Python packages and functions that you may find useful for this assignment.

All wav files required for this assignment are contained in the zip file Audio_files_for_assignment that can be downloaded from Blackboard.

Please submit your answers via Blackboard Assignments. Please type your answers, using a text editor software package such as Word, Latex, LyX, or similar and submit a single pdf file with your responses and the listing of your Python scripts. Explain the steps you take (methods and algorithms) to arrive at your answers just listing the Python scripts is not sufficient. The structure and main elements of your code should be clearly explained in the main text of your report, so that it should be possible for the marker to understand what you have done and how you obtained the results without looking at your code.If you find a question unclear, or believe information is missing, please make necessary assumptions, and justify these.

The technical writing and the overall presentation style are assessed and contribute towards 5% of the final mark for this assignment.

Marks

Question 1

25%

Question 2

32%

Question 3

38%

Presentation style

5%

Total

100%

Question 1

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.                                                        3%

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.          7%

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.            7%

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. 4%

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'. 4%

Total [25%]

Question 2

                                          Sound source

y

θ

Mic .1

d

Mic .2

x

n(t)

y2 (t)

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). 6%

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. 5%

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] 8%

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. 7%

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. 6%

Total [32%]

Question 3

w [n]

Low-pass

filter

x [n]

High-pass

filter

Figure 2: diagram of digital the cross-over network of a loudspeaker

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

Output      file      name

Low-pass

Output    file     name

High-pass

White noise

x_noise.wav

y_l_noise.wav

y_h _noise.wav

100 Hz sinusoid

x_sin100.wav

y_l _sin100.wav

y_h _sin100.wav

3 kHz sinusoid

x_sin3k.wav

y_l _sin3k.wav

y_h _sin3k.wav

7 kHz sinusoid

x_sin7k.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 y 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. 9%

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. 4%

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? 8%

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. 7%

Appendix 1

List of Useful packages and functions

numpy

 

numpy.fft

Library of FFT function (includes fft, ifft, rfft, irfft)

scipy

 

scipy.signal.get_window

Creates  a  window,  useful  for  spectrogram,  periodogram, auto- and cross-spectral calculation

scipy.io.wavfile.read

For reading wav files (refer to Tutorial 1 for its use)

matplotlib

 

matplotlib.pyplot.pcolormesh

For colour map plots, useful for spectrogram plots

Appendix 2

Design a band-stop filter

b, a = signal.butter(6, np.array([f1, f2]), btype='bandstop',fs=fs)

b and a are the filter coefficient vectors

N is the filter order – for question 2, set this parameter to 6

btype=’bandstop  indicates that the filter is a band-stop filter

fs is the sampling frequency

f1 and f2 are the lower and upper edge frequencies that define the stop band of the filter Applying a digital filter to a signal x

x_filtered = scipy.signal.filtfilt(b, a, x)

b and a are the filter coefficient that you calculated with the function   scipy.signal.butter(6, np.array([f1, f2]), btype='bandstop',fs=fs) above

x is the signal to be filtered

x_filtered is the filtered signal

Appendix 3

Calculate and plot the cross-correlation between two signals x and y (of same length)

R12=scipy.signal.correlate(x1, x2) #find cross-correlation between x1 and x2

lags=np.arange(-len(x1)+1,len(x1)) #find array of values of lags