Question: Create a function on MATLAB that extracts the main lobe of the magnitude spectrum of a window given the window type and its length. The

Create a function on MATLAB that extracts the main lobe of the magnitude spectrum of a window given the
window type and its length. The function should return the samples corresponding to the main lobe in decibels
(dB). The input arguments of the function are the window type and the length of window. You may expect as
input the window type to be rectangular, Hamming, and Blackman-Harris.
Tip: log10(0) is not well defined, so its a common practice to add a small value such as 1020 to the magnitude
spectrum before computing it in dB.
2. Measure the SNR in the reconstructed signal using the STFT model
Create a function that computes the SNR of a signal using the short-time Fourier model (STFT). Use the timedomain energy definition to calculate the SNR. The input arguments to the function are a wav. file name including
the path, window type, window length, FFT size, and hop size. The function should return the SNR over the entire
length of the input (SNR1) and the SNR for the segment of signals left after discarding M samples from both the
start and the end, where M is the STFT window length.
Test case: you may run your code using the piano.wav file with blackman window, window length =513, FFT
size =2048 and hop size =128.
3. Computing band-wise energy envelopes of a signal
Create a function that computes band-wise energy envelopes of a given audio signal using STFT in decibels.
For this task, consider two frequency bands: low and high. The low frequency band is the set of all frequencies
between 0 and 3000 Hz and the high frequency band is the set of all frequencies between 3000 and 10000 Hz. At
3
a given frame, the value of the energy envelope of a band is computed as the sum of squared values of all
frequency coefficient in that band. The input arguments to the function are a wav. file name including the path,
window type, window length, FFT size, and hop size. The function should return a matrix with two columns,
where the first column is the energy envelope of the low frequency band and the second is that of the second
frequency band.
Test case: you may run your code using the piano.wav file with blackman window, window length =513, FFT
size =1024 and hop size =128.
4. Computing an onset detection function
Create a function that computes a simple onset detection function (ODF) using STFT. Compute two ODFs
for two frequency bands: the set of all frequencies between 0 and 3000 Hz and the set of all frequencies between
3000 and 10000 Hz. A brief description of the onset detection function is provided in this document. Set
ODF(0)=0 to make the length of the ODF the same as the energy envelope. Remember to apply a half wave
rectification on the ODF. The input arguments to the function are a wav. file name including the path, window
type, window length, FFT size, and hop size. The function should return a matrix with two columns, where the
first column is the ODF computed on the low frequency band and the second column is the ODF computed on
the high frequency band.
Test case: you may run your code using the piano.wav file with blackman window, window length =513, FFT
size =1024 and hop size =128.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!