mathieu@14: function [template] = getTemplate(instanceAnnotFile,instanceAudioFile) 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: %% get audioFile mathieu@30: [signal,sr] = audioread(instanceAudioFile); mathieu@14: if(size(signal,2)==2) mathieu@14: signal=mean(signal,2); mathieu@14: end mathieu@14: signal=0.99*signal/(max(abs(signal))); mathieu@14: template.sceneDuration=length(signal)/sr; mathieu@14: mathieu@14: %% get onset/offset times and background Location mathieu@14: [onset,offset,classNames]=loadEventsList(instanceAnnotFile); mathieu@14: bgLocation=(~getEventsLocation(length(signal),sr,onset,offset)); mathieu@14: mathieu@14: %% Get Template mathieu@14: [uniqueClassNames,~,ib]=unique(classNames); mathieu@14: template.class=cell(1,length(uniqueClassNames)); mathieu@14: mathieu@14: for ii=1:length(uniqueClassNames) mathieu@14: template.class{ii}=cell(1,13); mathieu@14: mathieu@14: onsetTmp=onset(ib==ii); mathieu@14: offsetTmp=offset(ib==ii); mathieu@14: mathieu@14: if(length(onsetTmp)>1) mathieu@14: meanSpacingTime = mean(onsetTmp(2:end)-onsetTmp(1:end-1)); mathieu@14: stdSpacingTime = std(onsetTmp(2:end)-onsetTmp(1:end-1)); mathieu@14: else mathieu@14: meanSpacingTime = -1; mathieu@14: stdSpacingTime = 0; mathieu@14: end mathieu@14: mathieu@14: [ebr]=getEbrs(bgLocation,signal,sr,onsetTmp,offsetTmp); mathieu@14: mathieu@14: template.class{ii}={uniqueClassNames{ii},uniqueClassNames{ii},mean(ebr),std(ebr),meanSpacingTime,stdSpacingTime,... mathieu@14: onsetTmp(1),offsetTmp(end),0,0,onsetTmp,offsetTmp,ebr}; mathieu@14: end mathieu@14: