annotate aim-mat/tools/AIsum.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
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 AIsum(framestruct_a);
tomwalters@0 16 % plots the current frame (cframe) together with its sum
tomwalters@0 17 % all relevant data must be in the frame-object
tomwalters@0 18
tomwalters@0 19 % framestruct.current_frame = current_frame;
tomwalters@0 20 % framestruct.maximum_time_interval = maximum_time_interval; in ms!!!!
tomwalters@0 21 % framestruct.minimum_time_interval= minimum_time_interval;in ms!!!!
tomwalters@0 22 % framestruct.is_log='log' or 'linear';
tomwalters@0 23
tomwalters@0 24 if ~isstruct(framestruct_a)
tomwalters@0 25 % error('AIsum must be called with a structure');
tomwalters@0 26 framestruct.current_frame=framestruct_a;
tomwalters@0 27 else
tomwalters@0 28 framestruct=framestruct_a;
tomwalters@0 29 end
tomwalters@0 30
tomwalters@0 31 if ~isfield(framestruct,'show_time');
tomwalters@0 32 show_time=0;
tomwalters@0 33 else
tomwalters@0 34 show_time=framestruct.show_time;
tomwalters@0 35 end
tomwalters@0 36
tomwalters@0 37 if ~isfield(framestruct,'plot_scale');
tomwalters@0 38 plot_scale=1;
tomwalters@0 39 else
tomwalters@0 40 plot_scale=framestruct.plot_scale;
tomwalters@0 41 end
tomwalters@0 42
tomwalters@0 43 if ~isfield(framestruct,'minimum_time_interval');
tomwalters@0 44 minimum_time_interval=1;
tomwalters@0 45 else
tomwalters@0 46 minimum_time_interval=framestruct.minimum_time_interval;
tomwalters@0 47 end
tomwalters@0 48
tomwalters@0 49 if ~isfield(framestruct,'maximum_time_interval');
tomwalters@0 50 maximum_time_interval=35;
tomwalters@0 51 else
tomwalters@0 52 maximum_time_interval=framestruct.maximum_time_interval;
tomwalters@0 53 end
tomwalters@0 54
tomwalters@0 55 if ~isfield(framestruct,'is_log');
tomwalters@0 56 is_log=1;
tomwalters@0 57 else
tomwalters@0 58 is_log=framestruct.is_log;;
tomwalters@0 59 end
tomwalters@0 60 current_frame=framestruct.current_frame;
tomwalters@0 61
tomwalters@0 62 scale_summe=getsumscale(current_frame);
tomwalters@0 63
tomwalters@0 64 % start plotting:
tomwalters@0 65 clf;
tomwalters@0 66 rect=[-0.04 0.15 0.97 0.85];
tomwalters@0 67 hint=1; % this indicate that we dont want a title
tomwalters@0 68 mysubplot(1,1,1,rect, hint);
tomwalters@0 69 plot_struct.t_min=minimum_time_interval/1000;
tomwalters@0 70 plot_struct.t_max=maximum_time_interval/1000;
tomwalters@0 71 plot_struct.has_axis=0;
tomwalters@0 72 plot_struct.is_log=is_log;
tomwalters@0 73
tomwalters@0 74 cax=plot(current_frame,plot_struct);
tomwalters@0 75 set(gca,'zlim',[0 1/plot_scale]);
tomwalters@0 76
tomwalters@0 77 % xaxisxticklabel=get(gca,'XTickLabel');
tomwalters@0 78 % xaxisxtick=get(gca,'XTick');
tomwalters@0 79
tomwalters@0 80 set(gca,'XTickLabel',[]);
tomwalters@0 81
tomwalters@0 82 if show_time
tomwalters@0 83 srate=getsr(current_frame);
tomwalters@0 84 text_x=0.9*maximum_time_interval*srate/1000;
tomwalters@0 85 text_y=getnrchannels(current_frame)+5;
tomwalters@0 86 str=getstructure(current_frame);
tomwalters@0 87 if ~isfield(str,'current_frame_start_time')
tomwalters@0 88 str.current_frame_start_time=0.0;
tomwalters@0 89 end
tomwalters@0 90 frame_number=str.current_frame_number;
tomwalters@0 91 frame_time=str.current_frame_start_time*1000;
tomwalters@0 92 text(text_x,text_y,sprintf('%d : %4.0fms',frame_number,frame_time),'FontSize',8);
tomwalters@0 93 % text(text_x,text_y,sprintf('%d',frame_number),'FontSize',8);
tomwalters@0 94 end
tomwalters@0 95
tomwalters@0 96 % and the sum
tomwalters@0 97 rect=[-0.04 0 0.97 0.2];
tomwalters@0 98 mysubplot(1,1,1,rect, hint);
tomwalters@0 99 summe=getsum(current_frame); % here it is calculated
tomwalters@0 100
tomwalters@0 101 srate=getsr(current_frame);
tomwalters@0 102 if is_log
tomwalters@0 103 t=minimum_time_interval;
tomwalters@0 104 ti=[t 2*t 4*t 8*t 16*t 32*t 64*t];
tomwalters@0 105 tix=(ti)/1000*srate; % there shell be the tix
tomwalters@0 106 ti=(ti);
tomwalters@0 107 ti=round(ti*100)/100;
tomwalters@0 108 psumme=getpart(summe,getminimumtime(summe),0);
tomwalters@0 109 rsumme=reverse(psumme);
tomwalters@0 110 sumvalues=getvalues(rsumme);
tomwalters@0 111 min_x_screen=minimum_time_interval/1000*srate; % thats the first point we want to see on the screen
tomwalters@0 112 max_x_screen=maximum_time_interval/1000*srate; % thats the first point we want to see on the screen
tomwalters@0 113 else % its not logarithmic!
tomwalters@0 114 logstruc=getstructure(current_frame);
tomwalters@0 115 if isfield(logstruc,'samplerate')
tomwalters@0 116 if logstruc.samplerate==-1 % special case for logarithmic frames
tomwalters@0 117 scale_summe=max(summe);
tomwalters@0 118 else
tomwalters@0 119 summe=getpart(summe,-maximum_time_interval/1000,-minimum_time_interval/1000);
tomwalters@0 120 end
tomwalters@0 121 else
tomwalters@0 122 % summe=getpart(summe,-maximum_time_interval/1000,-minimum_time_interval/1000);
tomwalters@0 123 end
tomwalters@0 124 nr_labels=7;
tomwalters@0 125 xbis=getnrpoints(summe);
tomwalters@0 126 tix=0:xbis/nr_labels:xbis;
tomwalters@0 127 xstep=(maximum_time_interval-minimum_time_interval)*1000/nr_labels; %works from -35 to 5
tomwalters@0 128 xstep=round(xstep);
tomwalters@0 129 ti=([minimum_time_interval*1000:xstep:maximum_time_interval*1000])/1000;
tomwalters@0 130 ti=round(ti*10)/10;
tomwalters@0 131 sumvalues=getvalues(reverse(summe));
tomwalters@0 132
tomwalters@0 133 min_x_screen=0;
tomwalters@0 134 max_x_screen=(maximum_time_interval-minimum_time_interval)/1000*srate; % thats the first point we want to see on the screen
tomwalters@0 135
tomwalters@0 136 end
tomwalters@0 137
tomwalters@0 138
tomwalters@0 139 h=plot(sumvalues);
tomwalters@0 140 % set(h,'LineWidth',1);
tomwalters@0 141
tomwalters@0 142 axis([min_x_screen max_x_screen 0 scale_summe]);
tomwalters@0 143
tomwalters@0 144 set(gca,'XDir','reverse') % turn them around, because the higher values shell end on the right
tomwalters@0 145 if is_log
tomwalters@0 146 set(gca,'XScale','log')
tomwalters@0 147 end
tomwalters@0 148
tomwalters@0 149 if isstruct('logstruct')
tomwalters@0 150 if logstruct.samplerate==-1 % special case for logarithmic frames
tomwalters@0 151 nr_labels=6;
tomwalters@0 152 tix=0:max_x_screen/(nr_labels-1):max_x_screen;
tomwalters@0 153 tix(1)=1;
tomwalters@0 154 min_time=(logstruct.min_time*1000);
tomwalters@0 155 max_time=abs(logstruct.max_time*1000);
tomwalters@0 156 ti=distributelogarithmic(min_time,max_time,nr_labels);
tomwalters@0 157 text(30,-scale_summe/5,'time interval (ms)'); % this is at a nice position
tomwalters@0 158 end
tomwalters@0 159 else
tomwalters@0 160 if is_log
tomwalters@0 161 text(min_x_screen*1.9,-scale_summe/5,'time interval (ms)'); % this is at a nice position
tomwalters@0 162 else
tomwalters@0 163 text(120,-scale_summe/5,'time interval (ms)'); % this is at a nice position
tomwalters@0 164 end
tomwalters@0 165 end
tomwalters@0 166 set(gca,'XTick',tix);
tomwalters@0 167 set(gca,'XTickLabel',ti);
tomwalters@0 168
tomwalters@0 169 % set(gca,'XTick',xaxisxtick);
tomwalters@0 170 % set(gca,'XTickLabel',xaxisxticklabel);
tomwalters@0 171 set(gca,'YTickLabel',[]);