annotate nonExposed/getTemplate.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 58ad632e9c12
children
rev   line source
mathieu@14 1 function [template] = getTemplate(instanceAnnotFile,instanceAudioFile)
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 %% get audioFile
mathieu@30 20 [signal,sr] = audioread(instanceAudioFile);
mathieu@14 21 if(size(signal,2)==2)
mathieu@14 22 signal=mean(signal,2);
mathieu@14 23 end
mathieu@14 24 signal=0.99*signal/(max(abs(signal)));
mathieu@14 25 template.sceneDuration=length(signal)/sr;
mathieu@14 26
mathieu@14 27 %% get onset/offset times and background Location
mathieu@14 28 [onset,offset,classNames]=loadEventsList(instanceAnnotFile);
mathieu@14 29 bgLocation=(~getEventsLocation(length(signal),sr,onset,offset));
mathieu@14 30
mathieu@14 31 %% Get Template
mathieu@14 32 [uniqueClassNames,~,ib]=unique(classNames);
mathieu@14 33 template.class=cell(1,length(uniqueClassNames));
mathieu@14 34
mathieu@14 35 for ii=1:length(uniqueClassNames)
mathieu@14 36 template.class{ii}=cell(1,13);
mathieu@14 37
mathieu@14 38 onsetTmp=onset(ib==ii);
mathieu@14 39 offsetTmp=offset(ib==ii);
mathieu@14 40
mathieu@14 41 if(length(onsetTmp)>1)
mathieu@14 42 meanSpacingTime = mean(onsetTmp(2:end)-onsetTmp(1:end-1));
mathieu@14 43 stdSpacingTime = std(onsetTmp(2:end)-onsetTmp(1:end-1));
mathieu@14 44 else
mathieu@14 45 meanSpacingTime = -1;
mathieu@14 46 stdSpacingTime = 0;
mathieu@14 47 end
mathieu@14 48
mathieu@14 49 [ebr]=getEbrs(bgLocation,signal,sr,onsetTmp,offsetTmp);
mathieu@14 50
mathieu@14 51 template.class{ii}={uniqueClassNames{ii},uniqueClassNames{ii},mean(ebr),std(ebr),meanSpacingTime,stdSpacingTime,...
mathieu@14 52 onsetTmp(1),offsetTmp(end),0,0,onsetTmp,offsetTmp,ebr};
mathieu@14 53 end
mathieu@14 54