annotate aim-mat/tools/@signal/delay.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 % function delay(sig)
tomwalters@0 3 % delays the signal by so many seconds. Fills the start with zeros and cuts
tomwalters@0 4 % the end
tomwalters@0 5 %
tomwalters@0 6 % INPUT VALUES:
tomwalters@0 7 % sig: original @signal
tomwalters@0 8 %
bleeck@3 9 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 10 % (c) 2011, University of Southampton
bleeck@3 11 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 12 % download of current version is on the soundsoftware site:
bleeck@3 13 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 14 % documentation and everything is on http://www.acousticscale.org
bleeck@3 15
tomwalters@0 16
tomwalters@0 17 function sig=delay(sig,del)
tomwalters@0 18
tomwalters@0 19 sr=getsr(sig);
tomwalters@0 20 % nr_del=del*sr;
tomwalters@0 21 nr_del=round(del*sr);
tomwalters@0 22 vals=getvalues(sig);
tomwalters@0 23 nvals1=zeros(1,nr_del);
tomwalters@0 24 nvals2=vals(1:end-nr_del);
tomwalters@0 25
tomwalters@0 26 new_vals=[nvals1 nvals2'];
tomwalters@0 27 sig=setvalues(sig,new_vals);
tomwalters@0 28 sig=setname(sig,sprintf('%s delayed by %f sec',getname(sig),del));
tomwalters@0 29
tomwalters@0 30