Design and Evaluation of a MATLAB-Based Audio Noise-Removal System
Summary
A recorded audio signal has been contaminated by high-frequency noise. Working in groups, students must use MATLAB to analyze the signal, identify the unwanted frequency components, design and apply an appropriate digital filter, and evaluate how effectively the original audio is recovered.
This activity requires students to use MATLAB to develop an audio noise-removal system. Students will begin with an audio recording, introduce or identify high-frequency noise, and examine the signal in both the time and frequency domains. They will then design and apply an FIR low-pass filter to reduce the unwanted noise. The original, noisy and filtered signals will be compared using graphical analysis, frequency spectra and audio playback.
Through this activity, students will develop practical skills in MATLAB programming, digital signal processing, FFT analysis, FIR filter design, data visualization and interpretation of results. They will also strengthen their problem-solving, critical-thinking, teamwork and technical communication skills.
Key words/index terms: MATLAB, digital signal processing, DSP, audio processing, noise removal, FFT, frequency analysis, FIR filter, low-pass filter, signal analysis, data visualization and problem-based learning.
Learning Goals
The primary goal of this activity is to help students understand how digital signal-processing techniques can be applied to a practical audio noise-removal problem. Students will learn how noise affects an audio signal, how signals can be represented in the time and frequency domains, and how frequency analysis can be used to identify unwanted signal components. They will also learn the principles of FIR low-pass filter design, including cutoff frequency, filter order and windowing methods.
MATLAB is used to import or record audio, introduce noise, display signal waveforms, calculate and plot frequency spectra using the Fast Fourier Transform (FFT), design and apply an FIR filter, and play the audio before and after filtering. MATLAB allows students to connect DSP theory with audible and graphical results, making abstract concepts such as frequency content, attenuation and filter performance easier to understand.
By completing the activity, students should be able to:
* Analyse audio signals in the time and frequency domains.
* Use the FFT to identify unwanted frequency components.
* Select appropriate specifications for an FIR low-pass filter.
* Design and apply an FIR filter using MATLAB.
* Compare different windowing methods and explain their effect on filter performance.
* Evaluate the effectiveness of noise removal using plots, audio playback and appropriate performance measures.
* Modify and troubleshoot MATLAB code to improve the filtering results.
The activity develops higher-order thinking skills by requiring students to investigate a problem, interpret data, select filter parameters, compare possible solutions and justify their final design. Students must combine theoretical knowledge, computational results and observations from audio playback to reach evidence-based conclusions.
The activity also develops teamwork, technical communication and report-writing skills. Students may work collaboratively to develop and test their solution, document their MATLAB procedure and results, and present a short oral explanation of their filter design, findings and recommendations.
Context for Use
This activity is designed for students in diploma or undergraduate electrical engineering, electronics engineering, telecommunications, computer engineering, or related engineering-technology programmes. It is most appropriate for a digital signal processing, signals and systems, or MATLAB laboratory course. The activity may be completed individually or in pairs and is suitable for classes of approximately 12–30 students, provided each student or pair has access to a computer with MATLAB and the Signal Processing Toolbox.
The activity is intended as a structured laboratory exercise or workshop lasting approximately three hours. Additional time may be provided for students to complete their analysis and prepare a brief report or presentation. It is best positioned after students have been introduced to discrete-time signals, sampling, frequency, noise, Fourier analysis and basic digital-filter concepts.
Before beginning the activity, students should be able to:
* Navigate the MATLAB environment and use the Command Window, Workspace and Live Editor or Script Editor.
* Create, save, edit and run MATLAB scripts.
* Define variables, vectors and arrays.
* Use basic mathematical and logical operators.
* Import or read an audio file into MATLAB.
* Use standard plotting commands and appropriately label graphs.
* Understand basic programming structures such as conditional statements and loops.
* Interpret time-domain and frequency-domain representations of signals.
* Explain the purpose of sampling, the FFT and digital filtering.
During the activity, the instructor may provide partially completed code or demonstrations for students with limited MATLAB experience. More experienced students can be challenged to select their own filter specifications, compare different FIR windowing methods and evaluate filter performance quantitatively. The activity can therefore be adapted for introductory or advanced classes, shorter workshops, remote instruction, or longer group projects. It may also be modified to use other types of signals, noise sources or filtering techniques.
Description and Teaching Materials
Students will work individually or in pairs to develop an audio noise-removal system using MATLAB. The activity begins with a short introduction to audio signals, noise, frequency analysis and FIR filtering. Students are then provided with a clean audio recording, which they import into MATLAB and examine in the time domain. They listen to the recording and use the Fast Fourier Transform (FFT) to display and interpret its frequency spectrum.
A high-frequency noise signal is then added to the original recording. Students compare the clean and noisy signals through audio playback, time-domain plots and frequency spectra. Based on their analysis, they identify the unwanted frequency components and select an appropriate cutoff frequency for an FIR low-pass filter.
Students design and apply the filter using MATLAB and then compare the original, noisy and filtered signals. They may adjust the filter order, cutoff frequency and windowing method to improve the quality of the recovered audio. Each group must justify its selected filter specifications and explain how effectively the filter removed the noise without significantly affecting the original audio.
MATLAB is used to import and play audio, generate noise, plot signals, calculate frequency spectra, design the FIR filter and process the noisy signal. Although the activity could be completed using Python or GNU Octave, MATLAB is selected because it provides an integrated environment for programming, signal processing, visualization and audio playback. This allows students to change filter parameters and immediately see and hear the effect on the signal.
The materials required are:
* A computer with MATLAB and the Signal Processing Toolbox.
* A short copyright-free WAV audio recording.
* Headphones or speakers for audio playback.
* A student activity sheet containing the problem, instructions and required analysis.
* A MATLAB starter script with partially completed sections.
* An instructor solution script for demonstration and troubleshooting.
* A student results sheet or laboratory report template.
* An assessment rubric for evaluating the MATLAB code, analysis, filter design and interpretation of results.
Student Activity Guide (Acrobat (PDF) 187kB Sep28 26)
MATLAB Starter Script (Microsoft Word 2007 (.docx) 40kB Sep28 26)
Teaching Notes and Tips
Digital Voice Recording
A voice signal is continuous in its natural form. When it is recorded in MATLAB, the microphone converts the sound into an electrical signal, and the computer converts that signal into a sequence of digital samples. Each sample represents the amplitude of the voice at a particular instant.
The sampling frequency, \(F_s\), is the number of samples recorded per second. For example, a sampling frequency of 44,100 Hz means that 44,100 samples are collected every second. The total number of samples is related to the recording duration by:
\[
N = F_s \times T
\]
where \(N\) is the number of samples and \(T\) is the recording duration in seconds.
The Nyquist frequency is half the sampling frequency:
\[
F_N = \frac{F_s}{2}
\]
The recorded signal should not contain frequencies above the Nyquist frequency, or aliasing may occur.
Time-Domain Analysis
The time-domain waveform shows how the amplitude of the voice signal changes with time. Sections of speech generally contain varying amplitudes, while pauses or silence produce values closer to zero.
A time vector can be created using:
\[
t = \frac{0:N-1}{F_s}
\]
The time vector and voice signal must contain the same number of values. The horizontal axis of the graph represents time in seconds, while the vertical axis represents signal amplitude.
The time-domain waveform is useful for observing the duration, amplitude and general structure of the recording. However, it does not clearly show the individual frequencies contained in the voice signal.
Frequency-Domain Analysis
A voice recording contains several frequency components occurring simultaneously. The Fast Fourier Transform converts the signal from the time domain into the frequency domain.
The frequency spectrum shows the magnitude of the frequency components contained in the voice recording. A single-sided spectrum is normally used for a real-valued audio signal because the negative-frequency portion of the FFT mirrors the positive-frequency portion.
The frequency axis is determined using the sampling frequency and the number of samples. Students should distinguish among:
- Sampling frequency: the number of samples recorded per second.
- Signal frequency: the rate at which a particular signal component repeats.
- FFT index: the position of a value within the FFT output.
- Nyquist frequency: the highest frequency that can be represented correctly.
Most speech energy is concentrated in the lower part of the audible-frequency range, although the exact spectrum will vary with the speaker, words spoken, microphone and recording environment.
Adding Noise
The unwanted noise used in the activity is generated as a sinusoidal signal:
\[
n(t) = A\sin(2\pi f_nt)
\]
where \(A\) is the noise amplitude and \(f_n\) is the noise frequency.
The noisy voice signal is produced by adding the generated noise to the original voice recording:
\[
x_{\text{noisy}}(t) = x_{\text{voice}}(t) + n(t)
\]
The noise should create a noticeable peak in the frequency spectrum. Its frequency should be below the Nyquist frequency but above most of the useful voice-frequency content so that it can be reduced using a low-pass filter.
The noise amplitude must be selected carefully. If it is too small, students may not clearly observe its effect. If it is too large, it may mask the voice or cause clipping.
FIR Low-Pass Filter
A low-pass filter allows frequencies below its cutoff region to pass while attenuating higher frequencies. In this activity, the objective is to preserve the useful voice frequencies while reducing the added high-frequency noise.
The main filter-design terms are:
- Passband: The frequency range that the filter allows to pass with minimal reduction.
- Stopband: The frequency range that the filter significantly attenuates.
- Cutoff frequency: The frequency that defines the approximate boundary between the passed and attenuated components.
- Transition band: The range over which the filter changes from the passband to the stopband.
- Filter order: A value related to the number of coefficients used by the FIR filter.
The cutoff frequency should be selected by examining the frequency spectrum. It should be high enough to retain the important voice components but low enough to reduce the added noise.
Filter Order and Windowing
Increasing the FIR filter order generally produces a narrower transition band and sharper separation between passed and attenuated frequencies. However, a higher order also increases computation and introduces a greater delay.
Windowing is used when determining the FIR filter coefficients. Different windows produce different transition widths and stopband attenuation.
- A rectangular window generally provides a narrow transition but produces larger sidelobes.
- A Hamming window reduces sidelobes and provides a useful balance between transition width and attenuation.
- A Blackman window provides greater sidelobe attenuation but normally produces a wider transition region.
There is no single filter configuration that is best for every voice signal. Students must compare the effects of the cutoff frequency, filter order and window type.
Evaluating the Filter
The effectiveness of the filter should be evaluated using more than audio playback. Students should compare:
- The original, noisy and filtered time-domain waveforms.
- The original, noisy and filtered frequency spectra.
- The magnitude of the noise-frequency component before and after filtering.
- The frequency response of the FIR filter.
- The audible clarity of the filtered voice.
- Any distortion or loss of useful voice information.
A successful filter should noticeably reduce the unwanted noise while preserving the intelligibility and important characteristics of the original voice recording.
A low-pass filter will not be effective if the unwanted noise occupies the same frequency range as the useful voice signal. In such cases, a notch, band-stop or adaptive filter may be more appropriate.
Tips for Instructors
- Test the microphone, MATLAB recording commands and Signal Processing Toolbox before the class.
- Ask students to record the same five- to ten-second phrase so that their results can be compared more easily.
- Ensure that MATLAB has permission to access each computer's microphone.
- Remind students to retain an unchanged copy of their original voice recording.
- Select or recommend a noise frequency that is below the Nyquist frequency but above most of the useful voice-frequency content.
- Provide starter code for recording and retrieving the voice signal if students have limited MATLAB experience.
- Ask students to reduce the playback volume before listening to the noisy signal.
- Encourage the use of headphones at a low and comfortable volume.
- Watch for mismatched dimensions between the voice and generated noise signals.
- Check that students create a time vector with the same number of samples as the recorded voice.
- Reinforce the difference between sampling frequency, signal frequency, FFT index and Nyquist frequency.
- Clarify whether the MATLAB filter-design command expects cutoff frequency in hertz or as a normalized value.
- Ask students to change only one filter parameter at a time so that its effect can be identified.
- Require students to test at least three filter configurations using the same noisy voice signal.
- Require consistent axis limits when students compare the original, noisy and filtered spectra.
- Use guiding questions rather than immediately correcting students' code:
- What frequency does the spectral peak represent?
- Is the noise frequency below the Nyquist frequency?
- Which part of the spectrum contains the useful voice information?
- What changed when the filter order was increased?
- Is the selected cutoff frequency removing useful voice content?
- Does the graphical evidence support what you hear?
- Place greater assessment weight on interpretation, filter justification and comparison of results than on students obtaining identical filter values.
Assessment
Student achievement is assessed through the completed MATLAB script, graphical results, filter-comparison table, analysis questions and conclusion. Students demonstrate that they have met the activity goals when they can:
- Record and process their own voice successfully in MATLAB.
- Produce correctly labelled time- and frequency-domain plots.
- Use the FFT to identify the useful voice range and added noise frequency.
- Design and test at least three FIR low-pass filter configurations.
- Select and justify appropriate filter parameters.
- Compare the original, noisy and filtered signals using graphical and audible evidence.
- Explain the effectiveness and limitations of the selected filter.
- Submit organized, clearly commented MATLAB code that runs without unresolved errors.
Assessment should emphasize correct analysis, interpretation and justification rather than requiring all students to obtain identical filter values.
References and Resources
- MathWorks – Record and Play Audio
https://www.mathworks.com/help/matlab/import_export/record-and-play-audio.html
This resource demonstrates how to record microphone input, play the recording and store the recorded voice as numerical data in MATLAB. It directly supports the voice-recording stage of the activity.
- MathWorks – `audiorecorder`
https://www.mathworks.com/help/matlab/ref/audiorecorder.html
This page explains how to create an audio-recorder object and define the sampling frequency, bit depth and number of recording channels. It is useful when students are setting up their recording parameters.
- MathWorks – `getaudiodata`
https://www.mathworks.com/help/matlab/ref/audiorecorder.getaudiodata.html
This documentation explains how to transfer the recorded voice from an `audiorecorder` object into a numerical array for plotting, FFT analysis and filtering.
- MathWorks – Fast Fourier Transform
https://www.mathworks.com/help/matlab/ref/fft.html
This page explains the MATLAB `fft` function and includes an example of converting an FFT result into a single-sided amplitude spectrum. It supports the frequency-analysis section of the activity.
- MathWorks – Basic Spectral Analysis
https://www.mathworks.com/help/matlab/math/basic-spectral-analysis.html
This resource demonstrates how time-domain data can be analysed in the frequency domain. It assists students with constructing and interpreting the frequency spectrum of their voice and noisy signals.
- MathWorks – FIR Filter Design
https://www.mathworks.com/help/signal/ug/fir-filter-design.html
This resource explains FIR-filter design, filter order, normalized cutoff frequency, windowing and linear-phase behaviour. It supports the design and comparison of the low-pass filters used in the activity.
- MathWorks – `fir1` Window-Based FIR Filter Design
https://www.mathworks.com/help/signal/ref/fir1.html
This page provides the syntax and examples for designing low-pass, high-pass, band-pass and band-stop FIR filters using different windows. Students can use it when completing the filter-design section of the starter script.
- MathWorks – `freqz` Frequency Response of a Digital Filter
https://www.mathworks.com/help/signal/ref/freqz.html
This resource explains how to calculate and display the magnitude and phase responses of a digital filter. It supports students in verifying whether their selected filter attenuates the added noise frequency.
- MathWorks – Filtering Data with Signal Processing Toolbox
https://www.mathworks.com/help/signal/ug/filtering-data-with-signal-processing-toolbox.html
This example demonstrates how to design and apply an FIR low-pass filter to a noisy signal. It is directly relevant to the noise-removal and filter-evaluation stages of the activity.
- MathWorks – `audiowrite`
https://www.mathworks.com/help/matlab/ref/audiowrite.html
This documentation explains how to save the original and filtered voice signals as audio files for submission and comparison.
Oppenheim, A. V., and Schafer, R. W. (2010). Discrete-Time Signal Processing (3rd ed.). Pearson.
This text provides supporting theory on discrete-time signals, sampling, Fourier analysis, FIR-filter design and digital-filter frequency response. It may be used by instructors or students who require a more detailed theoretical explanation of the concepts applied in the activity.