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

EE320 Assignment 1 — Hands-Free Telephony

1    Purpose

This assignment should give you some hands-on experience with designing and implementing discrete time (“digi- tal”) systems, and apply them to ltering audio signals.

The assignment will contribute 14% to your overall mark in EE320.

2    Completion, Submission, and Assessment

Please submit your assignment via MyPlace by Monday 6/2/2023, noon. Your submission should include

1.  an m-file containing your implementations and generating any plots;

2.  a brief document containing your answers and any supporting graphs; this does not have to be a formal report answers should be brief, but justihcations  are  important, and any supporting evidence  (matlab plots, calculations / references to material covered in the lectures) should be included.

Scans or photographs of your handwritten workings are perfectly acceptable.

You can receive assistance with your assignment during a number of surgeries which we will hold during December 2022 and January 2023 — probably a mix between being the laboratory and online.  Details will be announced separately via MyPlace.

We will assess your solution based on the correctness of your implementations, and the justifications that you have provided.  We may hold interviews to assess your understanding and to ensure that the submitted work is yours; in this case an interview will contribute to or overwrite the assessment of your submission.  Therefore, you should only submit what is your own work, and be sure that you understand its purpose.

If you wish to work on this problem during the University holidays and do not have access to Matlab, you can consider the free Matlab clone Octave (https://www.gnu.org/software/octave/) which can do almost everything possibly except for playing audio les.

Important:  this exercise involves audio les.  If you listen to any audio les, particularly when using headphone, please ensure that you select a low volume, in case the signal amplitude is high!

3    Problem

A telephone connection between a far-end speaker Bob and a near-end speaker Prof Stewart operates hands-free at the near-end. Thus, Prof Stewart hears Bob’s voice over a loudspeaker, and speaks into a free-standing microphone on his desk.  This microphone picks up not only (i) Prof Stewart’s voice, but also (ii) an acoustic echo of Bob’s voice and (iii) noise. This situation is illustrated in Fig. 1.

Of the superposition of signals being passed back to the far-end, the acoustic echo is particularly disturbing to Bob. As a result, early hands-free telephone systems only permitted half-duplex, i.e. the line is only ever open in one direction, such that only either Bob or Professor Stewart can talk at any time, and acoustic feedback will not occur. The aim of this assignment is to implement a simple (although not very high-fidelity) full-duplex solution, where both speakers can be active at the same time.

 

北 [n]

y [n]

Fig.  1:  Hands-free telephone scenario with far-end speaker signal x[n],  and near-end microphone signal y[n].

Your assignment challenge has two parts:  we want to rst suppress the acoustic echo, and secondly design a system that can suppress the additional noise. We will do this by designing appropriate lters g[n], h[n] and a[n] as shown in Fig. 1, which will will operate on the far- and near-end signals. The subscript ( ·)f  means “filtered” .

If you save all the assignment les into your working directory, then you can obtain the far-end signal x[n] via x =  audioread(’FarEndSignal .wav’);

This signal is sampled at fs  = 8kHz, and you can listen to the le if you execute

sound(x,8000);

Without any further processing of x[n], you can obtain the near-end signal y[n] as

xf = x;                                       % no  filtering

[y,N] = room(xf,StudRegNum);

where StudRegNum is your student registration number. The return parameter N will be used later.

4    Specific Questions

4.1    Comb Filter Introductory Example

To start, a system h1 [n] has a transfer function H1 (z) = 1 + z 1 .

Q1.1:   Using pen & paper, calculate the squared magnitude response of this system.

Q1.2:   A new system H2 (z) = H1 (zN ), with N ∈ N (given as a return parameter N from the function call room()), arises through expansion of h1 [n].   Its impulse response h2 [n] is obtained through  expansion  from h1 [n]: h2 [n] = h1 [Nn], i.e. h2 [n] contains the coefficients of h1 [n], but each separated by (N − 1) zero coefficients:

h1 =  [1  1];

h2 = zeros(1,N*length(h1));

h2(1:N:end)  = h1;

Using pen & paper, what is the squared magnitude response of the expanded system h2 [n]? Q1.3:   How do the magnitude responses of h1 [n] and h2 [n] related to each other?

4.2    Comb Filter Design

Q2.1:   Design a lter h3 [n] and its N-fold expansion h[n] = h3 [nN].

h3 =  fir1(23,0 .4);

h = zeros(1,N*length(h3));

h(1:N:end)  = h3;

Plot its impulse and magnitude responses.

Q2.2:   Create a lter g3 [n] = (−1)n h3 [n] and its N-fold expansion g[n] = g3 [nN]. Plots its impulse and magnitude responses. How do the magnitude responses of h[n] and g[n] relate to each other?

4.3    Acoustic Echo Cancellation Implementation

Q3.1:   Listen to the near-end signal y[n] without any processing. What do you hear?

By implementing the overall system according to Fig. 1 including the systems h[n] and g[n] as defined in Q2 (you may use Matlab’s filter() command), what does yf [n] sound like?

Q3.2:   If so, why is the echo of Bob reduced?  Also, in case Prof Stewart’s voice is distorted, why could this be the case?

Q3.3:   Implement the lter without using any of Matlab’s provided functions. How can you minimise the compu- tational complexity of your implementation?

4.4    Interference Frequency Analysis

Estimate the frequency f0  or normalised angular frequency 0  = 2πf0 /fs  of the interferer by

Q4.1:   inspecting the time domain waveform y[n] by nding a segment where the signal is otherwise quiet (i.e. in- terference dominates);

Q4.2:   evaluating the discrete-time Fourier transform

fs =  8000;

f =  (0:length(y)-1)/length(y)*fs

plot(f,abs(fft(y)));

xlabel(’frequency  f  /  [Hz]’);

ylabel(’magnitude’);

%  sampling  frequency  in Hertz

;     %  frequency  scale

% discrete Fourier transform  of x

%  label  axes

Provide plots for the time domain segment in Q4.1 and the magnitude spectrum in Q4.2.

4.5    Interference Suppression

To suppress the sinusoidal interference, we want to utilise an IIR notch lter with transfer function

(1 ej0 z 1 )(1 e j0 z 1 ) 

Q(z) =

to operate on yf [n] and generate an output y[n]. For implementations and analysis below, please assume a value ρ = 0.9.

Q5.1:   Determine the denominator and numerator coecients ai  and bi , i = 0, 1, 2 when written as

b0 + b1 z 1 + b2 z 2 Q(z) =

;

and plot the magnitude response |H2 (ej)| in Matlab;

Q5.2:   with the Matlab coefficient vectors a and b containing the coefficients determined in (2), filter your music signal y with the IIR notch lter, and listen to it:

yff =  filter(b,a,yf);

sound(yff,8000);

% yf  is the  input  of  filter  q

% play back the  filtered  signal

Is the sinusoidal interference suppressed in yff?

Q5.3:   Can you swap the lters h[n] and q[n] without affecting the overall performance? Is so, why?

Q5.4:   Could you attenuate the interference without using q[n], and without further deteriorating Prof Stewart’s voice?

S. Weiss, December 2, 2022