how to implement hanning window with 50% overlap

8 views (last 30 days)
Wil
Wil on 18 Sep 2014
Commented: Wil on 18 Sep 2014
Hi there, I have a .wav file whic is attached here. I wish to get the sound pressure level (dB SPL re:1uPa) from this file and plot it against it's frequency components. Can someone check if my code is correct or what I need to do if it isn't. And very importantly, I need to apply a 'hanning window' with 50% overlap to my data, how do I do that?. Thanks very much for the anticipated helpful reply. Below is my code. Cheers.
% This reads in the .wav file [data Fs] = wavread('C:wil.wav'); T = 1/Fs; % Sample time L = length(data(:,1)); % Length of signal t = (0:L-1)*T; % Time vector x = data(:,1); subplot(3,1,1),plot(t,x) title('Signal') xlabel('time (Seconds)')
NFFT = 2^nextpow2(L); % Next power of 2 from length of y Y = fft(x,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum. subplot(3,1,2),plot(f,2*abs((Y(1:NFFT/2+1)))) title('Magnitude of FFT') xlabel('Frequency (Hz)') ylabel('Amplitude') xlim([0 10000]);
% Plot FFT in dB subplot(3,1,3),plot(f,-10*(log10(abs((Y(1:NFFT/2+1)).^2)))) title('FFT in dB') xlabel('Frequency (Hz)') ylabel('Amplitude (dB)') xlim([0 1000]);

Answers (1)

José-Luis
José-Luis on 18 Sep 2014
Please make it easier for to help you and format your post.
Also, we don't have your sound file so we can't really run your code.
If you have the signal processing toolbox, Matlab has its implementation of the Hanning window called hann()

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!