annotate aim-mat/tools/@signal/gettimevalue.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 % method of class @signal
tomwalters@0 2 %
tomwalters@0 3 % INPUT VALUES:
tomwalters@0 4 %
tomwalters@0 5 % RETURN VALUE:
tomwalters@0 6 %
bleeck@3 7 % This external file is included as part of the 'aim-mat' distribution package
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
tomwalters@0 13
tomwalters@0 14 function val=gettimevalue(sig,times)
tomwalters@0 15 % usage: val=gettimevalue(sig,time)
tomwalters@0 16 % returns the value at this point in time
tomwalters@0 17
tomwalters@0 18 val=zeros(size(times));
tomwalters@0 19 if isempty(times)
tomwalters@0 20 return
tomwalters@0 21 end
tomwalters@0 22
tomwalters@0 23 sr=1/getsr(sig);
tomwalters@0 24
tomwalters@0 25 threshold=sr/100;
tomwalters@0 26 nr_points=getnrpoints(sig);
tomwalters@0 27 start=getminimumtime(sig);
tomwalters@0 28 stop=getmaximumtime(sig);
tomwalters@0 29 x=start+sr:sr:stop;
tomwalters@0 30 Y=sig.werte;
tomwalters@0 31 method='linear';
tomwalters@0 32
tomwalters@0 33
tomwalters@0 34 for ii=1:length(times);
tomwalters@0 35 time=times(ii)-sig.start_time;
tomwalters@0 36
tomwalters@0 37 nrint=round(time/sr);
tomwalters@0 38 rint=time/sr;
tomwalters@0 39
tomwalters@0 40 if (nrint-rint)<threshold
tomwalters@0 41 if nrint>0 && nrint <= length(sig.werte)
tomwalters@0 42 val(ii)=sig.werte(nrint);
tomwalters@0 43 end
tomwalters@0 44 else
tomwalters@0 45 xi=times(ii);
tomwalters@0 46 val(ii)=interp1(x,Y,xi,method);
tomwalters@0 47 end
tomwalters@0 48 end
tomwalters@0 49
tomwalters@0 50