EEEE4120: Digital Signal Processing
Coursework 2 – Real-time filtering of audio
Department of Electrical and Electronic Engineering
October 2024
1 Introduction
As part of the Digital Signal Processing module (EEEE4120), students will be required to complete two coursework assignments – each assignment will contribute 30 % towards the module assessment. The projects outlined in these documents are based on real-world problems – students will have ample time to research different approaches to the problem, design, and code these approaches, implement and record the results of the implementation, and write a report on all these aspects.
This coursework is an individual assignment – it is expected that students collaborate only on the laboratory aspect of the project but not on the written report.
1.1 Background
In the modern setting, signals are often recorded using analogue transducers (e.g. microphones, magnetic pickups, sensors, etc), amplified, and converted to a digital signal. This allows the signals to be stored and copied on media that will not degrade after use. However, during all the electronic stages outlined, the signal will be susceptible to noise influence, which includes when the signal is transmitted between these states.
The content and sources of this noise is an unknown and engineers will often only receive the output waveform to operate with. The real-time processing of a signal, sound in this case, is a common practice in engineering and understanding what and how to filter correctly, without losing the underlying signal is a useful skill.
In normal circumstances, the development of the process only forms part of an engineer’s duty to communicate the problem, solutions, design, and results concisely are equally as important - for this coursework, this will take the form. of a report document.
1.2 Aims
The project aims to design, implement, and test digital filters to remove noise from the waveforms provided in the .wav clips to remove noise and recover the much of the original signal as possible. For this coursework, students will make use of MATLAB to process the signal, design and test a filter to then implement it in a real-time setting using an STM32 microcontroller during lab sessions (weeks 8,11).
The learning outcomes for Coursework 2 are as follows:
• An introduction to filter design for both post-processing and real-time applications.
• An introduction to the application and testing of digital filtering in a real-time, in-hardware setting.
• Obtain an appreciation of design issues when filtering signals in real-time (i.e. improvement of signal-to-noise versus latency and or CPU load).
Students will have the opportunity to design, test and apply digital filters and other signal-processing techniques, and by the end of the coursework, students should have a better understanding of these techniques.
1.3 Deliverables
Based on the application of the signal processing techniques, students will produce (a) a short report (see section (3.4), (b) a Matlab script (filter design and test offline) and, (c) a main.c script (real-time implementation).
When submitting, students must submit all written Matlab code that they have used to obtain results (including the input parameters). The code should be organised in a single .m file and the file must have no compilation errors. If the students have used the signalAnalyzer or other GUI programs, they should give ALL input parameters used in the report. Students should also submit the .c (main.c only) with all the filter functions used in the STM32 to produce the results.
The report and Matlab files should be written individually, the .c file used to program the STM32 can be the same among the allocated groups on each bench only.
Submission of the coursework will be STRICTLY online using the Moodle page for Digital Signal Processing ONLY (https://moodle.nottingham.ac.uk).
Students should submit their written report as a .pdf file only and do not submit the data files used for submission.
2 Resources
2.1 Laboratory sessions
For successful completion of coursework 2, it is necessary to attend laboratory sessions on weeks 8 and 11. Without these lab allocations, students will not be able to program, apply the filters and acquire data to complete the report. Students should complete their designs by week 8 so they use the time at the laboratory effectively.
2.2 Data files
In order to complete this coursework, students will be provided with two sound files:
• Coursework2_audio.wav: This is a 3-minute tone which is contaminated by random noise. This is the corrupted sound file that you will need to process (waveform. shown in Figure 1). Note the clip is stereo and while working in Matlab, only select a few seconds at random to work on. This will keep processing run time short.
• Coursework2_audio2.wav: This is a piece of music corrupted by noise.
Figure 1: Waveform. excerpt of Coursework2_audio.wav. The audio file is in stereo and therefore has right and left channels.
3 Assignment
For this coursework, the assignment has three parts:
3.1.- Pre-laboratory tasks
(a) To process the provided noisy signals and design, apply and test (in Matlab) a kernel-based filter (non-DFT) of their choosing that can remove the random noise in the signals utilising various filtering techniques. This will require students to use the knowledge gained during the Digital Signal Processing lectures, coursework 1 as well as through their research around the topic. The filters should be designed to operate at the sampling frequency that the STM32 will be operating at.
Students should investigate the impact different processing techniques and or parameters have on the corrupted sound signal and analyse the efficacy of these techniques. More specifically:
• Design a strategy to remove the noise in the signal that can be implemented in a real-time setting. Explain your reasonings.
• Systematically assess the positive (i.e. signal-to-noise ratio) and negative (i.e. signal attenuation) aspects of the applied method. Discuss your results including the mention of less successful attempts.
(b) Design an algorithm to apply the filters in the STM considering that any processing functions should only take one sample in and produce one sample out. For instance: Dac_value(i) = Mov_avg (adc_value(i)); This function can be simulated in Matlab. Students can implement additional libraries but must at least use one filtering function of their own.
3.2.- Programming and applying filters in the STM32
To implement and test the proposed filter solutions in real-time using the STM32 microcontroller during the lab sessions. More specifically:
• Write a function, for the specific type of filter(s) you have designed, in the microcontroller code. An additional laboratory document will be released in week 8 to support you in this task.
• Measure the filter’s frequency response using the signal generator and single-frequency signals at various frequencies (i.e. 100Hz, 1kHz, 5Kh etc ). Record data on the scope as you go along.
• Test the filters using the provided audio data and record the filter output using the oscilloscope. Try to take a relatively long trace (>1s) to facilitate subjective analysis (listening). An additional laboratory document will be released in week 8 to support you in this task.
3.3.- Analysis of the filter(s) performance.
Use all the recorded data to analyse the performance of your implementations in Matlab. More specifically:
• Remove DAC-induced harmonics and resample to the audio sampling frequency (44.1kHz).
• Remove offset and centre the signal amplitude at 0.
• Compare the spectrum of the filtered and unfiltered signals.
• Calculate the approximate transfer function of the microcontroller filter and compare it to the original design.
• Calculate the signal-to-noise ratio before and after the filter.
3.4.- Writing the Report
Assessment of the coursework will take the form of a short report. A key skill of any engineer is the ability to present findings in a concise form. This may include flow diagrams, exemplar waveforms before and after processing steps, and discussion of the observations. The student may want to include more than one strategy and discuss their performance.
This coursework will have a 10-page limit (including ancillary pages, e.g. cover/contents/references pages). Students should use Arial, font size 10 (or an equivalent sized font) on A4-sized pages, with all margins no smaller than 25.4 mm. The text should be sectioned with suitable headings. All figures should contain legible label text, be well presented, be referred to, and be captioned. References should be placed at the end of the report using the IEEE reference guidelines (i.e. square bracketed numbers in the text, reference list at the end with the associated square bracketed numbers) [1]. The report should not contain text or images found in this brief, either in the current or in a modified form.
A report should contain the following sections and discussion topics:
(1) Introduction
A concise introduction should be provided by the student that summarises the nature of the task, what sources of noise were found, what strategies were less and more successful, how it was implemented and what the results were.
(2)Review of methods
This section should include a brief literature review of the signal processing methods used as part of the project as well as other suitable methods.
(3) Methodology
This is the major section of the report and should describe the following:
• Description of the methodology along with a justification for using it.
• The implementation of their chosen algorithmic solutions in MATLAB and the STM32 (filter function only). These should be presented as flow diagrams and not code.
(4) Results
This section should present all the information required to demonstrate that the tasks were completed and should include:
• Graphical representations (figures) of the results obtained from the different tasks.
• A discussion/analysis of the obtained results and the efficacy of the solutions presented.
(5)Conclusion
The report conclusions should contain:
• A summary of the work.
• Mayor outcomes and problems.
• A brief reflection of the work and potential next steps.
References
[1] “IEEE Citation Guidelines.” https://ieee-dataport.org/sites/default/files/analysis/27/IEEE Citation Guidelines.pdf, Oct. 2022.
[2] “Read and Write Audio Files - MATLAB & Simulink - MathWorks United Kingdom.” https://uk.mathworks.com/help/matlab/import_export/read-and-get-information-aboutaudio-
files.html#d120e12602, Oct. 2022.
[3] “1-D median filtering - MATLAB medfilt1 - MathWorks United Kingdom.” https://uk.mathworks.com/help/signal/ref/medfilt1.html, Oct. 2022.
[4] “Using Signal Analyzer App - MATLAB & Simulink - MathWorks United Kingdom.” https://uk.mathworks.com/help/signal/ug/using-signal-analyzer-app.html, Oct. 2022.
[5] “Introduction to Filter Designer - MATLAB & Simulink Example - MathWorks United Kingdom.” https://uk.mathworks.com/help/signal/examples/introduction-to-filter-designer.html, Oct. 2022.