Write a MATLAB program that reads in an mp3 file The file sh

Write a MATLAB program that reads in an mp3 file. The file should be approxomately 10 seconds long. The data vector should then be filtered using the Overlap & Add method (see below). Use the 2 provided (from MYCOURSE) filter unit impulse responses. a) Filter in the frequency domain (i.e. Use the MATLAB FFTbuilt in function to transform the data into the frequency domain then multiply by the frequen response of the of the given filter, then use the MATLAB IFFT built in function to move back in to the discrete time domain. The overall filtering process must use the Overlapp & Add method presented in class. b) Use the MATLAB sound command to listen to the results.

Solution

CODE FOR FFT

function y = FourierT(x, dt)

% FourierT(x,dt) computes forward FFT of x with sampling time interval dt

% FourierT approximates the Fourier transform where the integrand of the

% transform is x*exp(2*pi*i*f*t)

% For NDE applications the frequency components are normally in MHz,

% dt in microseconds

[nr, nc] = size(x);

if nr == 1 N = nc;

else N = nr;

end

y = N*dt*ifft(x);

CODE FOR IFFT

function y = IFourierT(x, dt)

% IFourierT(x,dt) computes the inverse FFT of x, for a sampling time interval dt

% IFourierT assumes the integrand of the inverse transform is given by

% x*exp(-2*pi*i*f*t)

% The first half of the sampled values of x are the spectral components for

% positive frequencies ranging from 0 to the Nyquist frequency 1/(2*dt)

% The second half of the sampled values are the spectral components for

% the corresponding negative frequencies. If these negative frequency

% values are set equal to zero then to recover the inverse FFT of x we must

% replace x(1) by x(1)/2 and then compute 2*real(IFourierT(x,dt)) [nr,nc] = size(x);

if nr == 1 N = nc;

else N = nr;

end

y =(1/(N*dt))*fft(x);

OVERLAP ADD METHOD

function olam1()

x=input(\'Enter the long data input sequence x(n)=„)

Nsig=length(x)

h=input(\'Enter the filter co-efficientsh(n)=„)

M=length(h)

L=input(\'Input the length of each segment=\'

)Nframes=ceil(Nsig/L)

Nt=Nsig+M-1

k=1:1:Nt

xsig=[x zeros(1,M-1)]

subplot(Nframes+2,1,1)

stem(k,xsig)

y=zeros(1,Nt)

for m = 0:(Nframes-1)

index=m*L+1:min((m+1)*L,Nsig)

xm= x(index)

xzp=[xmzeros(1,M-1)]

N=length(xm)+M-1

hzp=[h zeros(1,N-M)]

H=fft(hzp,N)

X=fft(xzp,N)

Ym=X.*H

ym=ifft(Ym,N) %N-point IDFT

ym=[zeros(1,m*L) ym]

ym=[ymzeros(1,min(Nsig-(m+1)*L,Ntlength(ym)))]

subplot(Nframes+2,1,m+2)

stem(k,ym)

y=y+ym

end

subplot(Nframes+2,1,Nframes+2)

stem(k,y)

yc=conv(x,h)

figure(2)

subplot(2,1,1)

stem(y)

title(\'Plot of Overlap Add\')

ylabel(\'y\')

xlabel(\'n\')

subplot(2,1,2)

stem(yc)

title(\'Plot of Direct Convolution\')

ylabel(\'yc\')

xlabel(\'n\')

 Write a MATLAB program that reads in an mp3 file. The file should be approxomately 10 seconds long. The data vector should then be filtered using the Overlap &
 Write a MATLAB program that reads in an mp3 file. The file should be approxomately 10 seconds long. The data vector should then be filtered using the Overlap &
 Write a MATLAB program that reads in an mp3 file. The file should be approxomately 10 seconds long. The data vector should then be filtered using the Overlap &

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site