annotate nonExposed/getSampleInfo.m @ 51:ebf92ed7d680 tip master

Added -fd (--full-duration) argument.
author Emmanouil Theofanis Chourdakis <e.t.chourdakis@qmul.ac.uk>
date Sun, 30 Sep 2018 13:21:49 +0100
parents 92f73423eb37
children
rev   line source
gregoire@16 1 function [o] = getSampleInfo(label,query,sampleType,inputData,trackLength,eventInfo,sr)
mathieu@14 2
mathieu@14 3 % This program was written by Mathias Rossignol & Grégoire Lafay
mathieu@14 4 % is Copyright (C) 2015 IRCAM <http://www.ircam.fr>
mathieu@14 5 %
mathieu@14 6 % This program is free software: you can redistribute it and/or modify it
mathieu@14 7 % under the terms of the GNU General Public License as published by the Free
mathieu@14 8 % Software Foundation, either version 3 of the License, or (at your option)
mathieu@14 9 % any later version.
mathieu@14 10 %
mathieu@14 11 % This program is distributed in the hope that it will be useful, but
mathieu@14 12 % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
mathieu@14 13 % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mathieu@14 14 % for more details.
mathieu@14 15 %
mathieu@14 16 % You should have received a copy of the GNU General Public License along
mathieu@14 17 % with this program. If not, see <http://www.gnu.org/licenses/>.
mathieu@14 18
mathieu@14 19 o.isBackground = strcmp(sampleType,'background');
mathieu@14 20 o.classLabel = label;
mathieu@14 21 o.startTimes = [];
mathieu@14 22 o.endTimes = [];
gregoire@16 23 o.names={};
mathieu@14 24 o.query= query;
mathieu@14 25 o.trackLength=trackLength;
mathieu@14 26 path = [inputData sampleType '/'];
mathieu@14 27
gregoire@16 28 if any(strcmp(query,{eventInfo.query}))
gregoire@16 29 o.startTimes=eventInfo(strcmp(query,{eventInfo.query})).startTimes;
gregoire@16 30 o.endTimes=eventInfo(strcmp(query,{eventInfo.query})).endTimes;
gregoire@16 31 o.names=eventInfo(strcmp(query,{eventInfo.query})).names;
gregoire@16 32 else
gregoire@16 33
gregoire@16 34 if ~exist(path, 'dir')
gregoire@16 35 error(['Could not find local dir ',path,'\n']);
gregoire@16 36 end
gregoire@16 37
gregoire@16 38 samples = dir([path '*wav']);
gregoire@16 39 samplesInd = find(cellfun('isempty',regexpi({samples.name},query,'match'))==0);
gregoire@16 40
gregoire@16 41 for ii=1:length(samplesInd)
gregoire@16 42 samplesInfo=audioinfo([path,'/',samples(samplesInd(ii)).name]);
gregoire@16 43
gregoire@16 44 if sr~=samplesInfo.SampleRate
gregoire@16 45 error('Sample Rate must be 44100')
gregoire@16 46 end
gregoire@16 47
gregoire@16 48 o.startTimes(end+1) = 0;
gregoire@16 49 o.endTimes(end+1) = samplesInfo.TotalSamples/samplesInfo.SampleRate;
gregoire@16 50 o.names{end+1}=samples(samplesInd(ii)).name;
gregoire@16 51 end
mathieu@14 52 end