Mercurial > hg > mauch-mirex-2010
comparison _misc/featureextraction/.svn/text-base/myframefft.m~.svn-base @ 8:b5b38998ef3b
added all that other stuff
author | matthiasm |
---|---|
date | Fri, 11 Apr 2014 15:54:25 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7:12abff5474c8 | 8:b5b38998ef3b |
---|---|
1 | |
2 % segment audio data into overlapping frames and take fft of each frame | |
3 | |
4 function fftframes = myframefft(audiodata, winlength, overlap, windowkind, varargin) | |
5 | |
6 if nargin > 4 | |
7 nPad = varargin{1}; | |
8 zeropadding = true; | |
9 end | |
10 | |
11 fprintf(1,''); | |
12 | |
13 win = winlength; | |
14 | |
15 % Pad audio with zeros so that first analysis frame corresponds with first | |
16 % audio sample | |
17 | |
18 pad = zeros((win/2),1); | |
19 | |
20 %audiodata = [pad; audiodata; pad]; | |
21 | |
22 % find size of input | |
23 ilength = length(audiodata); | |
24 | |
25 | |
26 %pad audio data | |
27 audiodata = [pad; audiodata; pad]; | |
28 | |
29 % set hop size | |
30 hop = fix(win.*overlap); | |
31 | |
32 % set number of windows | |
33 num_win = ceil((ilength+1)/win/overlap); | |
34 | |
35 start=1; | |
36 | |
37 fftframes = zeros(win,num_win); | |
38 | |
39 check = ceil(num_win/10); | |
40 | |
41 if windowkind == 'hamming' | |
42 window = hamming(win); | |
43 else | |
44 window = rectwin(win); | |
45 end | |
46 | |
47 | |
48 % do fft analysis for each window: | |
49 for i = 1 : num_win; | |
50 start = floor(win * overlap * (i-1) + 1); | |
51 if ~zeropadding | |
52 segment = window .* audiodata(start:(start + win - 1)); | |
53 fftframes(:,i) = fft(segment, win)'; | |
54 else | |
55 segment = [window .* audiodata(start:(start + win - 1)) zeros(nPad*win)]; | |
56 fftframes(:,i) = fft(segment, win)'; | |
57 end | |
58 | |
59 % start = start + hop | |
60 | |
61 if mod(i,check) == 0 | |
62 fprintf(1,'.'); | |
63 end | |
64 | |
65 end; | |
66 fprintf(1,'\n'); | |
67 | |
68 |