mathieu@14: function [sceneSchedule] = getSceneSchedule(sceneSchedule,sceneObjects,settings,time,indReplicate) 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: if strcmp(settings.ebrMode,'replicate') mathieu@14: sceneSchedule(settings.schedPos).ebr=settings.ebrs(indReplicate); mathieu@14: else mathieu@14: sceneSchedule(settings.schedPos).ebr= settings.ebr_mean+randn*settings.ebr_std; mathieu@14: end mathieu@14: gregoire@16: switch settings.randomFlag gregoire@16: case {'random'} % Random choice of sample gregoire@16: inst = randi(length(sceneObjects(settings.classId).startTimes)); gregoire@16: case {'random-unique'} % Random choice of sample without repetition gregoire@16: instances=[sceneSchedule(1:end-1).instance]; gregoire@16: instanceDone=instances([sceneSchedule(1:end-1).classId]==length(sceneObjects)); gregoire@16: inst=1:length(sceneObjects(end).endTimes); gregoire@16: inst(arrayfun(@(x) any(instanceDone==x),inst))=[]; gregoire@16: if isempty(inst) gregoire@16: error(['using samplechoice : random-unique; Not enough isolated samples for the class' sceneObjects(end).classLabel]) gregoire@16: else gregoire@16: inst=inst(randperm(length(inst),1)); gregoire@16: end gregoire@16: case {'close'} % Choose the sample closest in duration to the annotation. gregoire@16: [~,inst] = min(abs(sceneObjects(settings.classId).endTimes-sceneObjects(settings.classId).startTimes-(settings.end_times(indReplicate)-settings.start_times(indReplicate)))); mathieu@14: end mathieu@14: mathieu@14: switch settings.timeMode mathieu@14: case 'generate' mathieu@14: dur = sceneObjects(settings.classId).endTimes(inst)-sceneObjects(settings.classId).startTimes(inst); mathieu@14: case 'abstract' mathieu@14: dur = sceneObjects(settings.classId).endTimes(inst)-sceneObjects(settings.classId).startTimes(inst); mathieu@14: if(dur-settings.template_duration_mean-settings.template_duration_std>5 ) mathieu@14: dur= settings.template_duration_mean+randn*settings.template_duration_std; mathieu@14: disp('Sample Duration - meanDuration - stdDuration > 5: cut sample') mathieu@14: end mathieu@14: case 'replicate' mathieu@14: dur = settings.end_times(indReplicate)-settings.start_times(indReplicate); mathieu@14: end mathieu@14: mathieu@14: mathieu@14: sceneSchedule(settings.schedPos).classId=settings.classId; mathieu@14: sceneSchedule(settings.schedPos).classLabel=settings.label; mathieu@14: sceneSchedule(settings.schedPos).isBackground = 0; mathieu@14: sceneSchedule(settings.schedPos).instance = inst; mathieu@14: sceneSchedule(settings.schedPos).position = time; mathieu@14: sceneSchedule(settings.schedPos).duration=dur; mathieu@14: mathieu@14: %% Fade I/O mathieu@14: mathieu@14: if (time < settings.start_time+settings.fade_in_time && settings.fade_in_time>0) mathieu@14: sceneSchedule(settings.schedPos).ebr = -20 + ((time-settings.start_time)/settings.fade_in_time) * (sceneSchedule(settings.schedPos).ebr+20); mathieu@14: end mathieu@14: if (time > settings.end_time-settings.fade_out_time && settings.fade_out_time>0) mathieu@14: sceneSchedule(settings.schedPos).ebr = -20 + ((settings.end_time-time)/settings.fade_out_time) * (sceneSchedule(settings.schedPos).ebr+20); mathieu@14: end mathieu@14: mathieu@14: %% check ebr mathieu@14: if (~isfinite(sceneSchedule(settings.schedPos).ebr)) mathieu@14: error('Error while computing ebr; ebr = +/-inf') mathieu@14: end mathieu@14: mathieu@14: end mathieu@14: