In this problem, we will study the significance of phase information in the sinusoidal coding of audio. Use the audio file $\operatorname{ch} 9 a u d 1 . w a v$. Consider a frame size of $N=512$ samples. Let $S_i(k)$ be the 512 -point FFT of the $i$-th audio frame, and $S_i(k)=\left|S_i(k)\right| e^{j \Phi_i(k)}$ where $\left|S_i(k)\right|$ is the magnitude spectrum and $\Phi_i(k)$ is the phase at the $k$-th FFT bin. Write a MATLAB program to pick 30 spectral peaks from the 512-point FFT magnitude spectrum. Set the rest of the spectral component magnitudes to a very small value, e.g., 0.000001 . Call the resulting spectral magnitude as $\left|\hat{S}_i(k)\right|$.
a. Set the phase $\Phi_i(k)=0$ and reconstruct the audio signal, $\hat{s}_i(n)=$ $\mathrm{IFFT}_{512}\left[\hat{S}_i(k)\right]$ for all the frames, $i=1,2, \ldots, N_f$.
b. Calculate the sample MSE, $E_i=\mathrm{E}\left[e_i^2(n)\right]$ for each frame, $i$. Compute the average MSE, $E_{\mathrm{Avg}}=\frac{1}{N_f} \sum_{i=1}^{N_f} E_i$, where $N_f$ is the number of frames.
c. Set the phase $\left.\boldsymbol{\Phi}_i=\pi(2 \operatorname{rand}(1,512)-1)\right)$, where $\boldsymbol{\Phi}_i$ is the $[1 \times 512]$ uniform random phase vector that varies between $-\pi$ and $\pi$. Reconstruct the audio signal, $\hat{s}_i(n)=\operatorname{IFFT}_{512}\left[\hat{S}_i(k) e^{j \Phi_i}\right]$ for all the frames. Note that you must avoid using the same set of random phase components in all the frames. Repeat step (b).
d. Set the phase $\Phi_i(k)=\arg \left[S_i(k)\right]$, i.e., we are using the input signal phase. Reconstruct the audio, $\hat{s}_i(n)=\operatorname{IFFT}_{512}\left[\hat{S}_i(k) e^{j \Phi_i(k)}\right]$ for all the frames. Repeat step (b).
e. Perform an experiment where the low-frequency sinusoids $(<1.5 \mathrm{kHz})$ use the input signal phase and the high-frequency components use random phase as in part (c). Compute $E_i$ and $E_{\text {Avg }}$ using step (b).
f. Give a dB plot of $E_i$ obtained from steps (a) and (b) across the number of frames, $i=1,2, \ldots, N_f$. Now superimpose the $E_i$ 's obtained in steps (c), (d), and (e). Which case performed better in terms of the MSE measure?
g. Evaluate to the synthesized audio obtained from steps (a), (c), (d), and (e). Which case results in better perceptual quality?