bleeck@3: % method of class @signal bleeck@3: % bleeck@3: % INPUT VALUES: bleeck@3: % sig,attenuation,ramp bleeck@3: % sig is the signal or a array of two signals for stereo bleeck@3: % attenuation is the attenuation against the lowdest possible tone bleeck@3: % with amplitude =1 bleeck@3: % default=1 bleeck@3: % bleeck@3: % RETURN VALUE: bleeck@3: % bleeck@3: % 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 bleeck@3: bleeck@3: bleeck@3: % function play(sig,attenuation,ramp) bleeck@3: function play(sig,attenuation,ramp) bleeck@3: bleeck@3: if nargin < 3 bleeck@3: ramp=0; bleeck@3: end bleeck@3: if nargin < 2 bleeck@3: attenuation=0; bleeck@3: end bleeck@3: if attenuation > 0 bleeck@3: % error('cant play sounds louder then maximum, reduce attenuation!'); bleeck@3: disp('warning: signal\play:: play sounds louder then maximum, reduce attenuation!'); bleeck@3: end bleeck@3: bleeck@3: if length(sig)>1 % stereo! bleeck@3: sig(1)=attenuate(sig(1),attenuation); bleeck@3: sig(2)=attenuate(sig(2),attenuation); bleeck@3: bleeck@3: values1=getvalues(sig(1)); bleeck@3: values2=getvalues(sig(2)); bleeck@3: bleeck@3: finvals=[values1 values2]; bleeck@3: sr=getsr(sig(1)); bleeck@3: bleeck@3: sound(finvals,sr); bleeck@3: pause(getlength(sig(1))); bleeck@3: else bleeck@3: bleeck@3: bleeck@3: % beware of playing a NULL-stimulus! bleeck@3: if getlength(sig)<=1/getsr(sig) bleeck@3: return bleeck@3: end bleeck@3: bleeck@3: if ramp>0 bleeck@3: sig=rampamplitude(sig,ramp); bleeck@3: end bleeck@3: bleeck@3: sig=attenuate(sig,attenuation); bleeck@3: bleeck@3: if max(sig)>1 bleeck@3: disp('warning: signal\play:: clipping in signal'); bleeck@3: end bleeck@3: sound(sig.werte,sig.samplerate); bleeck@3: bleeck@3: pause(getlength(sig)); bleeck@3: end