tomwalters@0: % tool tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % tomwalters@0: % bleeck@3: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org bleeck@3: tomwalters@0: tomwalters@0: function options=AIFrePtiP(framestruct_a); tomwalters@0: % plots the current frame (cframe) together with its sum of intervals tomwalters@0: % and the sum of frequencies tomwalters@0: % no pitch is calculated or plotted! for this use AIFrePtiPstress tomwalters@0: % all relevant data must be in the frame-object tomwalters@0: % the return value "pitch" is the result from the call to "calcresidualprobability" tomwalters@0: tomwalters@0: tomwalters@0: if ~isstruct(framestruct_a) tomwalters@0: % error('AIsum must be called with a structure'); tomwalters@0: framestruct.current_frame=framestruct_a; tomwalters@0: else tomwalters@0: framestruct=framestruct_a; tomwalters@0: end tomwalters@0: tomwalters@0: if ~isfield(framestruct,'show_time'); tomwalters@0: show_time=1; tomwalters@0: else tomwalters@0: show_time=framestruct.show_time; tomwalters@0: end tomwalters@0: tomwalters@0: if ~isfield(framestruct,'plot_scale'); tomwalters@0: plot_scale=1; tomwalters@0: else tomwalters@0: plot_scale=framestruct.plot_scale; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: if ~isfield(framestruct,'minimum_time_interval'); tomwalters@0: minimum_time_interval=1; tomwalters@0: else tomwalters@0: minimum_time_interval=framestruct.minimum_time_interval; tomwalters@0: end tomwalters@0: tomwalters@0: if ~isfield(framestruct,'is_log'); tomwalters@0: is_log=1; tomwalters@0: else tomwalters@0: is_log=framestruct.is_log;; tomwalters@0: end tomwalters@0: tomwalters@0: if isfield(framestruct,'frequency_profile_scale'); tomwalters@0: frequency_profile_scale=framestruct.frequency_profile_scale; tomwalters@0: else tomwalters@0: frequency_profile_scale=1; tomwalters@0: end tomwalters@0: if isfield(framestruct,'time_profile_scale'); tomwalters@0: time_profile_scale=framestruct.time_profile_scale; tomwalters@0: else tomwalters@0: time_profile_scale=1; tomwalters@0: end tomwalters@0: % if the time scale is reversed (time from left to right) tomwalters@0: if isfield(framestruct,'time_reversed'); tomwalters@0: time_reversed=framestruct.time_reversed; tomwalters@0: else tomwalters@0: time_reversed=0; tomwalters@0: end tomwalters@0: tomwalters@0: % hier wird der current frame definiert: tomwalters@0: current_frame=framestruct.current_frame; tomwalters@0: tomwalters@0: if ~isfield(framestruct,'maximum_time_interval'); tomwalters@0: maximum_time_interval=35; tomwalters@0: else tomwalters@0: maximum_time_interval=framestruct.maximum_time_interval; tomwalters@0: end tomwalters@0: tomwalters@0: if maximum_time_interval/1000>getlength(current_frame) tomwalters@0: maximum_time_interval=getlength(current_frame)*1000; tomwalters@0: end tomwalters@0: tomwalters@0: if isfield(framestruct,'options'); tomwalters@0: options=framestruct.options; tomwalters@0: else tomwalters@0: options=[]; tomwalters@0: end tomwalters@0: if ~isfield(options,'oldhandle1') tomwalters@0: options.oldhandle1=0; tomwalters@0: end tomwalters@0: if ~isfield(options,'oldhandle2') tomwalters@0: options.oldhandle2=0; tomwalters@0: end tomwalters@0: if ~isfield(options,'oldhandle3') tomwalters@0: options.oldhandle3=0; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: % schmeisse die physikalisch nicht sinnvollen Bereiche raus! tomwalters@0: % current_frame=extractpitchregion(current_frame); tomwalters@0: tomwalters@0: scale_summe=getscalesumme(current_frame); tomwalters@0: tomwalters@0: % start plotting: tomwalters@0: % clf; tomwalters@0: axis off tomwalters@0: caxes=get(gca,'position'); tomwalters@0: tomwalters@0: channel_density=0.015; % passt für 76 channels von 100 bis 6000 tomwalters@0: % channel_density=2*0.015; % passt für 76 channels von 100 bis 6000 tomwalters@0: hoehe=getnrchannels(current_frame)*channel_density; tomwalters@0: if hoehe>1 tomwalters@0: hoehe=1; tomwalters@0: end tomwalters@0: if hoehe < 0.2 tomwalters@0: hoehe = 0.2; tomwalters@0: end tomwalters@0: tomwalters@0: rect=[-0.04 0.15 0.9 hoehe*0.85]; tomwalters@0: rect(1:2)=caxes(1:2)+(rect(1:2).*caxes(3:4)); tomwalters@0: rect(3:4)=rect(3:4).*caxes(3:4); tomwalters@0: tomwalters@0: hint=1; % this indicate that we dont want a title tomwalters@0: mysubplot(1,1,1,rect, hint); tomwalters@0: if options.oldhandle1~=0 tomwalters@0: delete(options.oldhandle1); tomwalters@0: end tomwalters@0: options.oldhandle1=gca; tomwalters@0: tomwalters@0: plot_struct.t_min=minimum_time_interval/1000; tomwalters@0: plot_struct.t_max=maximum_time_interval/1000; tomwalters@0: plot_struct.has_axis=0; tomwalters@0: plot_struct.is_log=is_log; tomwalters@0: plot_struct.has_y_axis=0; tomwalters@0: axis off tomwalters@0: tomwalters@0: plot(current_frame,plot_struct); tomwalters@0: set(gca,'zlim',[0 1/plot_scale]); tomwalters@0: tomwalters@0: if show_time tomwalters@0: srate=getsr(current_frame); tomwalters@0: text_x=0.8*maximum_time_interval*srate/1000; tomwalters@0: text_y=getnrchannels(current_frame)*1.1; tomwalters@0: frame_number=getcurrentframenumber(current_frame); tomwalters@0: frame_time=getcurrentframestarttime(current_frame); tomwalters@0: text(text_x,text_y,sprintf('%3d : %4.0fms',frame_number,frame_time*1000),'FontSize',8); tomwalters@0: % text(text_x,text_y,sprintf('%d',frame_number),'FontSize',8); tomwalters@0: end tomwalters@0: tomwalters@0: % interval sum tomwalters@0: rect=[-0.04 0 0.9 0.2]; tomwalters@0: rect(1:2)=caxes(1:2)+(rect(1:2).*caxes(3:4)); tomwalters@0: rect(3:4)=rect(3:4).*caxes(3:4); tomwalters@0: mysubplot(1,1,1,rect, hint); tomwalters@0: if options.oldhandle2~=0 tomwalters@0: delete(options.oldhandle2); tomwalters@0: end tomwalters@0: options.oldhandle2=gca; tomwalters@0: tomwalters@0: summe=getsum(current_frame); % here it is calculated tomwalters@0: axis off tomwalters@0: tomwalters@0: srate=getsr(current_frame); tomwalters@0: if is_log tomwalters@0: t=minimum_time_interval; tomwalters@0: if t<=0 tomwalters@0: error('in logarithmic plots, the minimum time interval must be positiv!'); tomwalters@0: end tomwalters@0: ti=[t 2*t 4*t 8*t 16*t 32*t 64*t]; tomwalters@0: tix=(ti)/1000*srate; % there shell be the tix tomwalters@0: ti=(ti); tomwalters@0: ti=round(ti*100)/100; tomwalters@0: if getminimumtime(summe) <0 tomwalters@0: psumme=getpart(summe,getminimumtime(summe),0); tomwalters@0: else tomwalters@0: psumme=getpart(summe,getminimumtime(summe),maximum_time_interval/1000); tomwalters@0: end tomwalters@0: % rsumme=reverse(psumme); tomwalters@0: rsumme=psumme; tomwalters@0: sumvalues=getvalues(rsumme); tomwalters@0: min_x_screen=minimum_time_interval/1000*srate; % thats the first point we want to see on the screen tomwalters@0: max_x_screen=maximum_time_interval/1000*srate; % thats the first point we want to see on the screen tomwalters@0: else % its not logarithmic! tomwalters@0: frame_start_time=getminimumtime(current_frame); tomwalters@0: if maximum_time_interval>0 tomwalters@0: summe=getpart(summe,(minimum_time_interval/1000+frame_start_time),maximum_time_interval/1000+frame_start_time); tomwalters@0: else tomwalters@0: summe=getpart(summe,(-maximum_time_interval/1000+frame_start_time),-minimum_time_interval/1000+frame_start_time); tomwalters@0: end tomwalters@0: nr_labels=8; tomwalters@0: xbis=getnrpoints(summe); tomwalters@0: tix=0:xbis/nr_labels:xbis; tomwalters@0: xstep=(maximum_time_interval-minimum_time_interval)*1000/nr_labels; %works from -35 to 5 tomwalters@0: xstep=round(xstep); tomwalters@0: ti=([minimum_time_interval*1000:xstep:maximum_time_interval*1000])/1000; tomwalters@0: ti=round(ti*10)/10; tomwalters@0: % sumvalues=getvalues(reverse(summe)); tomwalters@0: sumvalues=getvalues(summe); tomwalters@0: tomwalters@0: min_x_screen=0; tomwalters@0: max_x_screen=(maximum_time_interval-minimum_time_interval)/1000*srate; % thats the first point we want to see on the screen tomwalters@0: tomwalters@0: end tomwalters@0: tomwalters@0: h=plot(sumvalues); hold on tomwalters@0: if scale_summe==0 tomwalters@0: axis([min_x_screen max_x_screen 0 1]); tomwalters@0: else tomwalters@0: axis([min_x_screen max_x_screen 0 scale_summe/time_profile_scale]); tomwalters@0: end tomwalters@0: tomwalters@0: % set(gca,'XDir','reverse') % turn them around, because the higher values shell end on the right tomwalters@0: if is_log tomwalters@0: set(gca,'XScale','log') tomwalters@0: end tomwalters@0: tomwalters@0: if time_reversed tomwalters@0: ti=ti(end:-1:1); tomwalters@0: end tomwalters@0: set(gca,'XTick',tix); tomwalters@0: set(gca,'XTickLabel',ti); tomwalters@0: set(gca,'YTickLabel',[]); tomwalters@0: % tomwalters@0: if is_log tomwalters@0: text(max_x_screen*0.5,-scale_summe/5,'time interval (ms)'); % this is at a nice position tomwalters@0: else tomwalters@0: text(500,-scale_summe/5,'time interval (ms)'); % this is at a nice position tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: % frequency sum tomwalters@0: scale_frequency=getscalefrequency(current_frame); tomwalters@0: tomwalters@0: hoehe=getnrchannels(current_frame)*channel_density; tomwalters@0: if hoehe>1 tomwalters@0: hoehe=1; tomwalters@0: end tomwalters@0: tomwalters@0: rect=[0.856 0.19 0.1 hoehe*0.81]; tomwalters@0: rect(1:2)=caxes(1:2)+(rect(1:2).*caxes(3:4)); tomwalters@0: rect(3:4)=rect(3:4).*caxes(3:4); tomwalters@0: mysubplot(1,1,1,rect, hint); tomwalters@0: if options.oldhandle3~=0 tomwalters@0: delete(options.oldhandle3); tomwalters@0: end tomwalters@0: options.oldhandle3=gca; tomwalters@0: fresumme=getfrequencysum(current_frame); % here it is calculated tomwalters@0: % fresumme=smooth(fresumme,1);% glätte die Summe tomwalters@0: tomwalters@0: % fresumme=fresumme/frequency_profile_scale; tomwalters@0: tomwalters@0: fresumme=setname(fresumme,''); tomwalters@0: fresumme=setunit_x(fresumme,''); tomwalters@0: fresumme=setunit_y(fresumme,''); tomwalters@0: tomwalters@0: plot(fresumme,'r'); hold on tomwalters@0: v=getvalues(fresumme); tomwalters@0: axis([0 size(v,1)*47/42 0 scale_frequency/frequency_profile_scale]); tomwalters@0: view(-90,90); tomwalters@0: % make y-Ticks tomwalters@0: nr_labels=8; tomwalters@0: nr_channels=getnrpoints(fresumme); tomwalters@0: xstep=(nr_channels-1)/(nr_labels-1); tomwalters@0: tix=1:xstep:nr_channels; tomwalters@0: cfs=getcf(current_frame); tomwalters@0: ti=cfs(floor(tix))/1000; tomwalters@0: ti=round(ti*10)/10; tomwalters@0: set(gca,'XTick',tix); tomwalters@0: set(gca,'XTickLabel',ti); tomwalters@0: set(gca,'YTickLabel',[]); tomwalters@0: set(gca,'XAxisLocation','top'); tomwalters@0: