tomwalters@0: % method of class @frame tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % tomwalters@0: % tomwalters@0: % (c) 2003, University of Cambridge, Medical Research Council tomwalters@0: % Stefan Bleeck (stefan@bleeck.de) tomwalters@0: % http://www.mrc-cbu.cam.ac.uk/cnbh/aimmanual tomwalters@0: % $Date: 2003/01/17 16:57:46 $ tomwalters@0: % $Revision: 1.3 $ tomwalters@0: tomwalters@0: function fr=extractpitchregion(fr) tomwalters@0: tomwalters@0: dominant_scale_factor=1; tomwalters@0: tomwalters@0: graphix=0; tomwalters@0: tomwalters@0: nr_ch=getnrchannels(fr); tomwalters@0: cfs=getcf(fr); tomwalters@0: end_time=getmaximumtime(fr); tomwalters@0: sr=getsr(fr); tomwalters@0: geslen=getlength(fr); tomwalters@0: starttime=getminimumtime(fr); tomwalters@0: tomwalters@0: for i=1:nr_ch tomwalters@0: ch_fre=cfs(i); tomwalters@0: ch=getsinglechannel(fr,i); tomwalters@0: tomwalters@0: % firstfre=-1/ch_fre*1; % up to the second tomwalters@0: % firstbin=time2bin(ch,firstfre); tomwalters@0: % firsttime=firstbin/sr-geslen; tomwalters@0: tomwalters@0: % set all values below the first harmonic to 0 tomwalters@0: firsttime=-1/ch_fre*1; % up to the second tomwalters@0: if graphix clf;plot(ch);hold on;end tomwalters@0: ch=setvalues(ch,0,time2bin(ch,firsttime)); tomwalters@0: if graphix plot(ch,'r');end tomwalters@0: tomwalters@0: % scale all values between the first and second from 0 to 1 tomwalters@0: secondtime=-1/ch_fre*2; tomwalters@0: dur=abs(secondtime)-abs(firsttime); tomwalters@0: nr_points=time2bin(ch,firsttime)-time2bin(ch,secondtime); tomwalters@0: msig=linspace(1,0,nr_points); tomwalters@0: ch=mult(ch,msig,secondtime,nr_points/sr); tomwalters@0: if graphix plot(ch,'g');end tomwalters@0: tomwalters@0: % scale all values between the second and third from 1 to dominant_scale_factor tomwalters@0: thirdtime=-1/ch_fre*3; tomwalters@0: dur=abs(thirdtime)-abs(secondtime); tomwalters@0: nr_points=time2bin(ch,secondtime)-time2bin(ch,thirdtime); tomwalters@0: msig=linspace(dominant_scale_factor,1,nr_points); tomwalters@0: ch=mult(ch,msig,thirdtime,nr_points/sr); tomwalters@0: if graphix plot(ch,'k');end tomwalters@0: tomwalters@0: % scale all values between the third and six by dominant_scale_factor tomwalters@0: sixtime=-1/ch_fre*6; tomwalters@0: dur=abs(sixtime)-abs(thirdtime); tomwalters@0: nr_points=time2bin(ch,thirdtime)-time2bin(ch,sixtime); tomwalters@0: msig=ones(1,nr_points)*dominant_scale_factor; tomwalters@0: if sixtime < starttime tomwalters@0: sixtime=starttime; tomwalters@0: nr_points=time2bin(ch,thirdtime)-time2bin(ch,sixtime); tomwalters@0: msig=ones(1,nr_points)*dominant_scale_factor; tomwalters@0: end tomwalters@0: ch=mult(ch,msig,sixtime,nr_points/sr); tomwalters@0: if graphix plot(ch,'y');end tomwalters@0: tomwalters@0: % scale all values between the six and seven from dominant_scale_factor to 1 tomwalters@0: seventime=-1/ch_fre*7; tomwalters@0: dur=abs(seventime)-abs(sixtime); tomwalters@0: nr_points=time2bin(ch,sixtime)-time2bin(ch,seventime); tomwalters@0: msig=linspace(1,dominant_scale_factor,nr_points); tomwalters@0: if seventime < starttime tomwalters@0: seventime=starttime; tomwalters@0: nr_points=time2bin(ch,sixtime)-time2bin(ch,seventime); tomwalters@0: msig=linspace(1,dominant_scale_factor,nr_points); tomwalters@0: end tomwalters@0: if nr_points > 0 tomwalters@0: ch=mult(ch,msig,seventime,nr_points/sr); tomwalters@0: end tomwalters@0: if graphix plot(ch,'c');end tomwalters@0: tomwalters@0: tomwalters@0: % scale the amplitude of higher cf-channels down tomwalters@0: cutoff=2000; tomwalters@0: db_per_octave=6; tomwalters@0: scaler=getfiltervalue(ch_fre,cutoff,db_per_octave); tomwalters@0: ch=ch*scaler; tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: fr=setsinglechannel(fr,i,ch); tomwalters@0: tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: