tomwalters@0: % method of class @signal tomwalters@0: % function sig=generatesinus(sig,[fre],[amplitude],[phase]) tomwalters@0: % INPUT VALUES: tomwalters@0: % sig: original @signal with length and samplerate tomwalters@0: % fre: frequency (Hz) [1000] tomwalters@0: % amplitude: [1] tomwalters@0: % phase: startphase [0] tomwalters@0: % phases must be in degrees! tomwalters@0: % RETURN VALUE: tomwalters@0: % sig: @signal tomwalters@0: % bleeck@3: % This external file is included as part of the 'aim-mat' distribution package 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 tomwalters@0: tomwalters@0: tomwalters@0: function sig=generatesinus(sig,fre,amplitude,phase) tomwalters@0: tomwalters@0: if nargin < 4 tomwalters@0: phase=0; tomwalters@0: end tomwalters@0: if nargin < 3 tomwalters@0: amplitude=1; tomwalters@0: end tomwalters@0: if nargin < 2 tomwalters@0: fre=1000; tomwalters@0: end tomwalters@0: tomwalters@0: nr_points=getnrpoints(sig); tomwalters@0: sr=getsr(sig); tomwalters@0: length=getlength(sig); tomwalters@0: tomwalters@0: von=0+phase; tomwalters@0: periode=1/fre; tomwalters@0: bis=2*pi*length/periode + phase; tomwalters@0: tomwalters@0: tomwalters@0: temp=linspace(von,bis,nr_points); tomwalters@0: data=sin(temp); tomwalters@0: tomwalters@0: data=data*amplitude; tomwalters@0: tomwalters@0: sig=signal(data); tomwalters@0: sig=setsr(sig,sr); tomwalters@0: sig=setname(sig,sprintf('Sinus %4.2f kHz',fre/1000));