Mercurial > hg > simscene-py
comparison simScene.m @ 16:92f73423eb37
update figure generation
author | GregoireLafay <gregoire.lafay@irccyn.ec-nantes.fr> |
---|---|
date | Wed, 06 Jan 2016 18:04:24 +0100 |
parents | 69410ac2a50d |
children | fc99c676c280 |
comparison
equal
deleted
inserted
replaced
15:69410ac2a50d | 16:92f73423eb37 |
---|---|
98 % | 98 % |
99 % - instanceAudioFile: if timeMode and / or ebrMode are set to 'abstract' | 99 % - instanceAudioFile: if timeMode and / or ebrMode are set to 'abstract' |
100 % or 'replicate', this parameter is the path to the wav | 100 % or 'replicate', this parameter is the path to the wav |
101 % file of the reference scene sampled at 44100 Hz. | 101 % file of the reference scene sampled at 44100 Hz. |
102 % | 102 % |
103 % - displayFigures: Boolean (default 0), save pictures (piano roll, time | 103 % - figuresOption: (default 1) save and show pictures (piano roll, time domain stacked visualization, overlaid spectrogram) |
104 % domain stacked visualization, overlaid spectrogram) | 104 % 0: don't save or display pictures |
105 % | 105 % 1: save pictures without displaying them |
106 % 2: save and display pictures | |
107 % | |
106 % - outputFileName: name of generated files with no extension | 108 % - outputFileName: name of generated files with no extension |
107 % | 109 % |
108 % - sampleChoice: method for choosing sample to schedule within a track | 110 % - sampleChoice: method for choosing sample to schedule within a track |
109 % 'random': unconstrained sampling | 111 % 'random': unconstrained sampling |
112 % 'random-unique': unconstrained sampling with no sample repetition | |
110 % 'close': choose among the sampling dataset the sample that | 113 % 'close': choose among the sampling dataset the sample that |
111 % has the closest duration to the reference one. | 114 % has the closest duration to the reference one. |
112 % This mode is available only for the replicate timeMode. | 115 % This mode is available only for the replicate timeMode. |
113 % | 116 % |
114 % - minSpace: floating point value (default -1: overlapping between events allowed): | 117 % - minSpace: floating point value (default -1: overlapping between events allowed): |
150 % | 153 % |
151 % Uses Mark Paskin's process_options.m from KPMtools | 154 % Uses Mark Paskin's process_options.m from KPMtools |
152 | 155 |
153 addpath(genpath('nonExposed')); | 156 addpath(genpath('nonExposed')); |
154 | 157 |
155 [timeMode,ebrMode,instanceAnnotFile,instanceAudioFile,displayFigures,sampleChoice,outputFileName,minSpace,endCut]=process_options(varargin,'timeMode','generate','ebrMode','generate','instanceAnnotFile','none','instanceAudioFile','none','displayFigures','1','sampleChoice','random','outputFileName','simulatedScene','minSpace',-1,'endCut',0); | 158 [timeMode,ebrMode,instanceAnnotFile,instanceAudioFile,figuresOption,sampleChoice,outputFileName,minSpace,endCut,eventInfoPath,norm]=process_options(varargin,'timeMode','generate','ebrMode','generate','instanceAnnotFile','none','instanceAudioFile','none','figuresOption',1,'sampleChoice','random','outputFileName','simulatedScene','minSpace',-1,'endCut',0,'eventInfoPath','','norm',0); |
159 | |
160 sr=44100; | |
156 | 161 |
157 check_options(timeMode,ebrMode,score) | 162 check_options(timeMode,ebrMode,score) |
158 | 163 |
159 %% Get score (only if at least one of the modes is not set to generate). | 164 %% Get score (only if at least one of the modes is not set to generate). |
160 % Else use score inpu variable | 165 % Else use score inpu variable |
170 score.sceneDuration=template.sceneDuration; | 175 score.sceneDuration=template.sceneDuration; |
171 end | 176 end |
172 end | 177 end |
173 | 178 |
174 %% Get sceneSchedule and sceneObjects | 179 %% Get sceneSchedule and sceneObjects |
175 [sceneSchedule,sceneObjects]=getBackground(inputPath,score); | 180 |
176 [sceneSchedule,sceneObjects]=getEvent(sceneSchedule,sceneObjects,inputPath,score,timeMode,ebrMode,strcmp(sampleChoice,'random')); | 181 if ~strcmp(eventInfoPath,'') |
182 load(eventInfoPath); | |
183 else | |
184 eventInfo{1}.query='null'; | |
185 end | |
186 | |
187 [sceneSchedule,sceneObjects]=getBackground(inputPath,score,eventInfo,sr); | |
188 [sceneSchedule,sceneObjects]=getEvent(sceneSchedule,sceneObjects,inputPath,score,timeMode,ebrMode,sampleChoice,eventInfo,sr); | |
177 | 189 |
178 %% Manage overlapping | 190 %% Manage overlapping |
179 if minSpace>=0 | 191 if minSpace>=0 |
180 [sceneSchedule] = manageOverlapping(sceneSchedule,minSpace); | 192 [sceneSchedule] = manageOverlapping(sceneSchedule,minSpace); |
181 end | 193 end |
190 end | 202 end |
191 if (~exist([outputPath,'annotation'], 'dir')) | 203 if (~exist([outputPath,'annotation'], 'dir')) |
192 mkdir([outputPath,'annotation']) | 204 mkdir([outputPath,'annotation']) |
193 end | 205 end |
194 | 206 |
195 [simsSceneWav,sceneSchedule] = generateScene(sceneSchedule,sceneObjects,score,inputPath,outputPath,outputFileName,displayFigures,timeMode,endCut); | 207 [simsSceneWav,sceneSchedule] = generateScene(sceneSchedule,sceneObjects,score,inputPath,outputPath,outputFileName,figuresOption,timeMode,endCut,norm,sr); |
196 | 208 |
197 %% Check simulated scene | 209 %% Check simulated scene |
198 | 210 |
199 checkClassPresence(sceneSchedule,sceneObjects); | 211 checkClassPresence(sceneSchedule,sceneObjects); |
200 | 212 |
201 if minSpace>=0 | 213 if minSpace>=0 |
202 checkOverlapping(sceneSchedule,score.sceneDuration) | 214 checkOverlapping(sceneSchedule,score.sceneDuration) |
203 end | 215 end |
204 | 216 |
205 %% Generate Sound | 217 %% Generate Sound |
206 % wavwrite(simsSceneWav,44100,[outputPath,'sound/',outputFileName,'.wav']); | 218 audiowrite([outputPath,'sound/',outputFileName,'.wav'],simsSceneWav,sr); |
207 audiowrite([outputPath,'sound/',outputFileName,'.wav'],simsSceneWav,44100); | 219 end |
208 end |