annotate aim-mat/gui/edit_duration.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 % procedure for 'aim-mat'
tomwalters@0 2 %
tomwalters@0 3 % INPUT VALUES:
tomwalters@0 4 %
tomwalters@0 5 % RETURN VALUE:
tomwalters@0 6 %
tomwalters@0 7 %
tomwalters@0 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
tomwalters@0 16 function handles=edit_duration(hObject, eventdata, handles)
tomwalters@0 17
tomwalters@0 18
tomwalters@0 19 curval=get(hObject,'String');
tomwalters@0 20 curval=str2num(curval);
tomwalters@0 21
tomwalters@0 22 handles.slideredit_duration=...
tomwalters@0 23 slidereditcontrol_set_raweditvalue(handles.slideredit_duration,curval);
tomwalters@0 24
tomwalters@0 25 sig=handles.data.signal;
tomwalters@0 26
tomwalters@0 27 if handles.info.current_plot>=6 %sai has additionally the start time below:
tomwalters@0 28 current_start_time=slidereditcontrol_get_value(handles.slideredit_duration); % the new value
tomwalters@0 29 framelen=getcurrentframestarttime(handles.data.sai{2})-getcurrentframestarttime(handles.data.sai{1});
tomwalters@0 30
tomwalters@0 31 nr_frames=length(handles.data.sai);
tomwalters@0 32 current_frame_nr=round((current_start_time-getminimumtime(sig))/framelen)+1; % plus 1 because of the duration of the frame itself
tomwalters@0 33 current_frame_nr=min(nr_frames,current_frame_nr);
tomwalters@0 34 current_frame_nr=max(1,current_frame_nr);
tomwalters@0 35 handles.currentslidereditcombi=slidereditcontrol_set_value(handles.currentslidereditcombi,current_frame_nr);
tomwalters@0 36 realval=(current_frame_nr-1)*framelen+getminimumtime(sig);
tomwalters@0 37 handles.slideredit_duration=...
tomwalters@0 38 slidereditcontrol_set_value(handles.slideredit_duration,realval);
tomwalters@0 39 else
tomwalters@0 40 % check range
tomwalters@0 41 start=slidereditcontrol_get_value(handles.currentslidereditcombi);
tomwalters@0 42 dur=slidereditcontrol_get_value(handles.slideredit_duration);
tomwalters@0 43 siglen=getmaximumtime(sig);
tomwalters@0 44 if start+dur>siglen
tomwalters@0 45 dur=siglen-start;
tomwalters@0 46 end
tomwalters@0 47
tomwalters@0 48
tomwalters@0 49 handles.slideredit_duration=...
tomwalters@0 50 slidereditcontrol_set_value(handles.slideredit_duration,dur);
tomwalters@0 51
tomwalters@0 52 % set the range of the start_slider accordingly
tomwalters@0 53 len=slidereditcontrol_get_value(handles.slideredit_duration);
tomwalters@0 54 handles.currentslidereditcombi=slidereditcontrol_set_range(handles.currentslidereditcombi,len); % the duration
tomwalters@0 55
tomwalters@0 56 end