gerard@1
|
1 % Copyright 2013 MUSIC TECHNOLOGY GROUP, UNIVERSITAT POMPEU FABRA
|
gerard@1
|
2 %
|
gerard@1
|
3 % Written by Gerard Roma <gerard.roma@upf.edu>
|
gerard@1
|
4 %
|
gerard@1
|
5 % This program is free software: you can redistribute it and/or modify
|
gerard@1
|
6 % it under the terms of the GNU Affero General Public License as published by
|
gerard@1
|
7 % the Free Software Foundation, either version 3 of the License, or
|
gerard@1
|
8 % (at your option) any later version.
|
gerard@1
|
9 %
|
gerard@1
|
10 % This program is distributed in the hope that it will be useful,
|
gerard@1
|
11 % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
gerard@1
|
12 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
gerard@1
|
13 % GNU Affero General Public License for more details.
|
gerard@1
|
14 %
|
gerard@1
|
15 % You should have received a copy of the GNU Affero General Public License
|
gerard@1
|
16 % along with this program. If not, see <http://www.gnu.org/licenses/>.
|
gerard@1
|
17
|
gerard@1
|
18 function [ features ] = analyze_files( input_files, tmp_path )
|
gerard@1
|
19 use_stored_features = 1;
|
gerard@1
|
20
|
gerard@1
|
21 features = [];
|
gerard@1
|
22 for i=1:length(input_files)
|
gerard@1
|
23 disp(strcat('analyzing',input_files(i)));
|
gerard@1
|
24 features = [features; analyze(input_files(i))];
|
gerard@1
|
25 end
|
gerard@1
|
26
|
gerard@1
|
27 function ftrs = analyze(in_file)
|
gerard@1
|
28 w = 40;
|
gerard@1
|
29 h = 20;
|
gerard@1
|
30 r = 0.03;
|
gerard@1
|
31 dl = 2;
|
gerard@1
|
32 vl = 2;
|
gerard@1
|
33 [pathstr, name, ext] = fileparts(char(in_file));
|
gerard@1
|
34 tmp_fname = strcat(tmp_path,'/',name,'.mat');
|
gerard@1
|
35 if use_stored_features && (exist(tmp_fname)==2)
|
gerard@1
|
36 load(tmp_fname);
|
gerard@1
|
37 else
|
gerard@1
|
38 [x,fs] = wavread(char(in_file));
|
gerard@1
|
39 x = x(:,1);
|
gerard@1
|
40 mfcc = melfcc(x,fs,'minfreq',0,'maxfreq',900,'dither',1)';
|
gerard@1
|
41 N = max(size(mfcc));
|
gerard@1
|
42 steps = round(N/h);
|
gerard@1
|
43 wrqa = [];
|
gerard@1
|
44 for i = 0:steps-1
|
gerard@1
|
45 init = (i*h)+1;
|
gerard@1
|
46 final = min((i*h)+w,N);
|
gerard@1
|
47 ftr = mfcc(init:final,:);
|
gerard@1
|
48 d = squareform(pdist(ftr,'cosine'));
|
gerard@1
|
49 D = d<r;
|
gerard@1
|
50 rqa = RQA(D,dl,vl);
|
gerard@1
|
51 wrqa = [wrqa;rqa];
|
gerard@1
|
52 end
|
gerard@1
|
53
|
gerard@1
|
54 ftrs = [mean(mfcc,1),std(mfcc,1),mean(wrqa,1)];
|
gerard@1
|
55 ftrs(isnan(ftrs))=0;
|
gerard@1
|
56 ftrs(isinf(ftrs))=0;
|
gerard@1
|
57 save(tmp_fname,'ftrs');
|
gerard@1
|
58 end
|
gerard@1
|
59 end
|
gerard@1
|
60 end
|
gerard@1
|
61
|