tomwalters@0
|
1 % tool
|
tomwalters@0
|
2 %
|
tomwalters@0
|
3 % INPUT VALUES:
|
tomwalters@0
|
4 %
|
tomwalters@0
|
5 % RETURN VALUE:
|
tomwalters@0
|
6 %
|
tomwalters@0
|
7 %
|
bleeck@3
|
8 % (c) 2011, University of Southampton
|
bleeck@3
|
9 % Maintained by Stefan Bleeck (bleeck@gmail.com)
|
bleeck@3
|
10 % download of current version is on the soundsoftware site:
|
bleeck@3
|
11 % http://code.soundsoftware.ac.uk/projects/aimmat
|
bleeck@3
|
12 % documentation and everything is on http://www.acousticscale.org
|
bleeck@3
|
13
|
tomwalters@0
|
14
|
tomwalters@0
|
15 function makeaimmovie(varargin)
|
tomwalters@0
|
16 %usage: function makemovie(arguments)
|
tomwalters@0
|
17 %
|
tomwalters@0
|
18 % produces a quicktime-video from an AMS/AIM spf file and a sound file
|
tomwalters@0
|
19 % inputs:
|
tomwalters@0
|
20 % if no or only one parameter is given, than a make file is read instead
|
tomwalters@0
|
21 % that should contain all parameters and their values
|
tomwalters@0
|
22 % this file is generated automatically as "lastrun.genmovie"
|
tomwalters@0
|
23 %
|
tomwalters@0
|
24 % otherwise parameter must come in pairs: 'param','value'
|
tomwalters@0
|
25 %
|
tomwalters@0
|
26 % parameters for generating the SAI:
|
tomwalters@0
|
27 % modelfile - the spf file that specifies the version of AMS/AIM (required)
|
tomwalters@0
|
28 % output_normalization - the norm_mode parameter in out_file very useful for automatic scaling
|
tomwalters@0
|
29 % soundfile - a wave or raw file with the sound in (required)
|
tomwalters@0
|
30 % sound_sample_rate - the sample rate of the sound file
|
tomwalters@0
|
31 % sound_endian - endian of the sound file (l or b)(PC's are little endian Suns are big endian)
|
tomwalters@0
|
32 % framespersecond (default: 12)
|
tomwalters@0
|
33 % moviefile - the name of the output file (default: "name of model plus name of sound")
|
tomwalters@0
|
34 % echo - if off, than no output is created on screen
|
tomwalters@0
|
35 % aifffile - optional instead of model. When aifffile is given, the aif file is read in directly from it
|
tomwalters@0
|
36 %
|
tomwalters@0
|
37 % Parameter for generating the graphic
|
tomwalters@0
|
38 % AuditoryImageFormat: "AI", "AIpitch", "AIsum", "AIsum2", "sumai", or "AIsurface" (default: AIsum) or any user-defined-function
|
tomwalters@0
|
39 % the user-defined-function is called with the current frame and must produce a picture
|
tomwalters@0
|
40 % currently supported: show_pitch_spiral
|
tomwalters@0
|
41 % AIFrePtiPStress (Auditory Image with Frequency profile and time interval profile with the colors in the image where the information was derived from
|
tomwalters@0
|
42 %
|
tomwalters@0
|
43 % TimeIntervalUnits "log" or "linear" (default: log)
|
tomwalters@0
|
44 % colormap (default: black)
|
tomwalters@0
|
45 % input_scale - scaling factor, that is directly applied to the input values - to prevent too loud sounds (default 1 can be set to auto)
|
tomwalters@0
|
46 % minimum_time_interval - the minimal time that should be displayed in logarithmic form (in ms)
|
tomwalters@0
|
47 % maximum_time_interval - the maximal time that should be displayed in logarithmic form
|
tomwalters@0
|
48 % linewidth - Width of all plotted lines (default 1)
|
tomwalters@0
|
49 % showtime - plot the time and the number of each frame (default on)
|
tomwalters@0
|
50 % text - show a text in each frame in the upper right corner. The text must be given in a struct with .time and .label
|
tomwalters@0
|
51 % plot_scale - scales the whole frame up or down
|
tomwalters@0
|
52 % profile_scale - increases the amplitude of the profiles
|
tomwalters@0
|
53
|
tomwalters@0
|
54 % the length of the final movie is the length of the soundfile plus the length of one picture in the beginning
|
tomwalters@0
|
55
|
tomwalters@0
|
56 % valid calls:
|
tomwalters@0
|
57 % the shortest valid call:
|
tomwalters@0
|
58 % makemovie('modelfile''aim.spf','soundfile','cegc_br.raw')
|
tomwalters@0
|
59 % produces the video "aim.mov" from the soundfile "cegc_br.wav" and the model file aim.spf
|
tomwalters@0
|
60 % example
|
tomwalters@0
|
61 %makemovie( 'modelfile','AIMghs.spf',...
|
tomwalters@0
|
62 % 'soundfile','f128h8j0-2.wav',...
|
tomwalters@0
|
63 % 'framespersecond','12',...
|
tomwalters@0
|
64 % 'moviefile', 'impressing_movie',... %(".mov" is added)
|
tomwalters@0
|
65 % 'TimeIntervalUnits','log',... % (or linear)
|
tomwalters@0
|
66 % 'input_scale','default',... % ( or any number >0)
|
tomwalters@0
|
67 % 'output_normalization','1000',... % (this number overwrites the NORM_MODE.DataFile_Out)
|
tomwalters@0
|
68 % 'AuditoryImageFormat','sum',... % ( or AI,AIsurface,AIsum)
|
tomwalters@0
|
69 % 'sound_sample_rate','20000',... % ( if the soundfile is not a wavfile - this must be togehter with the next one)
|
tomwalters@0
|
70 % 'minimum_time_interval','2',... % ( in ms the smalles time, that is displayed)
|
tomwalters@0
|
71 % 'sound_endian','l') % ( if the soundfile is not a wavfile - this must be togehter with the previous one)
|
tomwalters@0
|
72
|
tomwalters@0
|
73
|
tomwalters@0
|
74 % you can choose between several types without changing the spf-file! If you want all channels with the waterfal than
|
tomwalters@0
|
75 % the according reduce_channels are commented out automatically
|
tomwalters@0
|
76
|
tomwalters@0
|
77 % the full movie will consist of so many pictures as the length of the soundfile divided by the frames per seconds.
|
tomwalters@0
|
78 % To avoid clicks (due to quicktime) at the onset of the sound one frame and
|
tomwalters@0
|
79 % an pause of one frame is inserted at the beginning of the movie.
|
tomwalters@0
|
80 % To avoid a black picture at the end, one more frame is inserted at the end of the movie, so that the final movie
|
tomwalters@0
|
81 % is slighly longer than the sound and the last picture is shown twice
|
tomwalters@0
|
82
|
tomwalters@0
|
83 % the principle of the generation is to load the spf file and crucial variables are overwwitten:
|
tomwalters@0
|
84 % the file_in is overwritten by the calling "soundfile" and the sound-out is overwritten by some temp-aiff file
|
tomwalters@0
|
85 % the modified spf-file is stored under makemovie_temp.spf and this file is called via ams
|
tomwalters@0
|
86
|
tomwalters@0
|
87 temp_sound_file_name='temp_sound.wav'; % must be the same as in getaiffs!!!
|
tomwalters@0
|
88
|
tomwalters@0
|
89 if nargin<2 % only one parameter -> read file
|
tomwalters@0
|
90 if size(varargin)==1
|
tomwalters@0
|
91 makefilename=varargin{1};
|
tomwalters@0
|
92 else
|
tomwalters@0
|
93 makefilename='lastrun.genmovie';
|
tomwalters@0
|
94 end
|
tomwalters@0
|
95 % fprintf('movie is produced from file %s from aifffile "makemovie_temp.aif"\n!',makefilename);
|
tomwalters@0
|
96 % fprintf('movie is produced from file ''%s''\n',makefilename);
|
tomwalters@0
|
97 else
|
tomwalters@0
|
98 makefilename='lastrun.genmovie';
|
tomwalters@0
|
99 generateparameterfile(makefilename,varargin);
|
tomwalters@0
|
100 end
|
tomwalters@0
|
101 arguments=readparameterfile(makefilename);
|
tomwalters@0
|
102
|
tomwalters@0
|
103
|
tomwalters@0
|
104 str_moviefile=getargument(arguments,'moviefile');
|
tomwalters@0
|
105 str_aifffile=getargument(arguments,'aifffile');
|
tomwalters@0
|
106 str_movie_duration=getargument(arguments,'movie_duration');
|
tomwalters@0
|
107 str_movie_start_time=getargument(arguments,'movie_start_time');
|
tomwalters@0
|
108 str_AuditoryImageFormat=getargument(arguments,'AuditoryImageFormat');
|
tomwalters@0
|
109 str_TimeIntervalUnits=getargument(arguments,'TimeIntervalUnits');
|
tomwalters@0
|
110 str_colormap=getargument(arguments,'colormap');
|
tomwalters@0
|
111 str_minimum_time_interval=getargument(arguments,'minimum_time_interval');
|
tomwalters@0
|
112 str_maximum_time_interval=getargument(arguments,'maximum_time_interval');
|
tomwalters@0
|
113 str_sound_sample_rate=getargument(arguments,'sound_sample_rate');
|
tomwalters@0
|
114 str_sound_endian=getargument(arguments,'sound_endian');
|
tomwalters@0
|
115 str_linewidth=getargument(arguments,'linewidth');
|
tomwalters@0
|
116 str_echo=getargument(arguments,'echo');
|
tomwalters@0
|
117 str_showtime=getargument(arguments,'showtime');
|
tomwalters@0
|
118 str_showtextname=getargument(arguments,'showtextname');
|
tomwalters@0
|
119 str_showtexttime=getargument(arguments,'showtexttime');
|
tomwalters@0
|
120 str_plotscale=getargument(arguments,'plotscale');
|
tomwalters@0
|
121 str_profile_scale=getargument(arguments,'profile_scale');
|
tomwalters@0
|
122
|
tomwalters@0
|
123 % data originally used in readaiff, but needed here also:
|
tomwalters@0
|
124 str_framespersecond=getargument(arguments,'framespersecond');
|
tomwalters@0
|
125 str_model=getargument(arguments,'modelfile');
|
tomwalters@0
|
126 str_soundcommand=getargument(arguments,'soundfile');
|
tomwalters@0
|
127
|
tomwalters@0
|
128
|
tomwalters@0
|
129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
130 % set some default values, if the values are not explecitly given:
|
tomwalters@0
|
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
133
|
tomwalters@0
|
134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
135 % scale the amplitude of the whole picture up
|
tomwalters@0
|
136 if isempty(str_plotscale) % default frames per second
|
tomwalters@0
|
137 plot_scale=1;
|
tomwalters@0
|
138 else
|
tomwalters@0
|
139 eval(sprintf('plot_scale=%s;',str_plotscale));
|
tomwalters@0
|
140 end
|
tomwalters@0
|
141
|
tomwalters@0
|
142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
143 % scale the amplitude of the profiles (only when profiles are plotted of course)
|
tomwalters@0
|
144 if isempty(str_profile_scale) % default frames per second
|
tomwalters@0
|
145 profile_scale=1;
|
tomwalters@0
|
146 else
|
tomwalters@0
|
147 eval(sprintf('profile_scale=%s;',str_profile_scale));
|
tomwalters@0
|
148 end
|
tomwalters@0
|
149
|
tomwalters@0
|
150 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
151 % show time and number of frame
|
tomwalters@0
|
152 if isempty(str_showtime) % default frames per second
|
tomwalters@0
|
153 showtime=1;
|
tomwalters@0
|
154 else
|
tomwalters@0
|
155 if strcmp(str_showtime,'off')
|
tomwalters@0
|
156 showtime=0;
|
tomwalters@0
|
157 else
|
tomwalters@0
|
158 showtime=1;
|
tomwalters@0
|
159 end
|
tomwalters@0
|
160 end
|
tomwalters@0
|
161
|
tomwalters@0
|
162
|
tomwalters@0
|
163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
164 % frames per second
|
tomwalters@0
|
165 if isempty(str_framespersecond) % default frames per second
|
tomwalters@0
|
166 framespersecond=12;
|
tomwalters@0
|
167 else
|
tomwalters@0
|
168 eval(sprintf('framespersecond=%s;',str_framespersecond));
|
tomwalters@0
|
169 end
|
tomwalters@0
|
170
|
tomwalters@0
|
171
|
tomwalters@0
|
172 if isempty(str_linewidth) % how much the spf file should be normalized by setting the norm_mode parameter in out_file
|
tomwalters@0
|
173 line_width=1;
|
tomwalters@0
|
174 else
|
tomwalters@0
|
175 eval(sprintf('line_width=%s;',str_linewidth));
|
tomwalters@0
|
176 end
|
tomwalters@0
|
177
|
tomwalters@0
|
178 if isempty(str_TimeIntervalUnits) % output is linear or logarithmic
|
tomwalters@0
|
179 TimeIntervalUnits='log';
|
tomwalters@0
|
180 else
|
tomwalters@0
|
181 TimeIntervalUnits=str_TimeIntervalUnits;
|
tomwalters@0
|
182 end
|
tomwalters@0
|
183
|
tomwalters@0
|
184 if isempty(str_moviefile) % default name of the movie
|
tomwalters@0
|
185 [dumy_path,tempmodelname,ext,versn] = fileparts(str_model);
|
tomwalters@0
|
186 [dumy_path,tempsoundname,ext,versn] = fileparts(str_soundcommand);
|
tomwalters@0
|
187 moviefile=sprintf('soundfile_%s_model_%s.mov',tempsoundname,tempmodelname);
|
tomwalters@0
|
188 else
|
tomwalters@0
|
189 [dumy_path,tempmodelname,ext,versn] = fileparts(str_moviefile);
|
tomwalters@0
|
190 if strcmp(ext,'')
|
tomwalters@0
|
191 moviefile=sprintf('%s.mov',str_moviefile);
|
tomwalters@0
|
192 else
|
tomwalters@0
|
193 moviefile=str_moviefile;
|
tomwalters@0
|
194 end
|
tomwalters@0
|
195 end
|
tomwalters@0
|
196
|
tomwalters@0
|
197 if isempty(str_AuditoryImageFormat) % which AuditoryImageFormat should be used
|
tomwalters@0
|
198 AuditoryImageFormat='AIsum';
|
tomwalters@0
|
199 else
|
tomwalters@0
|
200 AuditoryImageFormat=str_AuditoryImageFormat;
|
tomwalters@0
|
201 end
|
tomwalters@0
|
202
|
tomwalters@0
|
203 if isempty(str_colormap) % an aifffile that is read instead
|
tomwalters@0
|
204 if strcmp(AuditoryImageFormat,'AI') | strcmp(AuditoryImageFormat,'AIsum') | strcmp(AuditoryImageFormat,'sum')| strcmp(AuditoryImageFormat,'singlegraphic')
|
tomwalters@0
|
205 clrmap=zeros(64,3); % all black
|
tomwalters@0
|
206 end
|
tomwalters@0
|
207 if strcmp(AuditoryImageFormat,'AIsurface')
|
tomwalters@0
|
208 clrmap=1-gray; % invertes grayscale: 0 is white and 1 is black
|
tomwalters@0
|
209 end
|
tomwalters@0
|
210 else % colormap was given
|
tomwalters@0
|
211 eval(sprintf('clrmap=%s;',str_colormap));
|
tomwalters@0
|
212 end
|
tomwalters@0
|
213
|
tomwalters@0
|
214 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
215 % sound-file. can be a command or a file
|
tomwalters@0
|
216 if isempty(str_soundcommand) %
|
tomwalters@0
|
217 error('soundcommand must be given');
|
tomwalters@0
|
218 else
|
tomwalters@0
|
219 soundcommand=str_soundcommand;
|
tomwalters@0
|
220 end
|
tomwalters@0
|
221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
222 % echo on screen
|
tomwalters@0
|
223 if isempty(str_echo) % default frames per second
|
tomwalters@0
|
224 echo=1;
|
tomwalters@0
|
225 else
|
tomwalters@0
|
226 if strcmp(str_echo,'off')
|
tomwalters@0
|
227 echo=0;
|
tomwalters@0
|
228 else
|
tomwalters@0
|
229 echo=1;
|
tomwalters@0
|
230 end
|
tomwalters@0
|
231 end
|
tomwalters@0
|
232
|
tomwalters@0
|
233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
234 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
236 % construct the aiff-file with a call to the dsam-routine:
|
tomwalters@0
|
237
|
tomwalters@0
|
238 % if aifffile is given from a previous run, than simply load it:
|
tomwalters@0
|
239 if ~isempty(str_aifffile)
|
tomwalters@0
|
240 allframes=SBReadAiff(str_aifffile,echo); % returns all info in a struct
|
tomwalters@0
|
241 else
|
tomwalters@0
|
242 allframes=getaiffs(makefilename);
|
tomwalters@0
|
243 end
|
tomwalters@0
|
244
|
tomwalters@0
|
245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
246
|
tomwalters@0
|
247
|
tomwalters@0
|
248
|
tomwalters@0
|
249
|
tomwalters@0
|
250
|
tomwalters@0
|
251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
tomwalters@0
|
252 % read the sound command and transfere the data to the buffer
|
tomwalters@0
|
253 if ~isempty(str_movie_duration) % default frames per second
|
tomwalters@0
|
254 eval(sprintf('movie_duration=%s;',str_movie_duration));
|
tomwalters@0
|
255 eval(sprintf('movie_start_time=%s;',str_movie_start_time));
|
tomwalters@0
|
256 [sounddata,samplerate,bits,endian]=producesounddata(soundcommand,temp_sound_file_name,str_sound_sample_rate,str_sound_endian,movie_start_time,movie_duration);
|
tomwalters@0
|
257 else
|
tomwalters@0
|
258 movie_start_time=0;
|
tomwalters@0
|
259 [sounddata,samplerate,bits,endian]=producesounddata(soundcommand,temp_sound_file_name,str_sound_sample_rate,str_sound_endian);
|
tomwalters@0
|
260 movie_duration=length(sounddata)/samplerate;
|
tomwalters@0
|
261 end
|
tomwalters@0
|
262
|
tomwalters@0
|
263
|
tomwalters@0
|
264 % the duration of the whole video
|
tomwalters@0
|
265 videolength=size(sounddata,1)/samplerate;
|
tomwalters@0
|
266 % so long is one picture:
|
tomwalters@0
|
267 duration=1/framespersecond;
|
tomwalters@0
|
268
|
tomwalters@0
|
269 % so many frames is the video size in the end:
|
tomwalters@0
|
270 nr_frames=videolength*framespersecond;
|
tomwalters@0
|
271
|
tomwalters@0
|
272 % find out about the general structure of all frames by taking the first as a sample (they are all identical)
|
tomwalters@0
|
273 sample_frame=allframes(1);
|
tomwalters@0
|
274 nr_channels=getnrchannels(sample_frame);
|
tomwalters@0
|
275 nr_points=getnrpoints(sample_frame);
|
tomwalters@0
|
276 nr_frames=size(allframes,2);
|
tomwalters@0
|
277 t_plus=getmaximumtime(sample_frame); % usually 5 ms
|
tomwalters@0
|
278 t_minus=getminimumtime(sample_frame); % usually -35 ms
|
tomwalters@0
|
279
|
tomwalters@0
|
280 % set a variable for the current starting time of each frame for plotting
|
tomwalters@0
|
281 for i=1:nr_frames
|
tomwalters@0
|
282 allframes(i)=setcurrentframestarttime(allframes(i),(i-1)*duration);
|
tomwalters@0
|
283 end
|
tomwalters@0
|
284
|
tomwalters@0
|
285 % start producing the movie!
|
tomwalters@0
|
286 MakeQTMovie('start',moviefile);
|
tomwalters@0
|
287 MakeQTMovie('size', [640 400]);
|
tomwalters@0
|
288 MakeQTMovie('quality', 0.8); % reduces the size
|
tomwalters@0
|
289
|
tomwalters@0
|
290 if echo fprintf('start produce pictures:\n'); end
|
tomwalters@0
|
291
|
tomwalters@0
|
292 % We start the time at zero:
|
tomwalters@0
|
293 current_time=0;
|
tomwalters@0
|
294
|
tomwalters@0
|
295 for i=0:nr_frames
|
tomwalters@0
|
296 if echo
|
tomwalters@0
|
297 % plot a start for each frame, so that we see, how long it takes
|
tomwalters@0
|
298 fprintf('*');
|
tomwalters@0
|
299 if(mod(i+1,30)==0)
|
tomwalters@0
|
300 fprintf('\n');
|
tomwalters@0
|
301 end
|
tomwalters@0
|
302 end
|
tomwalters@0
|
303
|
tomwalters@0
|
304 if i==0 % trick: the first picture is the same as the second to prevent quick time from producing a click sound, that it otherwise does
|
tomwalters@0
|
305 c_frame=allframes(1);
|
tomwalters@0
|
306 current_time=0;
|
tomwalters@0
|
307 else
|
tomwalters@0
|
308 c_frame=allframes(i);
|
tomwalters@0
|
309 end
|
tomwalters@0
|
310
|
tomwalters@0
|
311 % set some default values that depend on the frames
|
tomwalters@0
|
312 if strcmp(TimeIntervalUnits,'log')>0
|
tomwalters@0
|
313 framestruct.is_log=1;
|
tomwalters@0
|
314 else
|
tomwalters@0
|
315 framestruct.is_log=0;
|
tomwalters@0
|
316 end
|
tomwalters@0
|
317
|
tomwalters@0
|
318 if showtime
|
tomwalters@0
|
319 framestruct.show_time=1;
|
tomwalters@0
|
320 else
|
tomwalters@0
|
321 framestruct.show_time=0;
|
tomwalters@0
|
322 end
|
tomwalters@0
|
323
|
tomwalters@0
|
324 if ~isempty(str_showtextname)
|
tomwalters@0
|
325 texts=str2cell(str_showtextname);
|
tomwalters@0
|
326 times=str2cell(str_showtexttime);
|
tomwalters@0
|
327 nr_times=size(times,1);
|
tomwalters@0
|
328 if nr_times<=1 % every picture
|
tomwalters@0
|
329 c_frame=settext(c_frame,texts(1));
|
tomwalters@0
|
330 else
|
tomwalters@0
|
331 for i=1:nr_times
|
tomwalters@0
|
332 tt=str2num(times{i});
|
tomwalters@0
|
333 if tt>current_time
|
tomwalters@0
|
334 c_frame=settext(c_frame,texts(i));
|
tomwalters@0
|
335 break;
|
tomwalters@0
|
336 end
|
tomwalters@0
|
337 end
|
tomwalters@0
|
338 end
|
tomwalters@0
|
339 end
|
tomwalters@0
|
340
|
tomwalters@0
|
341 if isempty(str_minimum_time_interval) % how much the spf file should be normalized by setting the norm_mode parameter in out_file
|
tomwalters@0
|
342 if framestruct.is_log
|
tomwalters@0
|
343 minimum_time_interval=2; % ms = default value for the minimum time
|
tomwalters@0
|
344 else
|
tomwalters@0
|
345 minimum_time_interval=-t_plus*1000; % ms = default value for the minimum time
|
tomwalters@0
|
346 end
|
tomwalters@0
|
347 else
|
tomwalters@0
|
348 eval(sprintf('minimum_time_interval=%s;',str_minimum_time_interval));
|
tomwalters@0
|
349 if framestruct.is_log
|
tomwalters@0
|
350 if minimum_time_interval < 0
|
tomwalters@0
|
351 disp('minimum time interval must be >0 for log plots');
|
tomwalters@0
|
352 minimum_time_interval=2;
|
tomwalters@0
|
353 end
|
tomwalters@0
|
354 end
|
tomwalters@0
|
355 end
|
tomwalters@0
|
356
|
tomwalters@0
|
357 if isempty(str_maximum_time_interval) % default value for maximum time
|
tomwalters@0
|
358 maximum_time_interval=-t_minus*1000; % in ms! % to the end of the stimulus
|
tomwalters@0
|
359 else
|
tomwalters@0
|
360 eval(sprintf('maximum_time_interval=%s;',str_maximum_time_interval));
|
tomwalters@0
|
361 end
|
tomwalters@0
|
362
|
tomwalters@0
|
363 % construct the framestructure for calling the plotting-routine
|
tomwalters@0
|
364 framestruct.current_frame = c_frame;
|
tomwalters@0
|
365 framestruct.maximum_time_interval=maximum_time_interval;
|
tomwalters@0
|
366 framestruct.minimum_time_interval=minimum_time_interval;
|
tomwalters@0
|
367 framestruct.plot_scale=plot_scale;
|
tomwalters@0
|
368 framestruct.profile_scale=profile_scale;
|
tomwalters@0
|
369
|
tomwalters@0
|
370
|
tomwalters@0
|
371 % call the plotting routine
|
tomwalters@0
|
372 eval(sprintf('%s(framestruct);',AuditoryImageFormat));
|
tomwalters@0
|
373
|
tomwalters@0
|
374 % bring the figure to front
|
tomwalters@0
|
375 figure(gcf);
|
tomwalters@0
|
376
|
tomwalters@0
|
377 % and add it to the movie
|
tomwalters@0
|
378 MakeQTMovie('addframe');
|
tomwalters@0
|
379
|
tomwalters@0
|
380 current_time=current_time+duration;
|
tomwalters@0
|
381
|
tomwalters@0
|
382 end % End of current_frame - loop
|
tomwalters@0
|
383
|
tomwalters@0
|
384 % add one, to fill the last picture (the sound is longer than n*nr_frames)
|
tomwalters@0
|
385 MakeQTMovie('addframe');
|
tomwalters@0
|
386 MakeQTMovie('framerate', framespersecond);
|
tomwalters@0
|
387
|
tomwalters@0
|
388 % soundgap=zeros(floor(samplerate/framespersecond),1);
|
tomwalters@0
|
389 % stemp=[soundgap' sounddata'];
|
tomwalters@0
|
390 % sounddata=stemp';
|
tomwalters@0
|
391 MakeQTMovie('addsound',sounddata,samplerate);
|
tomwalters@0
|
392
|
tomwalters@0
|
393 MakeQTMovie('finish');
|
tomwalters@0
|
394 MakeQTMovie('cleanup');
|
tomwalters@0
|
395
|
tomwalters@0
|
396 % fprintf('\n\nFinished successfully! :-)\n');
|
tomwalters@0
|
397 if echo
|
tomwalters@0
|
398 disp(sprintf('\n\nWrote QuickTime movie %s\\%s',pwd,moviefile));
|
tomwalters@0
|
399 end
|
tomwalters@0
|
400
|
tomwalters@0
|
401 return
|
tomwalters@0
|
402
|
tomwalters@0
|
403
|
tomwalters@0
|
404 % clean up
|
tomwalters@0
|
405 ans=input('start with QuickTime? y/[n]','s')
|
tomwalters@0
|
406 if ans=='y'
|
tomwalters@0
|
407 !C:\Program Files\QuickTime\QuickTimePlayer
|
tomwalters@0
|
408 end
|
tomwalters@0
|
409
|
tomwalters@0
|
410
|
tomwalters@0
|
411 % not cleaning up: (for test purpose)
|
tomwalters@0
|
412 return
|
tomwalters@0
|
413 % clean up temporary files
|
tomwalters@0
|
414 try
|
tomwalters@0
|
415 delete('makemovie_temp.spf');
|
tomwalters@0
|
416 end
|
tomwalters@0
|
417 try
|
tomwalters@0
|
418 delete('makemovie_temp.aif');
|
tomwalters@0
|
419 end
|
tomwalters@0
|
420 if rememberdeletesoundfile
|
tomwalters@0
|
421 try
|
tomwalters@0
|
422 delete(soundfile);
|
tomwalters@0
|
423 end
|
tomwalters@0
|
424 end
|