annotate nonExposed/getSceneSchedule.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
mathieu@14 1 function [sceneSchedule] = getSceneSchedule(sceneSchedule,sceneObjects,settings,time,indReplicate)
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 if strcmp(settings.ebrMode,'replicate')
mathieu@14 20 sceneSchedule(settings.schedPos).ebr=settings.ebrs(indReplicate);
mathieu@14 21 else
mathieu@14 22 sceneSchedule(settings.schedPos).ebr= settings.ebr_mean+randn*settings.ebr_std;
mathieu@14 23 end
mathieu@14 24
gregoire@16 25 switch settings.randomFlag
gregoire@16 26 case {'random'} % Random choice of sample
gregoire@16 27 inst = randi(length(sceneObjects(settings.classId).startTimes));
gregoire@16 28 case {'random-unique'} % Random choice of sample without repetition
gregoire@16 29 instances=[sceneSchedule(1:end-1).instance];
gregoire@16 30 instanceDone=instances([sceneSchedule(1:end-1).classId]==length(sceneObjects));
gregoire@16 31 inst=1:length(sceneObjects(end).endTimes);
gregoire@16 32 inst(arrayfun(@(x) any(instanceDone==x),inst))=[];
gregoire@16 33 if isempty(inst)
gregoire@16 34 error(['using samplechoice : random-unique; Not enough isolated samples for the class' sceneObjects(end).classLabel])
gregoire@16 35 else
gregoire@16 36 inst=inst(randperm(length(inst),1));
gregoire@16 37 end
gregoire@16 38 case {'close'} % Choose the sample closest in duration to the annotation.
gregoire@16 39 [~,inst] = min(abs(sceneObjects(settings.classId).endTimes-sceneObjects(settings.classId).startTimes-(settings.end_times(indReplicate)-settings.start_times(indReplicate))));
mathieu@14 40 end
mathieu@14 41
mathieu@14 42 switch settings.timeMode
mathieu@14 43 case 'generate'
mathieu@14 44 dur = sceneObjects(settings.classId).endTimes(inst)-sceneObjects(settings.classId).startTimes(inst);
mathieu@14 45 case 'abstract'
mathieu@14 46 dur = sceneObjects(settings.classId).endTimes(inst)-sceneObjects(settings.classId).startTimes(inst);
mathieu@14 47 if(dur-settings.template_duration_mean-settings.template_duration_std>5 )
mathieu@14 48 dur= settings.template_duration_mean+randn*settings.template_duration_std;
mathieu@14 49 disp('Sample Duration - meanDuration - stdDuration > 5: cut sample')
mathieu@14 50 end
mathieu@14 51 case 'replicate'
mathieu@14 52 dur = settings.end_times(indReplicate)-settings.start_times(indReplicate);
mathieu@14 53 end
mathieu@14 54
mathieu@14 55
mathieu@14 56 sceneSchedule(settings.schedPos).classId=settings.classId;
mathieu@14 57 sceneSchedule(settings.schedPos).classLabel=settings.label;
mathieu@14 58 sceneSchedule(settings.schedPos).isBackground = 0;
mathieu@14 59 sceneSchedule(settings.schedPos).instance = inst;
mathieu@14 60 sceneSchedule(settings.schedPos).position = time;
mathieu@14 61 sceneSchedule(settings.schedPos).duration=dur;
mathieu@14 62
mathieu@14 63 %% Fade I/O
mathieu@14 64
mathieu@14 65 if (time < settings.start_time+settings.fade_in_time && settings.fade_in_time>0)
mathieu@14 66 sceneSchedule(settings.schedPos).ebr = -20 + ((time-settings.start_time)/settings.fade_in_time) * (sceneSchedule(settings.schedPos).ebr+20);
mathieu@14 67 end
mathieu@14 68 if (time > settings.end_time-settings.fade_out_time && settings.fade_out_time>0)
mathieu@14 69 sceneSchedule(settings.schedPos).ebr = -20 + ((settings.end_time-time)/settings.fade_out_time) * (sceneSchedule(settings.schedPos).ebr+20);
mathieu@14 70 end
mathieu@14 71
mathieu@14 72 %% check ebr
mathieu@14 73 if (~isfinite(sceneSchedule(settings.schedPos).ebr))
mathieu@14 74 error('Error while computing ebr; ebr = +/-inf')
mathieu@14 75 end
mathieu@14 76
mathieu@14 77 end
mathieu@14 78