tomwalters@0: % method of class @signal tomwalters@0: % function sig=generaterampsinus(sig,carfre,modfre,amplitude,halflife) tomwalters@0: % INPUT VALUES: tomwalters@0: % sig: original @signal with length and samplerate tomwalters@0: % carfre: carrier frequency (Hz) [1000] tomwalters@0: % modfre: modulation frequency (Hz) [100] tomwalters@0: % amplitude: [1] tomwalters@0: % halflife: time for the envelope envelope to rise exponentially tomwalters@0: % to 1/2 tomwalters@0: % 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=generaterampsinus(sig,carfre,modfre,amplitude,halflife) tomwalters@0: tomwalters@0: if nargin < 5 tomwalters@0: halflife=0.01; tomwalters@0: end tomwalters@0: if nargin < 4 tomwalters@0: amplitude=1; tomwalters@0: end tomwalters@0: tomwalters@0: if nargin < 3 tomwalters@0: modfre=100; tomwalters@0: end tomwalters@0: if nargin < 2 tomwalters@0: carfre=1000; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: sinus=generatesinus(sig,carfre,amplitude,0); tomwalters@0: tomwalters@0: % calculate envelope and mult both tomwalters@0: envelope=sig; tomwalters@0: time_const=halflife/0.69314718; tomwalters@0: tomwalters@0: env_vals=getvalues(envelope); tomwalters@0: time=0; tomwalters@0: sr=getsr(envelope); tomwalters@0: reprate=1/modfre; tomwalters@0: tomwalters@0: tomwalters@0: for i=1:getnrpoints(envelope); tomwalters@0: time=time+1/sr; tomwalters@0: tomwalters@0: env_vals(i)= exp(-(reprate-time)/time_const); tomwalters@0: time=mod(time,reprate); tomwalters@0: tomwalters@0: end tomwalters@0: tomwalters@0: envelope=setvalues(envelope,env_vals); tomwalters@0: tomwalters@0: sig=sinus*envelope; tomwalters@0: % sig=sig*amplitude; tomwalters@0: tomwalters@0: sig=setname(sig,sprintf('Ramp Sinus %4.2f kHz, Modulation=%4.2f Hz, halflife=%4.2f ms',carfre/1000,modfre,halflife*1000));