gregoire@16: function [o] = getSampleInfo(label,query,sampleType,inputData,trackLength,eventInfo,sr) mathieu@14: mathieu@14: % This program was written by Mathias Rossignol & Grégoire Lafay mathieu@14: % is Copyright (C) 2015 IRCAM mathieu@14: % mathieu@14: % This program is free software: you can redistribute it and/or modify it mathieu@14: % under the terms of the GNU General Public License as published by the Free mathieu@14: % Software Foundation, either version 3 of the License, or (at your option) mathieu@14: % any later version. mathieu@14: % mathieu@14: % This program is distributed in the hope that it will be useful, but mathieu@14: % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY mathieu@14: % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License mathieu@14: % for more details. mathieu@14: % mathieu@14: % You should have received a copy of the GNU General Public License along mathieu@14: % with this program. If not, see . mathieu@14: mathieu@14: o.isBackground = strcmp(sampleType,'background'); mathieu@14: o.classLabel = label; mathieu@14: o.startTimes = []; mathieu@14: o.endTimes = []; gregoire@16: o.names={}; mathieu@14: o.query= query; mathieu@14: o.trackLength=trackLength; mathieu@14: path = [inputData sampleType '/']; mathieu@14: gregoire@16: if any(strcmp(query,{eventInfo.query})) gregoire@16: o.startTimes=eventInfo(strcmp(query,{eventInfo.query})).startTimes; gregoire@16: o.endTimes=eventInfo(strcmp(query,{eventInfo.query})).endTimes; gregoire@16: o.names=eventInfo(strcmp(query,{eventInfo.query})).names; gregoire@16: else gregoire@16: gregoire@16: if ~exist(path, 'dir') gregoire@16: error(['Could not find local dir ',path,'\n']); gregoire@16: end gregoire@16: gregoire@16: samples = dir([path '*wav']); gregoire@16: samplesInd = find(cellfun('isempty',regexpi({samples.name},query,'match'))==0); gregoire@16: gregoire@16: for ii=1:length(samplesInd) gregoire@16: samplesInfo=audioinfo([path,'/',samples(samplesInd(ii)).name]); gregoire@16: gregoire@16: if sr~=samplesInfo.SampleRate gregoire@16: error('Sample Rate must be 44100') gregoire@16: end gregoire@16: gregoire@16: o.startTimes(end+1) = 0; gregoire@16: o.endTimes(end+1) = samplesInfo.TotalSamples/samplesInfo.SampleRate; gregoire@16: o.names{end+1}=samples(samplesInd(ii)).name; gregoire@16: end mathieu@14: end