Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

On Carmen, I have posted a sound file of “Mary had a little lamb …”. The file is

ID: 3680951 • Letter: O

Question

On Carmen, I have posted a sound file of “Mary had a little lamb …”. The file is called
sound3.m4a. The file is an audio recording of the nursery rhyme (the significance of which is
that it is one of the earliest known recordings of Thomas Edison).


(a) Using the built-in MATLAB function called audioread, “read” the file sound3.m4a into
your newly created script file, and find the sampling frequency. The amplitude has arbitrary
units, so you need not worry about it. Make sure you read the MATLAB documentation to
find out how to get that. Why do you think that is a default in MATLAB and why does it
have the value that it has?


(b) Find the time interval over which this recording has been performed (in seconds).
(c) Make a figure (2 plots x 2 plots) with the first plot on the top left corner being the signal
you just read in, as a function of time, t, where time is in seconds.


(d) Calculate the absolute value of the FFT of this signal and plot it as a subplot in the same
figure as in (c), in the top right corner, over a frequency range from 0 to 5000 Hz.


(e) Identify the frequency of the background noise (the constant annoying continuous beep you
hear). Note that since sound is never a pure tone, this background noise may have a
primary frequency but there could be other frequencies of smaller amplitude that
correspond to this background noise, in the vicinity of the primary frequency.


(f) In the same script file, write code to remove this background noise, i.e. filter it. Note that if
the background noise occurs at a frequency of s, you may have to remove its harmonics
(i.e. 2s, 3s, 4s, etc. as well as (1/2)s, (1/3)s, (1/4)s, etc.) to eliminate it completely.
This may require you to filter out some of these peaks in the FFT, transform back to the
time domain and replay the cleaned up file. To replay the sound, you will need to use the
built-in function ifft and sound commands. Remember to make use of the sampling
frequency from part (a).


(g) Plot the cleaned up (i.e. filtered) magnitude of the FFT signal in the same figure, lower left
corner, as a function of frequency (again from 0 to 5000 Hz).


(h) Plot the cleaned up (filtered) signal in the time domain as a subplot in the same figure in
the lower right corner.

Explanation / Answer

Hi, its a very large question. So, I am posting answers to first four parts. Following is the required matlab code

%script to read audio files and perform the required operations

%(a) reading the audiofile with sampled data in y, and sampling frequency in Fs
[y, Fs] = audioread('sound.mp3');


%(b) Finding the time interval over which this recording has been performed (in seconds).
time = length(y)/Fs;

%(c) figures and plots
% first plot is of the same audio signal
figure
subplot(2,2,1);

t = [1/Fs:1/Fs:length(y)/Fs];

plot(t,y);
title('Audio Signal')


%(d) calculating the absolute value of fft of the audio signal
absFFT = abs(fft(y(:,1), 5001));

%plotting the absolute fft over frequency ranging from 0 to 5000
freqRange = 0:5000;
subplot(2,2,2);
plot(freqRange, absFFT);
title('FFT plot');

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote