-
Notifications
You must be signed in to change notification settings - Fork 0
/
PowSpecs.m
38 lines (35 loc) · 1.15 KB
/
PowSpecs.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function [PS,NN,nbFrames] = PowSpecs(data)
%% Computing MFCC Co-efficients.. page 13 doc Reconocimiento.pdf
%% (1) Frame Blocking.. page 42 dc TesisRecon.pdf
N = 256; % N point FFT
%30ms = Ts*N, entc N = 30ms*Frecq Submuestreo
M = 200; % Overlapping
NN = floor(N/2+1); %N/2
nbFrames = ceil((length(data)-N)/M);
Frames = zeros(nbFrames+1,N);
for i = 0:nbFrames-1
temp = data(i*M+1:i*M+N);
Frames(i+1,1:N) = temp;
end
% Last Frame..
temp = zeros(1,N);
lastLength = length(data)- nbFrames*M;
temp(1:lastLength) = data(nbFrames*M+1:(nbFrames*M +1 + lastLength-1));
Frames(nbFrames+1, 1:N) = temp;
%% (2) Windowing..
frameSize = size(Frames);
nbFrames = frameSize(1);
nbSamples = frameSize(2);
% Hamming window..
w = hamming(nbSamples);
Windows = zeros(nbFrames,nbSamples);
for i = 1:nbFrames
temp = Frames(i,1:nbSamples);
Windows(i, 1:nbSamples) = w'.*temp;
end
%% (3) Fourier Transform..
ffts = fft(Windows');
%% (4) Mel-frequency Wrapping..
% (a) Calculate Power spectrum..
PS = abs(ffts).^2;
PS = PS(1:NN-1,:);