mathieu@14: function [ sceneSchedule ] = manageOverlapping( sceneSchedule,minSpace ) 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 sceneSchedule index in order to have position in ascending order mathieu@14: mathieu@14: positions= [sceneSchedule.position]; mathieu@14: isBackground= [sceneSchedule.isBackground]; mathieu@14: [~,index]=sort(positions(logical(~isBackground))); mathieu@14: index=index+length(isBackground(isBackground==1)); mathieu@14: idFlag=zeros(length(unique([sceneSchedule.classId])),1); mathieu@14: mathieu@14: endPos=0; mathieu@14: index2remove=[]; mathieu@14: for jj = index mathieu@14: if(sceneSchedule(jj).position > endPos) mathieu@14: endPos= sceneSchedule(jj).position+sceneSchedule(jj).duration; mathieu@14: idFlag(sceneSchedule(jj).classId)=1; mathieu@14: elseif(2*sceneSchedule(jj).duration>endPos-(sceneSchedule(jj).position+sceneSchedule(jj).duration) || idFlag(sceneSchedule(jj).classId)==0) mathieu@14: sceneSchedule(jj).position=endPos+minSpace; mathieu@14: endPos= sceneSchedule(jj).position+sceneSchedule(jj).duration; mathieu@14: idFlag(sceneSchedule(jj).classId)=1; mathieu@14: else mathieu@14: index2remove=[index2remove jj]; mathieu@14: end mathieu@14: end mathieu@14: mathieu@14: sceneSchedule(index2remove)=[];