donmike25 icon

DSP LAb 2 modification

donmike25 | PRO | 02/03/16 02:23:40 PM UTC | 0 ⭐ | 7250 👁️ | Never ⏰ | []
MatLab |

1.55 KB

|

None

|

0 👍

/

0 👎

path1='C:\Users\Ghostphreak\Desktop\lab2_note_on_frequency_spectrum_estimation'; % change to the path where you put your code
cd(path1)
close all, clear all;
[o_n,fs,b]= wavread('3n.wav'); % replace with your id, mine was 1112700303 hence the 3n % o_n vector that contain the stored audio signal ' noisy version'
[o_c,fs,b]=wavread('3o.wav'); % clean signal
 
%b=fir1(132,0.4);
%a=1;
%freqz(b,1,512,8012);
 
%estimate the frequency content
N = length(o_n);
X_n=fft(o_n,N); % perform N point DFT to obtain N fourier transform samples
X_c=fft(o_c,N); % Do fft on clean signal
%% Plot with discrete frequency 0-2pi
w = ( 0:(N-1) )/N * 2*pi ; % discrete time frequency vector [0 ,...2pi]
fvec = w*fs/(2*pi); % f = w*fsampling/(2*pi)frequency vector in hertz
%% Plot only from 0 to half sampling frequency (Hertz)
halfN = round(length(fvec)/2);
fv = fvec(1:halfN);
magX = abs(X_n);
magX_noisy = abs(X_c);
X_n_half = magX(1:halfN);
X_c_half = magX_noisy(1:halfN);
figure,plot(fv,abs(X_n_half),'b-');
xlabel('Frequency in hertz 0-> half of fsampling (Hertz) , fsampling = 8000Hz');
ylabel(' magnitude of fourier transform coefficients');
% Plot the clean, superimposed
hold on
plot(fv,abs(X_c_half),'r-') % red is clean
title('Spectrum analysis of clean and noisy signal')
legend('noisy','clean')
 
%hamming %added codes
%credits to bro chakrawarthi
Na= 132; %class order
wc = 0.424; %cutoff freq
h=fir1(Na,wc, hamming (Na+1));
freqz(h,1,512,fs);
s=filter(h,1,o_n);
s_s=fft(s,N);
magS=abs(s_s);
s_s_half=magS(1:halfN);
figure,plot(fv,abs(s_s_half),'b-');%}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎