0% found this document useful (0 votes)
20 views11 pages

Lab 4a 1D Filtering in Frequency Domain

Uploaded by

farhan020813
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views11 pages

Lab 4a 1D Filtering in Frequency Domain

Uploaded by

farhan020813
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

CSC567

Lab 4a: 1D Frequency Domain Filtering

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.

5.1 Preparation
Download the following files: timeDomainPlot.m, frequencyDomainPlot.m, lab
annoying.wav, and lab bandpass.wav.

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’)

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’);

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.

5.3 Syntax

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.

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].
5.4 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);

5.5 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);

5.6 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]);

5.8 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]);
Lab Assignment 4:
Name: Mohammad Farhan Bin Mohd Fauzi
Student ID: 2023104337

1. What is a frequency domain filter?

Answer:
A frequency domain filter is any filter that attenuates or enhances certain
frequency components after the signal has been reconstructed in the
frequency domain using Fourier Transform, for instance. It works by a mask
or a function that slides on the signal in the frequency domain, bringing
down or raising specific regions.

2. What are the common types of filters used in sound processing?

Answer:
The first one is Low-pass filters which permit the transmission of signals
only at frequencies lower than the cut-off frequency. Then, High-pass filters
that permit passage of frequencies above a certain limit after the cut-off
frequency. The third one is allowing the passage of signals in a specific
frequency range. The last one is Band-stop (notch) filters which remove
signals present in a particular range.

3. How does a low-pass filter affect a sound signal in the frequency domain?

Answer :
A low pass filter tends to reduce the amplitude of higher frequencies in a
signal but will maintain most low-frequency signals. This will lead to a less
complex or smoother sound since the higher frequencies have been
eliminated mastering sharpness and clarity which add noise unpleasantly.

4. What happens when you apply a high-pass filter to a noisy sound signal?

Answer:
A high-pass filter will only allow high-frequency signals to pass through,
filtering out any sounds or noise that existed below a certain frequency
level, hence controlling the low-end noise which may be undesirable. This is
helpful as it increases the clarity of the prevailing signal especially if most
of the noise is at the lower frequencies.

5. Why is filtering in the frequency domain useful for sound processing?

Answer:
The advantages of frequency domain filters were their ability to deal with
specific frequency ranges when changing a signal, for example lowering
noise, boosting a signal or changing its tone. This is especially effective in
sound editing since many audio parameters are related to certain frequency
regions.
6. What is the purpose of using a band-pass filter in sound processing?

Answer:
A band-pass filter is a device that restricts the output to a specific frequency
range and hence, a particular sound spectrum can be targeted and used
effectively. For instance, it can boost the mid-range frequencies in music or
voice, while low and high frequencies are reduced.

7. How does increasing the cutoff frequency of a low-pass filter affect the output
signal?

Answer:
Raising the threshold frequency in a low pass filter increases the amount of
higher frequencies that are let through resulting in a signal that retains more
of the original high frequencies. In other words, it reduces the suppression
of high frequencies.

8. How do you implement a filter in the frequency domain using Fourier Transform?

Answer:
To implement a filter in the frequency domain, first apply the Fourier
Transform to the signal to convert it from the time domain to the frequency
domain. Then apply a frequency-based mask that modifies or removes
certain frequencies. Finally, perform the Inverse Fourier Transform to
convert the filtered signal back to the time domain.

9. What is the advantage of using an ideal frequency-domain filter over time-domain


filters?

Answer:
The perfect frequency domain filters can efficiently suppress or enhance
certain frequency ranges without much of a hindrance, which can be a
difficult task with time domain filters. It also makes it easy to work on the
signals since filtering in the frequency domain is usually low-cost in terms
of processing power and can be done systematically over the entire
frequency range.

10. Filter your own music (any song in .wav format and less than 30 second) using the low
pass filter, high pass filter, band pass filter and band stop filter as in the steps given
above. Change the cut-off frequency for each filter based on your preferences. Then
print screen and crop the output signal generated after passing through these four
filters. Paste your source code and the output signals HERE. Attach your .wav file
during submission.
Sound : pianos-by-jtwayne-7-174717.wav

Low Pass Filter :


frequencyDomainPlot('pianos-by-jtwayne-7-174717.wav', 'low', 690);
>> global player
>> global stopped
>> timeDomainPlot('pianos-by-jtwayne-7-174717.wav')
High-pass filter :
frequencyDomainPlot('pianos-by-jtwayne-7-174717.wav', 'high', 1600);

>> global player


>> global stopped
>> timeDomainPlot('pianos-by-jtwayne-7-174717.wav')
Band-pass filter

frequencyDomainPlot('pianos-by-jtwayne-7-174717.wav', 'bandpass', [900 2100]);

>> global player


>> global stopped
>> timeDomainPlot('pianos-by-jtwayne-7-174717.wav')
Notch/band-stop filters
frequencyDomainPlot('pianos-by-jtwayne-7-174717.wav', 'stop', [600 2300]);
>> global player
>> global stopped
>> frequencyDomainPlot('pianos-by-jtwayne-7-174717.wav', 'bandpass', [700 1500]);
Example:
SOURCE CODE & OUTPUT
Low-pass filter
frequencyDomainPlot('Music.wav', 'low', 690);
>> global player
>> global stopped
>> timeDomainPlot('Music.wav')

High-pass filter
frequencyDomainPlot('Music.wav', 'high', 1600);

>> global player


>> global stopped
>> timeDomainPlot('Music.wav')
Band-pass filter

frequencyDomainPlot('Music.wav', 'bandpass', [900 2100]);

>> global player


>> global stopped
>> timeDomainPlot('Music.wav')
Notch/band-stop filters
frequencyDomainPlot('Music.wav', 'stop', [600 2300]);
>> global player
>> global stopped
>> frequencyDomainPlot('Music.wav', 'bandpass', [700 1500]);

You might also like