annotate nonExposed/getBackground.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 786f7138a2d5
children
rev   line source
gregoire@24 1 function [sceneSchedule,sceneObjects,score]=getBackground(inputPath,score,eventInfo,sr,noiseLevel,noiseFiltMaxFreq,noiseFiltOrder)
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
gregoire@24 19 if isfield(score,'backgrounds')
gregoire@24 20
gregoire@24 21 for i=1:length(score.backgrounds)
gregoire@24 22 sceneObjects(i) = getSampleInfo(score.backgrounds{i}{1},score.backgrounds{i}{2},'background',inputPath,score.sceneDuration,eventInfo,sr);
gregoire@24 23 sceneSchedule(i).classId=i;
gregoire@24 24 sceneSchedule(i).classLabel=score.backgrounds{i}{2};
gregoire@24 25 sceneSchedule(i).position=0;
gregoire@24 26 sceneSchedule(i).instance=1;
gregoire@24 27 sceneSchedule(i).isBackground = 1;
gregoire@24 28 sceneSchedule(i).duration = score.sceneDuration;
gregoire@24 29 if (i==1)
gregoire@24 30 sceneSchedule(i).ebr=1;
gregoire@24 31 else
gregoire@24 32 sceneSchedule(i).ebr= score.backgrounds{i}{3};
gregoire@24 33 end
mathieu@14 34 end
gregoire@24 35
gregoire@24 36 else
gregoire@24 37
gregoire@24 38 noise=randn(1,sr*score.sceneDuration);
gregoire@24 39 noise=noise./max(abs(noise));
gregoire@24 40
gregoire@24 41 if noiseFiltMaxFreq
gregoire@24 42 noise=filter(fir1(noiseFiltOrder,noiseFiltMaxFreq/sr/2),1,noise);
gregoire@24 43 end
gregoire@24 44
gregoirelafay@27 45 noise=noise.*power(noiseLevel/20);
gregoire@24 46
gregoire@24 47 sceneObjects(1).isBackground = 1;
gregoire@24 48 sceneObjects(1).classLabel = 'noise';
gregoire@24 49 sceneObjects(1).startTimes = 0;
gregoire@24 50 sceneObjects(1).endTimes = score.sceneDuration;
gregoire@24 51 sceneObjects(1).names={'noise'};
gregoire@24 52 sceneObjects(1).query= 'noise';
gregoire@24 53 sceneObjects(1).trackLength=score.sceneDuration;
gregoire@24 54
gregoire@24 55 sceneSchedule(1).classId=1;
gregoire@24 56 sceneSchedule(1).classLabel='noise';
gregoire@24 57 sceneSchedule(1).position=0;
gregoire@24 58 sceneSchedule(1).instance=1;
gregoire@24 59 sceneSchedule(1).isBackground = 1;
gregoire@24 60 sceneSchedule(1).duration = score.sceneDuration;
gregoire@24 61
gregoire@24 62 score.backgrounds{1}{1}='noise';
gregoire@24 63 score.backgrounds{1}{2}=noise;
mathieu@14 64 end
mathieu@14 65 end