0% found this document useful (0 votes)
20 views

Lab 4

This document discusses applying different types of filters (low-pass, high-pass, band-pass, notch) to audio signals using MATLAB. It provides examples of using these filters on music clips to attenuate certain frequencies and isolate instruments. The lab investigates the effect of filters on time-domain and frequency-domain plots of audio.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Lab 4

This document discusses applying different types of filters (low-pass, high-pass, band-pass, notch) to audio signals using MATLAB. It provides examples of using these filters on music clips to attenuate certain frequencies and isolate instruments. The lab investigates the effect of filters on time-domain and frequency-domain plots of audio.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CSC567

Lab 4b: 1 Dimensional Filter

Name: SITI SARAH NAZIRAH BINTI MAT RAHIM


Student ID: 2021856396

This lab investigates the effect of high-pass, low-pass, band-pass, and band-stop (notch)
filters on audio. When filters are applied to audio signals, certain frequencies of sound are
attenuated. Music professionals use more complicated filters and equalizers to change the
balance of instruments or to eliminate an unwanted sound. We will apply simpler filters to
music using MATLAB.

4.1 Preparation
Download the following files from the Ufuture website and save it into your MATLAB file
directory:

• timeDomainPlot.m
• frequencyDomainPlot.m
• lab_annoying.wav
• lab_bandpass.wav.

If you want to experiment with filters on your own music, convert the song(s) to WAV format
and clip them to 30 seconds or less. (Longer songs can work, up to a limit, but will take too
long for the purposes of this lab).
Launch MATLAB and change your current directory to the folder containing the m-files and
the music files. Type the following lines into the command prompt:
global player
global stopped
timeDomainPlot('lab_bandpass.wav')

Output (graph):

1
You should hear music playing and see a time-domain plot of the sound’s amplitude.

Now view the frequency-domain plot for the same music clip:

frequencyDomainPlot('lab_bandpass.wav')

Output (graph):

4.2 Syntax

Open and examine files timeDomainPlot.m and frequencyDomainPlot.m

• timeDomainPlot(filename) shows a time-domain plot of the sound’s amplitude.

• timeDomainPlot(filename, filter_type, w_cutoff) shows a time-domain


plot of the sound’s amplitude, with a filter applied to the sound.

• frequencyDomainPlot(filename) shows a frequency-domain plot of the sound’s


amplitude.

• frequencyDomainPlot(filename, filter_type, w_cutoff) shows a


frequency-domain plot of the sound’s amplitude, with a filter applied to the sound.

2
Possible filter types are ‘low’, ‘high’, ‘bandpass, and ‘stop’. If you’re using a low-
pass or high-pass filter, w_cutoff is a scalar; if you’re using a bandpass or stop-band filter,
w_cutoff is a two-element array in the form [w1 w2].

Note: To stop a song early, hit the ‘Stop’ button on the lower-left corner of the plot. If you
close the plot in any other way, you must kill the script from the command prompt with CTRL+C,
and pause the audio with pause(player). Also, if you do not have the global variables
player and stopped declared, the ‘Stop’ button won’t work.

4.3 Low-pass filters

Run the frequencyDomainPlot script for the music clip ‘lab_annoying.wav’. Note the
sound and the frequency range. Use a low-pass filter to completely eliminate the annoying
high-pitched sound. (This will take a few iterations of guess-and-check.) What value of
w_cutoff did you use?
Example:
frequencyDomainPlot('lab_annoying.wav', 'low', 500);

Output (graph):

3
4.4 High-pass filters
Run the frequencyDomainPlot script for the music clip ‘lab_annoying.wav’, with a
high-pass filter using the same w_cutoff. What happens?
Example:
frequencyDomainPlot('lab_annoying.wav', 'high', 1000);

Output (graph):

4.5 Band-pass filters


Run the frequencyDomainPlot script for the music clip ‘lab bandpass.wav’, Then use
a bandpass filter to isolate the midrange instrument. (Remember, you need a two-element
array for w_cutoff now. What values work well?

(Warning: Do not go below w_1 = 150)


Example:
frequencyDomainPlot('lab_bandpass.wav', 'bandpass', [1000 2000]);
Output (graph):

4
4.6 Notch/band-stop filters

Run the frequencyDomainPlot script for the music clip ‘lab_bandpass.wav’, using a
band-stop filter to remove the midrange instrument. What values for w_cutoff work well?
Example:
frequencyDomainPlot('lab_bandpass.wav', 'stop', [200 1500]);

Output (graph):

You might also like