comparison nonExposed/getSampleInfo.m @ 14:b1901e8d8f5f

initial commit
author Mathieu Lagrange <mathieu.lagrange@cnrs.fr>
date Tue, 17 Mar 2015 09:34:13 +0100
parents
children 69410ac2a50d
comparison
equal deleted inserted replaced
-1:000000000000 14:b1901e8d8f5f
1 function [o] = getSampleInfo(label,query,sampleType,inputData,trackLength)
2
3 % This program was written by Mathias Rossignol & Grégoire Lafay
4 % is Copyright (C) 2015 IRCAM <http://www.ircam.fr>
5 %
6 % This program is free software: you can redistribute it and/or modify it
7 % under the terms of the GNU General Public License as published by the Free
8 % Software Foundation, either version 3 of the License, or (at your option)
9 % any later version.
10 %
11 % This program is distributed in the hope that it will be useful, but
12 % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 % for more details.
15 %
16 % You should have received a copy of the GNU General Public License along
17 % with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 o.isBackground = strcmp(sampleType,'background');
20 o.classLabel = label;
21 o.startTimes = [];
22 o.endTimes = [];
23 o.query= query;
24 o.trackLength=trackLength;
25 path = [inputData sampleType '/'];
26
27 if ~exist(path, 'dir')
28 error(['Could not find local dir ',path,'\n']);
29 end
30
31 samples = dir([path '*wav']);
32 samplesInd = find(cellfun('isempty',regexpi({samples.name},query,'match'))==0);
33
34 for ii=1:length(samplesInd)
35 [sampleSize,sr]=wavread([path,'/',samples(samplesInd(ii)).name],'size');
36 o.startTimes(end+1) = 0;
37 o.endTimes(end+1) = sampleSize(1)/sr;
38 end
39