gregoire@24: function [sceneSchedule,sceneObjects,score]=getBackground(inputPath,score,eventInfo,sr,noiseLevel,noiseFiltMaxFreq,noiseFiltOrder) 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: gregoire@24: if isfield(score,'backgrounds') gregoire@24: gregoire@24: for i=1:length(score.backgrounds) gregoire@24: sceneObjects(i) = getSampleInfo(score.backgrounds{i}{1},score.backgrounds{i}{2},'background',inputPath,score.sceneDuration,eventInfo,sr); gregoire@24: sceneSchedule(i).classId=i; gregoire@24: sceneSchedule(i).classLabel=score.backgrounds{i}{2}; gregoire@24: sceneSchedule(i).position=0; gregoire@24: sceneSchedule(i).instance=1; gregoire@24: sceneSchedule(i).isBackground = 1; gregoire@24: sceneSchedule(i).duration = score.sceneDuration; gregoire@24: if (i==1) gregoire@24: sceneSchedule(i).ebr=1; gregoire@24: else gregoire@24: sceneSchedule(i).ebr= score.backgrounds{i}{3}; gregoire@24: end mathieu@14: end gregoire@24: gregoire@24: else gregoire@24: gregoire@24: noise=randn(1,sr*score.sceneDuration); gregoire@24: noise=noise./max(abs(noise)); gregoire@24: gregoire@24: if noiseFiltMaxFreq gregoire@24: noise=filter(fir1(noiseFiltOrder,noiseFiltMaxFreq/sr/2),1,noise); gregoire@24: end gregoire@24: gregoirelafay@27: noise=noise.*power(noiseLevel/20); gregoire@24: gregoire@24: sceneObjects(1).isBackground = 1; gregoire@24: sceneObjects(1).classLabel = 'noise'; gregoire@24: sceneObjects(1).startTimes = 0; gregoire@24: sceneObjects(1).endTimes = score.sceneDuration; gregoire@24: sceneObjects(1).names={'noise'}; gregoire@24: sceneObjects(1).query= 'noise'; gregoire@24: sceneObjects(1).trackLength=score.sceneDuration; gregoire@24: gregoire@24: sceneSchedule(1).classId=1; gregoire@24: sceneSchedule(1).classLabel='noise'; gregoire@24: sceneSchedule(1).position=0; gregoire@24: sceneSchedule(1).instance=1; gregoire@24: sceneSchedule(1).isBackground = 1; gregoire@24: sceneSchedule(1).duration = score.sceneDuration; gregoire@24: gregoire@24: score.backgrounds{1}{1}='noise'; gregoire@24: score.backgrounds{1}{2}=noise; mathieu@14: end mathieu@14: end