EC244_Assigment2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Electronics and Communications Department

Digital Signal Processing Lab (EC244)

Marked Assignment 2
Digital Resampling

Submission Deadline 5pm 27th March 2021

Instructions
This assignment forms the second part of the marked assessment process for Digital Signal Processing Lab course EC244. The
completed solution for this assignment must be submitted via the Google form link by the deadline above. All solution reports
should be in the form of a word document. In particular, submissions should be made up of two elements:

1. A report of no more than 3 pages (excluding appendix) describing your understanding of the problem and provide a
detailed description of your proposed solutions. All figures included should be fully and correctly labelled. If the assignment
asks for comments on issues then these should be made in this section. A copy of all MATLAB code should be included in
the appendix.
2. MATLAB code used in the exercise should be separately submitted as a single m-file entitled: audio_resample.m

NOTE: ALL SUBMISSIONS MUST BE THE STUDENTS OWN WORK. SUBMISSIONS ARE AUTOMATICALLY CHECKED
USING ANTI-PLAGARISM SOFTWARE. PLAGARISM AND COPYING WILL BE SUBJECT TO SEVERE PENALTY.

Digital resampling
Introduction
Digital signals and images are often provided with standard sampling rates (audio) or pixel sizes (images). For example, high quality
music is usually sampled at 22 kHz, 32 kHz or 44 kHz while for telephone quality speech it is sufficient to sample at 8 kHz. Low
resolution computer images are often digitized to VGA resolution (640 x 480) while digital camera images for an 8 Megapixel camera
are: 3264 x 2448.

Moving from one sampling rate to another in audio signals, or changing the resolution of an image is called digital resampling and a
very useful tool in DSP.

This lab will look at generating an audio resampling function that can resample signals from one sampling rate to another.

Note: while MATLAB has a set of specific routines for re-sampling, these may NOT be used for the purposes of this lab.

Changing the sampling rate


If the two sampling frequencies are integer valued then re-sampling can be achieved by the following steps:

1. Up sampling: An up sampled version of the signal (with aliasing) can be generated by interleaving the original samples
with the appropriate number of 0s.

2. Anti-aliasing filter: to remove the aliasing it is necessary to low pass filter the up-sampled signal at the appropriate rate.

3. Down sampling: to reduce the sampling rate it is now only necessary to retain the appropriate samples.

Low pass filter design


You will need to design an appropriate digital low pass filter. The ideal digital anti-aliasing filter is a digital sinc function of the
appropriate bandwidth. In the exercise below you may approximate this with an appropriately truncated sinc function or you may

1 EC244
use MATLAB’s filter design function call FIR1. The output of FIR1 is the filter’s impulse response function which can then be
convolved with the input signal. Care must be taken in selecting a suitable filter length and the correct cut-off frequency.

NOTE: The frequency response function for a filter can be plotted using MATLAB’s freqz function.

Assignment
1) Audio re-sampling function
Write a MATLAB function called audio_resample.m that has the following syntax and functionality:

function output = audio_resample(input,input_rate,output_rate);


%
% Input values:
% input : the input signal
% input_rate : the sampling frequency of the input signal
% output_rate : the sampling frequency of the output signal
%
% Output variables:
% output : the input signal resampled to the output
% rate
%
% Admissible sampling rates are restricted to: 8kHz, 15kHz, 22kHz, 32kHz
% or 44kHz
%
% If an incorrect rate is given the function should indicate an error has
% occurred at then exit
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Describe your implementation in your report and include a plot of the anti-aliasing filter frequency response. Explain any design
decisions made.

2) Audio re-sampling test


Illustrate your function from part (1) using the audio file "music_signal.wav," sampled at 44 kHz which can be found in
the Resources directory. Show the effect of the key steps of the implementation when resampling the signal to 32 kHz.
Your report should contain frequency and time plots to illustrate the key steps in the process (power spectra can be plotted
using MATLAB’s pwelch function).

3) Filtering and resampling


Use your code from part (1) to generate a filtered version of the output of part (2) filtered using the impulse response function of
an intercom given in the file IntercomIR.wav, which is sampled at 22 kHz. The output signal should still be sampled at 32
kHz. Your report should indicate how you use the code from part (1) and include appropriate frequency and time plots to
illustrate the process.

Marking Scheme
Marks will be awarded for the following components of the work:

Report
1. Overall presentation ………………….. 10%
2. Problem understanding……………….. 40%
3. Results and Conclusions……………… 20%

MATLAB audio_resample.m code

1. Quality of proposed solutions (including correct execution)…. 20%


2. Clarity and presentation of code (layout, comments, etc.)… 10%

Submission checklist
Please make sure that your submission contains the following:

1. Assignment report (not more than 3 pages excluding appendix


in word format)
2. MATLAB code: audio_resample.m
2 EC244

You might also like