Mercurial > hg > simscene-py
diff nonExposed/getSampleInfo.m @ 16:92f73423eb37
update figure generation
author | GregoireLafay <gregoire.lafay@irccyn.ec-nantes.fr> |
---|---|
date | Wed, 06 Jan 2016 18:04:24 +0100 |
parents | 69410ac2a50d |
children |
line wrap: on
line diff
--- a/nonExposed/getSampleInfo.m Tue Dec 08 10:45:15 2015 +0100 +++ b/nonExposed/getSampleInfo.m Wed Jan 06 18:04:24 2016 +0100 @@ -1,4 +1,4 @@ -function [o] = getSampleInfo(label,query,sampleType,inputData,trackLength) +function [o] = getSampleInfo(label,query,sampleType,inputData,trackLength,eventInfo,sr) % This program was written by Mathias Rossignol & Grégoire Lafay % is Copyright (C) 2015 IRCAM <http://www.ircam.fr> @@ -20,24 +20,33 @@ o.classLabel = label; o.startTimes = []; o.endTimes = []; +o.names={}; o.query= query; o.trackLength=trackLength; path = [inputData sampleType '/']; -if ~exist(path, 'dir') - error(['Could not find local dir ',path,'\n']); +if any(strcmp(query,{eventInfo.query})) + o.startTimes=eventInfo(strcmp(query,{eventInfo.query})).startTimes; + o.endTimes=eventInfo(strcmp(query,{eventInfo.query})).endTimes; + o.names=eventInfo(strcmp(query,{eventInfo.query})).names; +else + + if ~exist(path, 'dir') + error(['Could not find local dir ',path,'\n']); + end + + samples = dir([path '*wav']); + samplesInd = find(cellfun('isempty',regexpi({samples.name},query,'match'))==0); + + for ii=1:length(samplesInd) + samplesInfo=audioinfo([path,'/',samples(samplesInd(ii)).name]); + + if sr~=samplesInfo.SampleRate + error('Sample Rate must be 44100') + end + + o.startTimes(end+1) = 0; + o.endTimes(end+1) = samplesInfo.TotalSamples/samplesInfo.SampleRate; + o.names{end+1}=samples(samplesInd(ii)).name; + end end - -samples = dir([path '*wav']); -samplesInd = find(cellfun('isempty',regexpi({samples.name},query,'match'))==0); - -for ii=1:length(samplesInd) -% [sampleSize,sr]=wavread([path,'/',samples(samplesInd(ii)).name],'size'); - samplesInfo=audioinfo([path,'/',samples(samplesInd(ii)).name]); - sampleSize = samplesInfo.TotalSamples'; - sr = samplesInfo.SampleRate; - - o.startTimes(end+1) = 0; - o.endTimes(end+1) = sampleSize(1)/sr; -end -