comparison nonExposed/getBackground.m @ 24:2abd1116ae14

add automatic background generation
author Gregoire Lafay <gregoire.lafay@irccyn.ec-nantes.fr>
date Fri, 15 Jan 2016 17:19:09 +0100
parents 92f73423eb37
children 786f7138a2d5
comparison
equal deleted inserted replaced
23:0163f857f13f 24:2abd1116ae14
1 function [sceneSchedule,sceneObjects]=getBackground(inputPath,score,eventInfo,sr) 1 function [sceneSchedule,sceneObjects,score]=getBackground(inputPath,score,eventInfo,sr,noiseLevel,noiseFiltMaxFreq,noiseFiltOrder)
2 2
3 % This program was written by Mathias Rossignol & Grégoire Lafay 3 % This program was written by Mathias Rossignol & Grégoire Lafay
4 % is Copyright (C) 2015 IRCAM <http://www.ircam.fr> 4 % is Copyright (C) 2015 IRCAM <http://www.ircam.fr>
5 % 5 %
6 % This program is free software: you can redistribute it and/or modify it 6 % This program is free software: you can redistribute it and/or modify it
14 % for more details. 14 % for more details.
15 % 15 %
16 % You should have received a copy of the GNU General Public License along 16 % You should have received a copy of the GNU General Public License along
17 % with this program. If not, see <http://www.gnu.org/licenses/>. 17 % with this program. If not, see <http://www.gnu.org/licenses/>.
18 18
19 for i=1:length(score.backgrounds) 19 if isfield(score,'backgrounds')
20 sceneObjects(i) = getSampleInfo(score.backgrounds{i}{1},score.backgrounds{i}{2},'background',inputPath,score.sceneDuration,eventInfo,sr); 20
21 sceneSchedule(i).classId=i; 21 for i=1:length(score.backgrounds)
22 sceneSchedule(i).classLabel=score.backgrounds{i}{2}; 22 sceneObjects(i) = getSampleInfo(score.backgrounds{i}{1},score.backgrounds{i}{2},'background',inputPath,score.sceneDuration,eventInfo,sr);
23 sceneSchedule(i).position=0; 23 sceneSchedule(i).classId=i;
24 sceneSchedule(i).instance=1; 24 sceneSchedule(i).classLabel=score.backgrounds{i}{2};
25 sceneSchedule(i).isBackground = 1; 25 sceneSchedule(i).position=0;
26 sceneSchedule(i).duration = score.sceneDuration; 26 sceneSchedule(i).instance=1;
27 if (i==1) 27 sceneSchedule(i).isBackground = 1;
28 sceneSchedule(i).ebr=1; 28 sceneSchedule(i).duration = score.sceneDuration;
29 else 29 if (i==1)
30 sceneSchedule(i).ebr= score.backgrounds{i}{3}; 30 sceneSchedule(i).ebr=1;
31 else
32 sceneSchedule(i).ebr= score.backgrounds{i}{3};
33 end
31 end 34 end
35
36 else
37
38 noise=randn(1,sr*score.sceneDuration);
39 noise=noise./max(abs(noise));
40
41 if noiseFiltMaxFreq
42 noise=filter(fir1(noiseFiltOrder,noiseFiltMaxFreq/sr/2),1,noise);
43 end
44
45 noise=noise.*exp(noiseLevel/20);
46
47 sceneObjects(1).isBackground = 1;
48 sceneObjects(1).classLabel = 'noise';
49 sceneObjects(1).startTimes = 0;
50 sceneObjects(1).endTimes = score.sceneDuration;
51 sceneObjects(1).names={'noise'};
52 sceneObjects(1).query= 'noise';
53 sceneObjects(1).trackLength=score.sceneDuration;
54
55 sceneSchedule(1).classId=1;
56 sceneSchedule(1).classLabel='noise';
57 sceneSchedule(1).position=0;
58 sceneSchedule(1).instance=1;
59 sceneSchedule(1).isBackground = 1;
60 sceneSchedule(1).duration = score.sceneDuration;
61
62 score.backgrounds{1}{1}='noise';
63 score.backgrounds{1}{2}=noise;
32 end 64 end
33 end 65 end